Skip to content

Commit fd724a1

Browse files
committed
Add lerp method
1 parent 48d6e7a commit fd724a1

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/utils/ColorDecisionList.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseEvent, EventDispatcher, Uniform, Vector3 } from "three";
1+
import { BaseEvent, EventDispatcher, MathUtils, Uniform, Vector3 } from "three";
22
import { CDLPreset } from "../enums/CDLPreset.js";
33

44
/**
@@ -169,4 +169,21 @@ export class ColorDecisionList extends EventDispatcher<CDLEventMap> {
169169

170170
}
171171

172+
/**
173+
* Sets this CDL to the linearly interpolated result of two given CDLs.
174+
*
175+
* @param cdl1 - The start CDL.
176+
* @param cdl2 - The end CDL.
177+
* @param alpha - The interpolation factor in the range [0, 1].
178+
*/
179+
180+
lerp(cdl1: ColorDecisionList, cdl2: ColorDecisionList, alpha: number): void {
181+
182+
this.slope.lerpVectors(cdl1.slope, cdl2.slope, alpha);
183+
this.offset.lerpVectors(cdl1.offset, cdl2.offset, alpha);
184+
this.power.lerpVectors(cdl1.power, cdl2.power, alpha);
185+
this.saturation = MathUtils.lerp(cdl1.saturation, cdl2.saturation, alpha);
186+
187+
}
188+
172189
}

0 commit comments

Comments
 (0)