Skip to content

Commit

Permalink
Merge pull request #20 from hsimpson/feature/gh-action-deploy
Browse files Browse the repository at this point in the history
Feature/gh action deploy
  • Loading branch information
hsimpson committed May 31, 2023
2 parents a201cf3 + bc33314 commit c1bd399
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 203 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
workflow_dispatch:

jobs:
build:
Expand All @@ -14,12 +15,12 @@ jobs:
node-version: [16.x]
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
node-version-file: '.nvmrc'

- name: Install node_modules
run: yarn install
Expand All @@ -28,7 +29,7 @@ jobs:
run: yarn run build

- name: Deploy
uses: JamesIves/github-pages-deploy-action@4.1.7
uses: JamesIves/github-pages-deploy-action@4
with:
branch: gh-pages
folder: dist
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"deploy": "yarn run build && gh-pages -d dist",
"check-types": "tsc --noemit",
"lint:ts": "eslint . --ext .ts,.tsx --fix",
"lint": "yarn check-types && yarn lint:ts"
Expand Down Expand Up @@ -39,7 +38,6 @@
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"gh-pages": "^5.0.0",
"prettier": "^2.8.8",
"resize-observer-polyfill": "^1.5.1",
"rimraf": "^5.0.1",
Expand Down
20 changes: 12 additions & 8 deletions src/textures/noise.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { vec3 } from 'gl-matrix';
// import { snoise } from './simplex3dnoise';
import SimplexNoise from 'simplex-noise';
import alea from 'alea';
import { createNoise3D } from 'simplex-noise';
import { serializable } from '../serializing';
import { Perlin } from './perlin';
import { Texture } from './texture';

const RANDOMSEED = 'just a random seed string';
// create a random number generator based on a seed string
const prng = alea('just a random seed string');
const noise3D = createNoise3D(prng);

@serializable
export class NoiseTexture extends Texture {
private _noise = new Perlin();
private _scale: number;
private _simplexNoise: SimplexNoise;
// private _simplexNoise: SimplexNoise;

public constructor(scale: number) {
super();
Expand All @@ -22,16 +26,16 @@ export class NoiseTexture extends Texture {
}

public turb(p: vec3, depth = 7): number {
if (!this._simplexNoise) {
this._simplexNoise = new SimplexNoise(RANDOMSEED);
}
// if (!this._simplexNoise) {
// this._simplexNoise = new SimplexNoise(RANDOMSEED);
// }

let accum = 0.0;
const tempP = p;
let weight = 1.0;
for (let i = 0; i < depth; i++) {
// accum += weight * snoise(tempP);
accum += weight * this._simplexNoise.noise3D(p[0], p[1], p[2]);
accum += weight * noise3D(p[0], p[1], p[2]);
weight *= 0.5;
vec3.scale(tempP, tempP, 2.0);
}
Expand All @@ -43,7 +47,7 @@ export class NoiseTexture extends Texture {
return vec3.scale(
vec3.create(),
vec3.scale(vec3.create(), vec3.fromValues(1, 1, 1), 0.5),
1.0 + Math.sin(this._scale * p[2] + 10.0 * this.turb(p))
1.0 + Math.sin(this._scale * p[2] + 10.0 * this.turb(p)),
);
}
}
Loading

0 comments on commit c1bd399

Please sign in to comment.