Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lots of type issues in Tween system #16948

Merged
merged 24 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
bb31f0a
Add generic for action types.
dumganhar May 6, 2024
c1f7798
Action class should not be a template.
dumganhar May 6, 2024
d7cc73e
Update
dumganhar May 6, 2024
09ea1cf
Revert
dumganhar May 6, 2024
0bf9b6a
Revert again.
dumganhar May 6, 2024
f170af4
More type fixes.
dumganhar May 7, 2024
6d8b592
Remove unused function _searchElementByTarget in action-manager.ts an…
dumganhar May 7, 2024
9dbef39
Remove two unused functions - 'easing' and '_computeEaseTime' in acti…
dumganhar May 7, 2024
142f869
Use abstract keyword for abstract classes in actions.
dumganhar May 7, 2024
74fc3f3
More specific type for action factory functions.
dumganhar May 7, 2024
c48c839
Tween.call supports to pass this object and custom data.
dumganhar May 7, 2024
8435739
Revert initWithAction
dumganhar May 7, 2024
a06d144
Remove more eslint comments.
dumganhar May 7, 2024
773291e
Rename
dumganhar May 7, 2024
81be9f6
More ? to if
dumganhar May 7, 2024
4c51ce6
Remove unused T for removeAction in action-manager.ts
dumganhar May 7, 2024
5320dd3
Add insertAction private method for inserting a action to current tween.
dumganhar May 7, 2024
3138562
format code for torus.ts
dumganhar May 8, 2024
1410d00
Tween.show/hide/removeSelf/destroySelf return unknown type if T is no…
dumganhar May 8, 2024
046cd0f
Update comment
dumganhar May 8, 2024
4cdfb19
opts.!relative -> opts.relative.
dumganhar May 8, 2024
7ea568c
Set target to null in Action.stop
dumganhar May 10, 2024
43dffb9
Tween<T> ---> Tween<T extends object = any>
dumganhar May 10, 2024
d25cf8f
Update ci
dumganhar May 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);
Copy link
Contributor Author

@dumganhar dumganhar May 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the error:

'Math.pow' is restricted from being used. Use the exponentiation operator (**) instead.eslint[no-restricted-properties](https://eslint.org/docs/latest/rules/no-restricted-properties)
Use the '**' operator instead of 'Math.pow'.eslint[prefer-exponentiation-operator](https://eslint.org/docs/latest/rules/prefer-exponentiation-operator)

}

/**
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