load smaller preset pack and randomize initial preset

This commit is contained in:
jberg 2018-06-06 23:31:01 -07:00 committed by Jordan Eldredge
parent 0a32ab71fb
commit 76f60e14a5
3 changed files with 13 additions and 27 deletions

View File

@ -22,14 +22,14 @@ class MilkdropWindow extends React.Component {
}
componentDidMount() {
require.ensure(
[
"butterchurn",
"butterchurn-presets/presets/converted/Geiss - Reaction Diffusion 2.json"
],
["butterchurn", "butterchurn-presets/lib/butterchurnPresetsMinimal.min"],
require => {
const analyserNode = this.props.analyser;
const butterchurn = require("butterchurn");
const reactionDiffusion2 = require("butterchurn-presets/presets/converted/Geiss - Reaction Diffusion 2.json");
const butterchurnPresets = require("butterchurn-presets/lib/butterchurnPresetsMinimal.min");
this.presets = butterchurnPresets.getPresets();
this.presetKeys = Object.keys(this.presets);
const presetIdx = Math.floor(Math.random() * this.presetKeys.length);
this.visualizer = butterchurn.createVisualizer(
analyserNode.context,
@ -43,7 +43,7 @@ class MilkdropWindow extends React.Component {
this._canvasNode.width = this.props.width;
this._canvasNode.height = this.props.height;
this.visualizer.connectAudio(analyserNode);
this.visualizer.loadPreset(reactionDiffusion2, 0);
this.visualizer.loadPreset(this.presets[this.presetKeys[presetIdx]], 0);
// Kick off the animation loop
const loop = () => {
if (this.props.status === "PLAYING") {
@ -53,21 +53,7 @@ class MilkdropWindow extends React.Component {
};
loop();
screenfull.onchange(this._handleFullscreenChange);
},
e => {
console.error("Error loading Butterchurn", e);
},
"butterchurn"
);
require.ensure(
["butterchurn-presets"],
require => {
const butterchurnPresets = require("butterchurn-presets");
this.presets = butterchurnPresets.getPresets();
this.presetKeys = Object.keys(this.presets);
this.presetHistory = [];
this.presetHistory = [presetIdx];
this.presetRandomize = true;
this.presetCycle = true;
this._restartCycling();
@ -76,9 +62,9 @@ class MilkdropWindow extends React.Component {
);
},
e => {
console.error("Error loading Butterchurn presets", e);
console.error("Error loading Butterchurn", e);
},
"butterchurn-presets"
"butterchurn"
);
}
componentWillUnmount() {

View File

@ -55,7 +55,7 @@
"babel-preset-react": "^6.24.1",
"babel-runtime": "^6.26.0",
"butterchurn": "^2.4.3",
"butterchurn-presets": "^2.4.1",
"butterchurn-presets": "^2.4.4",
"canvas-mock": "0.0.0",
"cardinal-spline-js": "^2.3.6",
"classnames": "^2.2.5",

View File

@ -1269,9 +1269,9 @@ builtin-status-codes@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8"
butterchurn-presets@^2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/butterchurn-presets/-/butterchurn-presets-2.4.1.tgz#cad3e94bf5665d65610bf336b57623616726bbe8"
butterchurn-presets@^2.4.4:
version "2.4.4"
resolved "https://registry.yarnpkg.com/butterchurn-presets/-/butterchurn-presets-2.4.4.tgz#23764b47e9d30c29caf95d974a92002f6f29c057"
dependencies:
babel-runtime "^6.26.0"
ecma-proposal-math-extensions "0.0.2"