Added namespaces

This commit is contained in:
Thomas FORGIONE
2015-07-01 16:31:43 +02:00
parent 5e0551179e
commit 9c7350d41b
38 changed files with 552 additions and 556 deletions

View File

@@ -1,31 +1,30 @@
// class camera extends THREE.PerspectiveCamera
var Camera = function() {
L3D.Camera = function() {
THREE.PerspectiveCamera.apply(this, arguments);
this.theta = 0;
this.position.x = Camera.DISTANCE_X;
this.position.z = Camera.DISTANCE_Z;
this.position.x = L3D.Camera.DISTANCE_X;
this.position.z = L3D.Camera.DISTANCE_Z;
this.up = new THREE.Vector3(0,0,1);
this.target = new THREE.Vector3();
};
Camera.prototype = Object.create(THREE.PerspectiveCamera.prototype);
L3D.Camera.prototype = Object.create(THREE.PerspectiveCamera.prototype);
// Update function
Camera.prototype.update = function(time) {
L3D.Camera.prototype.update = function(time) {
if (time === undefined) {
time = 20;
}
this.theta += 0.01 * time / 20;
this.position.x = Camera.DISTANCE_X*Math.cos(this.theta);
this.position.y = Camera.DISTANCE_X*Math.sin(this.theta);
this.position.x = L3D.Camera.DISTANCE_X*Math.cos(this.theta);
this.position.y = L3D.Camera.DISTANCE_X*Math.sin(this.theta);
};
// Look function
Camera.prototype.look = function() {
L3D.Camera.prototype.look = function() {
this.lookAt(this.target);
};
// Static members
Camera.DISTANCE_X = 1000;
Camera.DISTANCE_Z = 300;
L3D.Camera.DISTANCE_X = 1000;
L3D.Camera.DISTANCE_Z = 300;

View File

@@ -1,4 +1,4 @@
var CameraContainer = function (pointerCamera, cameras) {
L3D.CameraContainer = function (pointerCamera, cameras) {
if (cameras !== undefined) {
this.cameras = cameras;
} else {
@@ -10,7 +10,7 @@ var CameraContainer = function (pointerCamera, cameras) {
}
};
CameraContainer.prototype.mainCamera = function(id) {
L3D.CameraContainer.prototype.mainCamera = function(id) {
if (id === undefined) {
return this.pointerCamera;
}
@@ -22,35 +22,35 @@ CameraContainer.prototype.mainCamera = function(id) {
this.current_camera = id;
};
CameraContainer.prototype.forEach = function(callback) {
L3D.CameraContainer.prototype.forEach = function(callback) {
callback(this.pointerCamera);
this.cameras.forEach(callback);
};
CameraContainer.prototype.look = function() {
L3D.CameraContainer.prototype.look = function() {
this.mainCamera().look();
};
CameraContainer.prototype.updateMainCamera = function(time) {
L3D.CameraContainer.prototype.updateMainCamera = function(time) {
this.pointerCamera.update(time);
};
CameraContainer.prototype.update = function(position) {
L3D.CameraContainer.prototype.update = function(position) {
this.cameras.map(function (elt) { elt.update(position); });
};
CameraContainer.prototype.push = function(camera) {
L3D.CameraContainer.prototype.push = function(camera) {
this.pointerCamera = camera;
this.push = function(camera) {
this.cameras.push(camera);
};
};
CameraContainer.prototype.get = function(i) {
L3D.CameraContainer.prototype.get = function(i) {
return this.cameras[i];
};
CameraContainer.prototype.getByObject = function(object) {
L3D.CameraContainer.prototype.getByObject = function(object) {
for (var i in this.cameras) {
if (this.cameras[i].containsObject(object)) {
return this.get(i);
@@ -58,20 +58,20 @@ CameraContainer.prototype.getByObject = function(object) {
}
};
CameraContainer.prototype.setById = function(id) {
L3D.CameraContainer.prototype.setById = function(id) {
var i = this.getById(id);
if (i !== -1)
this.current_camera = i;
};
CameraContainer.prototype.nextCamera = function() {
L3D.CameraContainer.prototype.nextCamera = function() {
if (this.cameras.length !== 0) {
this.current_camera++;
this.current_camera%=this.cameras.length;
}
};
CameraContainer.prototype.map = function(callback) {
L3D.CameraContainer.prototype.map = function(callback) {
this.cameras.map(callback);
};

View File

@@ -3,7 +3,7 @@
* @constructor
* @augments THREE.PerspectiveCamera
*/
var PointerCamera = function() {
L3D.PointerCamera = function() {
THREE.PerspectiveCamera.apply(this, arguments);
/**
@@ -115,9 +115,9 @@ var PointerCamera = function() {
/**
* History of the moves of the camera
* @type {History}
* @type {L3D.History}
*/
this.history = new History();
this.history = new L3D.History();
/**
* Option to enable or disable the pointer lock
@@ -176,16 +176,16 @@ var PointerCamera = function() {
* The camera we will move to when we'll reset the camera
* @param {Object}
*/
this.resetElements = resetBobombElements();
this.resetElements = {position: new THREE.Vector3(0,1,1), target: new THREE.Vector3()};
};
PointerCamera.prototype = Object.create(THREE.PerspectiveCamera.prototype);
PointerCamera.prototype.constructor = PointerCamera;
L3D.PointerCamera.prototype = Object.create(THREE.PerspectiveCamera.prototype);
L3D.PointerCamera.prototype.constructor = L3D.PointerCamera;
/**
* Locks the pointer inside the canvas, and displays a gun sight at the middle of the renderer
* This method works only if the browser supports requestPointerLock
*/
PointerCamera.prototype.lockPointer = function() {
L3D.PointerCamera.prototype.lockPointer = function() {
if (this.shouldLock) {
this.renderer.domElement.requestPointerLock =
@@ -207,7 +207,7 @@ PointerCamera.prototype.lockPointer = function() {
* Check that the pointer is locked or not, and updated locked attribute
* @returns true if the pointer is locked, false otherwise
*/
PointerCamera.prototype.isLocked = function() {
L3D.PointerCamera.prototype.isLocked = function() {
var toto =
document.pointerLockElement === this.renderer.domElement ||
document.mozPointerLockElement === this.renderer.domElement ||
@@ -220,7 +220,7 @@ PointerCamera.prototype.isLocked = function() {
/**
* Update the camera when the pointer lock changes state
*/
PointerCamera.prototype.onPointerLockChange = function() {
L3D.PointerCamera.prototype.onPointerLockChange = function() {
if (this.isLocked()) {
@@ -259,7 +259,7 @@ PointerCamera.prototype.onPointerLockChange = function() {
* Update the position of the camera
* @param {Number} time number of milliseconds between the previous and the next frame
*/
PointerCamera.prototype.update = function(time) {
L3D.PointerCamera.prototype.update = function(time) {
if (this.moving) {
this.linearMotion(time);
} else if (this.movingHermite) {
@@ -273,15 +273,15 @@ PointerCamera.prototype.update = function(time) {
* Update the camera according to its linear motion
* @param {Number} time number of milliseconds between the previous and the next frame
*/
PointerCamera.prototype.linearMotion = function(time) {
var position_direction = Tools.diff(this.new_position, this.position);
var target_direction = Tools.diff(this.new_target, this.target);
L3D.PointerCamera.prototype.linearMotion = function(time) {
var position_direction = L3D.Tools.diff(this.new_position, this.position);
var target_direction = L3D.Tools.diff(this.new_target, this.target);
this.position.add(Tools.mul(position_direction, 0.05 * time / 20));
this.target.add(Tools.mul(target_direction, 0.05 * time / 20));
this.position.add(L3D.Tools.mul(position_direction, 0.05 * time / 20));
this.target.add(L3D.Tools.mul(target_direction, 0.05 * time / 20));
if (Tools.norm2(Tools.diff(this.position, this.new_position)) < 0.01 &&
Tools.norm2(Tools.diff(this.target, this.new_target)) < 0.01) {
if (L3D.Tools.norm2(L3D.Tools.diff(this.position, this.new_position)) < 0.01 &&
L3D.Tools.norm2(L3D.Tools.diff(this.target, this.new_target)) < 0.01) {
this.moving = false;
this.anglesFromVectors();
}
@@ -291,13 +291,13 @@ PointerCamera.prototype.linearMotion = function(time) {
* Update the camera according to its hermite motion
* @param {Number} time number of milliseconds between the previous and the next frame
*/
PointerCamera.prototype.hermiteMotion = function(time) {
L3D.PointerCamera.prototype.hermiteMotion = function(time) {
var e = this.hermitePosition.eval(this.t);
this.position.x = e.x;
this.position.y = e.y;
this.position.z = e.z;
this.target = Tools.sum(this.position, this.hermiteAngles.eval(this.t));
this.target = L3D.Tools.sum(this.position, this.hermiteAngles.eval(this.t));
this.t += 0.01 * time / 20;
@@ -311,7 +311,7 @@ PointerCamera.prototype.hermiteMotion = function(time) {
* Update the camera according to the user's input
* @param {Number} time number of milliseconds between the previous and the next frame
*/
PointerCamera.prototype.normalMotion = function(time) {
L3D.PointerCamera.prototype.normalMotion = function(time) {
// Update angles
if (this.motion.increasePhi) {this.phi += this.sensitivity * time / 20; this.changed = true; }
@@ -340,7 +340,7 @@ PointerCamera.prototype.normalMotion = function(time) {
self.shouldLogCameraAngles = true;
}, 100);
var event = new BD.Event.KeyboardEvent();
var event = new L3D.BD.Event.KeyboardEvent();
event.camera = this;
}
@@ -367,10 +367,10 @@ PointerCamera.prototype.normalMotion = function(time) {
var direction = new THREE.Vector3();
if (this.motion.boost) speed *= 10;
if (this.motion.moveForward) {direction.add(Tools.mul(forward, speed)); this.changed = true;}
if (this.motion.moveBackward) {direction.sub(Tools.mul(forward, speed)); this.changed = true;}
if (this.motion.moveLeft) {direction.add(Tools.mul(left, speed)); this.changed = true;}
if (this.motion.moveRight) {direction.sub(Tools.mul(left, speed)); this.changed = true;}
if (this.motion.moveForward) {direction.add(L3D.Tools.mul(forward, speed)); this.changed = true;}
if (this.motion.moveBackward) {direction.sub(L3D.Tools.mul(forward, speed)); this.changed = true;}
if (this.motion.moveLeft) {direction.add(L3D.Tools.mul(left, speed)); this.changed = true;}
if (this.motion.moveRight) {direction.sub(L3D.Tools.mul(left, speed)); this.changed = true;}
if (!this.collisions || !this.isColliding(direction)) {
this.position.add(direction);
@@ -384,17 +384,17 @@ PointerCamera.prototype.normalMotion = function(time) {
/**
* Reset the camera to its resetElements, and finishes any motion
*/
PointerCamera.prototype.reset = function() {
L3D.PointerCamera.prototype.reset = function() {
this.resetPosition();
this.moving = false;
this.movingHermite = false;
(new BD.Event.ResetClicked()).send();
(new L3D.BD.Event.ResetClicked()).send();
};
/**
* Reset the position of th camera
*/
PointerCamera.prototype.resetPosition = function() {
L3D.PointerCamera.prototype.resetPosition = function() {
this.position.copy(this.resetElements.position);
this.target.copy(this.resetElements.target);
this.anglesFromVectors();
@@ -403,7 +403,7 @@ PointerCamera.prototype.resetPosition = function() {
/**
* Computes the vectors (forward, left, ...) according to theta and phi
*/
PointerCamera.prototype.vectorsFromAngles = function() {
L3D.PointerCamera.prototype.vectorsFromAngles = function() {
// Update direction
this.forward.y = Math.sin(this.phi);
@@ -417,8 +417,8 @@ PointerCamera.prototype.vectorsFromAngles = function() {
/**
* Computes theta and phi according to the vectors (forward, left, ...)
*/
PointerCamera.prototype.anglesFromVectors = function() {
var forward = Tools.diff(this.target, this.position);
L3D.PointerCamera.prototype.anglesFromVectors = function() {
var forward = L3D.Tools.diff(this.target, this.position);
forward.normalize();
this.phi = Math.asin(forward.y);
@@ -433,7 +433,7 @@ 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
*/
PointerCamera.prototype.move = function(otherCamera, toSave) {
L3D.PointerCamera.prototype.move = function(otherCamera, toSave) {
if (toSave === undefined)
toSave = true;
@@ -442,8 +442,8 @@ PointerCamera.prototype.move = function(otherCamera, toSave) {
this.new_position = otherCamera.position.clone();
var t = [0,1];
var f = [this.position.clone(), this.new_position];
var fp = [Tools.diff(this.target, this.position), Tools.diff(this.new_target, this.new_position)];
this.hermite = new Hermite.Polynom(t,f,fp);
var fp = [L3D.Tools.diff(this.target, this.position), L3D.Tools.diff(this.new_target, this.new_position)];
this.hermite = new L3D.Hermite.Polynom(t,f,fp);
this.t = 0;
if (toSave) {
@@ -460,22 +460,22 @@ 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
*/
PointerCamera.prototype.moveHermite = function(otherCamera, toSave) {
L3D.PointerCamera.prototype.moveHermite = function(otherCamera, toSave) {
if (toSave === undefined)
toSave = true;
this.movingHermite = true;
this.t = 0;
this.hermitePosition = new Hermite.special.Polynom(
this.hermitePosition = new L3D.Hermite.special.Polynom(
this.position.clone(),
otherCamera.position.clone(),
Tools.mul(Tools.diff(otherCamera.target, otherCamera.position).normalize(),4)
L3D.Tools.mul(L3D.Tools.diff(otherCamera.target, otherCamera.position).normalize(),4)
);
this.hermiteAngles = new Hermite.special.Polynom(
Tools.diff(this.target, this.position),
Tools.diff(otherCamera.target, otherCamera.position),
this.hermiteAngles = new L3D.Hermite.special.Polynom(
L3D.Tools.diff(this.target, this.position),
L3D.Tools.diff(otherCamera.target, otherCamera.position),
new THREE.Vector3()
);
@@ -493,12 +493,12 @@ PointerCamera.prototype.moveHermite = function(otherCamera, toSave) {
* @param {THREE.Vector3} direction the direction of the camera
* @returns {Boolean} true if there is a collision, false otherwise
*/
PointerCamera.prototype.isColliding = function(direction) {
L3D.PointerCamera.prototype.isColliding = function(direction) {
this.raycaster.set(this.position, direction.clone().normalize());
var intersects = this.raycaster.intersectObjects(this.collidableObjects, true);
for (var i in intersects) {
if (intersects[i].distance < Tools.norm(direction) + this.speed * 300 &&
if (intersects[i].distance < L3D.Tools.norm(direction) + this.speed * 300 &&
intersects[i].object.raycastable) {
return true;
}
@@ -510,14 +510,14 @@ PointerCamera.prototype.isColliding = function(direction) {
/**
* Look method. Equivalent to gluLookAt for the current camera
*/
PointerCamera.prototype.look = function() {
L3D.PointerCamera.prototype.look = function() {
this.lookAt(this.target);
};
/**
* Adds the camera to the scene
*/
PointerCamera.prototype.addToScene = function(scene) {
L3D.PointerCamera.prototype.addToScene = function(scene) {
scene.add(this);
};
@@ -526,7 +526,7 @@ PointerCamera.prototype.addToScene = function(scene) {
* @param {event} event the event that happened
* @param {Booelean} toSet true if the key was pressed, false if released
*/
PointerCamera.prototype.onKeyEvent = function(event, toSet) {
L3D.PointerCamera.prototype.onKeyEvent = function(event, toSet) {
// Create copy of state
var motionJsonCopy = JSON.stringify(this.motion);
@@ -553,7 +553,7 @@ PointerCamera.prototype.onKeyEvent = function(event, toSet) {
}
if (motionJsonCopy != JSON.stringify(this.motion)) {
// Log any change
var e = new BD.Event.KeyboardEvent();
var e = new L3D.BD.Event.KeyboardEvent();
e.camera = this;
e.send();
}
@@ -563,7 +563,7 @@ PointerCamera.prototype.onKeyEvent = function(event, toSet) {
* Manages the key pressed events
* @param {event} event the event to manage
*/
PointerCamera.prototype.onKeyDown = function(event) {
L3D.PointerCamera.prototype.onKeyDown = function(event) {
this.onKeyEvent(event, true);
};
@@ -571,7 +571,7 @@ PointerCamera.prototype.onKeyDown = function(event) {
* Manages the key released events
* @param {event} event the event to manage
*/
PointerCamera.prototype.onKeyUp = function(event) {
L3D.PointerCamera.prototype.onKeyUp = function(event) {
this.onKeyEvent(event, false);
};
@@ -579,7 +579,7 @@ PointerCamera.prototype.onKeyUp = function(event) {
* Manages the mouse down events. Start drag'n'dropping if the options are set to drag'n'drop
* @param {event} event the event to manage
*/
PointerCamera.prototype.onMouseDown = function(event) {
L3D.PointerCamera.prototype.onMouseDown = function(event) {
if (!this.shouldLock) {
@@ -595,7 +595,7 @@ PointerCamera.prototype.onMouseDown = function(event) {
* Manages the mouse move events. Modifies the target of the camera according to the drag'n'drop motion
* @param {event} event the event to manage
*/
PointerCamera.prototype.onMouseMove = function(event) {
L3D.PointerCamera.prototype.onMouseMove = function(event) {
if (!this.shouldLock && this.dragging) {
var mouse = {x: this.mouse.x, y: this.mouse.y};
@@ -613,7 +613,7 @@ PointerCamera.prototype.onMouseMove = function(event) {
* Manages the mouse move envent in case of pointer lock
* @param {event} event the event to manage
*/
PointerCamera.prototype.onMouseMovePointer = function(e) {
L3D.PointerCamera.prototype.onMouseMovePointer = function(e) {
if (this.isLocked()) {
@@ -637,12 +637,12 @@ PointerCamera.prototype.onMouseMovePointer = function(e) {
* Manages the mouse up event. Stops the dragging
* @param {event} event the event to manage
*/
PointerCamera.prototype.onMouseUp = function(event) {
L3D.PointerCamera.prototype.onMouseUp = function(event) {
this.onMouseMove(event);
// Send log to DB
if (this.dragging && this.mouseMoved && !this.moving && !this.movingHermite) {
var e = new BD.Event.KeyboardEvent();
var e = new L3D.BD.Event.KeyboardEvent();
e.camera = this;
e.send();
}
@@ -653,7 +653,7 @@ PointerCamera.prototype.onMouseUp = function(event) {
/**
* Logs the camera to the terminal (pratical to create recommended views)
*/
PointerCamera.prototype.log = function() {
L3D.PointerCamera.prototype.log = function() {
console.log("createCamera(\nnew THREE.Vector3(" + this.position.x + "," + this.position.y + ',' + this.position.z + '),\n' +
"new THREE.Vector3(" + this.target.x + "," + this.target.y + ',' + this.target.z + ')\n)');
};
@@ -661,7 +661,7 @@ PointerCamera.prototype.log = function() {
/**
* Save the current state of the camera in the history
*/
PointerCamera.prototype.save = function() {
L3D.PointerCamera.prototype.save = function() {
var backup = {};
backup.position = this.position.clone();
backup.target = this.target.clone();
@@ -671,10 +671,10 @@ PointerCamera.prototype.save = function() {
/**
* Undo last motion according to the history
*/
PointerCamera.prototype.undo = function() {
L3D.PointerCamera.prototype.undo = function() {
var move = this.history.undo();
if (move !== undefined) {
var event = new BD.Event.PreviousNextClicked();
var event = new L3D.BD.Event.PreviousNextClicked();
event.previous = true;
event.camera = move;
event.send();
@@ -686,10 +686,10 @@ PointerCamera.prototype.undo = function() {
/**
* Redo last motion according to the history
*/
PointerCamera.prototype.redo = function() {
L3D.PointerCamera.prototype.redo = function() {
var move = this.history.redo();
if (move !== undefined) {
var event = new BD.Event.PreviousNextClicked();
var event = new L3D.BD.Event.PreviousNextClicked();
event.previous = false;
event.camera = move;
event.send();
@@ -702,7 +702,7 @@ PointerCamera.prototype.redo = function() {
* Checks if there is a undo possibility in the history
* @returns {Boolean} true if undo is possible, false otherwise
*/
PointerCamera.prototype.undoable = function() {
L3D.PointerCamera.prototype.undoable = function() {
return this.history.undoable();
};
@@ -710,11 +710,11 @@ PointerCamera.prototype.undoable = function() {
* Checks if there is a redo possibility in the history
* @returns {Boolean} true if redo is possible, false otherwise
*/
PointerCamera.prototype.redoable = function() {
L3D.PointerCamera.prototype.redoable = function() {
return this.history.redoable();
};
PointerCamera.prototype.toList = function() {
L3D.PointerCamera.prototype.toList = function() {
this.updateMatrix();
this.updateMatrixWorld();

View File

@@ -1,5 +1,5 @@
// class camera extends THREE.PerspectiveCamera
var ReplayCamera = function() {
L3D.ReplayCamera = function() {
THREE.PerspectiveCamera.apply(this, arguments);
this.coins = arguments[4];
@@ -31,18 +31,16 @@ var ReplayCamera = function() {
this.theta = Math.PI;
this.phi = Math.PI;
this.resetElements = resetBobombElements();
};
ReplayCamera.prototype = Object.create(THREE.PerspectiveCamera.prototype);
ReplayCamera.prototype.constructor = ReplayCamera;
L3D.ReplayCamera.prototype = Object.create(THREE.PerspectiveCamera.prototype);
L3D.ReplayCamera.prototype.constructor = L3D.ReplayCamera;
ReplayCamera.prototype.look = function() {
L3D.ReplayCamera.prototype.look = function() {
this.lookAt(this.target);
};
// Update function
ReplayCamera.prototype.update = function(time) {
L3D.ReplayCamera.prototype.update = function(time) {
if (this.started) {
if (this.event.type == 'camera') {
this.cameraMotion(time);
@@ -59,8 +57,8 @@ ReplayCamera.prototype.update = function(time) {
}
};
ReplayCamera.prototype.linearMotion = function(time) {
var tmp = Tools.sum(Tools.mul(this.old_position, 1-this.t), Tools.mul(this.new_position, this.t));
L3D.ReplayCamera.prototype.linearMotion = function(time) {
var tmp = L3D.Tools.sum(L3D.Tools.mul(this.old_position, 1-this.t), L3D.Tools.mul(this.new_position, this.t));
this.position.x = tmp.x;
this.position.y = tmp.y;
this.position.z = tmp.z;
@@ -71,13 +69,13 @@ ReplayCamera.prototype.linearMotion = function(time) {
}
};
ReplayCamera.prototype.cameraMotion = function(time) {
L3D.ReplayCamera.prototype.cameraMotion = function(time) {
var tmp = Tools.sum(Tools.mul(this.old_position, 1-this.t), Tools.mul(this.new_position, this.t));
var tmp = L3D.Tools.sum(L3D.Tools.mul(this.old_position, 1-this.t), L3D.Tools.mul(this.new_position, this.t));
this.position.x = tmp.x;
this.position.y = tmp.y;
this.position.z = tmp.z;
this.target = Tools.sum(Tools.mul(this.old_target, 1-this.t), Tools.mul(this.new_target, this.t));
this.target = L3D.Tools.sum(L3D.Tools.mul(this.old_target, 1-this.t), L3D.Tools.mul(this.new_target, this.t));
this.t += 1 / (((new Date(this.path[this.counter].time)).getTime() - (new Date(this.path[this.counter-1].time)).getTime()) / 20);
if (this.t > 1) {
@@ -85,13 +83,13 @@ ReplayCamera.prototype.cameraMotion = function(time) {
}
};
ReplayCamera.prototype.hermiteMotion = function(time) {
L3D.ReplayCamera.prototype.hermiteMotion = function(time) {
var e = this.hermitePosition.eval(this.t);
this.position.x = e.x;
this.position.y = e.y;
this.position.z = e.z;
this.target = Tools.sum(this.position, this.hermiteAngles.eval(this.t));
this.target = L3D.Tools.sum(this.position, this.hermiteAngles.eval(this.t));
this.t += 0.01 * time / 20;
@@ -100,7 +98,7 @@ ReplayCamera.prototype.hermiteMotion = function(time) {
}
};
ReplayCamera.prototype.nextEvent = function() {
L3D.ReplayCamera.prototype.nextEvent = function() {
this.counter++;
// Finished
@@ -137,19 +135,19 @@ ReplayCamera.prototype.nextEvent = function() {
}
};
ReplayCamera.prototype.reset = function() {
L3D.ReplayCamera.prototype.reset = function() {
this.resetPosition();
this.moving = false;
this.movingHermite = false;
};
ReplayCamera.prototype.resetPosition = function() {
L3D.ReplayCamera.prototype.resetPosition = function() {
this.position.copy(this.resetElements.position);
this.target.copy(this.resetElements.target);
this.anglesFromVectors();
};
ReplayCamera.prototype.vectorsFromAngles = function() {
L3D.ReplayCamera.prototype.vectorsFromAngles = function() {
// Update direction
this.forward.y = Math.sin(this.phi);
@@ -160,9 +158,9 @@ ReplayCamera.prototype.vectorsFromAngles = function() {
};
ReplayCamera.prototype.anglesFromVectors = function() {
L3D.ReplayCamera.prototype.anglesFromVectors = function() {
// Update phi and theta so that return to reality does not hurt
var forward = Tools.diff(this.target, this.position);
var forward = L3D.Tools.diff(this.target, this.position);
forward.normalize();
this.phi = Math.asin(forward.y);
@@ -172,7 +170,7 @@ ReplayCamera.prototype.anglesFromVectors = function() {
this.theta = Math.atan2(forward.x, forward.z);
};
ReplayCamera.prototype.move = function(otherCamera) {
L3D.ReplayCamera.prototype.move = function(otherCamera) {
this.moving = true;
this.old_target = this.target.clone();
this.old_position = this.position.clone();
@@ -182,21 +180,21 @@ ReplayCamera.prototype.move = function(otherCamera) {
};
ReplayCamera.prototype.moveHermite = function(otherCamera) {
L3D.ReplayCamera.prototype.moveHermite = function(otherCamera) {
this.movingHermite = true;
this.t = 0;
this.hermitePosition = new Hermite.special.Polynom(
this.hermitePosition = new L3D.Hermite.special.Polynom(
this.position.clone(),
otherCamera.position.clone(),
Tools.mul(Tools.diff(otherCamera.target, otherCamera.position).normalize(),4)
L3D.Tools.mul(L3D.Tools.diff(otherCamera.target, otherCamera.position).normalize(),4)
);
this.hermiteAngles = new Hermite.special.Polynom(
Tools.diff(this.target, this.position),
Tools.diff(otherCamera.target, otherCamera.position),
this.hermiteAngles = new L3D.Hermite.special.Polynom(
L3D.Tools.diff(this.target, this.position),
L3D.Tools.diff(otherCamera.target, otherCamera.position),
new THREE.Vector3()
);
};
ReplayCamera.prototype.save = function() {};
L3D.ReplayCamera.prototype.save = function() {};