Update Laser.js

This commit is contained in:
Elijah Lucian 2021-04-03 17:41:57 -06:00 committed by GitHub
parent 868e3636dc
commit 7a95d734de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,14 @@ import * as THREE from 'three';
const LASER_SIZE = 0.5; const LASER_SIZE = 0.5;
const BULLET_SPREAD = 0.1; 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 { export class Laser {
constructor(ship) { constructor(ship) {
const position = new THREE.Vector3(); const position = new THREE.Vector3();
@ -14,14 +22,9 @@ export class Laser {
ship.mesh.getWorldPosition(position) ship.mesh.getWorldPosition(position)
const shipGeo = new THREE.BoxGeometry(
LASER_SIZE * 0.03,
LASER_SIZE * 0.03,
LASER_SIZE
);
this.mesh = new THREE.Mesh( this.mesh = new THREE.Mesh(
shipGeo, geometery,
new THREE.MeshStandardMaterial(this.direction > 0 ? 0xff0000 : 0x0000ff, { flatShading: true }) material
); );
this.mesh.material.color.set( this.mesh.material.color.set(