diff --git a/js/components/MilkdropWindow/index.js b/js/components/MilkdropWindow/index.js index f07a5d33..e1951bd3 100644 --- a/js/components/MilkdropWindow/index.js +++ b/js/components/MilkdropWindow/index.js @@ -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() { diff --git a/package.json b/package.json index 4d985c01..58f56f42 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/yarn.lock b/yarn.lock index e315b917..4dace8b6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"