mirror of
https://github.com/wassname/GarageServer.IO.git
synced 2026-09-12 12:06:39 +08:00
Removed smoothing for now... clean start next time.
This commit is contained in:
@@ -10,7 +10,6 @@ options = {
|
|||||||
onInterpolation: function(currentState, previousState, targetState, amount)
|
onInterpolation: function(currentState, previousState, targetState, amount)
|
||||||
logging: true,
|
logging: true,
|
||||||
clientSidePrediction: true,
|
clientSidePrediction: true,
|
||||||
clientSmoothing: true,
|
|
||||||
interpolation: true,
|
interpolation: true,
|
||||||
interpolationDelay: 100,
|
interpolationDelay: 100,
|
||||||
pingInterval: 2000
|
pingInterval: 2000
|
||||||
@@ -22,10 +21,8 @@ window.GarageServerIO = (function (window, socketio) {
|
|||||||
function StateController() {
|
function StateController() {
|
||||||
this.state = {};
|
this.state = {};
|
||||||
this.time;
|
this.time;
|
||||||
this.frameTime = new Date().getTime();
|
|
||||||
this.delta;
|
this.delta;
|
||||||
this.playerId;
|
this.playerId;
|
||||||
this.clientSmoothing = 1;
|
|
||||||
this.pingDelay = 100;
|
this.pingDelay = 100;
|
||||||
this.fps = 0;
|
this.fps = 0;
|
||||||
this.fpsLastUpdate = (new Date()) * 1 - 1;
|
this.fpsLastUpdate = (new Date()) * 1 - 1;
|
||||||
@@ -177,9 +174,7 @@ window.GarageServerIO = (function (window, socketio) {
|
|||||||
updateState(data);
|
updateState(data);
|
||||||
});
|
});
|
||||||
_socket.on('ping', function(data) {
|
_socket.on('ping', function(data) {
|
||||||
var newPingDelay = new Date().getTime() - data;
|
_stateController.pingDelay = new Date().getTime() - data;
|
||||||
_stateController.clientSmoothing = _options.clientSmoothing ? ((_stateController.clientSmoothing + (_stateController.pingDelay / newPingDelay)) / 2) : 1;
|
|
||||||
_stateController.pingDelay = newPingDelay;
|
|
||||||
if (_options.onPing) {
|
if (_options.onPing) {
|
||||||
_options.onPing(_stateController.pingDelay);
|
_options.onPing(_stateController.pingDelay);
|
||||||
}
|
}
|
||||||
@@ -232,7 +227,6 @@ window.GarageServerIO = (function (window, socketio) {
|
|||||||
|
|
||||||
updateState = function (data) {
|
updateState = function (data) {
|
||||||
_stateController.setTime(data.time, _options.interpolationDelay ? _options.interpolationDelay : 100);
|
_stateController.setTime(data.time, _options.interpolationDelay ? _options.interpolationDelay : 100);
|
||||||
_stateController.frameTime = new Date().getTime();
|
|
||||||
_stateController.delta = data.delta;
|
_stateController.delta = data.delta;
|
||||||
|
|
||||||
updatePlayersState(data);
|
updatePlayersState(data);
|
||||||
@@ -317,9 +311,8 @@ window.GarageServerIO = (function (window, socketio) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getInterpolatedAmount = function (previousTime, targetTime) {
|
getInterpolatedAmount = function (previousTime, targetTime) {
|
||||||
var frameDiff = new Date().getTime() - _stateController.frameTime,
|
var range = targetTime - previousTime,
|
||||||
range = targetTime - previousTime,
|
difference = _stateController.time - previousTime,
|
||||||
difference = _stateController.time - previousTime + (frameDiff * _stateController.clientSmoothing),
|
|
||||||
amount = parseFloat((difference / range).toFixed(3));
|
amount = parseFloat((difference / range).toFixed(3));
|
||||||
|
|
||||||
return amount;
|
return amount;
|
||||||
|
|||||||
Reference in New Issue
Block a user