Skip to content

🎥 Make videos programmatically with React

remotion.dev/brand: Move core fix to separate PR

JonnyBurger0bc0313847a4
diff --git a/packages/core/src/interpolate.ts b/packages/core/src/interpolate.ts
index a259c6cfbf..55e5bdba46 100644
--- a/packages/core/src/interpolate.ts
+++ b/packages/core/src/interpolate.ts
@@ -787,19 +787,11 @@ const interpolateString = ({
// angle interpolates away from zero.
const adjacentAxisRotation =
parsed.values[0] === 0
- ? index === 0
- ? initiallyParsedOutputRange.find(
- (candidate) => candidate.axisRotation,
- )
- : index === initiallyParsedOutputRange.length - 1
- ? [...initiallyParsedOutputRange]
- .reverse()
- .find((candidate) => candidate.axisRotation)
- : index === segmentIndex
- ? initiallyParsedOutputRange[index + 1]
- : index === segmentIndex + 1
- ? initiallyParsedOutputRange[index - 1]
- : undefined
+ ? index === segmentIndex
+ ? initiallyParsedOutputRange[index + 1]
+ : index === segmentIndex + 1
+ ? initiallyParsedOutputRange[index - 1]
+ : undefined
: undefined;
const axis = adjacentAxisRotation?.axisRotation
? adjacentAxisRotation.values
diff --git a/packages/core/src/spring/spring-utils.ts b/packages/core/src/spring/spring-utils.ts
index bf227c65ca..4673d36b9a 100644
--- a/packages/core/src/spring/spring-utils.ts
+++ b/packages/core/src/spring/spring-utils.ts
@@ -139,6 +139,10 @@ export function springCalculation({
const frameClamped = Math.max(0, frame);
const unevenRest = frameClamped % 1;
for (let f = 0; f <= Math.floor(frameClamped); f++) {
+ if (f === Math.floor(frameClamped)) {
+ f += unevenRest;
+ }
+
const time = (f / fps) * 1000;
animation = advance({
animation,
@@ -150,17 +154,6 @@ export function springCalculation({
});
}
- if (unevenRest > 0) {
- animation = advance({
- animation,
- now: (frameClamped / fps) * 1000,
- config: {
- ...defaultSpringConfig,
- ...config,
- },
- });
- }
-
calculationCache[cacheKey] = animation;
return animation;
}
diff --git a/packages/core/src/test/interpolate.test.ts b/packages/core/src/test/interpolate.test.ts
index acce6c8e64..d891e2b034 100644
--- a/packages/core/src/test/interpolate.test.ts
+++ b/packages/core/src/test/interpolate.test.ts
@@ -758,90 +758,6 @@ test('Allow tail spring keeps previous string segment settling while the next se
expect(yWithTail).toBeLessThan(10);
});
-test('Allow tail spring stays continuous when followed by a hold segment', () => {
- const easing = [
- Easing.spring({
- allowTail: true,
- damping: 200,
- durationRestThreshold: 0.02,
- mass: 1,
- stiffness: 100,
- }),
- Easing.spring({
- allowTail: true,
- damping: 200,
- durationRestThreshold: 0.02,
- mass: 1,
- stiffness: 100,
- }),
- ] as const;
- const options = {
- easing,
- extrapolateLeft: 'clamp',
- extrapolateRight: 'clamp',
- output: 'perceptual-scale',
- } as const;
-
- const immediatelyBeforeHold = interpolate(
- 169.999,
- [21, 170, 591],
- [1.26, 6.02, 6.02],
- options,
- );
- const atHold = interpolate(170, [21, 170, 591], [1.26, 6.02, 6.02], options);
-
- expect(immediatelyBeforeHold).toBeCloseTo(atHold, 5);
-});
-
-test('Allow tail axis rotation keeps its axis while settling into a hold segment', () => {
- const axisRotation = '0.945221 -0.227695 0.233905 45.778028deg';
- const easing = [
- Easing.spring({
- allowTail: true,
- damping: 200,
- durationRestThreshold: 0.02,
- mass: 1,
- stiffness: 100,
- }),
- Easing.spring({
- allowTail: true,
- damping: 200,
- durationRestThreshold: 0.02,
- mass: 1,
- stiffness: 100,
- }),
- Easing.spring({
- allowTail: true,
- damping: 200,
- durationRestThreshold: 0.02,
- mass: 1,
- stiffness: 100,
- }),
- ] as const;
- const options = {
- easing,
- extrapolateLeft: 'clamp',
- extrapolateRight: 'clamp',
- } as const;
- const atHold = interpolate(
- 170,
- [21, 170, 591, 620],
- ['0deg', axisRotation, axisRotation, '0deg'],
- options,
- );
- const afterHold = interpolate(
- 171,
- [21, 170, 591, 620],
- ['0deg', axisRotation, axisRotation, '0deg'],
- options,
- );
-
- expect(afterHold).toStartWith('0.945221 -0.227695 0.233905 ');
- expect(Number(afterHold.split(' ')[3].replace('deg', ''))).toBeGreaterThan(
- Number(atHold.split(' ')[3].replace('deg', '')),
- );
-});
-
test('Clamp left test', () => {
expect(
interpolate(-2000, [0, 1, 1000], [Math.PI, 1, -1000], {