Smooth collisions
This commit is contained in:
parent
f64a861936
commit
5d0bd09139
|
@ -157,8 +157,14 @@ TutoCamera.prototype.normalMotion = function(time) {
|
||||||
normal.multiplyScalar(-1);
|
normal.multiplyScalar(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
normal.multiplyScalar(0.01);
|
// This is quite ugly, but it allows smooth collisions (well, quite smooth)
|
||||||
this.position.add(normal);
|
this.position.add(direction);
|
||||||
|
var dir = direction.clone();
|
||||||
|
dir.normalize();
|
||||||
|
this.position.add(Tools.mul(dir, 300*this.speed));
|
||||||
|
var move = (Tools.mul(normal,Tools.diff(vertices[face.a], this.position).dot(normal)));
|
||||||
|
this.position.add(move);
|
||||||
|
this.position.sub(Tools.mul(dir, 300*this.speed));
|
||||||
} else {
|
} else {
|
||||||
this.position.add(direction);
|
this.position.add(direction);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue