From d9d3cf239be20c7f9e5b302f8a2e2517e550cb51 Mon Sep 17 00:00:00 2001 From: agargaro Date: Thu, 14 Sep 2023 23:04:33 +0200 Subject: [PATCH 1/2] Add tween ColorRepresentation compatibility --- src/tweening/Actions.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tweening/Actions.ts b/src/tweening/Actions.ts index b0613f1..edc7d4d 100644 --- a/src/tweening/Actions.ts +++ b/src/tweening/Actions.ts @@ -1,4 +1,4 @@ -import { Color, Euler, MathUtils, Quaternion, Vector3 } from "three"; +import { Color, ColorRepresentation, Euler, MathUtils, Quaternion, Vector3 } from "three"; import { DEFAULT_EASING, Easing, EasingFunction, Easings } from "./Easings"; import { RunningAction } from "./RunningTween"; import { Tween } from "./Tween"; @@ -138,7 +138,7 @@ export class ActionMotion implements IAction { return typeof easing === "string" ? (easings[easing] ?? easings.linear) : easing; } - private vector3(key: string, actionValue: Vector3, targetValue: Vector3): RunningAction { + private vector3(key: string, actionValue: Vector3 | number, targetValue: Vector3): RunningAction { if (targetValue?.isVector3) { const value = typeof actionValue === "number" ? new Vector3(actionValue, actionValue, actionValue) : actionValue; return { @@ -180,14 +180,14 @@ export class ActionMotion implements IAction { } } - private color(key: string, actionValue: Color, targetValue: Color): RunningAction { + private color(key: string, actionValue: ColorRepresentation, targetValue: Color): RunningAction { if (targetValue?.isColor) { return { key, time: this.time, easing: this.getEasing(), start: targetValue.clone(), - end: this.isBy ? actionValue.clone().add(targetValue) : actionValue, + end: this.isBy ? new Color(actionValue).add(targetValue) : new Color(actionValue), callback: (start, end, alpha) => { targetValue.lerpColors(start, end, alpha) } }; } From 84f14f2a1aa5c643b05f45d56fe5c99104835af3 Mon Sep 17 00:00:00 2001 From: agargaro Date: Thu, 14 Sep 2023 23:37:11 +0200 Subject: [PATCH 2/2] Update types --- src/tweening/Actions.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tweening/Actions.ts b/src/tweening/Actions.ts index edc7d4d..3804f13 100644 --- a/src/tweening/Actions.ts +++ b/src/tweening/Actions.ts @@ -4,11 +4,12 @@ import { RunningAction } from "./RunningTween"; import { Tween } from "./Tween"; const easings = new Easings(); -export type AllowedTypes = number | Vector3 | Quaternion | Euler | Color; +export type AllowedTypes = number | Vector3 | Quaternion | Euler | ColorRepresentation; export type Omitype = { [P in keyof T as T[P] extends U ? never : P]: T[P] }; export type PickType = { [P in keyof T as T[P] extends U ? P : never]: T[P] }; export type TransformType = { [P in keyof T]: T[P] extends U ? T[P] | V : T[P] }; -export type FilteredType = PickType>, AllowedTypes>; +export type TransformedTypes = TransformType, Vector3, number>; +export type FilteredType = PickType>, AllowedTypes>; export type Motion = { [key in keyof FilteredType]: FilteredType[key] }; /**