Skip to content

Commit

Permalink
Fix envelope node
Browse files Browse the repository at this point in the history
  • Loading branch information
grifdail committed Nov 19, 2024
1 parent 1724a43 commit c274e41
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/Nodes/System/Precompute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ export const Precompute: NodeDefinition = {
needRedraw ||= when === "Per frame" && !context.frameBlackboard[keyComputed];
needRedraw ||= when === "Everytime";
if (needRedraw) {
var fn: (args: [key: string, port: PortConnection]) => [string, any] = ([key, value]) => [key, context.getInputValue(data, key, value.type)];
var fn: (args: [key: string, port: PortConnection]) => [string, any] = ([key, value]) => {
var v = context.getInputValue(data, key, value.type);
return [key, v];
};
const target = Object.fromEntries(Object.entries(data.dataInputs).map(fn));
context.blackboard[keyComputed] = true;
context.frameBlackboard[keyComputed] = true;
Expand Down
4 changes: 2 additions & 2 deletions src/Types/EnvelopeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const createDefaultEnvelopeStop = (): EnvelopeStop => ({
height: 0.5,
lerp: Easing.Linear,
});
export function interpolateEnvelope(envelope: EnvelopeData, pos: number): any {
export function interpolateEnvelope(envelope: EnvelopeData, pos: number): number {
if (envelope.length === 0) {
return 0;
}
Expand All @@ -28,7 +28,7 @@ export function interpolateEnvelope(envelope: EnvelopeData, pos: number): any {
}
for (var stop of envelope) {
if (pos < stop.pos) {
return VectorLerp([prev.height], [stop.height], evaluate(prev.lerp, clamp01(map(prev.pos, stop.pos, pos))));
return VectorLerp([prev.height], [stop.height], evaluate(prev.lerp, clamp01(map(prev.pos, stop.pos, pos))))[0];
} else {
prev = stop;
}
Expand Down

0 comments on commit c274e41

Please sign in to comment.