@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
26 lines (22 loc) • 748 B
JavaScript
import Signal from "../../../../core/events/signal/Signal.js";
import {uploadViaElement} from "./uploadViaElement.js";
import {AnimationCurve} from "../AnimationCurve.js";
/**
* Create upload to get curve data and trigger a signal
* @param {HTMLElement} el
* @returns {Signal}
*/
export function createCurveUploader(el) {
const onCurveChange = new Signal();
let curve = new AnimationCurve();
uploadViaElement(el, (text) => {
try {
const importedCurve = JSON.parse(text);
curve.fromJSON(importedCurve);
onCurveChange.send1(curve);
} catch (err) {
console.error("Invalid JSON curve file:", err);
}
});
return onCurveChange;
}