fix: sequenceCurve 进度为 0 时的值改为首段曲线在 0 处的值

This commit is contained in:
AncTe committed 2026-11-25 19:03:24 +08:00
1 parent 292f382c46
commit f2b5ba9d97
2 files changed
+17 -2

No files matched your search

+16 -2
View File
@@ -1,4 +1,4 @@
import { cumsum } from '@motajs/common';
import { cumsum, logger } from '@motajs/common';
import {
ExcitationCurve,
ExcitationCurve2D,
@@ -171,7 +171,21 @@ export function sequenceCurve(
scale: number[],
move: number[]
): ExcitationCurve {
const keep = [0, ...cumsum(duration)];
const lenEqual =
seq.length === duration.length &&
seq.length === scale.length &&
seq.length === move.length;
if (seq.length === 0 || !lenEqual) {
logger.warn(
216,
seq.length.toString(),
duration.length.toString(),
scale.length.toString(),
move.length.toString()
);
return () => 0;
}
const keep = [seq[0](0), ...cumsum(duration)];
return p => {
const index = keep.findIndex(sum => p <= sum);
if (index <= 0) return 0;
+1
View File
@@ -321,6 +321,7 @@
"213": "Setting item '$1' has existed in group '$2'. The item will be moved to new group '$3'.",
"214": "Range setting item get a number range that cannot be divided into integer by step: range=[$1, $2], step=$3. This may cause issues, please ensure number range can be divided by step evenly.",
"215": "Cannot change canvas size or block size of size-freezed map renderer.",
"216": "Expected all sequence curve arrays with a same length and larger than zero, but got: seq: $1, duration: $2, scale: $3, move: $4.",
"1001": "Event(setBlock): Unknown tile '$1' when setting block."
}
}