Last active
August 29, 2015 14:22
-
-
Save mathdoodle/5a586ef3cffb5a8e5cbd to your computer and use it in GitHub Desktop.
Axis Labeling
This file contains 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": "5fa27fe7-8c12-4360-982b-47feb33c8c50", | |
"description": "Axis Labeling", | |
"dependencies": { | |
"DomReady": "latest", | |
"davinci-mathbox": "1.0.14" | |
} | |
} |
This file contains 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 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() {ThreeBox.preload(['../shaders/MathBox.glsl.html'], init);}); | |
function init() { | |
// MathBox boilerplate | |
var mathbox = mathBox({ | |
cameraControls: true, | |
cursor: true, | |
controlClass: ThreeBox.OrbitControls, | |
elementResize: true, | |
fullscreen: true, | |
screenshot: true, | |
stats: false, | |
scale: 1, | |
}).start(); | |
// Viewport camera/setup | |
mathbox | |
// Cartesian viewport | |
.viewport({ | |
type: 'cartesian', | |
range: [[-3, 3], [-2, 2], [-1, 1]], | |
scale: [1, 1, 1], | |
}) | |
.camera({ | |
orbit: 3.5, | |
phi: τ/6, | |
theta: 0.3, | |
}) | |
.transition(300) | |
// Axes | |
.axis({ | |
id: 'a', | |
axis: 0, | |
color: 0xa0a0a0, | |
ticks: 5, | |
lineWidth: 2, | |
size: .05, | |
labels: true, | |
}) | |
.axis({ | |
id: 'b', | |
axis: 1, | |
color: 0xa0a0a0, | |
ticks: 5, | |
lineWidth: 2, | |
size: .05, | |
zero: false, | |
labels: true, | |
}) | |
.axis({ | |
id: 'c', | |
axis: 2, | |
color: 0xa0a0a0, | |
ticks: 5, | |
lineWidth: 2, | |
size: .05, | |
zero: false, | |
labels: true, | |
}) | |
// Grid | |
.grid({ | |
axis: [0, 2], | |
color: 0xc0c0c0, | |
lineWidth: 1, | |
}) | |
// Move axis | |
setTimeout(function () { | |
mathbox.set('#c', { zero: true }); | |
mathbox.animate('#a', { | |
offset: [0, 0, -1], | |
}, { duration: 1500 }); | |
mathbox.animate('#b', { | |
offset: [-3, 0, -1], | |
}, { duration: 1500 }); | |
mathbox.animate('#c', { | |
offset: [-3, 0, 0], | |
}, { duration: 1500 }); | |
}, 3000); | |
// Move axis + grid | |
setTimeout(function () { | |
mathbox.set('#b', { labels: false, arrow: false }); | |
mathbox.axis({ | |
id: 'd', | |
axis: 1, | |
offset: [3, 0, -1], | |
ticks: 5, | |
lineWidth: 2, | |
color: 0xa0a0a0, | |
labels: true, | |
arrow: false, | |
}); | |
mathbox.axis({ | |
id: 'e', | |
axis: 1, | |
offset: [-3, 0, 1], | |
ticks: 5, | |
lineWidth: 2, | |
arrow: false, | |
color: 0xa0a0a0, | |
}); | |
mathbox.axis({ | |
id: 'f', | |
axis: 1, | |
offset: [3, 0, 1], | |
ticks: 5, | |
lineWidth: 2, | |
arrow: false, | |
color: 0xa0a0a0, | |
}); | |
mathbox.animate('grid', { | |
offset: [0, -2, 0], | |
}, { duration: 1500 }); | |
mathbox.grid({ | |
axis: [0, 2], | |
ticks: [2, 1], | |
offset: [0, 2, 0], | |
color: 0xc0c0c0, | |
lineWidth: 1, | |
}); | |
mathbox.animate('camera', { orbit: 7, phi: τ*5/8 + .2 }, { duration: 2500 }); | |
mathbox.animate('#a', { | |
offset: [0, -2, -1], | |
}, { duration: 1500 }); | |
mathbox.animate('#c', { | |
offset: [-3, -2, 0], | |
}, { duration: 1500 }); | |
mathbox.vector({ | |
n: 2, | |
data: [[0, 0, 0], [1, 1, 1], [-1, -1, -1], [0, 1, .5]], | |
}); | |
}, 6000); | |
} |
This file contains 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
html, body { height: 100%; } | |
body { margin: 0; padding: 0 } | |
canvas { display: block } | |
#info { | |
position: absolute; | |
left: 50%; | |
bottom: 50px; | |
z-index: 20; | |
width: 300px; | |
margin-left: -150px; | |
padding: 25px; | |
background: rgba(0, 0, 0, .5); | |
color: #fff; | |
font-family: "Lucida Grande", sans-serif; | |
font-size: 16px; | |
text-align: center; | |
border-radius: 3px; | |
text-shadow: 0px 1px 0px rgba(0, 0, 0, .4); | |
opacity: 0; | |
} | |
#info.transition { | |
-webkit-transition: opacity 300ms ease-in-out; | |
-moz-transition: opacity 300ms ease-in-out; | |
transition: opacity 300ms ease-in-out; | |
} | |
#info kbd { | |
background: #aaa; | |
box-shadow: 0px 1px 1px rgba(0, 0, 0, .3); | |
border-radius: 3px; | |
padding: 3px; | |
margin: 3px; | |
font-family: inherit; | |
} | |
.mathbox-label { | |
font-family: 'klavika-web', sans-serif; | |
font-weight: normal; | |
font-style: normal; | |
text-shadow: | |
3px 0px 1px rgb(255, 255, 255), | |
-3px 0px 1px rgb(255, 255, 255), | |
0px -3px 1px rgb(255, 255, 255), | |
0px 3px 1px rgb(255, 255, 255), | |
2px 2px 1px rgb(255, 255, 255), | |
-2px 2px 1px rgb(255, 255, 255), | |
2px -2px 1px rgb(255, 255, 255), | |
-2px -2px 1px rgb(255, 255, 255), | |
3px 2px 1px rgb(255, 255, 255), | |
-3px 2px 1px rgb(255, 255, 255), | |
3px -2px 1px rgb(255, 255, 255), | |
-3px -2px 1px rgb(255, 255, 255), | |
1px 3px 1px rgb(255, 255, 255), | |
-1px 3px 1px rgb(255, 255, 255), | |
1px -3px 1px rgb(255, 255, 255), | |
-1px -3px 1px rgb(255, 255, 255), | |
-1px -1px 1px rgb(255, 255, 255), | |
-1px 1px 1px rgb(255, 255, 255), | |
1px -1px 1px rgb(255, 255, 255), | |
1px 1px 1px rgb(255, 255, 255); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment