Got rid of static_path...was a bad idea

This commit is contained in:
Thomas FORGIONE 2015-06-25 16:51:47 +02:00
parent 8308ce5ab7
commit e915fb58e7
9 changed files with 23 additions and 30 deletions

View File

@ -4,7 +4,6 @@ block title
title #{title} - Prototype title #{title} - Prototype
block extrajs block extrajs
script static_path = '/static/';
script(src="/static/js/prototypetools.min.js") script(src="/static/js/prototypetools.min.js")
block configjs block configjs
block mainjs block mainjs

View File

@ -4,7 +4,6 @@ block title
title #{title} - Prototype title #{title} - Prototype
block extrajs block extrajs
script static_path = '/static/'
script(src="/static/js/prototypetools.min.js") script(src="/static/js/prototypetools.min.js")
script RecommendedCamera = FixedCamera; script RecommendedCamera = FixedCamera;
script var params = params || {}; params.get = params.get || {}; params.get.id = #{id}; script var params = params || {}; params.get = params.get || {}; params.get.id = #{id};

View File

@ -10,7 +10,7 @@ var ProgessiveSphere = function(loader, res) {
res = 5; res = 5;
(function(self) { (function(self) {
loader.load(static_path + 'data/spheres/' + res + '.obj', function(object) { loader.load('/static/data/spheres/' + res + '.obj', function(object) {
object.traverse(function(child) { object.traverse(function(child) {
if (child instanceof THREE.Mesh) { if (child instanceof THREE.Mesh) {
child.up = new THREE.Vector3(0,0,1); child.up = new THREE.Vector3(0,0,1);

View File

@ -52,7 +52,7 @@ function init() {
// Capture of i // Capture of i
// I am pretty good // I am pretty good
(function(i) { (function(i) {
loader.load(static_path + 'data/spheres/' + (i+1) + '.obj', function (object) { loader.load('/static/data/spheres/' + (i+1) + '.obj', function (object) {
object.traverse(function (child) { object.traverse(function (child) {
if (child instanceof THREE.Mesh ) { if (child instanceof THREE.Mesh ) {
child.material.color.setHex(0xff0000); child.material.color.setHex(0xff0000);

View File

@ -147,7 +147,7 @@ Coin.init = function(scale) {
} }
Coin._loader.load( Coin._loader.load(
static_path + 'data/coin/Coin.obj', '/static/data/coin/Coin.obj',
function(object) { function(object) {
object.traverse(function (mesh) { object.traverse(function (mesh) {
if (mesh instanceof THREE.Mesh) { if (mesh instanceof THREE.Mesh) {
@ -161,6 +161,6 @@ Coin.init = function(scale) {
} }
); );
Coin.nextSound = new Audio(static_path + 'data/music/redcoins/1' + Coin.extension); Coin.nextSound = new Audio('/static/data/music/redcoins/1' + Coin.extension);
} }
} }

View File

@ -43,7 +43,7 @@ function resetPeachElements() {
}; };
} }
function initPeach(camera, scene, static_path, coins) { function initPeach(camera, scene, coins) {
addLight(scene); addLight(scene);
var loader = new THREE.OBJMTLLoader(); var loader = new THREE.OBJMTLLoader();
@ -66,20 +66,15 @@ function initPeach(camera, scene, static_path, coins) {
return cameras; return cameras;
} }
function initZeldaScene(scene, collidableObjects, loader, static_path) { function initZeldaScene(scene, collidableObjects, loader) {
// Create loader if not already done // Create loader if not already done
if (loader === undefined) { if (loader === undefined) {
loader = new THREE.OBJMTLLoader(); loader = new THREE.OBJMTLLoader();
} }
// Try to guess the path to static files
if (static_path === undefined) {
static_path = "/static/";
}
loader.load( loader.load(
static_path + 'data/zelda/Island.obj', '/static/data/zelda/Island.obj',
static_path + 'data/zelda/Island.mtl', '/static/data/zelda/Island.mtl',
function ( object ) { function ( object ) {
collidableObjects.push(object); collidableObjects.push(object);
object.scale.set(0.01,0.01,0.01); object.scale.set(0.01,0.01,0.01);
@ -163,7 +158,7 @@ function createPeachCameras(width, height) {
function initBobombScene(scene, collidableObjects, loader, camera) { function initBobombScene(scene, collidableObjects, loader, camera) {
var loader = new ProgressiveLoaderGeometry( var loader = new ProgressiveLoaderGeometry(
static_path + 'data/bobomb/bobomb battlefeild.obj', '/static/data/bobomb/bobomb battlefeild.obj',
scene, scene,
null, null,
function(object) { function(object) {
@ -273,7 +268,7 @@ function createBobombCameras(width, height) {
} }
function initBobomb(camera, scene, static_path, coins) { function initBobomb(camera, scene, coins) {
addLight(scene); addLight(scene);
var loader = new THREE.OBJMTLLoader(); var loader = new THREE.OBJMTLLoader();
@ -309,7 +304,7 @@ function initBobomb(camera, scene, static_path, coins) {
function initWhompScene(scene, collidableObjects, loader, camera) { function initWhompScene(scene, collidableObjects, loader, camera) {
var loader = new ProgressiveLoaderGeometry( var loader = new ProgressiveLoaderGeometry(
static_path + 'data/whomp/Whomps Fortress.obj', '/static/data/whomp/Whomps Fortress.obj',
scene, scene,
null, null,
function(object) { function(object) {
@ -437,7 +432,7 @@ function resetWhompElements() {
}; };
} }
function initWhomp(camera, scene, static_path, coins) { function initWhomp(camera, scene, coins) {
addLight(scene); addLight(scene);
var loader = new THREE.OBJMTLLoader(); var loader = new THREE.OBJMTLLoader();
@ -473,7 +468,7 @@ function initWhomp(camera, scene, static_path, coins) {
function initMountainScene(scene, collidableObjects, loader, camera) { function initMountainScene(scene, collidableObjects, loader, camera) {
var loader = new ProgressiveLoaderGeometry( var loader = new ProgressiveLoaderGeometry(
static_path + 'data/mountain/coocoolmountain.obj', '/static/data/mountain/coocoolmountain.obj',
scene, scene,
null, null,
function(object) { function(object) {
@ -590,7 +585,7 @@ function resetMountainElements() {
} }
} }
function initMountain(camera, scene, static_path, coins) { function initMountain(camera, scene, coins) {
addLight(scene); addLight(scene);
var loader = new THREE.OBJMTLLoader(); var loader = new THREE.OBJMTLLoader();
@ -691,7 +686,7 @@ function resetSponzaElements() {
}; };
} }
function initSponza(camera, scene, static_path, coins) { function initSponza(camera, scene, coins) {
addLight(scene); addLight(scene);
var loader = new THREE.JSONLoader(); var loader = new THREE.JSONLoader();

12
js/prototype/main.js vendored
View File

@ -125,12 +125,12 @@ function init() {
startCanvas.render(); startCanvas.render();
cameras = initMainScene(camera1, scene, static_path, coins); cameras = initMainScene(camera1, scene, coins);
// cameras = initPeach(camera1, scene, static_path, coins); // cameras = initPeach(camera1, scene, coins);
// cameras = initBobomb(camera1, scene, static_path, coins); // cameras = initBobomb(camera1, scene, coins);
// cameras = initWhomp(camera1, scene, static_path, coins); // cameras = initWhomp(camera1, scene, , coins);
// cameras = initMountain(camera1, scene, static_path, coins); // cameras = initMountain(camera1, scene, coins);
// cameras = initSponza(camera1, scene, static_path, coins); // cameras = initSponza(camera1, scene, coins);
// Add listeners // Add listeners
initListeners(); initListeners();

View File

@ -72,7 +72,7 @@ function init() {
// Initialize pointer camera // Initialize pointer camera
var camera1 = new ReplayCamera(50, container_size.width() / container_size.height(), 0.01, 100000, coins); var camera1 = new ReplayCamera(50, container_size.width() / container_size.height(), 0.01, 100000, coins);
cameras = initMainScene(camera1, scene, static_path, coins); cameras = initMainScene(camera1, scene, coins);
camera1.cameras = cameras; camera1.cameras = cameras;
// Add listeners // Add listeners

View File

@ -92,7 +92,7 @@ function init() {
tutorial.setCameras(cameras); tutorial.setCameras(cameras);
// Load peach scene // Load peach scene
initPeach(camera1, scene, static_path); initPeach(camera1, scene);
initListeners(); initListeners();