From 7a95d734de3d14917ea6f6a766055b3bdefb26ea Mon Sep 17 00:00:00 2001 From: Elijah Lucian Date: Sat, 3 Apr 2021 17:41:57 -0600 Subject: [PATCH] Update Laser.js --- webclient/src/spaceport/Laser.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/webclient/src/spaceport/Laser.js b/webclient/src/spaceport/Laser.js index c38aad0..54e84f0 100644 --- a/webclient/src/spaceport/Laser.js +++ b/webclient/src/spaceport/Laser.js @@ -3,6 +3,14 @@ import * as THREE from 'three'; const LASER_SIZE = 0.5; const BULLET_SPREAD = 0.1; +const geometry = new THREE.BoxGeometry( + LASER_SIZE * 0.03, + LASER_SIZE * 0.03, + LASER_SIZE +); + +const material = new THREE.MeshStandardMaterial(this.direction > 0 ? 0xff0000 : 0x0000ff, { flatShading: true }) + export class Laser { constructor(ship) { const position = new THREE.Vector3(); @@ -14,14 +22,9 @@ export class Laser { ship.mesh.getWorldPosition(position) - const shipGeo = new THREE.BoxGeometry( - LASER_SIZE * 0.03, - LASER_SIZE * 0.03, - LASER_SIZE - ); this.mesh = new THREE.Mesh( - shipGeo, - new THREE.MeshStandardMaterial(this.direction > 0 ? 0xff0000 : 0x0000ff, { flatShading: true }) + geometery, + material ); this.mesh.material.color.set(