Merge pull request #808 from kasparsj/hydra-options
add options param to initHydra
This commit is contained in:
commit
69e99fa902
1 changed files with 9 additions and 3 deletions
|
|
@ -1,13 +1,19 @@
|
||||||
import { getDrawContext } from '@strudel.cycles/core';
|
import { getDrawContext } from '@strudel.cycles/core';
|
||||||
|
|
||||||
export async function initHydra() {
|
export async function initHydra(
|
||||||
|
options = {
|
||||||
|
src: 'https://unpkg.com/hydra-synth',
|
||||||
|
detectAudio: false,
|
||||||
|
},
|
||||||
|
) {
|
||||||
if (!document.getElementById('hydra-canvas')) {
|
if (!document.getElementById('hydra-canvas')) {
|
||||||
const { canvas: testCanvas } = getDrawContext();
|
const { canvas: testCanvas } = getDrawContext();
|
||||||
await import('https://unpkg.com/hydra-synth');
|
const { src, ...opts } = options;
|
||||||
|
await import(src);
|
||||||
const hydraCanvas = testCanvas.cloneNode(true);
|
const hydraCanvas = testCanvas.cloneNode(true);
|
||||||
hydraCanvas.id = 'hydra-canvas';
|
hydraCanvas.id = 'hydra-canvas';
|
||||||
testCanvas.after(hydraCanvas);
|
testCanvas.after(hydraCanvas);
|
||||||
new Hydra({ canvas: hydraCanvas, detectAudio: false });
|
new Hydra(Object.assign({ canvas: hydraCanvas }, opts));
|
||||||
s0.init({ src: testCanvas });
|
s0.init({ src: testCanvas });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue