This commit is contained in:
Thomas FORGIONE 2015-06-15 09:40:30 +02:00
parent 638111c3b1
commit 5fca88ea8f
3 changed files with 240 additions and 463 deletions

View File

@ -1,194 +1,194 @@
var ProgressiveLoader = function(path, scene, materialCreator, transparentElements) { var ProgressiveLoader = function(path, scene, callback) {
if (transparentElements === undefined) { // Create MTLLoader
transparentElements = []; var loader = new THREE.MTLLoader(path.substring(0, path.lastIndexOf('/')) + '/');
} loader.load(path.replace('.obj', '.mtl'), function(materialCreator) {
// Create mesh materialCreator.preload();
var obj = new THREE.Object3D();
obj.up = new THREE.Vector3(0,0,1);
glob = obj;
var currentMesh; // Create mesh
var currentMaterial; var obj = new THREE.Object3D();
obj.up = new THREE.Vector3(0,0,1);
glob = obj;
var added = false; var currentMesh;
var finished = false; var currentMaterial;
var socket = io(); var added = false;
var finished = false;
var vertices = []; var socket = io();
var textCoords = [];
var uvs = [];
var faces = [];
// Init streaming with socket var vertices = [];
socket.emit('request', path); var textCoords = [];
var uvs = [];
var faces = [];
// When server's ready, start asking for the mesh // Init streaming with socket
socket.on('ok', function() { socket.emit('request', path.substring(1, path.length));
socket.emit('next');
});
// When receiving elements // When server's ready, start asking for the mesh
socket.on('elements', function(arr) { socket.on('ok', function() {
console.log("Got stuff");
if (!finished) {
socket.emit('next'); socket.emit('next');
} });
// Launch this code in async // When receiving elements
setTimeout(function() { socket.on('elements', function(arr) {
// We'll receive an array of string (obj) console.log("Got stuff");
for (var i = 0; i < arr.length; i++) {
var elts = arr[i]; if (!finished) {
socket.emit('next');
}
// console.log(line); // Launch this code in async
setTimeout(function() {
if (elts[0] === 'v') { // We'll receive an array of string (obj)
for (var i = 0; i < arr.length; i++) {
vertices.push(new THREE.Vector3( var elts = arr[i];
elts[1],
elts[2],
elts[3]
));
} else if (elts[0] === 'vt') { // console.log(line);
textCoords.push(new THREE.Vector2( if (elts[0] === 'v') {
elts[1],
elts[2]
));
} else if (elts[0] === 'f') { vertices.push(new THREE.Vector3(
elts[1],
elts[2],
elts[3]
));
faces.push(new THREE.Face3( } else if (elts[0] === 'vt') {
elts[1],
elts[2],
elts[3]
));
// If the face has 4 vertices, create second triangle textCoords.push(new THREE.Vector2(
if (elts.length === 5 || elts.length === 9) { elts[1],
elts[2]
));
} else if (elts[0] === 'f') {
faces.push(new THREE.Face3( faces.push(new THREE.Face3(
elts[1], elts[1],
elts[3], elts[2],
elts[4] elts[3]
)); ));
} // If the face has 4 vertices, create second triangle
if (elts.length === 5 || elts.length === 9) {
// Add texture faces.push(new THREE.Face3(
if (elts.length === 7) { elts[1],
uvs.push([ elts[3],
textCoords[elts[4]], elts[4]
textCoords[elts[5]], ));
textCoords[elts[6]]
]);
}
if (elts.length === 9) {
uvs.push([
textCoords[elts[5]],
textCoords[elts[6]],
textCoords[elts[7]]
]);
}
if (elts.length === 9) {
uvs.push([
textCoords[elts[5]],
textCoords[elts[7]],
textCoords[elts[8]]
]);
}
// Add currentMesh to scene one there are a few faces in it
if (!added) {
scene.add(obj);
added = true;
}
if (!currentMesh) {
var geo = new THREE.Geometry();
geo.vertices = vertices;
geo.faces = faces;
geo.faceVertexUvs = [uvs];
var material, tmp = currentMaterial;
if (currentMaterial === undefined || currentMaterial === null) {
material = new THREE.MeshLambertMaterial({color: 'red'});
} else {
material = materialCreator.materials[currentMaterial.trim()];
material.side = THREE.DoubleSide;
if (material.map)
material.map.wrapS = material.map.wrapT = THREE.RepeatWrapping;
currentMaterial = null;
}
currentMesh = new THREE.Mesh(geo, material);
if (tmp && transparentElements.indexOf(tmp.trim()) !== -1) {
THREEx.Transparency.push(currentMesh);
} else {
currentMesh.raycastable = true;
} }
currentMesh.geometry.computeFaceNormals(); // Add texture
if (elts.length === 7) {
uvs.push([
textCoords[elts[4]],
textCoords[elts[5]],
textCoords[elts[6]]
]);
}
if (elts.length === 9) {
uvs.push([
textCoords[elts[5]],
textCoords[elts[6]],
textCoords[elts[7]]
]);
}
if (elts.length === 9) {
uvs.push([
textCoords[elts[5]],
textCoords[elts[7]],
textCoords[elts[8]]
]);
}
// Add currentMesh to scene one there are a few faces in it
if (!added) {
scene.add(obj);
added = true;
}
if (!currentMesh) {
var geo = new THREE.Geometry();
geo.vertices = vertices;
geo.faces = faces;
geo.faceVertexUvs = [uvs];
var material, tmp = currentMaterial;
if (currentMaterial === undefined || currentMaterial === null) {
material = new THREE.MeshLambertMaterial({color: 'red'});
} else {
material = materialCreator.materials[currentMaterial.trim()];
material.side = THREE.DoubleSide;
if (material.map)
material.map.wrapS = material.map.wrapT = THREE.RepeatWrapping;
currentMaterial = null;
}
currentMesh = new THREE.Mesh(geo, material);
if (typeof callback === 'function') {
callback(currentMesh, obj);
}
currentMesh.geometry.computeFaceNormals();
}
obj.add(currentMesh);
} else if (elts[0] === 'u') {
// Add current mesh
// if (currentMesh) {
// obj.add(currentMesh);
// }
// Prepare new mesh
faces = [];
uvs = [];
// currentMesh.geometry.computeFaceNormals();
if (currentMesh) {
currentMesh.geometry.computeFaceNormals();
currentMesh.geometry.computeBoundingSphere();
currentMesh.geometry.groupsNeedUpdate = true;
currentMesh.geometry.elementsNeedUpdate = true;
currentMesh.geometry.normalsNeedUpdate = true;
currentMesh.geometry.uvsNeedUpdate = true;
}
currentMaterial = elts[1];
currentMesh = null;
// console.log(material.map);
// currentMesh = new THREE.Mesh(geo, material);
} }
obj.add(currentMesh);
} else if (elts[0] === 'u') {
// Add current mesh
// if (currentMesh) {
// obj.add(currentMesh);
// }
// Prepare new mesh
faces = [];
uvs = [];
// currentMesh.geometry.computeFaceNormals();
if (currentMesh) {
currentMesh.geometry.computeFaceNormals();
currentMesh.geometry.computeBoundingSphere();
currentMesh.geometry.groupsNeedUpdate = true;
currentMesh.geometry.elementsNeedUpdate = true;
currentMesh.geometry.normalsNeedUpdate = true;
currentMesh.geometry.uvsNeedUpdate = true;
}
currentMaterial = elts[1];
currentMesh = null;
// console.log(material.map);
// currentMesh = new THREE.Mesh(geo, material);
} }
} if (currentMesh) {
currentMesh.material.side = THREE.DoubleSide;
currentMesh.geometry.computeFaceNormals();
currentMesh.geometry.computeBoundingSphere();
currentMesh.geometry.groupsNeedUpdate = true;
currentMesh.geometry.elementsNeedUpdate = true;
currentMesh.geometry.normalsNeedUpdate = true;
currentMesh.geometry.uvsNeedUpdate = true;
}
if (currentMesh) { },0);
currentMesh.material.side = THREE.DoubleSide; });
currentMesh.geometry.computeFaceNormals();
currentMesh.geometry.computeBoundingSphere(); socket.on('disconnect', function() {
currentMesh.geometry.groupsNeedUpdate = true; console.log("Finished");
currentMesh.geometry.elementsNeedUpdate = true; finished = true;
currentMesh.geometry.normalsNeedUpdate = true; });
currentMesh.geometry.uvsNeedUpdate = true;
}
},0);
}); });
socket.on('disconnect', function() {
console.log("Finished");
finished = true;
});
return obj;
} }

