From mixed convetion (_, and camel case) to all camel case

This commit is contained in:
Thomas FORGIONE
2015-08-28 21:34:29 +02:00
parent f136ce833f
commit 74cad3824b
40 changed files with 323 additions and 312 deletions

View File

@@ -294,14 +294,14 @@ L3D.PointerCamera.prototype.update = function(time) {
* @param {Number} time number of milliseconds between the previous and the next frame
*/
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);
var positionDirection = L3D.Tools.diff(this.newPosition, this.position);
var targetDirection = L3D.Tools.diff(this.newTarget, this.target);
this.position.add(L3D.Tools.mul(position_direction, 0.05 * time / 20));
this.target.add(L3D.Tools.mul(target_direction, 0.05 * time / 20));
this.position.add(L3D.Tools.mul(positionDirection, 0.05 * time / 20));
this.target.add(L3D.Tools.mul(targetDirection, 0.05 * time / 20));
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) {
if (L3D.Tools.norm2(L3D.Tools.diff(this.position, this.newPosition)) < 0.01 &&
L3D.Tools.norm2(L3D.Tools.diff(this.target, this.newTarget)) < 0.01) {
this.moving = false;
this.anglesFromVectors();
}
@@ -461,11 +461,11 @@ L3D.PointerCamera.prototype.move = function(recommendation, toSave) {
this.movingHermite = false;
this.moving = true;
this.new_target = otherCamera.target.clone();
this.new_position = otherCamera.position.clone();
this.newTarget = otherCamera.target.clone();
this.newPosition = otherCamera.position.clone();
var t = [0,1];
var f = [this.position.clone(), this.new_position];
var fp = [L3D.Tools.diff(this.target, this.position), L3D.Tools.diff(this.new_target, this.new_position)];
var f = [this.position.clone(), this.newPosition];
var fp = [L3D.Tools.diff(this.target, this.position), L3D.Tools.diff(this.newTarget, this.newPosition)];
this.hermite = new L3D.Hermite.Polynom(t,f,fp);
this.t = 0;

View File

@@ -9,8 +9,8 @@ L3D.ReplayCamera = function() {
this.position = new THREE.Vector3();
this.target = new THREE.Vector3();
this.new_position = new THREE.Vector3();
this.new_target = new THREE.Vector3();
this.newPosition = new THREE.Vector3();
this.newTarget = new THREE.Vector3();
this.data = arguments[5];
@@ -54,7 +54,7 @@ L3D.ReplayCamera.prototype.update = function(time) {
};
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));
var tmp = L3D.Tools.sum(L3D.Tools.mul(this.oldPosition, 1-this.t), L3D.Tools.mul(this.newPosition, this.t));
this.position.copy(tmp);
this.t += 0.1 * time / 20;
@@ -65,9 +65,9 @@ L3D.ReplayCamera.prototype.linearMotion = function(time) {
L3D.ReplayCamera.prototype.cameraMotion = function(time) {
var tmp = L3D.Tools.sum(L3D.Tools.mul(this.old_position, 1-this.t), L3D.Tools.mul(this.new_position, this.t));
var tmp = L3D.Tools.sum(L3D.Tools.mul(this.oldPosition, 1-this.t), L3D.Tools.mul(this.newPosition, this.t));
this.position.copy(tmp);
this.target = L3D.Tools.sum(L3D.Tools.mul(this.old_target, 1-this.t), L3D.Tools.mul(this.new_target, this.t));
this.target = L3D.Tools.sum(L3D.Tools.mul(this.oldTarget, 1-this.t), L3D.Tools.mul(this.newTarget, 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) {
@@ -171,10 +171,10 @@ L3D.ReplayCamera.prototype.move = function(recommendation) {
var otherCamera = recommendation.camera || recommendation;
this.moving = true;
this.old_target = this.target.clone();
this.old_position = this.position.clone();
this.new_target = new THREE.Vector3(otherCamera.target.x, otherCamera.target.y, otherCamera.target.z);
this.new_position = new THREE.Vector3(otherCamera.position.x, otherCamera.position.y, otherCamera.position.z);
this.oldTarget = this.target.clone();
this.oldPosition = this.position.clone();
this.newTarget = new THREE.Vector3(otherCamera.target.x, otherCamera.target.y, otherCamera.target.z);
this.newPosition = new THREE.Vector3(otherCamera.position.x, otherCamera.position.y, otherCamera.position.z);
this.t = 0;
};

View File

@@ -132,11 +132,11 @@ L3D.MousePointer.prototype.render = function(style, force) {
this.domElement.width = this.domElement.width;
var i = container_size.width() / 2;
var i = containerSize.width() / 2;
var imin = i - this.size;
var imax = i + this.size;
var j = container_size.height() / 2;
var j = containerSize.height() / 2;
var jmin = j - this.size;
var jmax = j + this.size;

View File

@@ -61,15 +61,15 @@ L3D.Previewer = function(renderer, scene) {
/**
* Renders the preview
* @param {Number} container_width width of the container
* @param {Number} container_height height of the container
* @param {Number} containerWidth width of the container
* @param {Number} containerHeight height of the container
*/
L3D.Previewer.prototype.render = function(container_width, container_height) {
L3D.Previewer.prototype.render = function(containerWidth, containerHeight) {
var width, height, left, bottom;
if (this.camera) {
width = Math.floor(container_width / 5);
height = Math.floor(container_height / 5);
width = Math.floor(containerWidth / 5);
height = Math.floor(containerHeight / 5);
if (!this.fixed) {
left = Math.floor(this.mouse.x - width/2);
bottom = Math.floor(this.renderer.domElement.height - this.mouse.y + height/5);
@@ -88,22 +88,22 @@ L3D.Previewer.prototype.render = function(container_width, container_height) {
}
// Draw border
var can_bottom = container_height - bottom - height ;
var canBottom = containerHeight - bottom - height ;
this.ctx.strokeStyle = "#ffffff";
this.ctx.beginPath();
this.ctx.moveTo(left-1, can_bottom);
this.ctx.lineTo(left-1, can_bottom + height);
this.ctx.lineTo(left + width-1, can_bottom + height);
this.ctx.lineTo(left + width-1, can_bottom);
this.ctx.moveTo(left-1, canBottom);
this.ctx.lineTo(left-1, canBottom + height);
this.ctx.lineTo(left + width-1, canBottom + height);
this.ctx.lineTo(left + width-1, canBottom);
this.ctx.closePath();
this.ctx.stroke();
this.ctx.strokeStyle = "#000000";
this.ctx.beginPath();
this.ctx.moveTo(left, can_bottom + 1);
this.ctx.lineTo(left, can_bottom + height - 1);
this.ctx.lineTo(left + width - 2 , can_bottom + height-1);
this.ctx.lineTo(left + width - 2, can_bottom+1);
this.ctx.moveTo(left, canBottom + 1);
this.ctx.lineTo(left, canBottom + height - 1);
this.ctx.lineTo(left + width - 2 , canBottom + height-1);
this.ctx.lineTo(left + width - 2, canBottom+1);
this.ctx.closePath();
this.ctx.stroke();

View File

@@ -44,7 +44,7 @@ L3D.StartCanvas.prototype.render = function(force) {
this.ctx.font = '30px Verdana';
this.ctx.globalAlpha = 1;
this.ctx.fillStyle = 'black';
this.ctx.fillText('Click here to lock the pointer !', container_size.width()/3.25, container_size.height()/2-10);
this.ctx.fillText('Click here to lock the pointer !', containerSize.width()/3.25, containerSize.height()/2-10);
this.shown = true;

View File

@@ -2,9 +2,9 @@ var container = document.getElementById('content');
function print(text) {
var content = document.createTextNode(text);
var new_line = document.createElement('br');
var newLine = document.createElement('br');
container.appendChild(content);
container.appendChild(new_line);
container.appendChild(newLine);
}
function toString(variable) {

View File

@@ -190,26 +190,26 @@ L3D.BaseRecommendation.prototype.update = function(mainCamera) {
// Compute distance between center of camera and position
dist = L3D.Tools.norm2(L3D.Tools.diff(mainCamera.position, this.center));
var low_bound = 1;
var high_bound = 5;
var new_value;
var lowBound = 1;
var highBound = 5;
var newValue;
if (dist < low_bound) {
new_value = 0;
} else if (dist > high_bound) {
new_value = 1;
if (dist < lowBound) {
newValue = 0;
} else if (dist > highBound) {
newValue = 1;
} else {
new_value = (dist - low_bound)/(high_bound - low_bound);
newValue = (dist - lowBound)/(highBound - lowBound);
}
// Update opacity
var self = this;
this.object3D.traverse(function(elt) {
if (elt instanceof THREE.Mesh) {
elt.material.transparent = new_value < 0.9;
elt.material.opacity = new_value;
elt.material.transparent = newValue < 0.9;
elt.material.opacity = newValue;
if (new_value < 0.1)
if (newValue < 0.1)
self.raycastable = elt.raycastable = elt.material.transparent = elt.visible = false;
}
});

View File

@@ -42,8 +42,8 @@ L3D.ViewportRecommendation = function(arg1, arg2, arg3, arg4, position, target)
(function(self, direction, left, other) {
var material = new THREE.LineBasicMaterial({ color: '0x000000'});
var geometry = new THREE.Geometry();
var tmp_direction = L3D.Tools.mul(direction, -2);
var target = L3D.Tools.sum(self.camera.position, tmp_direction);
var tmpDirection = L3D.Tools.mul(direction, -2);
var target = L3D.Tools.sum(self.camera.position, tmpDirection);
// geometry.vertices.push(self.camera.position, target);
geometry.vertices.push(
L3D.Tools.sum(L3D.Tools.sum(self.camera.position, left), other),
@@ -53,16 +53,16 @@ L3D.ViewportRecommendation = function(arg1, arg2, arg3, arg4, position, target)
L3D.Tools.sum(L3D.Tools.sum(self.camera.position, left), other),
L3D.Tools.sum(L3D.Tools.diff(self.camera.position, other), left),
L3D.Tools.sum(self.camera.position, tmp_direction),
L3D.Tools.sum(self.camera.position, tmpDirection),
L3D.Tools.sum(L3D.Tools.sum(self.camera.position, left), other),
L3D.Tools.sum(self.camera.position, tmp_direction),
L3D.Tools.sum(self.camera.position, tmpDirection),
L3D.Tools.diff(L3D.Tools.sum(self.camera.position, other),left),
L3D.Tools.sum(self.camera.position, tmp_direction),
L3D.Tools.sum(self.camera.position, tmpDirection),
L3D.Tools.diff(L3D.Tools.diff(self.camera.position, left),other),
L3D.Tools.sum(self.camera.position, tmp_direction),
L3D.Tools.sum(self.camera.position, tmpDirection),
L3D.Tools.sum(L3D.Tools.diff(self.camera.position, other), left)
);
@@ -73,14 +73,14 @@ L3D.ViewportRecommendation = function(arg1, arg2, arg3, arg4, position, target)
var material = new THREE.MeshBasicMaterial();
var geometry = new THREE.Geometry();
var tmp_direction = L3D.Tools.mul(direction, -2);
var tmpDirection = L3D.Tools.mul(direction, -2);
geometry.vertices = [
L3D.Tools.sum(L3D.Tools.sum(self.camera.position, left), other),
L3D.Tools.diff(L3D.Tools.sum(self.camera.position, other),left),
L3D.Tools.diff(L3D.Tools.diff(self.camera.position, left),other),
L3D.Tools.sum(L3D.Tools.diff(self.camera.position, other), left),
L3D.Tools.sum(self.camera.position, tmp_direction)
L3D.Tools.sum(self.camera.position, tmpDirection)
];
geometry.faces = [
@@ -145,22 +145,22 @@ L3D.ViewportRecommendation.prototype.update = function(position) {
// Compute distance between center of camera and position
dist = L3D.Tools.norm2(L3D.Tools.diff(position.position, this.camera.position));
var low_bound = 0.5;
var high_bound = 5;
var new_value;
var max_value = 0.5;
var lowBound = 0.5;
var highBound = 5;
var newValue;
var maxValue = 0.5;
if (dist < low_bound)
new_value = 0;
else if (dist > high_bound)
new_value = max_value;
if (dist < lowBound)
newValue = 0;
else if (dist > highBound)
newValue = maxValue;
else
new_value = max_value * (dist - low_bound)/(high_bound - low_bound);
newValue = maxValue * (dist - lowBound)/(highBound - lowBound);
this.mesh.material.transparent = new_value < 0.9;
this.mesh.material.opacity = new_value;
this.mesh.material.transparent = newValue < 0.9;
this.mesh.material.opacity = newValue;
this.raycastable = this.line.visible = this.mesh.material.transparent = this.mesh.visible = new_value > 0.1;
this.raycastable = this.line.visible = this.mesh.material.transparent = this.mesh.visible = newValue > 0.1;
};
L3D.ViewportRecommendation.prototype.setSize = function(size) {
@@ -187,8 +187,8 @@ L3D.ViewportRecommendation.prototype.setSize = function(size) {
(function(self, direction, left, other, size) {
var tmp_direction = L3D.Tools.mul(direction, -2 * size);
var target = L3D.Tools.sum(self.camera.position, tmp_direction);
var tmpDirection = L3D.Tools.mul(direction, -2 * size);
var target = L3D.Tools.sum(self.camera.position, tmpDirection);
var vertices = [
L3D.Tools.sum(L3D.Tools.sum(self.camera.position, left), other),
@@ -198,16 +198,16 @@ L3D.ViewportRecommendation.prototype.setSize = function(size) {
L3D.Tools.sum(L3D.Tools.sum(self.camera.position, left), other),
L3D.Tools.sum(L3D.Tools.diff(self.camera.position, other), left),
L3D.Tools.sum(self.camera.position, tmp_direction),
L3D.Tools.sum(self.camera.position, tmpDirection),
L3D.Tools.sum(L3D.Tools.sum(self.camera.position, left), other),
L3D.Tools.sum(self.camera.position, tmp_direction),
L3D.Tools.sum(self.camera.position, tmpDirection),
L3D.Tools.diff(L3D.Tools.sum(self.camera.position, other),left),
L3D.Tools.sum(self.camera.position, tmp_direction),
L3D.Tools.sum(self.camera.position, tmpDirection),
L3D.Tools.diff(L3D.Tools.diff(self.camera.position, left),other),
L3D.Tools.sum(self.camera.position, tmp_direction),
L3D.Tools.sum(self.camera.position, tmpDirection),
L3D.Tools.sum(L3D.Tools.diff(self.camera.position, other), left)
];
@@ -218,14 +218,14 @@ L3D.ViewportRecommendation.prototype.setSize = function(size) {
(function(self, direction, left, other) {
var tmp_direction = L3D.Tools.mul(direction, -2 * size);
var tmpDirection = L3D.Tools.mul(direction, -2 * size);
self.collidingObject.geometry.vertices = [
L3D.Tools.sum(L3D.Tools.sum(self.camera.position, left), other),
L3D.Tools.diff(L3D.Tools.sum(self.camera.position, other),left),
L3D.Tools.diff(L3D.Tools.diff(self.camera.position, left),other),
L3D.Tools.sum(L3D.Tools.diff(self.camera.position, other), left),
L3D.Tools.sum(self.camera.position, tmp_direction)
L3D.Tools.sum(self.camera.position, tmpDirection)
];
})(this, direction, left, other, size);

View File

@@ -8,13 +8,13 @@ L3D.LogFunction = function(a,b) {
};
L3D.addLight = function(scene) {
var directional_light = new THREE.DirectionalLight(0xdddddd);
directional_light.position.set(1, 2.5, 1).normalize();
directional_light.castShadow = false;
scene.add(directional_light);
var directionalLight = new THREE.DirectionalLight(0xdddddd);
directionalLight.position.set(1, 2.5, 1).normalize();
directionalLight.castShadow = false;
scene.add(directionalLight);
var ambient_light = new THREE.AmbientLight(0x555555);
scene.add(ambient_light);
var ambientLight = new THREE.AmbientLight(0x555555);
scene.add(ambientLight);
};
L3D.initPeachCastle = function(scene, collidableObjects, recommendation, clickable) {
@@ -52,7 +52,7 @@ L3D.resetPeachElements = function() {
};
};
L3D.initPeach = function(camera, scene, coins, clickable, coin_ids) {
L3D.initPeach = function(camera, scene, coins, clickable, coinIds) {
L3D.addLight(scene);
var collidableObjects = [];
@@ -67,7 +67,7 @@ L3D.initPeach = function(camera, scene, coins, clickable, coin_ids) {
scene.add(camera);
var tmp = L3D.generateCoins(L3D.createPeachCoins(), coin_ids);
var tmp = L3D.generateCoins(L3D.createPeachCoins(), coinIds);
for (var i in tmp) {
coins.push(tmp[i]);
@@ -195,12 +195,12 @@ L3D.resetBobombElements = function() {
};
};
L3D.generateCoins = function(totalCoins, coin_ids) {
L3D.generateCoins = function(totalCoins, coinIds) {
var i = 0;
var tmp = [];
if (coin_ids === undefined) {
if (coinIds === undefined) {
tmp = [];
@@ -215,17 +215,17 @@ L3D.generateCoins = function(totalCoins, coin_ids) {
totalCoins.push(tmp[coinsId[i]]);
}
} else if (coin_ids === null) {
} else if (coinIds === null) {
return [];
} else {
for (i = 0; i < coin_ids.length; i++) {
for (i = 0; i < coinIds.length; i++) {
for (var j = 0; j < totalCoins.length; j++) {
if (coin_ids[i] === totalCoins[j].id) {
if (coinIds[i] === totalCoins[j].id) {
// Swap i and j
tmp = totalCoins[i];
@@ -241,7 +241,7 @@ L3D.generateCoins = function(totalCoins, coin_ids) {
var indices = [];
var coins = [];
var bound = (coin_ids instanceof Array && coin_ids.length === 0) ? totalCoins.length : 8;
var bound = (coinIds instanceof Array && coinIds.length === 0) ? totalCoins.length : 8;
for (i = 0; i < bound; i++) {
coins.push(totalCoins[i].coin);
@@ -317,7 +317,7 @@ L3D.createBobombRecommendations = function(width, height) {
};
L3D.initBobomb = function(camera, scene, coins, clickable, coin_ids) {
L3D.initBobomb = function(camera, scene, coins, clickable, coinIds) {
L3D.addLight(scene);
var collidableObjects = [];
@@ -333,13 +333,13 @@ L3D.initBobomb = function(camera, scene, coins, clickable, coin_ids) {
scene.add(camera);
Coin.init();
var tmp = L3D.generateCoins(L3D.createBobombCoins(), coin_ids);
var tmp = L3D.generateCoins(L3D.createBobombCoins(), coinIds);
for (var i in tmp) {
coins.push(tmp[i]);
}
var recommendations = L3D.createBobombRecommendations(container_size.width(), container_size.height());
var recommendations = L3D.createBobombRecommendations(containerSize.width(), containerSize.height());
recommendations.forEach(function(reco) {reco.addToScene(scene);});
@@ -473,7 +473,7 @@ L3D.resetWhompElements = function() {
};
};
L3D.initWhomp = function(recommendation, scene, coins, clickable, coin_ids) {
L3D.initWhomp = function(recommendation, scene, coins, clickable, coinIds) {
L3D.addLight(scene);
var collidableObjects = [];
@@ -489,13 +489,13 @@ L3D.initWhomp = function(recommendation, scene, coins, clickable, coin_ids) {
scene.add(recommendation);
Coin.init(0.002);
var tmp = L3D.generateCoins(L3D.createWhompCoins(), coin_ids);
var tmp = L3D.generateCoins(L3D.createWhompCoins(), coinIds);
for (var i in tmp) {
coins.push(tmp[i]);
}
var recommendations = L3D.createWhompRecommendations(container_size.width(), container_size.height());
var recommendations = L3D.createWhompRecommendations(containerSize.width(), containerSize.height());
recommendations.forEach(function(reco) {reco.addToScene(scene);});
@@ -610,7 +610,7 @@ L3D.resetMountainElements = function() {
};
};
L3D.initMountain = function(recommendation, scene, coins, clickable, coin_ids) {
L3D.initMountain = function(recommendation, scene, coins, clickable, coinIds) {
L3D.addLight(scene);
var collidableObjects = [];
@@ -626,13 +626,13 @@ L3D.initMountain = function(recommendation, scene, coins, clickable, coin_ids) {
scene.add(recommendation);
Coin.init();
var tmp = L3D.generateCoins(L3D.createMountainCoins(), coin_ids);
var tmp = L3D.generateCoins(L3D.createMountainCoins(), coinIds);
for (var i in tmp) {
coins.push(tmp[i]);
}
var recommendations = L3D.createMountainRecommendations(container_size.width(), container_size.height());
var recommendations = L3D.createMountainRecommendations(containerSize.width(), containerSize.height());
recommendations.forEach(function(reco) {reco.addToScene(scene);});
@@ -691,8 +691,6 @@ L3D.initSponzaScene = function(scene, collidableObjects, recommendation, clickab
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);
@@ -749,7 +747,7 @@ L3D.initSponza = function(recommendation, scene, coins, clickable) {
coins.push(tmp[i]);
}
var recommendations = L3D.createSponzaRecommendations(container_size.width(), container_size.height());
var recommendations = L3D.createSponzaRecommendations(containerSize.width(), containerSize.height());
recommendations.forEach(function(reco) {reco.addToScene(scene);});

View File

@@ -100,7 +100,7 @@ L3D.DB.Event.ArrowClicked = function() {
* Id of the arrow
* @type {Number}
*/
this.arrow_id = null;
this.arrowId = null;
};
@@ -109,7 +109,7 @@ L3D.DB.Event.ArrowClicked = function() {
*/
L3D.DB.Event.ArrowClicked.prototype.send = function() {
var url = "/posts/arrow-clicked";
var data = {arrow_id: this.arrow_id};
var data = {arrowId: this.arrowId};
L3D.DB.Private.sendData(url, data);
};
@@ -124,7 +124,7 @@ L3D.DB.Event.CoinClicked = function() {
* Id of the coin taken
* @type {Number}
*/
this.coin_id = null;
this.coinId = null;
};
/**
@@ -132,7 +132,7 @@ L3D.DB.Event.CoinClicked = function() {
*/
L3D.DB.Event.CoinClicked.prototype.send = function() {
var url = "/posts/coin-clicked";
var data = {coin_id: this.coin_id};
var data = {coinId: this.coinId};
L3D.DB.Private.sendData(url, data);
};
@@ -222,7 +222,7 @@ L3D.DB.Event.Hovered = function() {
* The id of the arrow hovered
* @type {Number}
*/
this.arrow_id = null;
this.arrowId = null;
/**
* true if the hover starts, false if finishes
@@ -239,7 +239,7 @@ L3D.DB.Event.Hovered.prototype.send = function() {
var url = "/posts/hovered";
var data = {
start: this.start,
arrow_id: this.arrow_id
arrowId: this.arrowId
};
L3D.DB.Private.sendData(url, data);