Skip to content

Commit

Permalink
Merge branch 'v3.8.1' into 3.8.1-spine
Browse files Browse the repository at this point in the history
  • Loading branch information
zxx43 authored Aug 3, 2023
2 parents fee88de + 3c6a849 commit 777bd08
Show file tree
Hide file tree
Showing 128 changed files with 3,831 additions and 1,203 deletions.
25 changes: 20 additions & 5 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ rules:
quotes: [warn, single, { allowTemplateLiterals: true }] # force single, but allow template literal
no-else-return: off # else-return is a common pattern which clearly expresses the control flow
no-unused-expressions: off # taken over by '@typescript-eslint/no-unused-expressions'
no-empty-function: off # taken over by '@typescript-eslint/no-empty-function'

##### AIRBNB-SPECIFIC RULE OVERRIDES #####

Expand All @@ -70,7 +71,14 @@ rules:
import/extensions: off # typescript doesn't support this
import/no-unresolved: off # TODO: fix internal modules
import/prefer-default-export: off # prefer named exports
indent: off # use @typescript-eslint/indent instead for better compatibility
indent: [error, 4, {
SwitchCase: 0,
ignoredNodes: [ # https://stackoverflow.com/a/72897089
"FunctionExpression > .params[decorators.length > 0]",
"FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
"ClassBody.body > PropertyDefinition[decorators.length > 0] > .key",
]
}]

lines-between-class-members: off # be more lenient on member declarations
max-classes-per-file: off # helper classes are common
Expand All @@ -94,6 +102,7 @@ rules:
prefer-destructuring: off # auto-fix is not smart enough to merge different instances
linebreak-style: off # we don't enforce this on everyone's dev environment for now
spaced-comment: off # for license declarations
default-case-last: off # Place default case clause to first make it more clear that this switch statement has handled all cases

##### TYPESCRIPT-SPECIFIC RULE OVERRIDES #####

Expand All @@ -103,9 +112,6 @@ rules:
'ts-nocheck': true,
'ts-check': false,
}]
'@typescript-eslint/indent': [warn, 4, {
SwitchCase: 0
}]
'@typescript-eslint/no-unused-expressions': warn

# TODO: this is just too much work
Expand All @@ -121,7 +127,16 @@ rules:

'@typescript-eslint/unbound-method': off # we exploit prototype methods sometimes to acheive better performace
'@typescript-eslint/no-explicit-any': off # still relevant for some heavily templated usages
'@typescript-eslint/no-empty-function': off # may become useful in some parent classes

'@typescript-eslint/no-empty-function': [error, {
allow: [
private-constructors,
protected-constructors,
decoratedFunctions,
overrideMethods,
]
}]

