From 7492bf4f259a5ea8b1e0994a39fb6f5db2f17426 Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 6 Apr 2021 00:43:40 +0200 Subject: Added more camera movements --- derelict.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/derelict.js b/derelict.js index abe960c..65acb7c 100644 --- a/derelict.js +++ b/derelict.js @@ -23,6 +23,8 @@ class SkirmishGrid { this.controls = new OrbitControls(this.camera, this.renderer2d.domElement) this.controls.minDistance = 2 this.controls.maxDistance = 30 + this.controls.enableDamping = true + this.controls.dampingFactor = 0.4 } add(obj) { @@ -32,6 +34,7 @@ class SkirmishGrid { draw() { this.renderer.render(this.scene, this.camera) this.renderer2d.render(this.scene, this.camera) + this.controls.update() requestAnimationFrame(() => this.draw()) } @@ -48,7 +51,7 @@ class Wreck { point = new THREE.Object3D() killmail - constructor({killmail, position, icon}) { + constructor({killmail, position, icon, grid}) { const iconElement = document.importNode(icon, true) const object2d = new CSS2DObject(this.domElement) @@ -63,6 +66,10 @@ class Wreck { this.point.add(object2d) this.domElement.onclick = () => window.open(`https://zkillboard.com/kill/${this.killmail.killmail_id}/`) + this.domElement.oncontextmenu = () => { + grid.controls.target.copy(position) + grid.controls.update() + } } } @@ -104,7 +111,7 @@ function processKillmails(grid, killmails, icon) { const vec3 = killmail.victim.position vec3.sub(center) vec3.divideScalar(SCALE) - const wreck = new Wreck({position: vec3, killmail, icon}) + const wreck = new Wreck({position: vec3, killmail, icon, grid}) grid.add(wreck.point) elements.push(wreck.domElement) }) -- cgit v1.1