diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3499d82 --- /dev/null +++ b/.gitignore @@ -0,0 +1,123 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test +.env.production + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +# .DS_Store +.DS_Store + +dist/** diff --git a/src/examples/webgl/scss/main.scss b/src/assets/fonts/.gitkeep similarity index 100% rename from src/examples/webgl/scss/main.scss rename to src/assets/fonts/.gitkeep diff --git a/src/examples/webgl/ts/shader/fragment.frag b/src/assets/images/.gitkeep similarity index 100% rename from src/examples/webgl/ts/shader/fragment.frag rename to src/assets/images/.gitkeep diff --git a/src/assets/images/github.svg b/src/assets/images/github.svg new file mode 100644 index 0000000..aa05db9 --- /dev/null +++ b/src/assets/images/github.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/images/logo.svg b/src/assets/images/logo.svg new file mode 100644 index 0000000..4243137 --- /dev/null +++ b/src/assets/images/logo.svg @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/images/twitter.svg b/src/assets/images/twitter.svg new file mode 100644 index 0000000..1970575 --- /dev/null +++ b/src/assets/images/twitter.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/examples/light-spot/index.ejs b/src/examples/light-spot/index.ejs deleted file mode 100644 index f99f258..0000000 --- a/src/examples/light-spot/index.ejs +++ /dev/null @@ -1,10 +0,0 @@ - - - -<%- include('../../util/template/head.ejs',{title:'universe-alpha'})%> - - - - - - \ No newline at end of file diff --git a/src/examples/light-spot/scss/main.scss b/src/examples/light-spot/scss/main.scss deleted file mode 100644 index 7af82b1..0000000 --- a/src/examples/light-spot/scss/main.scss +++ /dev/null @@ -1,6 +0,0 @@ - - -canvas{ - width: 100%; - height: 100%; -} \ No newline at end of file diff --git a/src/examples/light-spot/ts/create-buffer.ts b/src/examples/light-spot/ts/create-buffer.ts deleted file mode 100644 index 793eca3..0000000 --- a/src/examples/light-spot/ts/create-buffer.ts +++ /dev/null @@ -1,15 +0,0 @@ -const createBuffer = (gl:WebGLRenderingContext) => { - // Create and initialize buffer - const geometryBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, geometryBuffer); - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ - -1.0, -1.0, - 1.0, -1.0, - -1.0, 1.0, - 1.0, 1.0 - ]), gl.STATIC_DRAW); - - return geometryBuffer; -} - -export default createBuffer; diff --git a/src/examples/light-spot/ts/create-program.ts b/src/examples/light-spot/ts/create-program.ts deleted file mode 100644 index ef6a028..0000000 --- a/src/examples/light-spot/ts/create-program.ts +++ /dev/null @@ -1,15 +0,0 @@ -import createShader from './create-shader'; - -const createProgram = (gl:WebGLRenderingContext, shaderData:any) => { - const program = gl.createProgram(); - - shaderData - .map((s:any) => createShader(gl, s.src, s.type)) - .forEach((s:any) => gl.attachShader(program, s)); - - gl.linkProgram(program); - - return program; -}; - -export default createProgram; diff --git a/src/examples/light-spot/ts/create-shader.ts b/src/examples/light-spot/ts/create-shader.ts deleted file mode 100644 index 2b761bd..0000000 --- a/src/examples/light-spot/ts/create-shader.ts +++ /dev/null @@ -1,14 +0,0 @@ -const createShader = (gl:WebGLRenderingContext, sourceCode:string, type:WebGLRenderingContext['VERTEX_SHADER']|WebGLRenderingContext['FRAGMENT_SHADER']) => { - // Compiles either a shader of type gl.VERTEX_SHADER or gl.FRAGMENT_SHADER - var shader = gl.createShader( type ); - gl.shaderSource( shader, sourceCode ); - gl.compileShader( shader ); - - if ( !gl.getShaderParameter(shader, gl.COMPILE_STATUS) ) { - var info = gl.getShaderInfoLog(shader); - throw 'Could not compile WebGL program. \n\n' + info; - } - return shader; -}; - -export default createShader; diff --git a/src/examples/light-spot/ts/draw.ts b/src/examples/light-spot/ts/draw.ts deleted file mode 100644 index 4bd1240..0000000 --- a/src/examples/light-spot/ts/draw.ts +++ /dev/null @@ -1,15 +0,0 @@ -const draw = (gl:WebGLRenderingContext, now:number, state:any) => { - gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); - gl.bindBuffer(gl.ARRAY_BUFFER, state.geometryBuffer); - - gl.enableVertexAttribArray(state.attributes.position); - gl.vertexAttribPointer(state.attributes.position, 2, gl.FLOAT, false, 0, 0); - gl.uniform2f(state.uniforms.resolution, window.innerWidth, window.innerHeight); - gl.uniform1f(state.uniforms.millis, now); - - gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); - - requestAnimationFrame(now => draw(gl, now, state)); -}; - -export default draw; diff --git a/src/examples/light-spot/ts/index.ts b/src/examples/light-spot/ts/index.ts deleted file mode 100755 index 88be7a6..0000000 --- a/src/examples/light-spot/ts/index.ts +++ /dev/null @@ -1,62 +0,0 @@ -// This demo is from an anonymous Codepen. -// It has been modified to stop it having dependencies -// and been split up into seperate files. -// This is probably not a good resource to learn -// from as it has not been well thought out! -// https://codepen.io/anon/pen/EQLERV -const fragmentShaderSrc = require('./shaders/fragment.frag'); -const vertexShaderSrc = require('./shaders/vertex.vert'); -import resizeCanvas from './resize-canvas'; -import createProgram from './create-program'; -import createBuffer from './create-buffer'; -import draw from './draw'; -const init = () => { - // Create program - - let canvas = document.getElementById('canvas'); - if (!(canvas instanceof HTMLCanvasElement)) return; - const gl = canvas.getContext('webgl'); - - const shaders = [ - { src: fragmentShaderSrc, type: gl.FRAGMENT_SHADER }, - { src: vertexShaderSrc, type: gl.VERTEX_SHADER } - ]; - - const program = createProgram(gl, shaders); - - const geometryBuffer = createBuffer(gl); - - // Set up attributes and uniforms - const attributes = { - position: gl.getAttribLocation(program, 'a_position') - }; - - const uniforms = { - resolution: gl.getUniformLocation(program, 'u_resolution'), - millis: gl.getUniformLocation(program, 'u_millis') - }; - - // Set WebGL program here (we have only one) - gl.useProgram(program); - - - // Resize canvas and viewport - const resize = () => { - resizeCanvas(gl.canvas); - gl.viewport(0, 0, gl.canvas.width, gl.canvas.height); - }; - - // Setup canvas - window.onresize = resize; - resize(); - - // Start rendering - requestAnimationFrame(now => draw(gl, now, { - geometryBuffer, - attributes, - uniforms, - })); - -} - -window.onload = init; diff --git a/src/examples/light-spot/ts/resize-canvas.ts b/src/examples/light-spot/ts/resize-canvas.ts deleted file mode 100644 index f111c7c..0000000 --- a/src/examples/light-spot/ts/resize-canvas.ts +++ /dev/null @@ -1,12 +0,0 @@ -const resizeCanvas = (canvas:HTMLCanvasElement, multiplier = 1) => { - var width = canvas.clientWidth * multiplier | 0; - var height = canvas.clientHeight * multiplier | 0; - if (canvas.width !== width || canvas.height !== height) { - canvas.width = width; - canvas.height = height; - return true; - } - return false; -}; - -export default resizeCanvas; diff --git a/src/examples/light-spot/ts/shaders/fragment.frag b/src/examples/light-spot/ts/shaders/fragment.frag deleted file mode 100644 index 8a52106..0000000 --- a/src/examples/light-spot/ts/shaders/fragment.frag +++ /dev/null @@ -1,61 +0,0 @@ -#ifdef GL_ES - precision mediump float; -#endif - -uniform vec2 u_resolution; -uniform float u_millis; - -const int PARTICLES = 18; -const float ENERGY = 0.2; -const float BLOBINESS = 1.6; -const float BRIGHTNESS = 1.1; -const float OFFSET = 30000.0; - -float rand(vec2 co) { - return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); -} - -void main(void) { - vec2 pixel = (gl_FragCoord.xy / u_resolution.x); - float t = (u_millis + OFFSET ) * 0.001 * ENERGY; - - float a = 0.0; - float b = 0.0; - float c = 0.0; - - vec2 particle; - vec2 center = vec2(0.5, 0.5 * (u_resolution.y / u_resolution.x)); - - float na, nb, nc, nd, d; - float size = float(PARTICLES); - float step = 1.0 / size; - float n = step; - - for (int i = 0; i < PARTICLES; i++) { - vec2 np = vec2(n, 0.0); - - na = rand(np * 1.1); - nb = rand(np * 2.8); - nc = rand(np * 0.7); - nd = rand(np * 3.2); - - particle = center; - particle.x += sin(t*na) * cos(t*nb) * 0.6; - particle.y += cos(t*nc) * sin(t*nd) * 0.4; - - d = pow(1.2 * na / length(particle - pixel), BLOBINESS); - - if (float(i) < size * 0.3333) { - a += d; - } else if (float(i) < size * 0.6666) { - b += d; - } else { - c += d; - } - - n += step; - } - - vec3 col = vec3(a*c, b*c, a*b) * 0.0001 * BRIGHTNESS; - gl_FragColor = vec4(col, 1.0); -} \ No newline at end of file diff --git a/src/examples/light-spot/ts/shaders/vertex.vert b/src/examples/light-spot/ts/shaders/vertex.vert deleted file mode 100644 index fb2ea12..0000000 --- a/src/examples/light-spot/ts/shaders/vertex.vert +++ /dev/null @@ -1,5 +0,0 @@ -attribute vec2 a_position; - -void main(void) { - gl_Position = vec4(a_position, 0, 1); -} diff --git a/src/examples/webgl/index.ejs b/src/examples/webgl/index.ejs deleted file mode 100644 index f99f258..0000000 --- a/src/examples/webgl/index.ejs +++ /dev/null @@ -1,10 +0,0 @@ - - - -<%- include('../../util/template/head.ejs',{title:'universe-alpha'})%> - - - - - - \ No newline at end of file diff --git a/src/examples/webgl/ts/index.ts b/src/examples/webgl/ts/index.ts deleted file mode 100644 index 13daea3..0000000 --- a/src/examples/webgl/ts/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -const fragmentShader = require('./shader/fragment.frag'); -const vertexShader = require('./shader/vertex.vert'); -import * as twgl from 'twgl.js' - -function init(){ - const cvs = document.getElementById('canvas'); - if (!(cvs instanceof HTMLCanvasElement)) return; - const gl = cvs.getContext('webgl'); - const program = twgl.createProgram(gl,[fragmentShader,vertexShader]); -} - -window.onload = init; \ No newline at end of file diff --git a/src/examples/webgl/ts/shader/vertex.vert b/src/examples/webgl/ts/shader/vertex.vert deleted file mode 100644 index e69de29..0000000 diff --git a/tsconfig-for-webpack-config.json b/tsconfig-for-webpack-config.json new file mode 100644 index 0000000..f419502 --- /dev/null +++ b/tsconfig-for-webpack-config.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "esModuleInterop": true + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..8263d28 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "outDir": "./dist/", + "noImplicitAny": true, + "module": "commonjs", + "target": "es5", + "jsx": "react", + "allowJs": true, + "moduleResolution": "node", + "declaration": true + }, + "exclude": [ + "node_modules", + "dist", + "./webpack.config.ts" + ] +} \ No newline at end of file