Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dist/aura.js

Large diffs are not rendered by default.

52 changes: 0 additions & 52 deletions dist/bundle.js

This file was deleted.

23 changes: 22 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,27 @@

<body>
<div id="aura-embed" data-app></div>
<script src="dist/bundle.js"></script>
<script src="dist/aura.js"></script>
<script>
// Initialize the aura using the library API
const container = document.getElementById('aura-embed');
const canvas = document.createElement('canvas');
container.appendChild(canvas);

const gl = canvas.getContext('webgl2', { preserveDrawingBuffer: true });

const params = {
...LightwardAura.defaultParams,
width: window.innerWidth,
height: window.innerHeight,
animTime: Math.random() * 9999,
seed: Math.round(Math.random() * 9999),
};

// LightwardAura is directly the Aura class constructor
const aura = new LightwardAura(gl, params);
aura.start();
window.aura = aura;
</script>
</body>
</html>
75 changes: 23 additions & 52 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,59 +1,30 @@
import babel from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import typescript from '@rollup/plugin-typescript';
import {terser} from 'rollup-plugin-terser';

export default [
// Original React app bundle
{
input: 'src/main.tsx',
output: {
file: 'dist/bundle.js',
format: 'cjs',
},
plugins: [
resolve(),
commonjs(),
typescript({
tsconfig: './tsconfig.json',
outputToFilesystem: false,
}),
terser(),
babel({
exclude: 'node_modules/**',
presets: ['@babel/preset-react'],
babelHelpers: 'bundled',
}),
replace({
preventAssignment: true,
'process.env.NODE_ENV': JSON.stringify('production'),
}),
],
export default {
input: 'src/Aura.ts',
output: {
file: 'dist/aura.js',
format: 'iife',
name: 'LightwardAura',
exports: 'default'
},
// Library build for script tag usage
{
input: 'src/Aura.ts',
output: {
file: 'dist/aura.js',
format: 'iife',
name: 'LightwardAura'
},
plugins: [
resolve({
browser: true
}),
commonjs(),
typescript({
tsconfig: './tsconfig.json',
outputToFilesystem: false,
}),
terser(),
replace({
preventAssignment: true,
'process.env.NODE_ENV': JSON.stringify('production'),
}),
],
},
];
plugins: [
resolve({
browser: true
}),
commonjs(),
typescript({
tsconfig: './tsconfig.json',
outputToFilesystem: false,
}),
terser(),
replace({
preventAssignment: true,
'process.env.NODE_ENV': JSON.stringify('production'),
}),
],
};
47 changes: 47 additions & 0 deletions src/Aura.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,54 @@ export interface AuraParams {
};
}

const defaultColors: AuraColor[] = [
[95, 168, 242], // freedom
[48, 64, 92], // eclipse
[220, 91, 172], // pink
[111, 200, 111], // seaFoam
[253, 205, 0], // golden
];

export default class Aura {
static defaultParams: Omit<AuraParams, 'width' | 'height'> = {
animTime: 0,
seed: 1,
colors: [...defaultColors, defaultColors[0]],
globalParams: {
contrast: 1.37,
displayGradient: false,
feedback: 0.99,
noise: 0.5,
saturation: 1.69,
speed: 0.13,
targetFps: 60,
value: 1,
},
layer1Params: {
blobbyness: 1.3,
blur: 1.01,
brightness: 0.52,
enabled: true,
},
layer2Params: {
blur: 1.47,
brightness: 0.6,
cycleSpeed: 0.12,
enabled: true,
},
feedbackSettings: {
amount: 0.28,
centerX: 0.5,
centerY: 0.5,
dist: 0.06,
scaleX: 1.01,
scaleY: 1.01,
},
blurSettings: {
iterations: 5,
radius: 5,
},
};
rng: seedrandom.PRNG;
gl: WebGL2RenderingContext;
canvas: HTMLCanvasElement;
Expand Down