Merge remote-tracking branch 'origin/main' into clear-hydra
This commit is contained in:
commit
4a25eab01a
28 changed files with 217 additions and 68 deletions
|
|
@ -1,17 +1,9 @@
|
|||
import { getDrawContext, controls } from '@strudel/core';
|
||||
import { getDrawContext } from '@strudel/draw';
|
||||
import { controls } from '@strudel/core';
|
||||
|
||||
let latestOptions;
|
||||
|
||||
function appendCanvas(c) {
|
||||
const { canvas: testCanvas } = getDrawContext();
|
||||
c.canvas.id = 'hydra-canvas';
|
||||
c.canvas.style.position = 'fixed';
|
||||
c.canvas.style.top = '0px';
|
||||
testCanvas.after(c.canvas);
|
||||
return testCanvas;
|
||||
}
|
||||
|
||||
let hydra;
|
||||
|
||||
export async function initHydra(options = {}) {
|
||||
// reset if options have changed since last init
|
||||
if (latestOptions && JSON.stringify(latestOptions) !== JSON.stringify(options)) {
|
||||
|
|
@ -23,8 +15,16 @@ export async function initHydra(options = {}) {
|
|||
const {
|
||||
src = 'https://unpkg.com/hydra-synth',
|
||||
feedStrudel = false,
|
||||
contextType = 'webgl',
|
||||
pixelRatio = 1,
|
||||
pixelated = true,
|
||||
...hydraConfig
|
||||
} = { detectAudio: false, ...options };
|
||||
} = {
|
||||
detectAudio: false,
|
||||
...options,
|
||||
};
|
||||
const { canvas } = getDrawContext('hydra-canvas', { contextType, pixelRatio, pixelated });
|
||||
hydraConfig.canvas = canvas;
|
||||
|
||||
await import(/* @vite-ignore */ src);
|
||||
hydra = new Hydra(hydraConfig);
|
||||
|
|
@ -33,7 +33,6 @@ export async function initHydra(options = {}) {
|
|||
canvas.style.display = 'none';
|
||||
hydra.synth.s0.init({ src: canvas });
|
||||
}
|
||||
appendCanvas(hydra);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue