Skip to content

Commit

Permalink
feat(compilation): switched to rollup
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlad Chirkov committed Aug 26, 2021
1 parent 27642f5 commit e4d82dd
Show file tree
Hide file tree
Showing 28 changed files with 35,511 additions and 173,479 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -5,10 +5,10 @@ notifications:
node_js:
- '8'
install:
- npm install && npm install -g gulp-cli
- npm install
before_script:
- npm prune
script: gulp build
script: npm run build
after_success:
- npm run semantic-release
branches:
Expand Down
71 changes: 34 additions & 37 deletions demo/Demo.js
Expand Up @@ -4,10 +4,8 @@
import TrackballControls from 'three-trackballcontrols';
import Stats from 'stats.js';
import dat from 'dat.gui/build/dat.gui';
import WebglStuff from '../src';

import {clone, extend, each} from 'lodash';
import clipboard from 'clipboard-js';
import WebglStuff from '../src/index';
import * as clipboard from 'clipboard-polyfill/text';
import Noty from 'noty';
import 'noty/lib/noty.css';

Expand All @@ -17,8 +15,8 @@ const KEYS = [
16 // 'alt'
];

export default class Demo {
constructor(el, preset = clone(WebglStuff.presets.normal), duration = 3000) {
export default class Demo {
constructor(el, preset = {...WebglStuff.presets.normal}, duration = 3000) {
this.el = el;
this.preset = preset;
this.duration = duration;
Expand All @@ -42,7 +40,7 @@ export default class Demo {
this.gui.add(this, 'duration')
.min(0).max(60 * 1000)
.step(100)
.onChange(this.transit.bind(this));
.onChange(() => this.transit());

this.initGuiPresetButtons().open();
this.initGuiCircles().open();
Expand All @@ -56,55 +54,55 @@ export default class Demo {
circles.add(this.preset, 'visible')
.min(0).max(WebglStuff.initial.circles)
.step(1)
.onChange(this.transit.bind(this));
.onChange(() => this.transit());
circles.add(this.preset, 'opacityStep')
.min(0).max(1)
.step(0.1)
.onChange(this.transit.bind(this));
.onChange(() => this.transit());
circles.addColor(this.preset, 'pointsColor')
.onChange(this.transit.bind(this));
.onChange(() => this.transit());
circles.add(this.preset, 'impact')
.min(-1).max(1)
.step(0.001)
.onChange(this.transit.bind(this));
.onChange(() => this.transit());
circles.add(this.preset, 'stabilityStart')
.min(0.5).max(2)
.step(0.001)
.onChange(this.transit.bind(this));
.onChange(() => this.transit());
circles.add(this.preset, 'stabilityEnd')
.min(0.5).max(2)
.step(0.001)
.onChange(this.transit.bind(this));
.onChange(() => this.transit());
circles.add(this.preset, 'rotation')
.min(-0.01).max(0.01)
.step(0.00001)
.onChange(this.transit.bind(this));
.onChange(() => this.transit());
circles.add(this.preset, 'perlin')
.min(-0.01).max(0.01)
.step(0.00001)
.onChange(this.transit.bind(this));
.onChange(() => this.transit());
return circles;
}

initGuiHighlight() {
let highlight = this.gui.addFolder('Highlight settings');
highlight.addColor(this.preset, 'ringColor')
.onChange(this.transit.bind(this));
.onChange(() => this.transit());
highlight.add(this.preset, 'opacity')
.min(0).max(1)
.step(0.1)
.onChange(this.transit.bind(this));
.onChange(() => this.transit());
return highlight;
}

initGuiBackground() {
let background = this.gui.addFolder('Background settings');
background.addColor(this.preset, 'background')
.onChange(this.transit.bind(this));
.onChange(() => this.transit());
background.add(this.preset, 'floatsOpacity')
.min(0).max(1)
.step(0.01)
.onChange(this.transit.bind(this));
.onChange(() => this.transit());
return background;
}

Expand All @@ -130,18 +128,18 @@ export default class Demo {
let clipboardAction = {
'copy preset': () => {
try {
clipboard.copy(JSON.stringify(this.preset, null, 4));
new Noty({
type: 'success',
text: 'Yay, copied :)',
layout: 'bottomRight',
progressBar: false,
killer: true,
timeout: 1000,
animation: {
close: null
}
}).show();
clipboard.writeText(JSON.stringify(this.preset, null, 4))
.then(() => new Noty({
type: 'success',
text: 'Yay, copied :)',
layout: 'bottomRight',
progressBar: false,
killer: true,
timeout: 1000,
animation: {
close: null
}
}).show());
} catch (e) {
new Noty({
type: 'error',
Expand All @@ -158,12 +156,11 @@ export default class Demo {
}

transit(preset, update = false) {
extend(this.preset, preset);
this.wgs.transitTo(this.preset, this.duration);

if (update) {
each(this.gui.__folders, folder => each(folder.__controllers, c => c.updateDisplay()));
if (preset) {
Object.assign(this.preset, preset);
Object.values(this.gui.__folders).forEach(folder => folder.__controllers.forEach(c => c.updateDisplay()));
}
this.wgs.transitTo(this.preset, this.duration);
}

initControls() {
Expand All @@ -185,4 +182,4 @@ export default class Demo {
this.wgs.on(WebglStuff.ON_UPDATE, () => this.controls.update());
this.wgs.on(WebglStuff.ON_AFTER_UPDATE, () => this.stats.end());
}
}
}

0 comments on commit e4d82dd

Please sign in to comment.