diff options
Diffstat (limited to 'derelict.js')
-rw-r--r-- | derelict.js | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/derelict.js b/derelict.js index 3f234e6..87bc4d5 100644 --- a/derelict.js +++ b/derelict.js @@ -4,7 +4,7 @@ import { CSS2DRenderer, CSS2DObject } from 'https://unpkg.com/three@0.126.1/exam const SCALE = 10000 const METERS_IN_AU = 149597871000 -const EXPIRY = 1000 * 60 * 5 +const EXPIRY = 1000 * 60 * 10 class SkirmishGrid { scene = new THREE.Scene() @@ -86,6 +86,7 @@ class Wreck { labelElement.classList.add('label') this.killmail = killmail + this.timestamp = Date.parse(killmail.killmail_time) this.point.position.copy(killmail.victim.position) this.point.add(object2d) @@ -100,18 +101,19 @@ class Wreck { } toggleKilled(timestamp) { - const timeDifference = timestamp - Date.parse(this.killmail.killmail_time) - if (timeDifference > EXPIRY) { + const timeDifference = this.timestamp - timestamp + this.domElement.classList.remove('future', 'alive', 'killed', 'expired') + if (timeDifference < -EXPIRY) { this.domElement.classList.add('expired') - this.domElement.classList.remove('future', 'killed') } - else if (timeDifference >= 0) { + else if (timeDifference <= 0) { this.domElement.classList.add('killed') - this.domElement.classList.remove('expired', 'future') + } + else if (timeDifference < EXPIRY) { + this.domElement.classList.add('alive') } else { this.domElement.classList.add('future') - this.domElement.classList.remove('killed', 'expired') } } } |