Skip to content

Commit

Permalink
Fix lots of type issues in Tween system (#16948)
Browse files Browse the repository at this point in the history
  • Loading branch information
dumganhar committed May 16, 2024
1 parent 3e3a3b4 commit ead9ae0
Show file tree
Hide file tree
Showing 14 changed files with 483 additions and 462 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/run_test_cases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ jobs:

- name: Checkout rebase
run: |
git config user.email
git config user.name
git fetch origin
git reset --hard
git checkout origin/${{ steps.parse_pr.outputs.pr_base_ref }}
Expand Down
16 changes: 8 additions & 8 deletions cocos/core/algorithm/easing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export function sineInOut (k: number): number {
* @zh 启动慢,加速快。具体效果可以参考[该文档](https://docs.cocos.com/creator/manual/zh/tween/tween-function.html)。
*/
export function expoIn (k: number): number {
return k === 0 ? 0 : Math.pow(1024, k - 1);
return k === 0 ? 0 : 1024 ** (k - 1);
}

/**
Expand All @@ -206,7 +206,7 @@ export function expoIn (k: number): number {
* @zh 起动迅速,减速慢。具体效果可以参考[该文档](https://docs.cocos.com/creator/manual/zh/tween/tween-function.html)。
*/
export function expoOut (k: number): number {
return k === 1 ? 1 : 1 - Math.pow(2, -10 * k);
return k === 1 ? 1 : 1 - (2 ** (-10 * k));
}

/**
Expand All @@ -223,9 +223,9 @@ export function expoInOut (k: number): number {
}
k *= 2;
if (k < 1) {
return 0.5 * Math.pow(1024, k - 1);
return 0.5 * 1024 ** (k - 1);
}
return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2);
return 0.5 * (-(2 ** (-10 * (k - 1))) + 2);
}

/**
Expand Down Expand Up @@ -278,7 +278,7 @@ export function elasticIn (k: number): number {
} else {
s = p * Math.asin(1 / a) / (2 * Math.PI);
}
return -(a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
return -(a * 2 ** (10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
}

/**
Expand All @@ -301,7 +301,7 @@ export function elasticOut (k: number): number {
} else {
s = p * Math.asin(1 / a) / (2 * Math.PI);
}
return (a * Math.pow(2, -10 * k) * Math.sin((k - s) * (2 * Math.PI) / p) + 1);
return (a * 2 ** (-10 * k) * Math.sin((k - s) * (2 * Math.PI) / p) + 1);
}

/**
Expand All @@ -327,9 +327,9 @@ export function elasticInOut (k: number): number {
k *= 2;
if (k < 1) {
return -0.5
* (a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
* (a * 2 ** (10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
}
return a * Math.pow(2, -10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1;
return a * 2 ** (-10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions cocos/misc/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,17 @@ export class Renderer extends Component {
}

protected _onMaterialModified (index: number, material: Material | null): void {
/* empty */
}

/**
* @engineInternal
*/
public _onRebuildPSO (index: number, material: Material | null): void {
/* empty */
}

protected _clearMaterials (): void {
/* empty */
}
}
14 changes: 13 additions & 1 deletion cocos/primitive/torus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,19 @@ interface ITorusOptions extends IGeometryOptions {
* @param tube @zh 管形大小。@en The radius of tube
* @param opts @zh 参数选项。@en The optional creation parameters of the torus
*/
export default function torus (radius = 0.4, tube = 0.1, opts: RecursivePartial<ITorusOptions> = {}): { positions: number[]; normals: number[]; uvs: number[]; indices: number[]; minPos: Vec3; maxPos: Vec3; boundingRadius: number; } {
export default function torus (
radius = 0.4,
tube = 0.1,
opts: RecursivePartial<ITorusOptions> = {},
): {
positions: number[];
normals: number[];
uvs: number[];
indices: number[];
minPos: Vec3;
maxPos: Vec3;
boundingRadius: number;
} {
const radialSegments = opts.radialSegments || 32;
const tubularSegments = opts.tubularSegments || 32;
const arc = opts.arc || 2.0 * Math.PI;
Expand Down

0 comments on commit ead9ae0

Please sign in to comment.