Cleaning BouncingCube and increase FixedCamera arrow resolution

This commit is contained in:
Thomas FORGIONE 2015-04-28 16:47:44 +02:00
parent 09cfce804a
commit 6442a7bcb9
2 changed files with 10 additions and 10 deletions

View File

@ -1,7 +1,3 @@
DT = new THREE.Vector3(0.1,0.1,0.1);
FRICTION = new THREE.Vector3(1, 1, 1);
G = new THREE.Vector3(0,0,-10);
var BouncingCube = function(size, style) { var BouncingCube = function(size, style) {
Cube.call(this, size, style); Cube.call(this, size, style);
@ -16,21 +12,25 @@ BouncingCube.prototype.constructor = BouncingCube;
BouncingCube.prototype.update = function() { BouncingCube.prototype.update = function() {
// Compute new center // Compute new center
var speed_clone = this.speed.clone(); var speed_clone = this.speed.clone();
speed_clone.multiply(DT); speed_clone.multiply(BouncingCube.DT);
this.speed.add(G); this.speed.add(BouncingCube.G);
if (this.speed.dot(this.speed) > 100) { if (this.speed.dot(this.speed) > 100) {
this.center.add(speed_clone); this.center.add(speed_clone);
} }
if (this.center.z < 0) { if (this.center.z < 0) {
this.speed.multiply(new THREE.Vector3(1,1,-0.5)); this.speed.multiply(BouncingCube.FRICTION);
this.center.z = 0; this.center.z = 0;
} }
// Update the mesh // Update the mesh
this.mesh.position.set(this.center.x, this.center.y, this.center.z); this.mesh.position.set(this.center.x, this.center.y, this.center.z);
// console.log(this.center.x, this.center.y, this.center.z);
} }
// Static variables
BouncingCube.DT = new THREE.Vector3(0.1,0.1,0.1);
BouncingCube.FRICTION = new THREE.Vector3(1, 1, -0.5);
BouncingCube.G = new THREE.Vector3(0,0,-10);

View File

@ -162,7 +162,7 @@ FixedCamera.prototype.regenerateArrow = function(mainCamera) {
var limit = this.fullArrow ? 0.1 : 0.3; var limit = this.fullArrow ? 0.1 : 0.3;
// for (var i = this.fullArrow ? 0 : 0.5; i <= 1.001; i += 0.05) { // for (var i = this.fullArrow ? 0 : 0.5; i <= 1.001; i += 0.05) {
for (var i = 1; i > limit; i -= 0.05) { for (var i = 1; i > limit; i -= 0.025) {
point = hermite.eval(i); point = hermite.eval(i);
deriv = hermite.prime(i); deriv = hermite.prime(i);
up.cross(deriv); up.cross(deriv);