mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-21 18:48:36 +00:00
Merge pull request #808 from kasparsj/hydra-options
add options param to initHydra
This commit is contained in:
commit
69e99fa902
@ -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…
x
Reference in New Issue
Block a user