|
@@ -299,27 +299,23 @@
|
|
var time = performance.now();
|
|
var time = performance.now();
|
|
var delta = ( time - prevTime ) / 1000;
|
|
var delta = ( time - prevTime ) / 1000;
|
|
|
|
|
|
- velocity.x -= velocity.x * 10.0 * delta;
|
|
|
|
- velocity.z -= velocity.z * 10.0 * delta;
|
|
|
|
-
|
|
|
|
velocity.y -= 9.8 * 100.0 * delta; // 100.0 = mass
|
|
velocity.y -= 9.8 * 100.0 * delta; // 100.0 = mass
|
|
|
|
|
|
direction.z = Number( moveForward ) - Number( moveBackward );
|
|
direction.z = Number( moveForward ) - Number( moveBackward );
|
|
- direction.x = Number( moveLeft ) - Number( moveRight );
|
|
|
|
|
|
+ direction.x = Number( moveRight ) - Number( moveLeft );
|
|
direction.normalize(); // this ensures consistent movements in all directions
|
|
direction.normalize(); // this ensures consistent movements in all directions
|
|
|
|
|
|
- if ( moveForward || moveBackward ) velocity.z -= direction.z * 400.0 * delta;
|
|
|
|
- if ( moveLeft || moveRight ) velocity.x -= direction.x * 400.0 * delta;
|
|
|
|
-
|
|
|
|
if ( onObject === true ) {
|
|
if ( onObject === true ) {
|
|
|
|
|
|
velocity.y = Math.max( 0, velocity.y );
|
|
velocity.y = Math.max( 0, velocity.y );
|
|
canJump = true;
|
|
canJump = true;
|
|
|
|
|
|
}
|
|
}
|
|
- controls.getObject().translateX( velocity.x * delta );
|
|
|
|
|
|
+
|
|
|
|
+ controls.moveRight( direction.x * 400.0 * delta );
|
|
|
|
+ controls.moveForward( direction.z * 400.0 * delta );
|
|
|
|
+
|
|
controls.getObject().position.y += ( velocity.y * delta ); // new behavior
|
|
controls.getObject().position.y += ( velocity.y * delta ); // new behavior
|
|
- controls.getObject().translateZ( velocity.z * delta );
|
|
|
|
|
|
|
|
if ( controls.getObject().position.y < 10 ) {
|
|
if ( controls.getObject().position.y < 10 ) {
|
|
|
|
|