Created
August 2, 2015 15:49
-
-
Save mathdoodle/6cea570d2557510e9112 to your computer and use it in GitHub Desktop.
EIGHT Template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"uuid": "a2d59298-4019-48d8-a785-91f3e80469e0", | |
"description": "EIGHT Template", | |
"dependencies": { | |
"DomReady": "latest", | |
"davinci-blade": "1.1.1", | |
"davinci-eight": "latest", | |
"gl-matrix": "2.2.1" | |
}, | |
"operatorOverloading": true | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<style> | |
/* STYLE-MARKER */ | |
</style> | |
<script id='vs' type='x-shader/x-vertex'> | |
attribute vec3 aVertexPosition; | |
void main(void) { | |
gl_Position = vec4(aVertexPosition, 1.0); | |
} | |
</script> | |
<script id='fs' type='x-shader/x-fragment'> | |
void main(void) { | |
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); | |
} | |
</script> | |
<!-- SCRIPTS-MARKER --> | |
</head> | |
<body> | |
<script> | |
// CODE-MARKER | |
</script> | |
<canvas id='my-canvas' width='400' height='300'> | |
Your browser does not support the canvas element. | |
</canvas> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DomReady.ready(function() { | |
try { | |
main(); | |
} | |
catch(e) { | |
console.error(e); | |
} | |
}); | |
var e1 = blade.e3ga.e1; | |
var e2 = blade.e3ga.e2; | |
var e3 = blade.e3ga.e3; | |
function main() { | |
var scene = EIGHT.drawList(); | |
var canvas = <HTMLCanvasElement>document.getElementById('my-canvas'); | |
var renderer = EIGHT.webGLRenderer(canvas); | |
renderer.clearColor(0.3, 0.3, 0.3, 1.0); | |
var monitor = EIGHT.contextMonitor(canvas).addContextUser(renderer).start(); | |
var perspective = EIGHT.perspective().setAspect(canvas.clientWidth / canvas.clientHeight).setEye(e1 + 3.0 * e3); | |
var ambients = EIGHT.uniforms([perspective]); | |
var mesh = new EIGHT.BoxBuilder().buildMesh(); | |
var model = new EIGHT.Node(); | |
var shaders = EIGHT.smartProgram(mesh.getAttribMeta(), [model.getUniformMeta(), ambients.getUniformMeta()]) | |
var cube = EIGHT.drawableModel(mesh, shaders, model); | |
cube.model.color = EIGHT.Color.fromRGB(1, 1, 0); | |
scene.add(cube); | |
EIGHT.animation((time: number) => { | |
renderer.render(scene, ambients); | |
}).start(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { margin: 0; } | |
canvas { width: 100%; height: 100% } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment