From python CGI to jekyll stuff

This commit is contained in:
Thomas FORGIONE
2015-04-23 17:49:59 +02:00
parent 36e4e5b916
commit 445219b013
135 changed files with 194 additions and 5112 deletions

View File

@@ -1,17 +1,23 @@
<section>
<h2>Streaming simulator</h2>
<p>
In fact, it's not really streaming. The sphere is fully
preloaded and then, a mesh is created and vertices and faces
are dynamically added to this mesh as time goes by.
</p>
<p>
You can try with a different resolution (between 1 and 25)
<form action="" method="GET">
Resolution : <input id="res" name="res" type="number" min="1" max="25" value="%(res)s" length=10/>
<input type="submit" value="Go !" />
</form>
</p>
<div style="border-width:1px; border-style: solid;" id="container"></div>
#
</section>
---
title: Streaming simulator
layout: withjs
extrajs: <script>params = {}; params.get= {}; params.get.res = 5;</script>
<script>
submitFunction = function(event) {
var form = document.getElementById('form');
form.action = "{% url 'stream' %}" + document.getElementById('res').value;
form.submit();
}
</script>
<script src="/static/js/stream/main.js"></script>
---
<section>
<h2>Streaming simulator</h2>
<p>
In fact, it's not really streaming. The sphere is fully
preloaded and then, a mesh is created and vertices and faces
are dynamically added to this mesh as time goes by.
</p>
<div style="border-width:1px; border-style: solid;" id="container"></div>
</section>

View File

@@ -1,48 +0,0 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import cgi
from webtools import Web
def main():
print('Content-type: text/html')
print()
page = Web.Element(Web.ROOT_DIR + 'templates/page.html')
head = Web.Element(Web.ROOT_DIR + 'templates/head.html')
body = Web.Element(Web.ROOT_DIR + 'templates/body.html')
jsIncludes = Web.Element(Web.ROOT_DIR + 'templates/jsIncludes.html')
# Parse parameter res
res = None
try:
parameters = cgi.FieldStorage()
res = int(cgi.escape(parameters.getvalue('res')))
if res < 1 or res > 25:
raise IndexError('res must be between 1 and 25')
except:
res = 5
mainJs = Web.Element()
mainJs.open_string = """\
<script>
params = {};
params.get = {};
params.post = {};
params.get.res = """ + str(res) + """;
</script>
<script src="js/main.js"></script>\
"""
content = Web.Element('index.html')
page.add_child(head)
page.add_child(body)
body.add_child(content)
body.add_child(jsIncludes)
jsIncludes.add_child(mainJs)
page.print({'res' : res})
if __name__ == '__main__':
main()

View File

@@ -1,87 +0,0 @@
var mesh_number = 25;
var renderer, scene, controls, cube, container, plane, mouse= {x:0, y:0}, sphere;
var bigmesh;
var raycaster;
var objects = [];
var spheres = new Array(mesh_number);
var visible = 0;
var loader;
var container_size = {width: 1067, height: 600};
init();
animate();
function init() {
// on initialise le moteur de rendu
container = document.getElementById('container');
container.style.height = container_size.height + 'px';
container.style.width = container_size.width + 'px';
renderer = new THREE.WebGLRenderer({alpha:"true"});
renderer.setSize(container_size.width, container_size.height);
renderer.shadowMapEnabled = true;
// renderer.setClearColor(0x000000);
document.getElementById('container').appendChild(renderer.domElement);
// on initialise la scène
scene = new THREE.Scene();
raycaster = new THREE.Raycaster();
// init light
var directional_light = new THREE.DirectionalLight(0x999999);
directional_light.position.set(1, 0.5, 1).normalize();
directional_light.castShadow = true;
scene.add(directional_light);
var ambient_light = new THREE.AmbientLight(0x333333);
scene.add(ambient_light);
// on initialise la camera que lon place ensuite sur la scène
camera = new Camera(50, container_size.width / container_size.height, 1, 100000);
scene.add(camera);
window.addEventListener('resize', onWindowResize, false);
container.addEventListener('mousedown', function() { } , false);
// Load the scene
loader = new THREE.OBJLoader();
sphere = new ProgessiveSphere(loader, params.get.res);
plane = new Plane(1000,1000);
plane.translate(0,0,-100);
plane.addToScene(scene);
}
function animate() {
// on appelle la fonction animate() récursivement à chaque frame
requestAnimationFrame(animate);
camera.update();
camera.look();
sphere.addFace();
renderer.render(scene, camera);
}
function onWindowResize() {
camera.aspect = container.offsetWidth / container.offsetHeight;
camera.updateProjectionMatrix();
renderer.setSize(container.offsetWidth, container.offsetHeight);
renderer.render(scene, camera);
}
function hide(object) {
object.traverse(function(object) {object.visible = false;});
}
function show(object) {
object.traverse(function(object) {object.visible = true;});
}
function click(event) {
// Nope
}