View File

@ -12,84 +12,25 @@ function addLight(scene) {
} }
function initPeachCastle(scene, collidableObjects, loader, static_path) { function initPeachCastle(scene, collidableObjects, loader, static_path) {
// Create loader if not already done
if (loader === undefined) {
loader = new THREE.OBJMTLLoader();
}
// Try to guess the path to static files ProgressiveLoader(
if (static_path === undefined) { '/static/data/castle/princess peaches castle (outside).obj',
static_path = "/static/"; scene,
} function(object, container) {
// var loader = new THREE.MTLLoader('/static/data/castle/');
// loader.load('/static/data/castle/princess peaches castle (outside).mtl', function(materialCreator) {
// materialCreator.preload();
// var mesh = ProgressiveLoader('static/data/castle/princess peaches castle (outside).obj', scene, materialCreator);
// });
loader.load(
static_path + 'data/castle/princess peaches castle (outside).obj',
static_path + 'data/castle/princess peaches castle (outside).mtl',
function ( object ) {
glob = object;
object.up = new THREE.Vector3(0,0,1);
scene.add(object);
collidableObjects.push(object); collidableObjects.push(object);
object.traverse(function (object) { object.raycastable = true;
if (object instanceof THREE.Mesh) { if (object.material.name === 'Material.103_princess_peaches_cast') {
object.geometry.mergeVertices(); THREEx.Transparency.push(object);
object.geometry.computeVertexNormals(); } else if (object.material.name === 'Material.136_princess_peaches_cast' ||
object.material.side = THREE.DoubleSide; object.material.name === 'Material.135_princess_peaches_cast') {
object.raycastable = true; THREEx.Transparency.push(object);
if (object.material.name === 'Material.103_princess_peaches_cast') { object.material.opacity = 0.5;
THREEx.Transparency.push(object); object.raycastable = false;
} else if (object.material.name === 'Material.136_princess_peaches_cast' || object.material.side = THREE.FrontSide;
object.material.name === 'Material.135_princess_peaches_cast') { }
THREEx.Transparency.push(object);
object.material.opacity = 0.5;
object.material.side = THREE.FrontSide;
object.raycastable = false;
var newObj = object.clone();
newObj.material = object.material.clone();
newObj.material.side = THREE.BackSide;
scene.add(newObj);
}
}
});
} }
); );
// loader.load(
// static_path + 'data/first/Floor 1.obj',
// static_path + 'data/first/Floor 1.mtl',
// function ( object ) {
// object.position.z -= 10.9;
// object.position.y += 0.555;
// object.position.x += 3.23;
// var theta = 0.27;
// object.rotation.y = Math.PI - theta;
// object.up = new THREE.Vector3(0,0,1);
// scene.add(object);
// collidableObjects.push(object);
// object.traverse(function (object) {
// if (object instanceof THREE.Mesh) {
// object.material.side = THREE.DoubleSide;
// object.geometry.mergeVertices();
// object.geometry.computeVertexNormals();
// object.raycastable = true;
// if (object.material.name === 'Material.054_777F0E0B_c.bmp' ||
// object.material.name === 'Material.061_5C3492AB_c.bmp' ) {
// THREEx.Transparency.push(object);
// }
// }
// });
// }
// );
} }
function resetPeachElements() { function resetPeachElements() {
@ -154,39 +95,6 @@ function initZeldaScene(scene, collidableObjects, loader, static_path) {
} }
); );
// loader.load(
// static_path + 'data/zelda/Sea.obj',
// static_path + 'data/zelda/Sea.mtl',
// function ( object ) {
// scene.add(object);
// collidableObjects.push(object);
// object.scale.set(0.01,0.01,0.01);
// object.traverse(function (object) {
// if (object instanceof THREE.Mesh) {
// object.geometry.mergeVertices();
// object.geometry.computeVertexNormals();
// object.raycastable = true;
// }
// });
// }
// );
// loader.load(
// static_path + 'data/zelda/Window Lights.obj',
// static_path + 'data/zelda/Window Lights.mtl',
// function ( object ) {
// scene.add(object);
// collidableObjects.push(object);
// object.scale.set(0.01,0.01,0.01);
// object.traverse(function (object) {
// if (object instanceof THREE.Mesh) {
// object.geometry.mergeVertices();
// object.geometry.computeVertexNormals();
// object.raycastable = true;
// }
// });
// }
// );
} }
@ -217,7 +125,8 @@ function createPeachCameras(width, height) {
cams.push(createCamera( cams.push(createCamera(
new THREE.Vector3(2.625389073616235, 1.2252620948239699, -4.818718135555419), new THREE.Vector3(2.625389073616235, 1.2252620948239699, -4.818718135555419),
new THREE.Vector3(-19.756833131355208, -16.20027570329664, -33.02132017177813) new THREE.Vector3(-19.756833131355208, -16.20027570329664, -33.02132017177813)
)); ));ader = new THREE.MTLLoader('/static/data/bobomb/');
// loader.
// cams.push(createCamera( // cams.push(createCamera(
// new THREE.Vector3(1.3304975149911331, 0.4836093721106701, -8.60618907952783), // new THREE.Vector3(1.3304975149911331, 0.4836093721106701, -8.60618907952783),
@ -251,99 +160,23 @@ function createPeachCameras(width, height) {
function initBobombScene(scene, collidableObjects, loader, static_path) { function initBobombScene(scene, collidableObjects, loader, static_path) {
// var loader = new THREE.MTLLoader('/static/data/bobomb/'); ProgressiveLoader(
// loader.load('/static/data/bobomb/bobomb battlefeild.mtl', function(materialCreator) {
// materialCreator.preload();
// var mesh = ProgressiveLoader('static/data/bobomb/bobomb battlefeild.obj', scene, materialCreator, [
// 'Material.071_574B138E_c.bmp',
// 'Material.070_41A41EE3_c.bmp'
// ]);
// // object.position.z -= 10.9;
// // object.position.y += 0.555;
// // object.position.x += 3.23;
// var theta = 0.27;
// mesh.rotation.y = Math.PI - theta;
// mesh.up = new THREE.Vector3(0,0,1);
// collidableObjects.push(mesh);
// });
// Create loader if not already done
if (loader === undefined) {
loader = new THREE.OBJMTLLoader();
}
// Try to guess the path to static files
if (static_path === undefined) {
static_path = "/static/";
}
loader.load(
static_path + 'data/bobomb/bobomb battlefeild.obj', static_path + 'data/bobomb/bobomb battlefeild.obj',
static_path + 'data/bobomb/bobomb battlefeild.mtl', scene,
function ( object ) { function(object) {
// object.position.z -= 10.9;
// object.position.y += 0.555;
// object.position.x += 3.23;
var theta = 0.27; var theta = 0.27;
object.rotation.y = Math.PI - theta; object.rotation.y = Math.PI - theta;
object.up = new THREE.Vector3(0,0,1); object.up = new THREE.Vector3(0,0,1);
collidableObjects.push(object); collidableObjects.push(object);
scene.add(object); object.raycastable = true;
glob = object; if (object.material.name === 'Material.071_574B138E_c.bmp' ||
object.traverse(function (object) { object.material.name === 'Material.070_41A41EE3_c.bmp') {
if (object instanceof THREE.Mesh) { THREEx.Transparency.push(object);
object.raycastable = true; }
object.material.side = THREE.DoubleSide;
object.geometry.mergeVertices();
object.geometry.computeVertexNormals();
if (object.material.name === 'Material.071_574B138E_c.bmp' ||
object.material.name === 'Material.070_41A41EE3_c.bmp') {
THREEx.Transparency.push(object);
}
}
});
} }
); );
// loader.load(
// static_path + 'data/star/GrandStar.obj',
// static_path + 'data/star/GrandStar.mtl',
// function ( object ) {
// object.position.z -= 10.9;
// object.position.y += 0.555;
// object.position.x += 3.23;
// var theta = 0.27;
// object.rotation.y = Math.PI - theta;
// object.up = new THREE.Vector3(0,0,1);
// scene.add(object);
// collidableObjects.push(object);
// object.traverse(function (object) {
// if (object instanceof THREE.Mesh) {
// object.scale.set(0.005,0.005,0.005);
// object.position.x = 13;
// object.position.z = -35;
// object.position.y = 30;
// object.rotation.z = Math.PI/2;
// object.rotation.x = Math.PI/2;
// object.rotation.y = Math.PI;
// object.material.side = THREE.DoubleSide;
// object.geometry.mergeVertices();
// object.geometry.computeVertexNormals();
// object.raycastable = true;
// }
// });
// }
//);
} }
function resetBobombElements() { function resetBobombElements() {
@ -469,36 +302,29 @@ function initBobomb(camera, scene, static_path, coins) {
} }
function initWhompScene(scene, collidableObjects, loader, static_path) { function initWhompScene(scene, collidableObjects, loader, static_path) {
loader.load(
static_path + './data/whomp/Whomps Fortress.obj', ProgressiveLoader(
static_path + './data/whomp/Whomps Fortress.mtl', static_path + 'data/whomp/Whomps Fortress.obj',
function ( object ) { scene,
function(object) {
object.rotation.x = -Math.PI/2; object.rotation.x = -Math.PI/2;
object.rotation.z = Math.PI/2; object.rotation.z = Math.PI/2;
object.scale.set(0.1,0.1,0.1); object.scale.set(0.1,0.1,0.1);
collidableObjects.push(object); collidableObjects.push(object);
scene.add(object); object.raycastable = true;
object.traverse(function (obj) { if (object.material.name === 'Shape_088' ||
if (obj instanceof THREE.Mesh) { object.material.name === 'Shape_089') {
obj.geometry.mergeVertices(); object.raycastable = false;
obj.geometry.computeVertexNormals(); THREEx.Transparency.push(object);
obj.material.side = THREE.DoubleSide; } else if (object.material.name === 'Shape_113') {
obj.raycastable = true; THREEx.Transparency.push(object);
object.material.opacity = 0.5;
} else if (object.material.name === 'Shape_076' ||
object.material.name === 'Shape_098' ||
object.material.name === 'Shape_092') {
object.visible = false;
}
if (obj.material.name === 'Shape_088' ||
obj.material.name === 'Shape_089') {
obj.raycastable = false;
THREEx.Transparency.push(obj);
} else if (obj.material.name === 'Shape_113') {
THREEx.Transparency.push(obj);
obj.material.opacity = 0.5;
} else if (obj.material.name === 'Shape_076' ||
obj.material.name === 'Shape_098' ||
obj.material.name === 'Shape_092') {
obj.visible = false;
}
}
});
} }
); );
} }
@ -623,39 +449,31 @@ function initWhomp(camera, scene, static_path, coins) {
} }
function initMountainScene(scene, collidableObjects, loader, static_path) { function initMountainScene(scene, collidableObjects, loader, static_path) {
loader.load(
static_path + './data/mountain/coocoolmountain.obj', ProgressiveLoader(
static_path + './data/mountain/coocoolmountain.mtl', static_path + 'data/mountain/coocoolmountain.obj',
// static_path + './data/mountain2/untitled.obj', scene,
// static_path + './data/mountain2/untitled.mtl', function(object) {
function ( object ) {
// object.rotation.x = -Math.PI/2; // object.rotation.x = -Math.PI/2;
// object.rotation.z = Math.PI/2; // object.rotation.z = Math.PI/2;
collidableObjects.push(object); collidableObjects.push(object);
scene.add(object); scene.add(object);
object.traverse(function (obj) { object.raycastable = true;
if (obj instanceof THREE.Mesh) { if (object.material.name === 'Material.070_13F025D5_c2.png' ||
obj.geometry.mergeVertices(); object.material.name === 'Material.068_5972FC88_c.bmp' ||
obj.geometry.computeVertexNormals(); object.material.name === 'Material.073_76F611AD_c.bmp' ||
obj.material.side = THREE.DoubleSide; object.material.name === 'Material.071_76F611AD_c.bmp' ||
obj.raycastable = true; object.material.name === 'Material.072_1723CCC7_c.bmp' ||
if (obj.material.name === 'Material.070_13F025D5_c2.png' || object.material.name === 'Material.069_78B64DC7_c.bmp' ||
obj.material.name === 'Material.068_5972FC88_c.bmp' || object.material.name === 'Material.070_13F025D5_c.bmp' ||
obj.material.name === 'Material.073_76F611AD_c.bmp' || object.material.name === 'Material.078_3165B23A_c.bmp' ||
obj.material.name === 'Material.071_76F611AD_c.bmp' || object.material.name === 'Material.067_1723CCC7_c.bmp' ||
obj.material.name === 'Material.072_1723CCC7_c.bmp' || object.material.name === 'Material.066_36DB292F_c.bmp') {
obj.material.name === 'Material.069_78B64DC7_c.bmp' || THREEx.Transparency.push(object);
obj.material.name === 'Material.070_13F025D5_c.bmp' || } else if (object.material.name === 'Material.082_6DAF90F6_c.bmp') {
obj.material.name === 'Material.078_3165B23A_c.bmp' || THREEx.Transparency.push(object);
obj.material.name === 'Material.067_1723CCC7_c.bmp' || object.material.opacity = 0.5;
obj.material.name === 'Material.066_36DB292F_c.bmp') { }
THREEx.Transparency.push(obj);
} else if (obj.material.name === 'Material.082_6DAF90F6_c.bmp') {
THREEx.Transparency.push(obj);
obj.material.opacity = 0.5;
}
}
});
} }
); );
} }
@ -782,66 +600,22 @@ function initMountain(camera, scene, static_path, coins) {
function initSponzaScene(scene, collidableObjects, loader, static_path) { function initSponzaScene(scene, collidableObjects, loader, static_path) {
var loader = new THREE.MTLLoader('/static/data/sponza/'); ProgressiveLoader('/static/data/sponza/sponza.obj', scene,
loader.load('/static/data/sponza/sponza.mtl', function(materialCreator) { function(obj) {
obj.scale.set(0.1,0.1,0.1);
collidableObjects.push(obj);
obj.raycastable = true;
materialCreator.preload(); if (obj.material.name === 'chain' ||
obj.material.name === 'leaf' ||
obj.material.name === 'Material__57') {
console.log("Starting loading..."); THREEx.Transparency.push(obj);
var mesh = ProgressiveLoader('static/data/sponza/sponza.obj', scene, materialCreator, [ }
'chain',
'leaf',
'Material__57'
]);
// object.position.z -= 10.9; }
// object.position.y += 0.555; );
// object.position.x += 3.23;
mesh.scale.set(0.01,0.01,0.01);
mesh.raycastable = true;
collidableObjects.push(mesh);
});
// var onProgress = function ( xhr ) {
// if ( xhr.lengthComputable ) {
// var percentComplete = xhr.loaded / xhr.total * 100;
// console.log( Math.round(percentComplete, 2) + '% downloaded' );
// }
// };
// loader.load(
// static_path + './data/sponza/sponza.json',
// function (geometry, materials) {
// console.log("OK");
// geometry.mergeVertices();
// var material = new THREE.MeshFaceMaterial(materials);
// var object = new THREE.Mesh(geometry, material);
// object.scale.set(0.01,0.01,0.01);
// object.raycastable = true;
// collidableObjects.push(object);
// // object.rotation.x = -Math.PI/2;
// // object.rotation.z = Math.PI/2;
// // collidableObjects.push(object);
// // scene.add(object);
// object.traverse(function (obj) {
// if (obj instanceof THREE.Mesh) {
// for (var i in obj.material.materials) {
// var m = obj.material.materials[i].map;
// if (m)
// m.wrapS = m.wrapT = THREE.RepeatWrapping;
// }
// // obj.material.map.wrapS = obj.material.map.wrapT = THREE.RepeatWrapping;
// }
// // obj.geometry.mergeVertices();
// // obj.geometry.computeVertexNormals();
// // obj.material.side = THREE.DoubleSide;
// // obj.raycastable = true;
// // }
// });
// scene.add(object);
// }
// , onProgress, function(xhr) { console.log("error");});
} }
function createSponzaCoins() { function createSponzaCoins() {
@ -854,8 +628,8 @@ function createSponzaCameras() {
function resetSponzaElements() { function resetSponzaElements() {
return { return {
position : new THREE.Vector3(-9.672189882510748,5.415297558602296,-1.5456794717808657), position: new THREE.Vector3(92.98373669520107,60.8877777990862,11.130138641670737),
target : new THREE.Vector3(27.18799151966882,-5.736834637451716,9.26898531637373) target: new THREE.Vector3(53.76696417668598,56.09739213575453,4.877382575136091)
}; };
} }
@ -870,7 +644,7 @@ function initSponza(camera, scene, static_path, coins) {
camera.resetElements = resetSponzaElements(); camera.resetElements = resetSponzaElements();
camera.collidableObjects = collidableObjects; camera.collidableObjects = collidableObjects;
camera.speed = 0.005; camera.speed = 0.05;
camera.reset(); camera.reset();
camera.save(); camera.save();

View File

@ -79,9 +79,9 @@ function init() {
// Initialize pointer camera // Initialize pointer camera
var camera1 = new PointerCamera(50, container_size.width() / container_size.height(), 0.1, 100000, renderer, container); var camera1 = new PointerCamera(50, container_size.width() / container_size.height(), 0.1, 100000, renderer, container);
// cameras = initMainScene(camera1, scene, static_path, coins); cameras = initMainScene(camera1, scene, static_path, coins);
// cameras = initPeach(camera1, scene, static_path, coins); // cameras = initPeach(camera1, scene, static_path, coins);
cameras = initBobomb(camera1, scene, static_path, coins); // cameras = initBobomb(camera1, scene, static_path, coins);
// cameras = initWhomp(camera1, scene, static_path, coins); // cameras = initWhomp(camera1, scene, static_path, coins);
// cameras = initMountain(camera1, scene, static_path, coins); // cameras = initMountain(camera1, scene, static_path, coins);
// cameras = initSponza(camera1, scene, static_path, coins); // cameras = initSponza(camera1, scene, static_path, coins);
@ -158,6 +158,9 @@ function render() {
// Hide arrows in recommendation // Hide arrows in recommendation
cameras.map(function(camera) { if (camera instanceof RecommendedCamera) hide(camera); }); cameras.map(function(camera) { if (camera instanceof RecommendedCamera) hide(camera); });
// Update transparent elements
THREEx.Transparency.update(cameras.mainCamera());
// Render preview // Render preview
previewer.render(cameraSelecter.prev, container_size.width(), container_size.height()); previewer.render(cameraSelecter.prev, container_size.width(), container_size.height());
} }