This commit is contained in:
Thomas FORGIONE 2015-06-18 15:03:06 +02:00
parent 547162e9bb
commit 9c9232d57b
3 changed files with 81 additions and 45 deletions

View File

@ -169,16 +169,20 @@ geo.MeshStreamer.prototype.start = function(socket) {
geo.MeshStreamer.prototype.nextElements = function(_camera) {
// Prepare camera (and scale to model)
var camera = null;
if (_camera !== null) {
var camera = {
position: {
x: _camera[0]*10,
y: _camera[1]*10,
z: _camera[2]*10
x: _camera[0],
y: _camera[1],
z: _camera[2]
},
target: {
x: _camera[3]*10,
y: _camera[4]*10,
z: _camera[5]*10
x: _camera[3],
y: _camera[4],
z: _camera[5]
}
}
@ -189,6 +193,8 @@ geo.MeshStreamer.prototype.nextElements = function(_camera) {
z: camera.target.z - camera.position.z
}
}
var sent = 0;
var data = [];
@ -239,6 +245,8 @@ geo.MeshStreamer.prototype.nextElements = function(_camera) {
var vertex2 = this.vertices[currentFace.b];
var vertex3 = this.vertices[currentFace.c];
if (camera !== null) {
var v1 = {
x: vertex1.x - camera.position.x,
y: vertex1.y - camera.position.y,
@ -267,6 +275,8 @@ geo.MeshStreamer.prototype.nextElements = function(_camera) {
}
}
if (!vertex1.sent) {
data.push(vertex1.toList());

View File

@ -13,7 +13,7 @@ function addLight(scene) {
function initPeachCastle(scene, collidableObjects, loader, camera) {
var loader = new ProgressiveLoader(
var loader = new ProgressiveLoaderGeometry(
'/static/data/castle/princess peaches castle (outside).obj',
scene,
camera,
@ -164,10 +164,10 @@ function createPeachCameras(width, height) {
function initBobombScene(scene, collidableObjects, loader, camera) {
var loader = new ProgressiveLoader(
var loader = new ProgressiveLoaderGeometry(
static_path + 'data/bobomb/bobomb battlefeild.obj',
scene,
camera,
null,
function(object) {
object.raycastable = true;
if (object.material.name === 'Material.071_574B138E_c.bmp' ||
@ -310,10 +310,10 @@ function initBobomb(camera, scene, static_path, coins) {
function initWhompScene(scene, collidableObjects, loader, camera) {
var loader = new ProgressiveLoader(
var loader = new ProgressiveLoaderGeometry(
static_path + 'data/whomp/Whomps Fortress.obj',
scene,
camera,
null,
function(object) {
if (object.material.name === 'Shape_088' ||
object.material.name === 'Shape_089') {
@ -336,6 +336,18 @@ function initWhompScene(scene, collidableObjects, loader, camera) {
loader.obj.rotation.x = -Math.PI/2;
loader.obj.rotation.z = Math.PI/2;
loader.obj.scale.set(0.1,0.1,0.1);
loader.getCamera = function() {
return [
loader.camera.position.z * 10,
loader.camera.position.x * 10,
loader.camera.position.y * 10,
loader.camera.target.z * 10,
loader.camera.target.x * 10,
loader.camera.target.y * 10
];
}
collidableObjects.push(loader.obj);
loader.obj.raycastable = true;
}
@ -461,10 +473,10 @@ function initWhomp(camera, scene, static_path, coins) {
function initMountainScene(scene, collidableObjects, loader, camera) {
var loader = new ProgressiveLoader(
var loader = new ProgressiveLoaderGeometry(
static_path + 'data/mountain/coocoolmountain.obj',
scene,
camera,
null,
function(object) {
// object.rotation.x = -Math.PI/2;
// object.rotation.z = Math.PI/2;
@ -628,11 +640,25 @@ function initSponzaScene(scene, collidableObjects, loader, camera) {
l = loader;
loader.load();
loader.getCamera = function() {
return [
loader.camera.position.x * 10,
loader.camera.position.y * 10,
loader.camera.position.z * 10,
loader.camera.target.x * 10,
loader.camera.target.y * 10,
loader.camera.target.z * 10
];
}
loader.obj.scale.set(0.1,0.1,0.1);
collidableObjects.push(loader.obj);
loader.obj.raycastable = true;
// ProgressiveLoader('/static/data/sponza/sponza.obj', scene,
// function(obj) {
// obj.scale.set(0.1,0.1,0.1);

View File

@ -45,7 +45,7 @@ function init() {
// Load the scene
// loader = new THREE.OBJLoader();
sphereLoader = new ProgressiveLoaderGeometry('/static/data/spheres/' + params.get.res + '.obj', scene);
sphereLoader = new ProgressiveLoaderGeometry('/static/data/spheres/' + params.get.res + '.obj', scene, camera);
sphereLoader.load();
sphere = sphereLoader.obj;