Skip to content

Commit

Permalink
Updating and fixing lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
peabnuts123 committed Dec 25, 2018
1 parent a2f4166 commit d429c40
Show file tree
Hide file tree
Showing 44 changed files with 389 additions and 460 deletions.
41 changes: 19 additions & 22 deletions src/builders/cylinder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import NoiseMap from '@app/noisemap';
import Cylinder from '@app/model/cylinder';
import NoiseMap from '@app/noisemap';

class NoiseMapBuilderCylinder {
private sourceModule: any;
Expand All @@ -11,7 +11,7 @@ class NoiseMapBuilderCylinder {
private _upperAngleBound: number;
private _upperHeightBound: number;

constructor(sourceModule, width: number, height: number) {
constructor(sourceModule?: any, width?: number, height?: number) {
this.sourceModule = sourceModule || null;
this.width = width || 256;
this.height = height || 256;
Expand All @@ -24,71 +24,68 @@ class NoiseMapBuilderCylinder {
this.noiseMap = new NoiseMap(this.width, this.height);
}

get lowerAngleBound() {
public get lowerAngleBound() {
return this._lowerAngleBound;
}
set lowerAngleBound(v) {
public set lowerAngleBound(v: number) {
if (v >= this.upperAngleBound) {
throw new Error('Lower bound cannot equal or exceed upper bound!');
}

this._lowerAngleBound = v;
}

get lowerHeightBound() {
public get lowerHeightBound() {
return this._lowerHeightBound;
}
set lowerHeightBound(v) {
public set lowerHeightBound(v: number) {
if (v >= this.upperHeightBound) {
throw new Error('Lower bound cannot equal or exceed upper bound!');
}

this._lowerHeightBound = v;
}

get upperAngleBound() {
public get upperAngleBound() {
return this._upperAngleBound;
}
set upperAngleBound(v) {
public set upperAngleBound(v: number) {
if (v <= this.upperAngleBound) {
throw new Error('Upper bound cannot equal or exceed upper bound!');
}

this._upperAngleBound = v;
}

get upperHeightBound() {
public get upperHeightBound() {
return this._upperHeightBound;
}
set upperHeightBound(v) {
public set upperHeightBound(v: number) {
if (v <= this.upperHeightBound) {
throw new Error('Upper bound cannot equal or exceed upper bound!');
}

this._upperHeightBound = v;
}

build() {

public build() {
if (!this.sourceModule) {

throw new Error('Invalid or missing module!');

}

// Create the cylinder model.
var cylinder = new Cylinder(this.sourceModule);
var xDelta = (this.upperAngleBound - this.lowerAngleBound) / this.width;
var yDelta = (this.upperHeightBound - this.lowerHeightBound) / this.height;
var curAngle = this.lowerAngleBound;
var curHeight = this.lowerHeightBound;
let cylinder = new Cylinder(this.sourceModule);
let xDelta = (this.upperAngleBound - this.lowerAngleBound) / this.width;
let yDelta = (this.upperHeightBound - this.lowerHeightBound) / this.height;
let curAngle = this.lowerAngleBound;
let curHeight = this.lowerHeightBound;

// Fill every point in the noise map with the output values from the model.
for (var y = 0; y < this.height; y++) {
for (let y = 0; y < this.height; y++) {

curAngle = this.lowerAngleBound;

for (var x = 0; x < this.width; x++) {
for (let x = 0; x < this.width; x++) {

this.noiseMap.setValue(x, y, cylinder.getValue(curAngle, curHeight));

Expand All @@ -103,7 +100,7 @@ class NoiseMapBuilderCylinder {
return this.noiseMap;
}

setBounds(lowerAngleBound, lowerHeightBound, upperAngleBound, upperHeightBound) {
public setBounds(lowerAngleBound: number, lowerHeightBound: number, upperAngleBound: number, upperHeightBound: number) {
this.lowerAngleBound = lowerAngleBound;
this.lowerHeightBound = lowerHeightBound;
this.upperAngleBound = upperAngleBound;
Expand Down
51 changes: 26 additions & 25 deletions src/builders/plane.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Interpolation from '@app/interpolation';
import NoiseMap from '@app/noisemap';
import Plane from '@app/model/plane';
import NoiseMap from '@app/noisemap';

class NoiseMapBuilderPlane {
private sourceModule: any;
Expand All @@ -13,7 +13,7 @@ class NoiseMapBuilderPlane {
private _upperXBound: number;
private _upperYBound: number;

constructor(sourceModule, width, height, seamless) {
constructor(sourceModule?: any, width?: number, height?: number, seamless?: boolean) {
this.sourceModule = sourceModule || null;
this.width = width || 256;
this.height = height || 256;
Expand All @@ -27,37 +27,37 @@ class NoiseMapBuilderPlane {
this.noiseMap = new NoiseMap(this.width, this.height);
}

get lowerXBound() {
public get lowerXBound() {
return this._lowerXBound;
}
set lowerXBound(v) {
public set lowerXBound(v: number) {
this._lowerXBound = v;
}

get lowerYBound() {
public get lowerYBound() {
return this._lowerYBound;
}
set lowerYBound(v) {
public set lowerYBound(v: number) {
this._lowerYBound = v;
}

get upperXBound() {
public get upperXBound() {
return this._upperXBound;
}
set upperXBound(v) {
public set upperXBound(v: number) {
this._upperXBound = v;
}

get upperYBound() {
public get upperYBound() {
return this._upperYBound;
}
set upperYBound(v) {
public set upperYBound(v: number) {
this._upperYBound = v;
}

build() {
var xExtent = this.upperXBound - this.lowerXBound;
var yExtent = this.upperYBound - this.lowerYBound;
public build() {
let xExtent = this.upperXBound - this.lowerXBound;
let yExtent = this.upperYBound - this.lowerYBound;

if (xExtent < 0 || yExtent < 0) {

Expand All @@ -72,19 +72,20 @@ class NoiseMapBuilderPlane {
}

// Create the plane model.
var plane = new Plane(this.sourceModule);
var xDelta = xExtent / this.width;
var yDelta = yExtent / this.height;
var curX = this.lowerXBound;
var curY = this.lowerYBound;
var value, xBlend;
let plane = new Plane(this.sourceModule);
let xDelta = xExtent / this.width;
let yDelta = yExtent / this.height;
let curX = this.lowerXBound;
let curY = this.lowerYBound;
let value;
let xBlend;

// Fill every point in the noise map with the output values from the model.
for (var y = 0; y < this.height; y++) {
for (let y = 0; y < this.height; y++) {

curX = this.lowerXBound;

for (var x = 0; x < this.width; x++) {
for (let x = 0; x < this.width; x++) {

if (!this.seamless) {

Expand All @@ -98,14 +99,14 @@ class NoiseMapBuilderPlane {
Interpolation.linear(
plane.getValue(curX, curY),
plane.getValue(curX + xExtent, curY),
xBlend
xBlend,
),
Interpolation.linear(
plane.getValue(curX, curY + yExtent),
plane.getValue(curX + xExtent, curY + yExtent),
xBlend
xBlend,
),
1.0 - ((curY - this.lowerYBound) / yExtent)
1.0 - ((curY - this.lowerYBound) / yExtent),
);
}

Expand All @@ -122,7 +123,7 @@ class NoiseMapBuilderPlane {
return this.noiseMap;
}

setBounds(lowerXBound, lowerYBound, upperXBound, upperYBound) {
public setBounds(lowerXBound: number, lowerYBound: number, upperXBound: number, upperYBound: number) {
this.upperXBound = upperXBound;
this.upperYBound = upperYBound;
this.lowerXBound = lowerXBound;
Expand Down
43 changes: 19 additions & 24 deletions src/builders/sphere.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import NoiseMap from '@app/noisemap';
import Sphere from '@app/model/sphere';
import NoiseMap from '@app/noisemap';

class NoiseMapBuilderSphere {
private sourceModule: any;
Expand All @@ -11,7 +11,7 @@ class NoiseMapBuilderSphere {
private _southLatBound: number;
private _westLonBound: number;

constructor(sourceModule, width, height) {
constructor(sourceModule?: any, width?: number, height?: number) {
this.sourceModule = sourceModule || null;
this.width = width || 256;
this.height = height || 256;
Expand All @@ -24,43 +24,43 @@ class NoiseMapBuilderSphere {
this.noiseMap = new NoiseMap(this.width, this.height);
}

get eastLonBound() {
public get eastLonBound() {
return this._eastLonBound;
}
set eastLonBound(v) {
public set eastLonBound(v: number) {
if (v <= this.westLonBound) {
throw new Error('Lower bound cannot equal or exceed east bound!');
}

this._eastLonBound = v;
}

get northLatBound() {
public get northLatBound() {
return this._northLatbound;
}
set northLatBound(v) {
public set northLatBound(v: number) {
if (v <= this.southLatBound) {
throw new Error('Lower bound cannot equal or exceed east bound!');
}

this._northLatbound = v;
}

get southLatBound() {
public get southLatBound() {
return this._southLatBound;
}
set southLatBound(v) {
public set southLatBound(v: number) {
if (v >= this.northLatBound) {
throw new Error('Lower bound cannot equal or exceed east bound!');
}

this._westLonBound = v;
}

get westLonBound() {
public get westLonBound() {
return this._westLonBound;
}
set westLonBound(v) {
public set westLonBound(v: number) {
if (v >= this.eastLonBound) {

throw new Error('Lower bound cannot equal or exceed east bound!');
Expand All @@ -70,27 +70,24 @@ class NoiseMapBuilderSphere {
this._westLonBound = v;
}

build() {

public build() {
if (!this.sourceModule) {

throw new Error('Invalid or missing module!');

}

// Create the cylinder model.
var sphere = new Sphere(this.sourceModule);
var xDelta = (this.eastLonBound - this.westLonBound) / this.width;
var yDelta = (this.northLatBound - this.southLatBound) / this.height;
var curLon = this.westLonBound;
var curLat = this.eastLonBound;
let sphere = new Sphere(this.sourceModule);
let xDelta = (this.eastLonBound - this.westLonBound) / this.width;
let yDelta = (this.northLatBound - this.southLatBound) / this.height;
let curLon = this.westLonBound;
let curLat = this.eastLonBound;

// Fill every point in the noise map with the output values from the model.
for (var y = 0; y < this.height; y++) {
for (let y = 0; y < this.height; y++) {

curLon = this.westLonBound;

for (var x = 0; x < this.width; x++) {
for (let x = 0; x < this.width; x++) {

this.noiseMap.setValue(x, y, sphere.getValue(curLat, curLon));

Expand All @@ -106,13 +103,11 @@ class NoiseMapBuilderSphere {

}

setBounds(westLonBound, eastLonBound, southLatBound, northLatBound) {

public setBounds(westLonBound: number, eastLonBound: number, southLatBound: number, northLatBound: number) {
this.westLonBound = westLonBound;
this.eastLonBound = eastLonBound;
this.southLatBound = southLatBound;
this.northLatBound = northLatBound;

}
}

Expand Down
10 changes: 6 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { test } from '@app/builders/test';
// import { test } from '@app/builders/test';

console.log("Test: " , test);
// console.log("Test: " , test);

const output = "Test: " + test;
export default output;
// const output = "Test: " + test;
// export default output;
let a: string = "Hello world";
console.log(a);
Loading

0 comments on commit d429c40

Please sign in to comment.