gibbon.js
Version:
Actor/Component system for use with pixi.js.
36 lines • 980 B
JavaScript
import Component from "@/component";
/**
*
*/
class Reckoner extends Component {
get heading() { return this._heading; }
set heading(v) {
this._heading = v;
this.receivedAt = Date.now();
}
/**
* Time when last heading was received.
*/
receivedAt = 0;
remoteDest;
remotePos;
remoteVelocity;
/**
* Time to match actual reckoned location, per unit distance.
*/
timeToMatchMs = 10;
/**
* Expected delay in heading information from server.
*/
delayMs = 100;
_heading;
update(delta) {
if (this._heading) {
/// compute theoretical server position.
const time = (Date.now() - this.receivedAt) + this.delayMs;
const atX = this._heading.at.x + this._heading.velocity.x * time;
const atY = this._heading.at.y + this._heading.velocity.y * time;
}
}
}
//# sourceMappingURL=reckoner.js.map