Everything seems to work, except viewport lines

This commit is contained in:
Thomas FORGIONE
2015-07-06 17:18:08 +02:00
parent 4da5754b64
commit 59e6806d16
17 changed files with 194 additions and 257 deletions

View File

@@ -1,77 +0,0 @@
L3D.CameraContainer = function (pointerCamera, cameras) {
if (cameras !== undefined) {
this.cameras = cameras;
} else {
this.cameras = [];
}
if (pointerCamera !== undefined) {
this.push(pointerCamera);
}
};
L3D.CameraContainer.prototype.mainCamera = function(id) {
if (id === undefined) {
return this.pointerCamera;
}
if (id >= cameras.length || id < 0) {
console.log('Warning : this camera does not exist');
return;
}
this.current_camera = id;
};
L3D.CameraContainer.prototype.forEach = function(callback) {
callback(this.pointerCamera);
this.cameras.forEach(callback);
};
L3D.CameraContainer.prototype.look = function() {
this.mainCamera().look();
};
L3D.CameraContainer.prototype.updateMainCamera = function(time) {
this.pointerCamera.update(time);
};
L3D.CameraContainer.prototype.update = function(position) {
this.cameras.map(function (elt) { elt.update(position); });
};
L3D.CameraContainer.prototype.push = function(camera) {
this.pointerCamera = camera;
this.push = function(camera) {
this.cameras.push(camera);
};
};
L3D.CameraContainer.prototype.get = function(i) {
return this.cameras[i];
};
L3D.CameraContainer.prototype.getByObject = function(object) {
for (var i in this.cameras) {
if (this.cameras[i].containsObject(object)) {
return this.get(i);
}
}
};
L3D.CameraContainer.prototype.setById = function(id) {
var i = this.getById(id);
if (i !== -1)
this.current_camera = i;
};
L3D.CameraContainer.prototype.nextCamera = function() {
if (this.cameras.length !== 0) {
this.current_camera++;
this.current_camera%=this.cameras.length;
}
};
L3D.CameraContainer.prototype.map = function(callback) {
this.cameras.map(callback);
};

View File

@@ -0,0 +1,28 @@
L3D.FixedCamera = function(arg1, arg2, arg3, arg4, position, target) {
THREE.PerspectiveCamera.apply(this, arguments);
if (position === undefined) {
position = new THREE.Vector3(0,0,5);
}
if (target === undefined ) {
target = new THREE.Vector3();
}
this.position.x = position.x;
this.position.y = position.y;
this.position.z = position.z;
this.target = target.clone();
}
L3D.FixedCamera.prototype = Object.create(THREE.PerspectiveCamera.prototype);
L3D.FixedCamera.prototype.constructor = L3D.FixedCamera;
L3D.FixedCamera.prototype.look = function() {
this.lookAt(this.target);
}

View File

@@ -260,15 +260,14 @@ L3D.PointerCamera.prototype.onPointerLockChange = function() {
* @param {Number} time number of milliseconds between the previous and the next frame
*/
L3D.PointerCamera.prototype.update = function(time) {
this.shouldLogCameraAngles = false;
if (this.moving) {
this.linearMotion(time);
} else if (this.movingHermite) {
this.hermiteMotion(time);
} else {
this.shouldLogCameraAngles = false;
if (this.movingHermite) {
this.hermiteMotion(time);
} else {
this.normalMotion(time);
}
this.shouldLogCameraAngles = true;
this.normalMotion(time);
}
};
@@ -341,7 +340,7 @@ L3D.PointerCamera.prototype.normalMotion = function(time) {
var self = this;
setTimeout(function() {
self.shouldLogCameraAngles = true;
}, 100);
}, 500);
var event = new L3D.BD.Event.KeyboardEvent();
event.camera = this;
@@ -437,10 +436,12 @@ L3D.PointerCamera.prototype.anglesFromVectors = function() {
* @param {Camera} camera Camera to move to
* @param {Boolean} [toSave=true] true if you want to save the current state of the camera
*/
L3D.PointerCamera.prototype.move = function(otherCamera, toSave) {
L3D.PointerCamera.prototype.move = function(recommendation, toSave) {
if (toSave === undefined)
toSave = true;
var otherCamera = recommendation.camera;
this.moving = true;
this.new_target = otherCamera.target.clone();
this.new_position = otherCamera.position.clone();
@@ -464,10 +465,12 @@ L3D.PointerCamera.prototype.move = function(otherCamera, toSave) {
* @param {Camera} camera Camera to move to
* @param {Boolean} [toSave=true] true if you want to save the current state of the camera
*/
L3D.PointerCamera.prototype.moveHermite = function(otherCamera, toSave) {
L3D.PointerCamera.prototype.moveHermite = function(recommendation, toSave) {
if (toSave === undefined)
toSave = true;
var otherCamera = recommendation.camera;
this.movingHermite = true;
this.t = 0;