Skip to content

Commit 7144e11

Browse files
committed
Add empty example + type check
1 parent bda029e commit 7144e11

File tree

8 files changed

+165
-7
lines changed

8 files changed

+165
-7
lines changed

build/MathBox-bundle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44082,7 +44082,7 @@ tQuery.World.registerInstance('mathBox', function (element, options) {
4408244082
*/
4408344083
MathBox.Director = function (stage, script) {
4408444084
this._stage = stage;
44085-
this.script = script;
44085+
this.script = script || [];
4408644086
this.rollback = {};
4408744087
this.clocks = {};
4408844088

build/MathBox-bundle.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/MathBox-core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ tQuery.World.registerInstance('mathBox', function (element, options) {
14731473
*/
14741474
MathBox.Director = function (stage, script) {
14751475
this._stage = stage;
1476-
this.script = script;
1476+
this.script = script || [];
14771477
this.rollback = {};
14781478
this.clocks = {};
14791479

build/MathBox-core.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/MathBox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4459,7 +4459,7 @@ tQuery.World.registerInstance('mathBox', function (element, options) {
44594459
*/
44604460
MathBox.Director = function (stage, script) {
44614461
this._stage = stage;
4462-
this.script = script;
4462+
this.script = script || [];
44634463
this.rollback = {};
44644464
this.clocks = {};
44654465

build/MathBox.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/Empty.html

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>MathBox - Empty Example.</title>
6+
7+
<!--
8+
This example is good for starting from.
9+
-->
10+
11+
<script type="text/javascript" charset="utf-8" src="../vendor/domready.js"></script>
12+
<script type="text/javascript" charset="utf-8" src="../build/MathBox-bundle.js"></script>
13+
14+
<script type="text/javascript" charset="utf-8">
15+
16+
function mathboxSetup() {
17+
// Viewport camera/setup
18+
mathbox
19+
// Cartesian viewport
20+
.viewport({
21+
type: 'cartesian',
22+
range: [[-3, 3], [-2, 2], [-1, 1]],
23+
scale: [1.5, 1, 1],
24+
})
25+
.camera({
26+
orbit: 3.5,
27+
phi: τ/4,
28+
theta: 0,
29+
})
30+
.transition(300)
31+
}
32+
33+
var mathboxScript = [
34+
// Steps go here
35+
/*
36+
['add', 'curve', {
37+
id: 'my-curve',
38+
domain: [-3, 3],
39+
expression: function (x, i) {
40+
return [x, Math.sin(x), 0];
41+
},
42+
// ...
43+
}, {
44+
delay: 500,
45+
duration: 300,
46+
}],
47+
*/
48+
];
49+
50+
</script>
51+
52+
<script type="text/javascript" charset="utf-8">
53+
/**
54+
* Bootstrap
55+
*/
56+
DomReady.ready(function() {
57+
ThreeBox.preload([
58+
'../shaders/snippets.glsl.html',
59+
], function () {
60+
61+
// MathBox boilerplate
62+
var mathbox = window.mathbox = mathBox({
63+
cameraControls: true,
64+
cursor: true,
65+
controlClass: ThreeBox.OrbitControls,
66+
elementResize: true,
67+
fullscreen: true,
68+
screenshot: true,
69+
stats: false,
70+
scale: 1,
71+
}).start();
72+
73+
// Set up director
74+
var script = window.mathboxScript;
75+
var director = window.director = new MathBox.Director(mathbox, script);
76+
77+
// Arrow controls
78+
// Controls for stand-alone
79+
window.addEventListener('touchstart', function (e) {
80+
director.forward();
81+
document.getElementById('info').style.opacity = '0';
82+
});
83+
window.addEventListener('keydown', function (e) {
84+
if (e.keyCode == 38 || e.keyCode == 37) director.back();
85+
else if (e.keyCode == 40 || e.keyCode == 39) director.forward();
86+
else {
87+
return;
88+
}
89+
90+
document.getElementById('info').style.opacity = '0';
91+
});
92+
93+
window.mathboxSetup(mathbox);
94+
95+
});
96+
});
97+
</script>
98+
99+
<script type="text/javascript" charset="utf-8">
100+
/**
101+
* file:// cross origin policy test
102+
*/
103+
DomReady.ready(function () {
104+
if (location.href.match(/^file:/)) {
105+
document.getElementById('info').style.opacity = 1;
106+
document.getElementById('info').innerHTML = "Sorry. This example does not work when accessed using file://. Please use an http:// host and try again.";
107+
}
108+
});
109+
</script>
110+
111+
<style type="text/css" media="screen">
112+
/**
113+
* css
114+
*/
115+
html, body { height: 100%; }
116+
body { margin: 0; padding: 0 }
117+
canvas { display: block }
118+
119+
#info {
120+
position: absolute;
121+
left: 50%;
122+
bottom: 50px;
123+
z-index: 20;
124+
125+
width: 300px;
126+
margin-left: -150px;
127+
128+
padding: 25px;
129+
background: rgba(0, 0, 0, .5);
130+
color: #fff;
131+
132+
font-family: "Lucida Grande", sans-serif;
133+
font-size: 16px;
134+
text-align: center;
135+
136+
border-radius: 3px;
137+
text-shadow: 0px 1px 0px rgba(0, 0, 0, .4);
138+
139+
opacity: 0;
140+
}
141+
142+
#info kbd {
143+
background: #aaa;
144+
145+
box-shadow: 0px 1px 1px rgba(0, 0, 0, .3);
146+
border-radius: 3px;
147+
padding: 3px;
148+
margin: 3px;
149+
150+
font-family: inherit;
151+
}
152+
</style>
153+
154+
</head>
155+
<body>
156+
<div id="info"></div>
157+
</body>
158+
</html>

src/Director.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
MathBox.Director = function (stage, script) {
88
this._stage = stage;
9-
this.script = script;
9+
this.script = script || [];
1010
this.rollback = {};
1111
this.clocks = {};
1212

0 commit comments

Comments
 (0)