Some cleaning 😢
This commit is contained in:
25
server/controllers/stream/index.js
Normal file
25
server/controllers/stream/index.js
Normal file
@@ -0,0 +1,25 @@
|
||||
var tools = require('../../lib/filterInt');
|
||||
|
||||
module.exports.index = function(req, res, next) {
|
||||
|
||||
// Parse get argument res
|
||||
res.locals.resolution = req.params.res;
|
||||
|
||||
if (res.locals.resolution === undefined) {
|
||||
res.locals.resolution = 5;
|
||||
} else {
|
||||
res.locals.resolution = tools.filterInt(res.locals.resolution);
|
||||
}
|
||||
|
||||
if (isNaN(res.locals.resolution) || res.locals.resolution < 1 || res.locals.resolution > 25) {
|
||||
var error = new Error("Resolution was not set properly");
|
||||
error.status = 404;
|
||||
next(error);
|
||||
return;
|
||||
}
|
||||
|
||||
res.setHeader('Content-Type', 'text/html');
|
||||
res.render('index.jade', res.locals, function(err, result) {
|
||||
res.send(result);
|
||||
});
|
||||
};
|
||||
3
server/controllers/stream/urls.js
Normal file
3
server/controllers/stream/urls.js
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/stream/:res?': 'index'
|
||||
};
|
||||
48
server/controllers/stream/views/index.jade
Normal file
48
server/controllers/stream/views/index.jade
Normal file
@@ -0,0 +1,48 @@
|
||||
extends ../../../views/main
|
||||
|
||||
block title
|
||||
title #{title} - Sphere streaming
|
||||
|
||||
block extrajs
|
||||
script params = {}; params.get= {}; params.get.res = #{resolution}
|
||||
script(src="/static/js/three.min.js")
|
||||
script(src="/static/js/socket.io.min.js")
|
||||
script(src="/static/js/l3d.min.js")
|
||||
script(src="/static/js/streamingsimulator.min.js")
|
||||
script(type='text/javascript').
|
||||
$(function() {
|
||||
var filterInt = function (value) {
|
||||
if(/^(\-|\+)?([0-9]+|Infinity)$/.test(value))
|
||||
return Number(value);
|
||||
return NaN;
|
||||
}
|
||||
|
||||
$('#form').submit(function(e) {
|
||||
e.preventDefault();
|
||||
var val = filterInt(document.getElementById('num').value);
|
||||
window.location.href = "/stream/" + val;
|
||||
});
|
||||
});
|
||||
|
||||
block content
|
||||
h2 Sphere streaming
|
||||
|
||||
p.
|
||||
<s>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.</s>
|
||||
|
||||
p.
|
||||
In fact, it is acutally streaming. If you web browser supports
|
||||
WebSocket, you'll connect to the server and the mesh will be streamed
|
||||
onto the socket and the faces will be displayed as soon as you receive
|
||||
them.
|
||||
|
||||
form.form-inline#form
|
||||
.form-group
|
||||
label Try another resolution (between 1 and 25)
|
||||
input#num(type='number', min=1, max=25, value=5, style={"margin-left":"10px"})
|
||||
.form-group
|
||||
button#submit.btn.btn-primary(type='submit', style={"margin-left":"10px"}) Go
|
||||
|
||||
#container
|
||||
Reference in New Issue
Block a user