Skip to content

Commit 12d9ccf

Browse files
author
theom
committed
Add the world and the following UI components:
- letter - editable text_line - paragraph - button with a text label Add some basic server-side code and make some preparations for the installation scripts.
1 parent 4637d62 commit 12d9ccf

24 files changed

+40602
-0
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
tornado
2+
zodb
3+
bin
4+
include
5+
lib
6+
__pycache__
7+
db
8+
*~

allteria/main_handler.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
import tornado.web
3+
4+
class main_handler(tornado.web.RequestHandler):
5+
6+
def get(self):
7+
f = open("../allteria/static/index.html", "r")
8+
self.write(f.read())

allteria/server.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
import socket
3+
4+
import tornado.ioloop
5+
import tornado.web
6+
7+
from ZEO import ClientStorage
8+
from ZODB import DB
9+
import transaction
10+
11+
from allteria.main_handler import *
12+
from allteria.websocket_handler import *
13+
from allteria.router import *
14+
from allteria.aqueue import *
15+
16+
addr = socket.gethostname(), 9100
17+
storage = ClientStorage.ClientStorage(addr)
18+
db = DB(storage)
19+
conn = db.open()
20+
21+
main_loop = tornado.ioloop.IOLoop.instance()
22+
23+
application = tornado.web.Application(
24+
[
25+
(r"/", main_handler),
26+
(r"/ws", websocket_handler),
27+
(r"/(.*)", tornado.web.StaticFileHandler, {"path": "../allteria/static"})
28+
],
29+
debug=True)
30+
31+
application.listen(8000)
32+
main_loop.start()

allteria/static/css/style.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
#canvas1
3+
{
4+
position: absolute;
5+
left: 0px;
6+
top: 0px;
7+
width: 100%;
8+
height: 100%;
9+
}

allteria/static/index.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<html>
2+
3+
<head>
4+
<meta charset="utf-8">
5+
<link rel="stylesheet" type="text/css" href="css/style.css">
6+
<script type="text/javascript" src="js/three.js"></script>
7+
<script type="text/javascript" src="js/detector.js"></script>
8+
<script type="text/javascript" src="js/threex.windowresize.js"></script>
9+
<script type="text/javascript" src="js/tween.js"></script>
10+
<script type="text/javascript" src="js/allteria.js"></script>
11+
</head>
12+
13+
<body id="body" onLoad="allteria.start();">
14+
<div id="canvas1"></div>
15+
<script type="text/javascript" src="js/socket.js"></script>
16+
<script type="text/javascript" src="js/ui_component.js"></script>
17+
<script type="text/javascript" src="js/letter.js"></script>
18+
<script type="text/javascript" src="js/letters.js"></script>
19+
<script type="text/javascript" src="js/text_line.js"></script>
20+
<script type="text/javascript" src="js/paragraph.js"></script>
21+
<script type="text/javascript" src="js/button.js"></script>
22+
<script type="text/javascript" src="js/world.js"></script>
23+
<script type="text/javascript" src="js/main.js"></script>
24+
</body>
25+
26+
</html>

allteria/static/js/allteria.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
// @author theom / https://www.axonehf.com
3+
4+
allteria = {};
5+
6+
allteria.extend = function(child, parent)
7+
{
8+
child.prototype = Object.create(parent.prototype);
9+
child.prototype.constructor = child;
10+
11+
if (arguments.length > 2)
12+
{
13+
for (var i = 2; i < arguments.length; i++)
14+
{
15+
var mixin = arguments[i];
16+
for (var method in mixin.prototype)
17+
{
18+
child.prototype[method] = mixin.prototype[prop];
19+
}
20+
}
21+
}
22+
}
23+
24+
three = THREE;
25+
threex = THREEx;
26+
tween = TWEEN;

allteria/static/js/button.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
// @author theom / https://www.axonehf.com
3+
4+
allteria.button = function button(text)
5+
{
6+
allteria.ui_component.call(this);
7+
8+
this.text = new allteria.text_line(text);
9+
10+
this.width = 1.2 * this.text.get_width();
11+
this.height = 1.8 * this.text.get_height();
12+
this.enabled = true;
13+
14+
this.text.translateX(-this.text.get_width() / 2);
15+
this.add(this.text);
16+
17+
var geo = new three.PlaneGeometry(this.width, this.height);
18+
var mat = new three.MeshBasicMaterial({color: 0x00dd00});
19+
this.background = new three.Mesh(geo, mat);
20+
this.add(this.background);
21+
22+
// Enable hit detection on all the children
23+
var self = this;
24+
this.traverse(function(mesh)
25+
{
26+
mesh.comp = self;
27+
});
28+
}
29+
30+
allteria.extend(allteria.button, allteria.ui_component);
31+
32+
allteria.button.prototype.on_mouse_down = function on_mouse_down(event)
33+
{
34+
if (this.on_click)
35+
{
36+
this.on_click(event);
37+
}
38+
}
39+
40+
allteria.button.prototype.on_mouse_enter = function on_mouse_enter(event)
41+
{
42+
if (this.enabled)
43+
{
44+
document.body.style.cursor = "pointer";
45+
}
46+
}
47+
48+
allteria.button.prototype.on_mouse_leave = function on_mouse_enter(event)
49+
{
50+
document.body.style.cursor = "default";
51+
}

allteria/static/js/detector.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* @author alteredq / http://alteredqualia.com/
3+
* @author mr.doob / http://mrdoob.com/
4+
*/
5+
6+
var Detector = {
7+
8+
canvas: !! window.CanvasRenderingContext2D,
9+
webgl: ( function () { try { var canvas = document.createElement( 'canvas' ); return !! window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ); } catch( e ) { return false; } } )(),
10+
workers: !! window.Worker,
11+
fileapi: window.File && window.FileReader && window.FileList && window.Blob,
12+
13+
getWebGLErrorMessage: function () {
14+
15+
var element = document.createElement( 'div' );
16+
element.id = 'webgl-error-message';
17+
element.style.fontFamily = 'monospace';
18+
element.style.fontSize = '13px';
19+
element.style.fontWeight = 'normal';
20+
element.style.textAlign = 'center';
21+
element.style.background = '#fff';
22+
element.style.color = '#000';
23+
element.style.padding = '1.5em';
24+
element.style.width = '400px';
25+
element.style.margin = '5em auto 0';
26+
27+
if ( ! this.webgl ) {
28+
29+
element.innerHTML = window.WebGLRenderingContext ? [
30+
'Your graphics card does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">WebGL</a>.<br />',
31+
'Find out how to get it <a href="http://get.webgl.org/" style="color:#000">here</a>.'
32+
].join( '\n' ) : [
33+
'Your browser does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">WebGL</a>.<br/>',
34+
'Find out how to get it <a href="http://get.webgl.org/" style="color:#000">here</a>.'
35+
].join( '\n' );
36+
37+
}
38+
39+
return element;
40+
41+
},
42+
43+
addGetWebGLMessage: function ( parameters ) {
44+
45+
var parent, id, element;
46+
47+
parameters = parameters || {};
48+
49+
parent = parameters.parent !== undefined ? parameters.parent : document.body;
50+
id = parameters.id !== undefined ? parameters.id : 'oldie';
51+
52+
element = Detector.getWebGLErrorMessage();
53+
element.id = id;
54+
55+
parent.appendChild( element );
56+
57+
}
58+
59+
};

0 commit comments

Comments
 (0)