Skip to content

Commit

Permalink
Fix some type issues. (#18241)
Browse files Browse the repository at this point in the history
  • Loading branch information
dumganhar authored Jan 23, 2025
1 parent aa841bd commit 915da6f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
19 changes: 9 additions & 10 deletions cocos/core/curves/bezier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ const sqrt = Math.sqrt;

function crt (v: number): number {
if (v < 0) {
return -Math.pow(-v, 1 / 3);
return -((-v) ** (1 / 3));
} else {
return Math.pow(v, 1 / 3);
return v ** (1 / 3);
}
}

Expand Down Expand Up @@ -85,11 +85,11 @@ function cardano (curve: BezierControlPoints, x: number): any {
// and determine the discriminant:
const discriminant = q2 * q2 + p3 * p3 * p3;
// and some reserved variables
let u1;
let v1;
let x1;
let x2;
let x3;
let u1: number;
let v1: number;
let x1: number;
let x2: number;
let x3: number;

// If the discriminant is negative, use polar coordinates
// to get around square roots of negative numbers
Expand Down Expand Up @@ -144,9 +144,8 @@ function cardano (curve: BezierControlPoints, x: number): any {
} else {
return x2;
}
}
// one real root, and two imaginary roots
else {
} else {
// one real root, and two imaginary roots
const sd = sqrt(discriminant);
u1 = crt(-q2 + sd);
v1 = crt(q2 + sd);
Expand Down
2 changes: 1 addition & 1 deletion cocos/core/curves/curve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ export class RealCurve extends KeyframeCurve<RealKeyframeValue> {
if (values !== undefined) {
assertIsTrue(Array.isArray(times));
this.setKeyframes(
times.slice(),
(times as number[]).slice(),
values.map((value) => createRealKeyframeValue(value)),
);
} else {
Expand Down
2 changes: 1 addition & 1 deletion cocos/core/curves/keyframe-curve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export class KeyframeCurve<TKeyframeValue> implements CurveBase, Iterable<KeyFra
if (values !== undefined) {
assertIsTrue(Array.isArray(times));
this.setKeyframes(
times.slice(),
(times as number[]).slice(),
values.slice(),
);
} else {
Expand Down
3 changes: 1 addition & 2 deletions cocos/core/curves/keys-shared-curves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

import { ccclass, serializable } from 'cc.decorator';
import { binarySearchEpsilon } from '../algorithm/binary-search';
import { ccclass, serializable } from '../data/decorators';
import { assertIsTrue } from '../data/utils/asserts';
import { approx, IQuatLike, lerp, Quat } from '../math';
import { ExtrapolationMode, RealCurve } from './curve';
Expand Down
2 changes: 1 addition & 1 deletion cocos/core/curves/quat-curve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export class QuatCurve extends KeyframeCurve<QuatKeyframeValue> {
if (values !== undefined) {
assertIsTrue(Array.isArray(times));
this.setKeyframes(
times.slice(),
(times as number[]).slice(),
values.map((value) => createQuatKeyframeValue(value)),
);
} else {
Expand Down

0 comments on commit 915da6f

Please sign in to comment.