'@typescript-eslint/no-unused-vars': off # may become useful in some parent classes
'@typescript-eslint/no-non-null-assertion': off # sometimes we just know better than the compiler
'@typescript-eslint/no-namespace': [warn, { # we need to declare static properties
Expand Down
23 changes: 19 additions & 4 deletions .github/workflows/web-interface-check-pr-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,29 @@ jobs:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- name: Download artifacts
- name: 'Get source run informations'
uses: potiuk/get-workflow-origin@v1_1
id: source_run_info
with:
token: ${{ secrets.GITHUB_TOKEN }}
sourceRunId: ${{ github.event.workflow_run.id }}

- name: 'Debug'
run: |
Write-Host "Source PR Number: ${{ github.event.workflow_run.pull_requests[0].number }}"
shell: pwsh

- name: Download artifacts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUN_ID: ${{ github.event.workflow_run.id }}
run: |
gh run download -R "${{ github.repository }}" --name "interface-diff.txt" "$RUN_ID"
gh run download -R "${{ github.repository }}" --name "interface-diff.txt" "$RUN_ID"
- name: Post interface-diff.txt as comment
uses: marocchino/sticky-pull-request-comment@v2
with:
path: interface-diff.txt
number: ${{ github.event.workflow_run.pull_requests[0].number }}
path: interface-diff.txt
number: ${{ steps.source_run_info.outputs.pullRequestNumber }}
# The following matters, see: https://github.com/orgs/community/discussions/25220
# number: ${{ github.event.workflow_run.pull_requests[0].number }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ native/external/

scripts/typedoc-plugin/lib/
!templates/**/*
templates/**/.DS_Store

@types/consts.d.ts

Expand Down
6 changes: 6 additions & 0 deletions cc.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,12 @@
"value": false,
"internal": true
},
"WASM_FALLBACK": {
"comment": "An internal constant to indicate whether need a fallback of wasm.\nIf true, we build a wasm fallback module for the compatibility of wasm files compiled by different version of emscripten.\nThis is useful when we use wasm on different version of Safari browsers.",
"type": "boolean",
"value": "$HTML5",
"internal": true
},
"WASM_SUBPACKAGE": {
"comment": "An internal constant to indicate whether we use wasm assets as minigame subpackage.\nThis is useful when we need to reduce code size.",
"type": "boolean",
Expand Down
8 changes: 7 additions & 1 deletion cocos/2d/components/ui-opacity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

import { ccclass, disallowMultiple, editable, executeInEditMode, executionOrder, help, menu, serializable, tooltip } from 'cc.decorator';
import { JSB } from 'internal:constants';
import { EDITOR_NOT_IN_PREVIEW, JSB } from 'internal:constants';
import { Component } from '../../scene-graph/component';
import { misc } from '../../core';
import { UIRenderer } from '../framework/ui-renderer';
Expand Down Expand Up @@ -67,6 +67,12 @@ export class UIOpacity extends Component {
this.node._uiProps.localOpacity = value / 255;

this.setEntityLocalOpacityDirtyRecursively(true);

if (EDITOR_NOT_IN_PREVIEW) {
setTimeout(() => {
EditorExtends.Node.emit('change', this.node.uuid, this.node);
}, 200);
}
}

private setEntityLocalOpacityDirtyRecursively (dirty: boolean): void {
Expand Down
2 changes: 1 addition & 1 deletion cocos/2d/utils/font-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ export function loadFont (url: string, options: Record<string, any>, onComplete:

// Default width reference to test whether new font is loaded correctly
const fontDesc = `40px ${fontFamilyName}`;
const refWidth = safeMeasureText(_canvasContext!, _testString, fontDesc);

// Setup font face style
const fontStyle = ccdocument.createElement('style');
Expand Down Expand Up @@ -195,6 +194,7 @@ export function loadFont (url: string, options: Record<string, any>, onComplete:
if (useNativeCheck()) {
nativeCheckFontLoaded(Date.now(), fontFamilyName, onComplete);
} else {
const refWidth = safeMeasureText(_canvasContext!, _testString, fontDesc);
// Save loading font
const fontLoadHandle = {
fontFamilyName,
Expand Down
8 changes: 7 additions & 1 deletion cocos/3d/framework/mesh-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -902,10 +902,11 @@ export class MeshRenderer extends ModelRenderer {
// because the lighting map will influence the model's shader
this._model.initLightingmap(this.bakeSettings.texture, this.bakeSettings.uvParam);
this._updateUseLightProbe();
this._updateUseReflectionProbe();
this._updateUseReflectionProbeType();
this._updateModelParams();
this._onUpdateLightingmap();
this._onUpdateLocalShadowBiasAndProbeId();
this._updateUseReflectionProbe();
this._updateReceiveDirLight();
this._onUpdateReflectionProbeDataMap();
this._onUpdateLocalReflectionProbeData();
Expand Down Expand Up @@ -1186,6 +1187,11 @@ export class MeshRenderer extends ModelRenderer {
this._updateReflectionProbeTexture();
}

protected _updateUseReflectionProbeType (): void {
if (!this._model) return;
this._model.reflectionProbeType = this.bakeSettings.reflectionProbe;
}

protected _updateBakeToReflectionProbe (): void {
if (!this._model) { return; }
this._model.bakeToReflectionProbe = this.bakeSettings.bakeToReflectionProbe;
Expand Down
21 changes: 12 additions & 9 deletions cocos/3d/reflection-probe/reflection-probe-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import { ccclass, executeInEditMode, menu, playOnFocus, serializable, tooltip, type, visible } from 'cc.decorator';
import { ccclass, executeInEditMode, help, menu, playOnFocus, serializable, tooltip, type, visible } from 'cc.decorator';
import { EDITOR, EDITOR_NOT_IN_PREVIEW } from 'internal:constants';
import { CCBoolean, CCObject, Color, Enum, Vec3, warn } from '../../core';

Expand Down Expand Up @@ -62,6 +62,7 @@ export enum ProbeResolution {
@menu('Rendering/ReflectionProbe')
@executeInEditMode
@playOnFocus
@help('i18n:cc.ReflectionProbe')
export class ReflectionProbe extends Component {
protected static readonly DEFAULT_CUBE_SIZE: Readonly<Vec3> = new Vec3(1, 1, 1);
protected static readonly DEFAULT_PLANER_SIZE: Readonly<Vec3> = new Vec3(5, 0.5, 5);
Expand Down Expand Up @@ -325,12 +326,14 @@ export class ReflectionProbe extends Component {
ReflectionProbeManager.probeManager.onUpdateProbes(true);
this._probe.enable();
}
this.node.on(Node.EventType.TRANSFORM_CHANGED, this._onProbeTransformChanged, this);
}
onDisable (): void {
if (this._probe) {
ReflectionProbeManager.probeManager.unregister(this._probe);
this._probe.disable();
}
this.node.off(Node.EventType.TRANSFORM_CHANGED, this._onProbeTransformChanged);
}

public start (): void {
Expand Down Expand Up @@ -362,14 +365,6 @@ export class ReflectionProbe extends Component {
}
}
}

if (this.node.hasChangedFlags) {
this.probe.updateBoundingBox();
}
if (this.node.hasChangedFlags & TransformBit.POSITION) {
ReflectionProbeManager.probeManager.onUpdateProbes(true);
ReflectionProbeManager.probeManager.updateProbeData();
}
}
if (this.probeType === ProbeType.PLANAR && this.sourceCamera) {
if ((this.sourceCamera.node.hasChangedFlags & TransformBit.TRS)
Expand All @@ -390,6 +385,14 @@ export class ReflectionProbe extends Component {
ReflectionProbeManager.probeManager.updatePreviewSphere(this.probe);
}

private _onProbeTransformChanged (type: TransformBit): void {
this.probe.updateBoundingBox();
if (type & Node.TransformBit.POSITION) {
ReflectionProbeManager.probeManager.onUpdateProbes(true);
ReflectionProbeManager.probeManager.updateProbeData();
}
}

private _createProbe (): void {
if (this._probeId === -1 || ReflectionProbeManager.probeManager.exists(this._probeId)) {
this._probeId = ReflectionProbeManager.probeManager.getNewReflectionProbeId();
Expand Down
26 changes: 21 additions & 5 deletions cocos/3d/reflection-probe/reflection-probe-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class ReflectionProbeManager {
if (!scene || !scene.renderScene) {
return;
}
const models = scene.renderScene.models;
const models = scene.renderScene.models as Model[];
for (let i = 0; i < models.length; i++) {
const model = models[i];
if (!model.node) continue;
Expand All @@ -106,7 +106,7 @@ export class ReflectionProbeManager {
if (!scene || !scene.renderScene) {
return;
}
const models = scene.renderScene.models;
const models = scene.renderScene.models as Model[];
for (let i = 0; i < models.length; i++) {
const model = models[i];
if (!model.node) continue;
Expand Down Expand Up @@ -441,6 +441,22 @@ export class ReflectionProbeManager {
return null;
}

/**
* @en Set reflection probe used by the model.
* @zh 手动设置模型使用的反射探针。
* @param model set the probe for this model
* @param probe reflection probe to be set
* @param blendProbe reflection probe for blend
*/
public setReflectionProbe (model: Model, probe: ReflectionProbe, blendProbe: ReflectionProbe | null = null): void {
if (!probe) return;
this._useCubeModels.set(model, probe);
this._updateCubemapOfModel(model, probe);
if (blendProbe) {
this._updateBlendProbeInfo(model, probe, blendProbe);
}
}

/**
* @en
* select the probe with the nearest distance.
Expand Down Expand Up @@ -535,7 +551,8 @@ export class ReflectionProbeManager {
if (probe) {
meshRender.updateReflectionProbeDataMap(this._dataTexture);
if (this._isUsedBlending(model)) {
this._updateBlendProbeInfo(model, probe);
const blendProbe = this._getBlendProbe(model);
this._updateBlendProbeInfo(model, probe, blendProbe);
}
}
}
Expand All @@ -559,7 +576,7 @@ export class ReflectionProbeManager {
return false;
}

private _updateBlendProbeInfo (model: Model, probe: ReflectionProbe): void {
private _updateBlendProbeInfo (model: Model, probe: ReflectionProbe, blendProbe: ReflectionProbe | null): void {
const node = model.node;
if (!node) {
return;
Expand All @@ -568,7 +585,6 @@ export class ReflectionProbeManager {
if (!meshRender) {
return;
}
const blendProbe = this._getBlendProbe(model);
if (blendProbe) {
meshRender.updateReflectionProbeBlendId(blendProbe.getProbeId());
meshRender.updateProbeBlendCubemap(blendProbe.cubemap);
Expand Down
6 changes: 3 additions & 3 deletions cocos/3d/skeletal-animation/skeletal-animation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

import {
ccclass, executeInEditMode, executionOrder, help, menu, tooltip, type, serializable, editable,
ccclass, executeInEditMode, executionOrder, help, menu, type, serializable, editable,
} from 'cc.decorator';
import { SkinnedMeshRenderer } from '../skinned-mesh-renderer';
import { Mat4, cclegacy, js, assertIsTrue } from '../../core';
Expand Down Expand Up @@ -107,7 +107,7 @@ export class SkeletalAnimation extends Animation {
* 当前动画组件维护的挂点数组。要挂载自定义节点到受动画驱动的骨骼上,必须先在此注册挂点。
*/
@type([Socket])
@tooltip('i18n:animation.sockets')
@editable
get sockets (): Socket[] {
return this._sockets;
}
Expand All @@ -131,7 +131,7 @@ export class SkeletalAnimation extends Animation {
* 是否使用预烘焙动画,默认启用,可以大幅提高运行效时率,但所有动画效果会被彻底固定,不支持任何形式的编辑和混合。<br>
* 运行时动态修改此选项会在播放下一条动画片段时生效。
*/
@tooltip('i18n:animation.use_baked_animation')
@editable
get useBakedAnimation (): boolean {
return this._useBakedAnimation;
}
Expand Down
6 changes: 2 additions & 4 deletions cocos/animation/animation-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
THE SOFTWARE.
*/

import { ccclass, executeInEditMode, executionOrder, help, menu, tooltip, type, serializable } from 'cc.decorator';
import { ccclass, executeInEditMode, executionOrder, help, menu, type, serializable, editable } from 'cc.decorator';
import { EDITOR_NOT_IN_PREVIEW, TEST } from 'internal:constants';
import { Component } from '../scene-graph/component';
import { Eventify, warnID, js, cclegacy } from '../core';
Expand Down Expand Up @@ -60,7 +60,6 @@ export class Animation extends Eventify(Component) {
* 设置时,已有剪辑关联的动画状态将被停止;若默认剪辑不在新的动画剪辑中,将被重置为空。
*/
@type([AnimationClip])
@tooltip('i18n:animation.clips')
get clips (): (AnimationClip | null)[] {
return this._clips;
}
Expand Down Expand Up @@ -103,7 +102,6 @@ export class Animation extends Eventify(Component) {
* @see [[playOnLoad]]
*/
@type(AnimationClip)
@tooltip('i18n:animation.default_clip')
get defaultClip (): AnimationClip | null {
return this._defaultClip;
}
Expand Down Expand Up @@ -131,7 +129,7 @@ export class Animation extends Eventify(Component) {
* 注意,若在组件开始运行前调用了 `crossFade` 或 `play()`,此字段将不会生效。
*/
@serializable
@tooltip('i18n:animation.play_on_load')
@editable
public playOnLoad = false;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,10 @@ class AnimationClipAGEvaluationRegular implements AnimationClipAGEvaluation {

const {
tracks,
[exoticAnimationTag]: exoticAnimation,
// NOTE: on OH platform, there is a bug on Destructuring Assignment syntax.
// [exoticAnimationTag]: exoticAnimation,
} = clip;
const exoticAnimation = clip[exoticAnimationTag];

for (const track of tracks) {
if (track instanceof UntypedTrack) {
Expand Down
Loading

0 comments on commit 777bd08

Please sign in to comment.