Skip to content

Commit

Permalink
Fix d.ts and Sonarcloud issue (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
agargaro authored Mar 10, 2024
1 parent f45c0a0 commit 4bfff44
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
7 changes: 0 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@ export * from './utils/Stats';
export * from './utils/Utils';
export * from './utils/VectorUtils';

/** @internal */
declare module 'three/src/math/Vector2' {
export interface Vector {
lerpVectors(v1: Vector, v2: Vector, alpha: number): this;
}
}

declare module 'three/src/core/Object3D' {
export interface Object3D extends Object3DExtPrototype { }
}
Expand Down
11 changes: 6 additions & 5 deletions src/tweening/Actions.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Color, ColorRepresentation, Euler, MathUtils, Quaternion, Vector, Vector2, Vector3, Vector4 } from "three";
import { DEFAULT_EASING, Easing, EasingFunction, Easings } from "./Easings";
import { Color, ColorRepresentation, Euler, MathUtils, Quaternion, Vector2, Vector3, Vector4 } from "three";
import { Easing, EasingFunction, Easings } from "./Easings";
import { RunningAction } from "./RunningTween";
import { Tween } from "./Tween";

const easings = new Easings();
export type Vector = Vector2 | Vector3 | Vector4;
export type AllowedTypes = number | Vector | Quaternion | Euler | ColorRepresentation;
export type Omitype<T, U> = { [P in keyof T as T[P] extends U ? never : P]: T[P] };
export type PickType<T, U> = { [P in keyof T as T[P] extends U ? P : never]: T[P] };
Expand Down Expand Up @@ -136,7 +137,7 @@ export class ActionMotion<T> implements IAction<T> {
}

private getEasing(): EasingFunction {
const easing = this.config?.easing ?? DEFAULT_EASING;
const easing = this.config?.easing ?? Easings.DEFAULT_EASING;
return typeof easing === "string" ? (easings[easing].bind(easings) ?? easings.linear) : easing;
}

Expand All @@ -149,8 +150,8 @@ export class ActionMotion<T> implements IAction<T> {
time: this.time,
easing: this.getEasing(),
start: targetValue.clone(),
end: this.isBy ? value.clone().add(targetValue) : value,
callback: (start, end, alpha) => { targetValue.lerpVectors(start, end, alpha) }
end: this.isBy ? value.clone().add(targetValue as Vector4) : value,
callback: (start, end, alpha) => { targetValue.lerpVectors(start as Vector4, end as Vector4, alpha) }
};
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/tweening/Easings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
export type EasingFunction = (x: number) => number;
/** Type representing an easing type, which can be either a predefined easing function or a custom easing function. */
export type Easing = keyof Easings | EasingFunction;
/** The default easing function used when no easing is specified. */
export let DEFAULT_EASING: keyof Easings = "easeInOutExpo";

/**
* Class that provides various easing functions for tweening animations.
* For more info on these easing functions, check https://easings.net.
*/
export class Easings {
/** The default easing function used when no easing is specified. */
public static DEFAULT_EASING: keyof Easings = "easeInOutExpo";

public linear(x: number): number {
return x;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/VectorUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type ObjVec3 = Vector3 | Object3D;
const ORIGIN = new Vector3();

export class VectorUtils {
public static DEFAULT_NORMAL = new Vector3(0, 0, 1);
public static readonly DEFAULT_NORMAL = new Vector3(0, 0, 1);

public static getPositionFromObject3D(item: VectorObject3D): Vector3 {
return (item as Object3D).isObject3D ? (item as Object3D).position : (item as Vector3);
Expand Down

0 comments on commit 4bfff44

Please sign in to comment.