Last active
August 29, 2015 14:23
-
-
Save mathdoodle/076dd6e8cd1031c00c0f to your computer and use it in GitHub Desktop.
Eight
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": "a9ed377b-e750-4731-8c26-3a8e7d5d09da", | |
"description": "Eight", | |
"dependencies": { | |
"davinci-eight": "latest" | |
}, | |
"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> | |
<!-- SCRIPTS-MARKER --> | |
</head> | |
<body> | |
<script> | |
// CODE-MARKER | |
</script> | |
</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
var scene = EIGHT.world(); | |
var camera = EIGHT.perspective(45 * Math.PI / 180, 1.0, 0.1, 100); | |
var renderer = EIGHT.viewport(); | |
var box = EIGHT.box(camera); | |
scene.add(box); | |
box.model.position = blade.vectorE3(-1.0,-0.5,-5.0); | |
var workbench = EIGHT.workbench(renderer.canvas, renderer, camera, window); | |
function setUp() { | |
workbench.setUp(); | |
monitor.start(); | |
} | |
var B = blade.bivectorE3(0,1,1); | |
B = B / B.norm() | |
var angle: number = 0; | |
/** | |
* Performs the animation. | |
*/ | |
function tick(time: number) { | |
var halfAngle = angle/2; | |
var c = Math.cos(halfAngle); | |
var s = Math.sin(halfAngle); | |
var R = c - B * s; | |
box.model.attitude = R; | |
renderer.render(scene, [camera]); | |
angle += 0.05; | |
} | |
/** | |
* Determines whether to terminate the animation. | |
*/ | |
function terminate(time: number) {return false;} | |
function tearDown(e) { | |
monitor.stop(); | |
if (e) { | |
console.log("Error during animation: " + e); | |
} | |
else { | |
console.log("Goodbye!"); | |
workbench.tearDown(); | |
} | |
} | |
var runner = EIGHT.animationRunner(tick, terminate, setUp, tearDown, window); | |
// TODO: Would be nicer to simply add dependents to the monitor. Is this just the same as the scene? | |
var monitor = EIGHT.contextMonitor(renderer.canvas); | |
monitor.addContextUser(scene); | |
monitor.addContextUser(renderer); | |
runner.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