Merge pull request #11192 from minggo/v3.6.0_merge_v3.5.1

V3.6.0 merge v3.5.1
This commit is contained in:
minggo
2022-05-24 16:42:57 +08:00
committed by GitHub
955 changed files with 11268 additions and 4732 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
{
"problemMatcher": [
{
"owner": "circular-reference-check",
"owner": "<Web> build",
"pattern": [
{
"regexp": "^Circular dependency: (.*)$",
+2 -1
View File
@@ -56,7 +56,8 @@
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js"
},
"args": [
"${fileBasenameNoExtension}"
"--runTestsByPath",
"${relativeFileDirname}/${fileBasename}"
],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
@@ -22,12 +22,6 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui-assembler
*/
import { Color, Vec3 } from '../../../../core/math';
import { IAssembler } from '../../../renderer/base';
import { MeshRenderData } from '../../../renderer/render-data';
-5
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui
*/
import './utils';
export * from './graphics';
-5
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui-assembler
*/
import { SpriteFrame } from '../../assets/sprite-frame';
import * as js from '../../../core/utils/js';
import { Color, Rect } from '../../../core/math';
-5
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui-assembler
*/
import { BitmapFont } from '../../assets';
import { Label } from '../../components';
import { IAssemblerManager } from '../../renderer/base';
-5
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui-assembler
*/
import { addon } from '../../../core/utils/js';
import { IBatcher } from '../../renderer/i-batcher';
import { Label } from '../../components/label';
-2
View File
@@ -23,8 +23,6 @@
THE SOFTWARE.
*/
import { maskAssembler as mask, maskEndAssembler as maskEnd } from './mask-assembler';
export {
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui-assembler
*/
import { IBatcher } from '../../renderer/i-batcher';
import { Mask, MaskType } from '../../components/mask';
import { IAssembler, IAssemblerManager } from '../../renderer/base';
-5
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui-assembler
*/
import { Color, Mat4, Vec3 } from '../../../core/math';
import { IRenderData, RenderData } from '../../renderer/render-data';
import { IBatcher } from '../../renderer/i-batcher';
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui-assembler
*/
import { SpriteFrame } from '../../assets';
import { Color, Mat4, Vec2, Vec3 } from '../../../core/math';
import { IRenderData, RenderData } from '../../renderer/render-data';
-5
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui-assembler
*/
import { Vec3 } from '../../../core/math';
import { IAssembler } from '../../renderer/base';
import { IRenderData, RenderData } from '../../renderer/render-data';
-5
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui-assembler
*/
import { Mat4, Vec3 } from '../../../core/math';
import { IRenderData, RenderData } from '../../renderer/render-data';
import { IBatcher } from '../../renderer/i-batcher';
-2
View File
@@ -23,8 +23,6 @@
THE SOFTWARE.
*/
import { Color, Mat4, Vec3 } from '../../core/math';
import { RenderData } from '../renderer/render-data';
import { IBatcher } from '../renderer/i-batcher';
-5
View File
@@ -24,11 +24,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module asset
*/
import { ccclass, type, serializable, editable } from 'cc.decorator';
import { Font } from './font';
import { SpriteFrame } from './sprite-frame';
-5
View File
@@ -24,11 +24,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module asset
*/
import { ccclass } from 'cc.decorator';
import { Asset } from '../../core/assets';
import { legacyCC } from '../../core/global-exports';
+1 -4
View File
@@ -1,7 +1,4 @@
/**
* @packageDocumentation
* @module asset
*/
export * from './sprite-frame';
export { SpriteAtlas } from './sprite-atlas';
-5
View File
@@ -24,11 +24,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module asset
*/
import { ccclass } from 'cc.decorator';
import { BitmapFont } from './bitmap-font';
import { legacyCC } from '../../core/global-exports';
-5
View File
@@ -24,11 +24,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module asset
*/
import { EDITOR, TEST } from 'internal:constants';
import { ccclass, serializable, editable } from 'cc.decorator';
import * as js from '../../core/utils/js';
+3 -8
View File
@@ -25,11 +25,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module asset
*/
import { ccclass } from 'cc.decorator';
import { EDITOR, TEST, BUILD } from 'internal:constants';
import { Rect, Size, Vec2 } from '../../core/math';
@@ -239,8 +234,8 @@ export class SpriteFrame extends Asset {
}
/**
* @en
* @zh
* @en uv update event
* @zh uv 更新事件
*/
public static EVENT_UV_UPDATED = 'uv_updated';
@@ -661,7 +656,7 @@ export class SpriteFrame extends Asset {
}
/**
* @en Gets the related GFX [[Texture]] resource
* @en Gets the related GFX [[gfx.Texture]] resource
* @zh 获取渲染贴图的 GFX 资源
*/
public getGFXTexture () {
-5
View File
@@ -24,11 +24,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module asset
*/
import { ccclass, string, override, serializable } from 'cc.decorator';
import { extname } from '../../core/utils/path';
import { Font } from './font';
-4
View File
@@ -23,10 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui
*/
import { Mask } from './mask';
import { Label } from './label';
import { LabelOutline } from './label-outline';
+80 -45
View File
@@ -24,11 +24,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui
*/
import { ccclass, help, executionOrder, menu, tooltip, type, visible, override, editable, serializable } from 'cc.decorator';
import { builtinResMgr } from '../../core/builtin';
import { InstanceMaterialType, UIRenderer } from '../framework/ui-renderer';
@@ -299,8 +294,10 @@ export class Graphics extends UIRenderer {
* @zh
* 移动路径起点到坐标(x, y)。
*
* @param x - 移动坐标 x 轴。
* @param y - 移动坐标 y 轴。
* @param x @en The x-axis coordinate of the target position.
* @zh 目标位置的 X 轴坐标。
* @param y @en The y-axis coordinate of the target position.
* @zh 目标位置的 y 轴坐标。
*/
public moveTo (x: number, y: number) {
if (!this.impl) {
@@ -317,8 +314,10 @@ export class Graphics extends UIRenderer {
* @zh
* 绘制直线路径。
*
* @param x - 绘制路径坐标 x 轴。
* @param y - 绘制路径坐标 y 轴。
* @param x @en The x-axis coordinate of the target position.
* @zh 目标位置的 x 轴坐标。
* @param y @en The x-axis coordinate of the target position.
* @zh 目标位置的 y 轴坐标。
*/
public lineTo (x: number, y: number) {
if (!this.impl) {
@@ -335,12 +334,18 @@ export class Graphics extends UIRenderer {
* @zh
* 绘制三次贝赛尔曲线路径。
*
* @param c1x - 第一个控制点的坐标 x 轴。
* @param c1y - 第一个控制点的坐标 y 轴。
* @param c2x - 第二个控制点的坐标 x 轴。
* @param c2y - 第二个控制点的坐标 y 轴。
* @param x - 最后一个控制点的坐标 x 轴。
* @param y - 最后一个控制点的坐标 y 轴。
* @param c1x @en The x-axis coordinate of the first control point.
* @zh 第一个控制点的 x 轴坐标。
* @param c1y @en The y-axis coordinate of the first control point.
* @zh 第一个控制点的 y 轴坐标。
* @param c2x @en The x-axis coordinate of the second control point.
* @zh 第二个控制点的 x 轴坐标。
* @param c2y @en The y-axis coordinate of the second control point.
* @zh 第二个控制点的 y 轴坐标。
* @param x @en The x-axis coordinate of the last control point.
* @zh 最后一个控制点的 x 轴坐标。
* @param y @en The y-axis coordinate of the last control point.
* @zh 最后一个控制点的 y 轴坐标。
*/
public bezierCurveTo (c1x: number, c1y: number, c2x: number, c2y: number, x: number, y: number) {
if (!this.impl) {
@@ -357,10 +362,14 @@ export class Graphics extends UIRenderer {
* @zh
* 绘制二次贝赛尔曲线路径。
*
* @param cx - 起始控制点的坐标 x 轴。
* @param cy - 起始控制点的坐标 y 轴。
* @param x - 终点控制点的坐标 x 轴。
* @param y - 终点控制点的坐标 x 轴。
* @param cx @en The x-axis coordinate of the starting control point.
* @zh 起始控制点的 x 轴坐标。
* @param cy @en The y-axis coordinate of the starting control point.
* @zh 起始控制点的 y 轴坐标。
* @param x @en The x-axis coordinates of the endpoint control point.
* @zh 终点控制点的 x 轴坐标。
* @param y @en The y-axis coordinates of the endpoint control point.
* @zh 终点控制点的 x 轴坐标。
*/
public quadraticCurveTo (cx: number, cy: number, x: number, y: number) {
if (!this.impl) {
@@ -378,12 +387,18 @@ export class Graphics extends UIRenderer {
* @zh
* 绘制圆弧路径。圆弧路径的圆心在 (cx, cy) 位置,半径为 r ,根据 counterclockwise (默认为false)指定的方向从 startAngle 开始绘制,到 endAngle 结束。
*
* @param cx - 中心控制点的坐标 x 轴。
* @param cy - 中心控制点的坐标 y 轴。
* @param r - 圆弧弧度。
* @param startAngle - 开始弧度,从正 x 轴顺时针方向测量。
* @param endAngle - 结束弧度,从正 x 轴顺时针方向测量。
* @param counterclockwise 如果为真,在两个角度之间逆时针绘制。默认顺时针。
* @param cx @en The coordinate x-axis of the central control point.
* @zh 中心控制点的坐标 x 轴。
* @param cy @en The coordinate y-axis of the central control point.
* @zh 中心控制点的坐标 y 轴。
* @param r @en Angle in Radian.
* @zh 圆弧弧度。
* @param startAngle @en The starting angle in radian, measured clockwise from the positive x-axis.
* @zh 弧度起点,从正 x 轴顺时针方向测量。
* @param endAngle @en The ending angle in radian, measured clockwise from the positive x-axis.
* @zh 弧度终点,从正 x 轴顺时针方向测量。
* @param counterclockwise @en If true, draws counterclockwise between the two angles. Default is clockwise.
* @zh 如果为真,在两个角度之间逆时针绘制。默认顺时针。
*/
public arc (cx: number, cy: number, r: number, startAngle: number, endAngle: number, counterclockwise: boolean) {
if (!this.impl) {
@@ -400,10 +415,14 @@ export class Graphics extends UIRenderer {
* @zh
* 绘制椭圆路径。
*
* @param cx - 中心点的坐标 x 轴。
* @param cy - 中心点的坐标 y 轴。
* @param rx - 椭圆 x 轴半径。
* @param ry - 椭圆 y 轴半径。
* @param cx @en The x-axis coordinates of the center point.
* @zh 中心点的 x 轴坐标。
* @param cy @en The y-axis coordinates of the center point.
* @zh 中心点的 y 轴坐标。
* @param rx @en The radius of the x-axis of the ellipse.
* @zh 椭圆 x 轴半径。
* @param ry @en The radius of the y-axis of the ellipse.
* @zh 椭圆 y 轴半径。
*/
public ellipse (cx: number, cy: number, rx: number, ry: number) {
if (!this.impl) {
@@ -420,9 +439,12 @@ export class Graphics extends UIRenderer {
* @zh
* 绘制圆形路径。
*
* @param cx - 中心点的坐标 x 轴。
* @param cy - 中心点的坐标 y 轴。
* @param r - 圆半径。
* @param cx @en The x-axis coordinates of the center point.
* @zh 中心点的 x 轴坐标。
* @param cy @en The y-axis coordinates of the center point.
* @zh 中心点的 y 轴坐标。
* @param r @en Radius.
* @zh 圆半径。
*/
public circle (cx: number, cy: number, r: number) {
if (!this.impl) {
@@ -439,10 +461,14 @@ export class Graphics extends UIRenderer {
* @zh
* 绘制矩形路径。
*
* @param x - 矩形起始坐标 x 轴。
* @param y - 矩形起始坐标 y 轴。
* @param w - 矩形宽度。
* @param h - 矩形高度。
* @param x @en The x-axis coordinate of the top left point of the rectangle.
* @zh 矩形起始 x 轴坐标。
* @param y @en The y-axis coordinate of the top left point of the rectangle.
* @zh 矩形起始 y 轴坐标。
* @param w @en The width of the rectangle.
* @zh 矩形宽度。
* @param h @en The height of the rectangle.
* @zh 矩形高度。
*/
public rect (x: number, y: number, w: number, h: number) {
if (!this.impl) {
@@ -459,11 +485,16 @@ export class Graphics extends UIRenderer {
* @zh
* 绘制圆角矩形路径。
*
* @param x - 矩形起始坐标 x 轴。
* @param y - 矩形起始坐标 y 轴。
* @param w - 矩形宽度。
* @param h - 矩形高度。
* @param r - 矩形圆角半径。
* @param x @en The x-axis coordinate of the top left point of the rectangle.
* @zh 矩形起始 x 轴坐标。
* @param y @en The y-axis coordinate of the top left point of the rectangle.
* @zh 矩形起始 y 轴坐标。
* @param w @en The width of the rectangle.
* @zh 矩形宽度。
* @param h @en The height of the rectangle.
* @zh 矩形高度。
* @param r @en Radius of rectangular rounded corners.
* @zh 矩形圆角半径。
*/
public roundRect (x: number, y: number, w: number, h: number, r: number) {
if (!this.impl) {
@@ -480,10 +511,14 @@ export class Graphics extends UIRenderer {
* @zh
* 绘制填充矩形。
*
* @param x - 矩形起始坐标 x 轴。
* @param y - 矩形起始坐标 y 轴。
* @param w - 矩形宽度。
* @param h - 矩形高度。
* @param x @en The x-axis coordinate of the top left point of the rectangle.
* @zh 矩形起始 x 轴坐标。
* @param y @en The y-axis coordinate of the top left point of the rectangle.
* @zh 矩形起始 y 轴坐标。
* @param w @en The width of the rectangle.
* @zh 矩形宽度。
* @param h @en The height of the rectangle.
* @zh 矩形高度。
*/
public fillRect (x, y, w, h) {
this.rect(x, y, w, h);
-5
View File
@@ -24,11 +24,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui
*/
import { ccclass, help, executionOrder, menu, tooltip, requireComponent, executeInEditMode, serializable } from 'cc.decorator';
import { Component } from '../../core/components/component';
import { Color } from '../../core/math';
-5
View File
@@ -24,11 +24,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui
*/
import { ccclass, help, executionOrder, menu, tooltip, requireComponent, executeInEditMode, serializable } from 'cc.decorator';
import { Component } from '../../core/components/component';
import { Color, Vec2 } from '../../core/math';
-5
View File
@@ -24,11 +24,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui
*/
import { ccclass, help, executionOrder, menu, tooltip, displayOrder, visible, multiline, type, serializable, editable } from 'cc.decorator';
import { BYTEDANCE, EDITOR } from 'internal:constants';
import { minigame } from 'pal/minigame';
-5
View File
@@ -24,11 +24,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui
*/
import { ccclass, help, executionOrder, menu, tooltip, displayOrder, type, visible, override, serializable, range, slide } from 'cc.decorator';
import { InstanceMaterialType, UIRenderer } from '../framework/ui-renderer';
import { clamp, Color, Mat4, Vec2, Vec3 } from '../../core/math';
+1 -5
View File
@@ -24,11 +24,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui
*/
import { ccclass, executeInEditMode, executionOrder, help, menu, tooltip, multiline, type, displayOrder, serializable } from 'cc.decorator';
import { DEV, EDITOR } from 'internal:constants';
import { Font, SpriteAtlas, TTFFont, SpriteFrame } from '../assets';
@@ -114,6 +109,7 @@ function getSegmentByPool (type: string, content: string | SpriteFrame) {
seg.comp.string = content as string;
seg.comp.horizontalAlign = HorizontalTextAlignment.LEFT;
seg.comp.verticalAlign = VerticalTextAlignment.TOP;
seg.comp.underlineHeight = 2;
}
node.setPosition(0, 0, 0);
const trans = node._uiProps.uiTransformComp!;
-5
View File
@@ -24,11 +24,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui
*/
import { ccclass, help, executionOrder, menu, tooltip, displayOrder, type, range, editable, serializable, visible } from 'cc.decorator';
import { EDITOR } from 'internal:constants';
import { SpriteAtlas } from '../assets/sprite-atlas';
+2 -7
View File
@@ -24,11 +24,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui
*/
import { ccclass, help, executionOrder, menu, executeInEditMode } from 'cc.decorator';
import { ModelRenderer } from '../../core/components/model-renderer';
import { RenderPriority } from '../../core/pipeline/define';
@@ -41,11 +36,11 @@ import { legacyCC } from '../../core/global-exports';
* @en
* The component of model.
* When you place particles or models in the UI, you must add this component to render.
* The component must be placed on a node with the [[MeshRenderer]] or the [[Particle]].
* The component must be placed on a node with the [[MeshRenderer]] or the [[ParticleSystem]].
*
* @zh
* UI 模型基础组件。
* 当你在 UI 中放置模型或者粒子的时候,必须添加该组件才能渲染。该组件必须放置在带有 [[MeshRenderer]] 或者 [[Particle]] 组件的节点上。
* 当你在 UI 中放置模型或者粒子的时候,必须添加该组件才能渲染。该组件必须放置在带有 [[MeshRenderer]] 或者 [[ParticleSystem]] 组件的节点上。
*/
@ccclass('cc.UIMeshRenderer')
@help('i18n:cc.UIMeshRenderer')
-5
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui
*/
import { ccclass, disallowMultiple, editable, executeInEditMode, executionOrder, help, menu, serializable, tooltip } from 'cc.decorator';
import { Component } from '../../core/components/component';
import { clampf } from '../../core/utils/misc';
-5
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui
*/
import { ccclass, help, menu, executionOrder, visible, override } from 'cc.decorator';
import { UIRenderer } from '../framework/ui-renderer';
import { IBatcher } from '../renderer/i-batcher';
+1 -6
View File
@@ -24,11 +24,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui
*/
import { ccclass, help, disallowMultiple, executeInEditMode,
executionOrder, menu, tooltip, type, serializable } from 'cc.decorator';
import { EDITOR } from 'internal:constants';
@@ -82,7 +77,7 @@ export class Canvas extends RenderRoot2D {
* intersperse 下可以指定 Canvas 与场景中的相机的渲染顺序,overlay 下 Canvas 会在所有场景相机渲染完成后渲染。
* 注意:场景里的相机(包括 Canvas 内置的相机)必须有一个的 ClearFlag 选择 SOLID_COLOR,否则在移动端可能会出现闪屏。
*
* @deprecated since v3.0, please use [[cameraComponent.priority]] to control overlapping between cameras.
* @deprecated since v3.0, please use [[Camera.priority]] to control overlapping between cameras.
*/
get renderMode () {
return this._renderMode;
-5
View File
@@ -24,11 +24,6 @@
*/
/* eslint-disable @typescript-eslint/no-unsafe-return */
/**
* @packageDocumentation
* @module ui
*/
import { markAsWarning, removeProperty, replaceProperty } from '../../core/utils';
import { UIComponent } from './ui-component';
import { UITransform } from './ui-transform';
-5
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui
*/
import { ccclass, disallowMultiple, executeInEditMode,
executionOrder, menu, requireComponent } from 'cc.decorator';
import { Component } from '../../core/components/component';
+2 -7
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui
*/
import { ccclass, disallowMultiple, executeInEditMode, executionOrder, requireComponent } from 'cc.decorator';
import { IBatcher } from '../renderer/i-batcher';
import { Component } from '../../core/components/component';
@@ -37,9 +32,9 @@ import { Stage } from '../renderer/stencil-manager';
/**
* @en Legacy 2D base class for rendering component, please use [[Renderable2D]] instead.
* This component will setup [[NodeUIProperties.uiComp]] in its owner [[Node]]
* This component will setup NodeUIProperties.uiComp in its owner [[Node]]
* @zh 旧的 2D 渲染组件基类,请使用 [[Renderable2D]] 替代。
* 这个组件会设置 [[Node]] 上的 [[NodeUIProperties.uiComp]]。
* 这个组件会设置 [[Node]] 上的 NodeUIProperties.uiComp。
* @deprecated since v3.4.1
*/
@ccclass('cc.UIComponent')
+3 -3
View File
@@ -101,10 +101,10 @@ export enum InstanceMaterialType {
/**
* @en Base class for UI components which supports rendering features.
* This component will setup [[NodeUIProperties.uiComp]] in its owner [[Node]]
* This component will setup NodeUIProperties.uiComp in its owner [[Node]]
*
* @zh 所有支持渲染的 UI 组件的基类。
* 这个组件会设置 [[Node]] 上的 [[NodeUIProperties.uiComp]]。
* 这个组件会设置 [[Node]] 上的 NodeUIProperties.uiComp。
*/
@ccclass('cc.UIRenderer')
@requireComponent(UITransform)
@@ -114,7 +114,7 @@ export class UIRenderer extends Renderer {
/**
* @en The blend factor enums
* @zh 混合模式枚举类型
* @see [[BlendFactor]]
* @see [[gfx.BlendFactor]]
*/
public static BlendState = BlendFactor;
/**
+23 -18
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui
*/
import { ccclass, help, executeInEditMode, executionOrder, menu, tooltip, displayOrder, serializable, disallowMultiple } from 'cc.decorator';
import { EDITOR } from 'internal:constants';
import { Component } from '../../core/components';
@@ -367,8 +362,10 @@ export class UITransform extends Component {
* 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。<br>
* 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。
*
* @param point - 节点锚点或节点 x 轴锚。
* @param y - 节点 y 轴锚。
* @param point @en Node anchor point or node x-axis anchor.
* @zh 节点锚点或节点 x 轴锚。
* @param y @en The y-axis anchor of the node.
* @zh 节点 y 轴锚。
* @example
* ```ts
* import { Vec2 } from 'cc';
@@ -401,7 +398,8 @@ export class UITransform extends Component {
}
/**
* Hit test with point in UI Space.
* @zh UI 空间中的点击测试。
* @en Hit test with point in UI Space.
*
* @param uiPoint point in UI Space.
* @deprecated since v3.5.0, please use `uiTransform.hitTest(screenPoint: Vec2)` instead.
@@ -447,13 +445,13 @@ export class UITransform extends Component {
return false;
}
/**
* Hit test with point in Screen Space.
* @zh 屏幕空间中的点击测试。
* @en Hit test with point in Screen Space.
*
* @param screenPoint point in Screen Space.
*/
public hitTest (screenPoint: Vec2) {
public hitTest (screenPoint: Vec2) {
const w = this._contentSize.width;
const h = this._contentSize.height;
const v3WorldPt = _vec3a;
@@ -529,9 +527,12 @@ export class UITransform extends Component {
* 将一个 UI 节点世界坐标系下点转换到另一个 UI 节点 (局部) 空间坐标系,这个坐标系以锚点为原点。
* 非 UI 节点转换到 UI 节点(局部) 空间坐标系,请走 Camera 的 `convertToUINode`。
*
* @param worldPoint - 世界坐标点。
* @param out - 转换后坐标。
* @returns - 返回与目标节点的相对位置。
* @param worldPoint @en Point in world space.
* @zh 世界坐标点。
* @param out @en Point in local space.
* @zh 转换后坐标。
* @returns @en Return the relative position to the target node.
* @zh 返回与目标节点的相对位置。
* @example
* ```ts
* const newVec3 = uiTransform.convertToNodeSpaceAR(cc.v3(100, 100, 0));
@@ -554,9 +555,12 @@ export class UITransform extends Component {
* @zh
* 将距当前节点坐标系下的一个点转换到世界坐标系。
*
* @param nodePoint - 节点坐标。
* @param out - 转换后坐标。
* @returns - 返回 UI 世界坐标系。
* @param nodePoint @en Point in local space.
* @zh 节点坐标。
* @param out @en Point in world space.
* @zh 转换后坐标。
* @returns @en Returns the coordinates in the UI world coordinate system.
* @zh 返回 UI 世界坐标系。
* @example
* ```ts
* const newVec3 = uiTransform.convertToWorldSpaceAR(3(100, 100, 0));
@@ -629,7 +633,8 @@ export class UITransform extends Component {
* @zh
* 返回包含当前包围盒及其子节点包围盒的最小包围盒。
*
* @param parentMat - 父节点矩阵。
* @param parentMat @en The parent node matrix.
* @zh 父节点矩阵。
* @returns
*/
public getBoundingBoxTo (parentMat: Mat4) {
+16 -10
View File
@@ -148,7 +148,8 @@ export class Batcher2D implements IBatcher {
* @zh
* 添加屏幕组件管理。
*
* @param comp - 屏幕组件。
* @param comp @en The render root of 2d.
* @zh 2d 渲染入口组件。
*/
public addScreen (comp: RenderRoot2D) {
this._screens.push(comp);
@@ -159,7 +160,8 @@ export class Batcher2D implements IBatcher {
* @zh
* Removes the Canvas from the list.
*
* @param comp - 被移除的屏幕。
* @param comp @en The target to removed.
* @zh 被移除的屏幕。
*/
public removeScreen (comp: RenderRoot2D) {
const idx = this._screens.indexOf(comp);
@@ -273,8 +275,9 @@ export class Batcher2D implements IBatcher {
}
/**
* Switch the mesh buffer for corresponding vertex layout if necessary.
* @param attributes use [[VertexFormat.vfmtPosUvColor]] by default
* @zh 如果有必要,为相应的顶点布局切换网格缓冲区。
* @en Switch the mesh buffer for corresponding vertex layout if necessary.
* @param attributes use VertexFormat.vfmtPosUvColor by default
*/
public switchBufferAccessor (attributes: Attribute[] = vfmtPosUvColor) {
const strideBytes = attributes === vfmtPosUvColor ? 36 /* 9x4 */ : getAttributeStride(attributes);
@@ -368,12 +371,12 @@ export class Batcher2D implements IBatcher {
/**
* @en
* Render component data submission process for individual [[InputAssembler]]
* Render component data submission process for individual [[gfx.InputAssembler]]
* @zh
* 渲染组件中针对独立 [[InputAssembler]] 的提交流程
* 渲染组件中针对独立 [[gfx.InputAssembler]] 的提交流程
* 例如:Spine 和 DragonBones 等包含动态数据和材质的组件在内部管理 IA 并提交批次
* @param comp - The committed renderable component
* @param ia - The committed [[InputAssembler]]
* @param ia - The committed [[gfx.InputAssembler]]
* @param tex - The texture used
* @param mat - The material used
* @param [transform] - The related node transform if the render data is based on node's local coordinates
@@ -489,7 +492,8 @@ export class Batcher2D implements IBatcher {
*
* @zh
* 提交独立渲染数据.
* @param comp 静态组件
* @param comp @en The UIStaticBatch component.
* @zh 静态组件
*/
public commitStaticBatch (comp: UIStaticBatch) {
this._batches.concat(comp.drawBatchList);
@@ -577,8 +581,10 @@ export class Batcher2D implements IBatcher {
* @zh
* 强行修改当前批次数据并合并。
*
* @param material - 当前批次的材质。
* @param sprite - 当前批次的精灵帧。
* @param material @en The material of the current batch.
* @zh 当前批次的材质。
* @param sprite @en Sprite frame of current batch.
* @zh 当前批次的精灵帧。
*/
public forceMergeBatches (material: Material, frame: TextureBase | SpriteFrame | null, renderComp: UIRenderer) {
this._currMaterial = material;
-5
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui
*/
import { Attribute, Device } from '../../core/gfx';
import type { MeshBuffer } from './mesh-buffer';
import { getComponentPerVertex } from './vertex-format';
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui
*/
import { InputAssembler, Device, Attribute } from '../../core/gfx';
import { MeshBuffer } from './mesh-buffer';
import { BufferAccessor } from './buffer-accessor';
+1 -5
View File
@@ -23,10 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module ui
*/
import { Device, BufferUsageBit, MemoryUsageBit, Attribute, Buffer, BufferInfo, InputAssembler, InputAssemblerInfo } from '../../core/gfx';
import { getComponentPerVertex } from './vertex-format';
import { getError, warnID } from '../../core/platform/debug';
@@ -137,7 +133,7 @@ export class MeshBuffer {
}
public checkCapacity (vertexCount: number, indexCount: number) {
const maxVertex = this.vertexOffset + vertexCount;
const maxVertex = (this.vertexOffset + vertexCount) * this._floatsPerVertex;
const maxIndex = this.indexOffset + indexCount;
if (maxVertex > this._initVDataCount || maxIndex > this._initIDataCount) {
return false;
+12
View File
@@ -36,6 +36,9 @@ import { getAttributeStride, vfmtPosUvColor } from './vertex-format';
import { Buffer, BufferInfo, BufferUsageBit, Device, InputAssembler, InputAssemblerInfo, MemoryUsageBit } from '../../core/gfx';
import { assertIsTrue } from '../../core/data/utils/asserts';
/**
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
*/
export interface IRenderData {
x: number;
y: number;
@@ -58,6 +61,9 @@ const _dataPool = new Pool(() => ({
let _pool: RecyclePool<RenderData> = null!;
/**
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
*/
export class BaseRenderData {
public material: Material | null = null;
get vertexCount () {
@@ -96,6 +102,9 @@ export class BaseRenderData {
}
}
/**
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
*/
export class RenderData extends BaseRenderData {
public static add (vertexFormat = vfmtPosUvColor, accessor?: StaticVBAccessor) {
if (!_pool) {
@@ -305,6 +314,9 @@ export class RenderData extends BaseRenderData {
}
}
/**
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
*/
export class MeshRenderData extends BaseRenderData {
public static add (vertexFormat = vfmtPosUvColor) {
const rd = _meshDataPool.add();
+2 -4
View File
@@ -23,12 +23,10 @@
THE SOFTWARE.
*/
import { Device, Attribute } from '../../core/gfx';
import { MeshBuffer } from './mesh-buffer';
import { BufferAccessor } from './buffer-accessor';
import { assertID, warnID } from '../../core/platform/debug';
import { assertID, errorID } from '../../core/platform/debug';
import { assertIsTrue } from '../../core/data/utils/asserts';
import { Pool } from '../../core/memop/pool';
import { macro } from '../../core/platform/macro';
@@ -170,7 +168,7 @@ export class StaticVBAccessor extends BufferAccessor {
return new StaticVBChunk(this, bid, buf, vertexOffset, vb, indexCount);
} else {
warnID(9004, byteLength);
errorID(9004, byteLength);
return null;
}
}
-1
View File
@@ -23,7 +23,6 @@
THE SOFTWARE.
*/
import { ComparisonFunc, StencilOp, DepthStencilState } from '../../core/gfx';
import { Mask } from '../components/mask';
import { Material } from '../../core';
@@ -1,7 +1,3 @@
/**
* @packageDocumentation
*/
import { EDITOR } from 'internal:constants';
import { Filter } from '../../../core/assets/asset-enum';
import { legacyCC } from '../../../core/global-exports';
-4
View File
@@ -1,7 +1,3 @@
/**
* @packageDocumentation
*/
import { PixelFormat } from '../../../core/assets/asset-enum';
import { ImageAsset } from '../../../core/assets/image-asset';
import { Texture2D } from '../../../core/assets/texture-2d';
-2
View File
@@ -23,8 +23,6 @@
THE SOFTWARE.
*/
import { warnID } from '../../core/platform/debug';
import { safeMeasureText } from './text-utils';
import { CompleteCallback, IDownloadParseOptions } from '../../core/asset-manager/shared';
+29 -3
View File
@@ -28,19 +28,23 @@ import { TEST } from 'internal:constants';
import { legacyCC } from '../../core/global-exports';
/**
*
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
*/
const eventRegx = /^(click)(\s)*=|(param)(\s)*=/;
const imageAttrReg = /(\s)*src(\s)*=|(\s)*height(\s)*=|(\s)*width(\s)*=|(\s)*align(\s)*=|(\s)*offset(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/;
/**
* A utils class for parsing HTML texts. The parsed results will be an object array.
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
*/
export interface IHtmlTextParserResultObj{
text?: string;
style?: IHtmlTextParserStack;
}
/**
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
*/
export interface IHtmlTextParserStack{
color?: string;
size?: number;
@@ -58,6 +62,9 @@ export interface IHtmlTextParserStack{
outline?: { color: string, width: number };
}
/**
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
*/
export class HtmlTextParser {
private _specialSymbolArray: Array<[RegExp, string]> = [];
private _stack: IHtmlTextParserStack[] = [];
@@ -165,6 +172,7 @@ export class HtmlTextParser {
header = /^(img(\s)*src(\s)*=[^>]+\/)/.exec(attribute);
let remainingArgument = '';
let rightQuot = -1;
if (header && header[0].length > 0) {
tagName = header[0].trim();
if (tagName.startsWith('img') && tagName[tagName.length - 1] === '/') {
@@ -177,7 +185,10 @@ export class HtmlTextParser {
tagName = attribute.substr(0, header[0].length);
// remove space and = character
remainingArgument = attribute.substring(tagName.length).trim();
nextSpace = remainingArgument.indexOf(' ');
rightQuot = this.getRightQuotationIndex(remainingArgument);
nextSpace = remainingArgument.indexOf(' ', rightQuot + 1 >= remainingArgument.length ? -1 : rightQuot + 1);
tagValue = (nextSpace > -1) ? remainingArgument.substr(0, nextSpace) : remainingArgument;
tagName = tagName.replace(/[^a-zA-Z]/g, '').trim();
@@ -301,6 +312,21 @@ export class HtmlTextParser {
return obj;
}
private getRightQuotationIndex (remainingArgument: string) {
let leftQuot = -1;
let rightQuot = -1;
// Skip a pair of quotations for avoiding spaces in image name are detected.
leftQuot = remainingArgument.indexOf('\'');
if (leftQuot > -1) {
rightQuot = remainingArgument.indexOf('\'', leftQuot + 1 >= remainingArgument.length ? -1 : leftQuot + 1);
} else {
leftQuot = remainingArgument.indexOf('"');
rightQuot = remainingArgument.indexOf('"', leftQuot + 1 >= remainingArgument.length ? -1 : leftQuot + 1);
}
return rightQuot;
}
private _processEventHandler (eventString: string) {
const obj = {};
let index = 0;
+3 -3
View File
@@ -160,9 +160,9 @@ const measureCache = new LRUCache(MAX_CACHE_SIZE);
const WORD_REG = /([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûа-яА-ЯЁё]+|\S)/;
// eslint-disable-next-line no-useless-escape
const SYMBOL_REG = /^[!,.:;'}\]%\?>、‘“》?。,!]/;
const LAST_WORD_REG = /([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁё]+|\S)$/;
const LAST_ENGLISH_REG = /[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁё]+$/;
const FIRST_ENGLISH_REG = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁё]/;
const LAST_WORD_REG = /([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁёáàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệiíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵđÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆIÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ]+|\S)$/;
const LAST_ENGLISH_REG = /[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁёáàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệiíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵđÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆIÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ]+$/;
const FIRST_ENGLISH_REG = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁёáàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệiíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵđÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆIÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ]/;
const WRAP_INSPECTION = true;
// The unicode standard will never assign a character from code point 0xD800 to 0xDFFF
// high surrogate (0xD800-0xDBFF) and low surrogate(0xDC00-0xDFFF) combines to a character on the Supplementary Multilingual Plane
+1
View File
@@ -28,3 +28,4 @@ import './deprecated';
export { Mesh } from './mesh';
export { Skeleton } from './skeleton';
export type { Morph, MorphTarget, SubMeshMorph } from './morph';
+5 -8
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module asset
*/
import { ccclass, serializable } from 'cc.decorator';
import { Asset } from '../../core/assets/asset';
import { IDynamicGeometry } from '../../primitive/define';
@@ -45,7 +40,8 @@ import {
FormatInfos, FormatType, MemoryUsageBit, PrimitiveMode, getTypedArrayConstructor, DrawInfo,
} from '../../core/gfx';
import { Mat4, Quat, Vec3 } from '../../core/math';
import { Morph, MorphRendering, createMorphRendering } from './morph';
import { Morph } from './morph';
import { MorphRendering, createMorphRendering } from './morph-rendering';
function getIndexStrideCtor (stride: number) {
switch (stride) {
@@ -669,8 +665,9 @@ export class Mesh extends Asset {
}
/**
* @en Get [[AABB]] bounds in the skeleton's bone space
* @zh 获取骨骼变换空间内下的 [[AABB]] 包围盒
* @en Get [[geometry.AABB]] bounds in the skeleton's bone space
* @zh 获取骨骼变换空间内下的 [[geometry.AABB]] 包围盒
* @param skeleton @en skeleton data @zh 骨骼信息
* @param skeleton @en skeleton data @zh 骨骼信息
*/
public getBoneSpaceBounds (skeleton: Skeleton) {
+65 -20
View File
@@ -23,11 +23,8 @@
THE SOFTWARE.
*/
import {
AttributeName, Buffer, BufferUsageBit, Device, Feature, MemoryUsageBit, DescriptorSet, BufferInfo,
FormatFeatureBit, Format,
AttributeName, Buffer, BufferUsageBit, Device, MemoryUsageBit, DescriptorSet, BufferInfo, FormatFeatureBit, Format,
} from '../../core/gfx';
import { Mesh } from './mesh';
import { Texture2D } from '../../core/assets/texture-2d';
@@ -35,7 +32,7 @@ import { ImageAsset } from '../../core/assets/image-asset';
import { UBOMorph, UNIFORM_NORMAL_MORPH_TEXTURE_BINDING,
UNIFORM_POSITION_MORPH_TEXTURE_BINDING, UNIFORM_TANGENT_MORPH_TEXTURE_BINDING } from '../../core/pipeline/define';
import { warn } from '../../core/platform/debug';
import { Morph, MorphRendering, MorphRenderingInstance, SubMeshMorph } from './morph';
import { Morph, SubMeshMorph } from './morph';
import { assertIsNonNullable, assertIsTrue } from '../../core/data/utils/asserts';
import { log2, nextPow2 } from '../../core/math/bits';
import { IMacroPatch } from '../../core/renderer';
@@ -44,13 +41,67 @@ import { PixelFormat } from '../../core/assets/asset-enum';
/**
* True if force to use cpu computing based sub-mesh rendering.
* Only customizable by modify the internal engine code.
*/
const preferCpuComputing = false;
/**
* Standard morph rendering.
* The standard morph rendering renders each of sub-mesh morph separately.
* Sub-mesh morph rendering may select different technique according sub-mesh morph itself.
* @en Interface for classes which control the rendering of morph resources.
* @zh 支持形变网格渲染的基类。
*/
export interface MorphRendering {
createInstance (): MorphRenderingInstance;
}
/**
* @en The instance of [[MorphRendering]] for dedicated control in the mesh renderer.
* The root [[MorphRendering]] is owned by [[Mesh]] asset, each [[MeshRenderer]] can have its own morph rendering instance.
* @zh 用于网格渲染器中独立控制 [[MorphRendering]] 的实例。原始 [[MorphRendering]] 被 [[Mesh]] 资源持有,每个 [[MeshRenderer]] 都持有自己的形变网格渲染实例。
*/
export interface MorphRenderingInstance {
/**
* Sets weights of targets of specified sub mesh.
* @param subMeshIndex
* @param weights
*/
setWeights (subMeshIndex: number, weights: number[]): void;
/**
* Adapts pipeline state to do the rendering.
* @param subMeshIndex
* @param pipelineState
*/
adaptPipelineState (subMeshIndex: number, descriptorSet: DescriptorSet): void;
/**
* Acquire the define overrides needed to do the rendering.
*/
requiredPatches (subMeshIndex: number): IMacroPatch[] | null;
/**
* Destroy the rendering instance.
*/
destroy (): void;
}
/**
* @en Create morph rendering from mesh which contains morph targets data.
* @zh 从包含形变对象的网格资源中创建形变网格渲染对象。
* @param mesh @en The mesh to create morph rendering from. @zh 用于创建形变网格渲染对象的原始网格资源。
* @param gfxDevice @en The device instance acquired from [[Root]]. @zh 设备对象实例,可以从 [[Root]] 获取。
*/
export function createMorphRendering (mesh: Mesh, gfxDevice: Device): MorphRendering {
return new StdMorphRendering(mesh, gfxDevice);
}
/**
* @en Standard morph rendering class, it supports both GPU and CPU based morph blending.
* If sub mesh morph targets count is less than [[pipeline.UBOMorph.MAX_MORPH_TARGET_COUNT]], then GPU based blending is enabled.
* Each of the sub-mesh morph has its own [[MorphRenderingInstance]],
* its morph target weights, render pipeline state and strategy of morph blending are controlled separately.
* @zh 标准形变网格渲染类,它同时支持 CPU 和 GPU 的形变混合计算。
* 如果子网格形变目标数量少于 [[pipeline.UBOMorph.MAX_MORPH_TARGET_COUNT]],那么就会使用基于 GPU 的形变混合计算。
* 每个子网格形变都使用自己独立的 [[MorphRenderingInstance]],它的形变目标权重、渲染管线状态和形变混合计算策略都是独立控制的。
*/
export class StdMorphRendering implements MorphRendering {
private _mesh: Mesh;
@@ -138,7 +189,8 @@ export class StdMorphRendering implements MorphRendering {
}
/**
* Describes how to render a sub-mesh morph.
* @en Sub-mesh morph rendering describes how to render a sub-mesh morph.
* @zh 子网格形变渲染定义如何渲染一个子网格形变。
*/
interface SubMeshMorphRendering {
/**
@@ -148,7 +200,9 @@ interface SubMeshMorphRendering {
}
/**
* The instance of once sub-mesh morph rendering.
* @en The instance of sub-mesh morph rendering, each sub-mesh have its own instance
* for controlling its morph target weights, render pipeline state and strategy of morph blending.
* @zh 子网格形变渲染的实例,每个子网格都拥有自己独立的子网格形变渲染实例,用于独立控制形变目标权重、渲染管线状态和形变混合计算策略。
*/
interface SubMeshMorphRenderingInstance {
/**
@@ -467,11 +521,6 @@ class MorphUniforms {
}
}
/**
*
* @param gfxDevice
* @param vec4Capacity Capacity of vec4.
*/
function createVec4TextureFactory (gfxDevice: Device, vec4Capacity: number) {
const hasFeatureFloatTexture = gfxDevice.getFormatFeatures(Format.RGBA32F) & FormatFeatureBit.SAMPLED_TEXTURE;
@@ -563,12 +612,8 @@ function createVec4TextureFactory (gfxDevice: Device, vec4Capacity: number) {
type MorphTexture = ReturnType<ReturnType<typeof createVec4TextureFactory>['create']>;
/**
* When use vertex-texture-fetch technique, we do need
* `gl_vertexId` when we sample per-vertex data.
* When use vertex-texture-fetch technique, we do need `gl_vertexId` when we sample per-vertex data.
* WebGL 1.0 does not have `gl_vertexId`; WebGL 2.0, however, does.
* @param mesh
* @param subMeshIndex
* @param gfxDevice
*/
function enableVertexId (mesh: Mesh, subMeshIndex: number, gfxDevice: Device) {
mesh.renderingSubMeshes[subMeshIndex].enableVertexIdChannel(gfxDevice);
+32 -56
View File
@@ -23,31 +23,13 @@
THE SOFTWARE.
*/
import { AttributeName, Device, DescriptorSet } from '../../core/gfx';
import { AttributeName } from '../../core/gfx';
import { Mesh } from './mesh';
import { StdMorphRendering } from './morph-rendering';
import { IMacroPatch } from '../../core/renderer';
export interface Morph {
/**
* Morph data of each sub-mesh.
*/
subMeshMorphs: (SubMeshMorph | null)[];
/**
* Common initial weights of each sub-mesh.
*/
weights?: number[];
/**
* Name of each target of each sub-mesh morph.
* This field is only meaningful if every sub-mesh has the same number of targets.
*/
targetNames?: string[];
}
/**
* @en Morph target contains all displacements data of each vertex attribute like position and normal.
* @zh 形变目标数据包含网格顶点属性在形变下的变化值,可能包含位移、法线等属性
*/
export interface MorphTarget {
/**
* Displacement of each target attribute.
@@ -55,6 +37,11 @@ export interface MorphTarget {
displacements: Mesh.IBufferView[];
}
/**
* @en Sub mesh morph data describes all morph targets for one sub mesh,
* including attributes in each morph target, morph targets data and weights corresponding each targets.
* @zh 子网格形变数据描述一个子网格下所有的形变目标数据,包含顶点形变属性,形变目标数据和对应每个形变目标的权重。
*/
export interface SubMeshMorph {
/**
* Attributes to morph.
@@ -72,39 +59,28 @@ export interface SubMeshMorph {
weights?: number[];
}
export function createMorphRendering (mesh: Mesh, gfxDevice: Device): MorphRendering | null {
return new StdMorphRendering(mesh, gfxDevice);
}
/**
* Class which control rendering of a morph resource.
* @en Mesh morph data structure to describe the sub meshes data of all sub meshes,
* it also contains all sub mesh morphs, global weights configuration and target names.
* Normally the global weights configuration should be identical to the sub mesh morph weights,
* but if not, the global weights in morph is less prioritized.
* @zh 网格的形变数据结构,包含所有子网格形变数据,全局的权重配置和所有形变目标名称。
* 一般来说,全局权重配置和子网格形变数据中保持一致,但如果有差异,以子网格形变数据中的权重配置为准。
*/
export interface MorphRendering {
createInstance (): MorphRenderingInstance;
}
/**
* This rendering instance of a morph resource.
*/
export interface MorphRenderingInstance {
/**
* Sets weights of targets of specified sub mesh.
* @param subMeshIndex
* @param weights
*/
setWeights (subMeshIndex: number, weights: number[]): void;
/**
* Adapts pipeline state to do the rendering.
* @param subMeshIndex
* @param pipelineState
*/
adaptPipelineState (subMeshIndex: number, descriptorSet: DescriptorSet): void;
requiredPatches (subMeshIndex: number): IMacroPatch[] | null;
/**
* Destroy the rendering instance.
*/
destroy (): void;
export interface Morph {
/**
* Morph data of each sub-mesh.
*/
subMeshMorphs: (SubMeshMorph | null)[];
/**
* Common initial weights of each sub-mesh.
*/
weights?: number[];
/**
* Name of each target of each sub-mesh morph.
* This field is only meaningful if every sub-mesh has the same number of targets.
*/
targetNames?: string[];
}
+5 -5
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module asset
*/
import { ccclass, type, serializable } from 'cc.decorator';
import { CCString } from '../../core/data/utils/attribute';
import { Mat4 } from '../../core/math';
@@ -119,6 +114,11 @@ export class Skeleton extends Asset {
return super.destroy();
}
/**
* @en Check whether the skeleton is validate which means it has both joints and bindposes data.
* @zh 检查当前骨骼对象是否是有效的,取决于它是否包含关节路径和绑定姿势数据。
* @returns @en Whether the skeleton is valid or not @zh 此骨骼是否有效
*/
public validate () {
return this.joints.length > 0 && this.bindposes.length > 0;
}
+64 -39
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module model
*/
import { ccclass, help, executeInEditMode, executionOrder, menu, tooltip, visible, type,
formerlySerializedAs, serializable, editable, disallowAnimation } from 'cc.decorator';
import { Texture2D } from '../../core/assets';
@@ -41,7 +36,7 @@ import { TransformBit } from '../../core/scene-graph/node-enum';
import { Enum } from '../../core/value-types';
import { builtinResMgr } from '../../core/builtin';
import { ModelRenderer } from '../../core/components/model-renderer';
import { MorphRenderingInstance } from '../assets/morph';
import { MorphRenderingInstance } from '../assets/morph-rendering';
import { legacyCC } from '../../core/global-exports';
import { assertIsTrue } from '../../core/data/utils/asserts';
import { CCFloat } from '../../core/data/utils/attribute';
@@ -70,19 +65,19 @@ const ModelShadowCastingMode = Enum({
*/
const ModelShadowReceivingMode = Enum({
/**
* @en Disable shadow projection.
* @en Disable shadow receiving.
* @zh 不接收阴影。
*/
OFF: 0,
/**
* @en Enable shadow projection.
* @en Enable shadow receiving.
* @zh 开启阴影投射。
*/
ON: 1,
});
/**
* @en model light map settings.
* @en Model's light map settings.
* @zh 模型光照图设置
*/
@ccclass('cc.ModelLightmapSettings')
@@ -101,8 +96,10 @@ class ModelLightmapSettings {
protected _lightmapSize = 64;
/**
* @en bakeable.
* @zh 是否可烘培。
* @en Whether the model is static and bake-able with light map.
* Notice: the model's vertex data must have the second UV attribute to enable light map baking.
* @zh 模型是否是静态的并可以烘培光照贴图。
* 注意:模型顶点数据必须包含第二套 UV 属性来支持光照贴图烘焙。
*/
@editable
get bakeable () {
@@ -114,8 +111,8 @@ class ModelLightmapSettings {
}
/**
* @en cast shadow.
* @zh 是否投射阴影。
* @en Whether to cast shadow in light map baking.
* @zh 在光照贴图烘焙中是否投射阴影。
*/
@editable
get castShadow () {
@@ -127,8 +124,8 @@ class ModelLightmapSettings {
}
/**
* @en receive shadow.
* @zh 是否接受阴影。
* @en Whether to receive shadow in light map baking.
* @zh 在光照贴图烘焙中是否接受阴影。
*/
@editable
get receiveShadow () {
@@ -140,8 +137,8 @@ class ModelLightmapSettings {
}
/**
* @en lightmap size.
* @zh 光照图大小
* @en The lightmap size.
* @zh 光照图大小。
*/
@editable
get lightmapSize () {
@@ -154,8 +151,10 @@ class ModelLightmapSettings {
}
/**
* @en Mesh renderer component
* @zh 网格渲染器组件。
* @en Mesh renderer component for general 3d model rendering, it generates and link to a Model in the render scene.
* It supports real time lighting and shadow, baked light map, and morph rendering.
* @zh 用于通用模型渲染的网格渲染器组件,会创建并关联一个渲染场景中的模型对象。
* 该组件支持实时光照和阴影,预烘焙光照贴图和形变网格渲染。
*/
@ccclass('cc.MeshRenderer')
@help('i18n:cc.MeshRenderer')
@@ -163,9 +162,21 @@ class ModelLightmapSettings {
@menu('Mesh/MeshRenderer')
@executeInEditMode
export class MeshRenderer extends ModelRenderer {
/**
* @en Shadow projection mode enumeration.
* @zh 阴影投射方式枚举。
*/
public static ShadowCastingMode = ModelShadowCastingMode;
/**
* @en Shadow receive mode enumeration.
* @zh 阴影接收方式枚举。
*/
public static ShadowReceivingMode = ModelShadowReceivingMode;
/**
* @en The settings for light map baking
* @zh 光照贴图烘焙的配置
*/
@serializable
@editable
@disallowAnimation
@@ -180,18 +191,18 @@ export class MeshRenderer extends ModelRenderer {
@serializable
protected _shadowReceivingMode = ModelShadowReceivingMode.ON;
// @serializable
private _subMeshShapesWeights: number[][] = [];
@serializable
protected _shadowBias = 0;
@serializable
protected _shadowNormalBias = 0;
// @serializable
private _subMeshShapesWeights: number[][] = [];
/**
* @en local shadow bias.
* @zh 模型局部的阴影偏移。
* @en Local shadow bias for real time lighting.
* @zh 实时光照下模型局部的阴影偏移。
*/
@type(CCFloat)
@tooltip('i18n:model.shadow_bias')
@@ -208,8 +219,8 @@ export class MeshRenderer extends ModelRenderer {
}
/**
* @en local shadow normal bias.
* @zh 模型局部的阴影法线偏移。
* @en local shadow normal bias for real time lighting.
* @zh 实时光照下模型局部的阴影法线偏移。
*/
@type(CCFloat)
@tooltip('i18n:model.shadow_normal_bias')
@@ -227,7 +238,7 @@ export class MeshRenderer extends ModelRenderer {
/**
* @en Shadow projection mode.
* @zh 阴影投射方式。
* @zh 实时光照下阴影投射方式。
*/
@type(ModelShadowCastingMode)
@tooltip('i18n:model.shadow_casting_model')
@@ -244,7 +255,7 @@ export class MeshRenderer extends ModelRenderer {
/**
* @en receive shadow.
* @zh 是否接受阴影。
* @zh 实时光照下是否接受阴影。
*/
@type(ModelShadowReceivingMode)
@tooltip('i18n:model.shadow_receiving_model')
@@ -261,9 +272,9 @@ export class MeshRenderer extends ModelRenderer {
/**
* @en Gets or sets the mesh of the model.
* Note, when set, all shape's weights would be reset to zero.
* Note, when set, all morph targets' weights would be reset to zero.
* @zh 获取或设置模型的网格数据。
* 注意,设置时,所有形状的权重都将归零。
* 注意,设置时,所有形变目标的权重都将归零。
*/
@type(Mesh)
@tooltip('i18n:model.mesh')
@@ -286,10 +297,18 @@ export class MeshRenderer extends ModelRenderer {
this._updateReceiveShadow();
}
/**
* @en Gets the model in [[RenderScene]].
* @zh 获取渲染场景 [[RenderScene]] 中对应的模型。
*/
get model () {
return this._model;
}
/**
* @en Whether to enable morph rendering.
* @zh 是否启用形变网格渲染。
*/
// eslint-disable-next-line func-names
@visible(function (this: MeshRenderer) {
return !!(
@@ -384,10 +403,10 @@ export class MeshRenderer extends ModelRenderer {
}
/**
* @zh 获取子网格指定外形的权重。
* @en Gets the weight at specified shape of specified sub mesh.
* @zh 获取子网格指定形变目标的权重。
* @en Gets the weight at specified morph target of the specified sub mesh.
* @param subMeshIndex Index to the sub mesh.
* @param shapeIndex Index to the shape of the sub mesh.
* @param shapeIndex Index to the morph target of the sub mesh.
* @returns The weight.
*/
public getWeight (subMeshIndex: number, shapeIndex: number) {
@@ -400,13 +419,11 @@ export class MeshRenderer extends ModelRenderer {
/**
* @zh
* 设置子网格所有外形的权重。
* `subMeshIndex` 是无效索引或 `weights` 的长度不匹配子网格的外形数量时,此方法不会生效。
* 设置子网格所有形变目标的权重。
* `subMeshIndex` 是无效索引或 `weights` 的长度不匹配子网格的形变目标数量时,此方法不会生效。
* @en
* Sets weights of each shape of specified sub mesh.
* If takes no effect if
* `subMeshIndex` out of bounds or
* `weights` has a different length with shapes count of the sub mesh.
* Sets weights of each morph target of the specified sub mesh.
* If takes no effect if `subMeshIndex` is out of bounds or if `weights` has a different length with morph targets count of the sub mesh.
* @param weights The weights.
* @param subMeshIndex Index to the sub mesh.
*/
@@ -739,6 +756,14 @@ export class MeshRenderer extends ModelRenderer {
}
export declare namespace MeshRenderer {
/**
* @en Shadow projection mode.
* @zh 阴影投射方式。
*/
export type ShadowCastingMode = EnumAlias<typeof ModelShadowCastingMode>;
/**
* @en Shadow receive mode.
* @zh 阴影接收方式。
*/
export type ShadowReceivingMode = EnumAlias<typeof ModelShadowReceivingMode>;
}
-5
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module component
*/
import { Light } from './light-component';
import { SpotLight } from './spot-light-component';
import { SphereLight } from './sphere-light-component';
+28 -31
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module component/light
*/
import { ccclass, range, slide, type, editable, visible, help, executeInEditMode,
menu, tooltip, serializable, formerlySerializedAs } from 'cc.decorator';
import { Light } from './light-component';
@@ -39,6 +34,10 @@ import { property } from '../../core/data/class-decorator';
import { CCBoolean, CCFloat } from '../../core/data/utils/attribute';
import { clamp } from '../../core';
/**
* @en The directional light component, only one real time directional light is permitted in one scene, it act as the main light of the scene.
* @zh 平行光源组件,一个场景只允许存在一个实时的平行光源,作为场景的主光源存在。
*/
@ccclass('cc.DirectionalLight')
@help('i18n:cc.DirectionalLight')
@menu('Light/DirectionalLight')
@@ -83,10 +82,8 @@ export class DirectionalLight extends Light {
protected _light: scene.DirectionalLight | null = null;
/**
* @en
* The light source intensity.
* @zh
* 光源强度。
* @en The light source intensity.
* @zh 光源强度。
*/
@tooltip('i18n:lights.illuminance')
get illuminance () {
@@ -109,8 +106,8 @@ export class DirectionalLight extends Light {
}
/**
* @en Whether activate shadow
* @zh 是否启用阴影?
* @en Whether activate real time shadow.
* @zh 是否启用实时阴影?
*/
@visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap)
@property({ group: { name: 'DynamicShadowSettings', displayOrder: 1 } })
@@ -127,8 +124,8 @@ export class DirectionalLight extends Light {
}
/**
* @en get or set shadow pcf.
* @zh 获取或者设置阴影pcf等级。
* @en The shadow pcf for real time shadow.
* @zh 实时阴影计算中的阴影 pcf 等级。
*/
@visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap)
@property({ group: { name: 'DynamicShadowSettings', displayOrder: 5 } })
@@ -145,8 +142,8 @@ export class DirectionalLight extends Light {
}
/**
* @en get or set shadow map sampler offset
* @zh 获取或者设置阴影纹理偏移值
* @en The shadow map sampler offset for real time shadow.
* @zh 实时阴影计算中的阴影纹理偏移值。
*/
@visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap)
@property({ group: { name: 'DynamicShadowSettings', displayOrder: 6 } })
@@ -163,8 +160,8 @@ export class DirectionalLight extends Light {
}
/**
* @en get or set normal bias.
* @zh 设置或者获取法线偏移。
* @en The global normal bias for real time shadow.
* @zh 实时阴影计算中的法线偏移。
*/
@visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap)
@property({ group: { name: 'DynamicShadowSettings', displayOrder: 7 } })
@@ -181,8 +178,8 @@ export class DirectionalLight extends Light {
}
/**
* @en Shadow color saturation
* @zh 阴影颜色饱和度
* @en The shadow color saturation for real time shadow.
* @zh 实时阴影计算中的阴影颜色饱和度。
*/
@visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap)
@property({ group: { name: 'DynamicShadowSettings', displayOrder: 8 } })
@@ -202,8 +199,8 @@ export class DirectionalLight extends Light {
}
/**
* @en get or set shadow camera far
* @zh 获取或者设置潜在阴影产生的范围
* @en The potential shadow distance from the camera for real time shadow.
* @zh 实时阴影计算中潜在阴影产生的范围
*/
@visible(function (this: DirectionalLight) {
return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type
@@ -226,8 +223,8 @@ export class DirectionalLight extends Light {
}
/**
* @en get or set shadow camera far
* @zh 获取或者设置潜在阴影产生的范围
* @en The occlusion range for real time shadow.
* @zh 实时阴影计算中剔除阴影的范围
*/
@visible(function (this: DirectionalLight) {
return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type
@@ -250,8 +247,8 @@ export class DirectionalLight extends Light {
}
/**
* @en get or set fixed area shadow
* @zh 是否是固定区域阴影
* @en Whether to use fixed area shadow in real time shadow.
* @zh 实时阴影计算中是否使用固定区域阴影。
*/
@visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap)
@property({ group: { name: 'DynamicShadowSettings', displayOrder: 11 } })
@@ -268,8 +265,8 @@ export class DirectionalLight extends Light {
}
/**
* @en get or set shadow camera near
* @zh 获取或者设置阴影相机近裁剪面
* @en The near clip plane of the shadow camera for fixed area shadow
* @zh 固定区域阴影设置中阴影相机近裁剪面
*/
@visible(function (this: DirectionalLight) {
return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type
@@ -289,8 +286,8 @@ export class DirectionalLight extends Light {
}
/**
* @en get or set shadow camera far
* @zh 获取或者设置阴影相机远裁剪面
* @en The far clip plane of the shadow camera for fixed area shadow.
* @zh 固定区域阴影设置中阴影相机远裁剪面。
*/
@visible(function (this: DirectionalLight) {
return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type
@@ -310,8 +307,8 @@ export class DirectionalLight extends Light {
}
/**
* @en get or set shadow camera orthoSize
* @zh 获取或者设置阴影相机正交大小
* @en The orthogonal size of the shadow camera for fixed area shadow.
* @zh 固定区域阴影设置中阴影相机的正交尺寸
*/
@visible(function (this: DirectionalLight) {
return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type
-1
View File
@@ -24,7 +24,6 @@
THE SOFTWARE.
*/
export { DirectionalLight } from './directional-light-component';
export { Light } from './light-component';
export { SphereLight } from './sphere-light-component';
+33 -23
View File
@@ -23,27 +23,27 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module component/light
*/
import { ccclass, tooltip, range, slide, type, displayOrder, serializable, editable } from 'cc.decorator';
import { Component } from '../../core/components/component';
import { Color, Vec3 } from '../../core/math';
import { Enum } from '../../core/value-types';
import { scene } from '../../core/renderer';
import { Root } from '../../core/root';
import { legacyCC } from '../../core/global-exports';
const _color_tmp = new Vec3();
/**
* @en The physical term used for light.
* @zh 光源所使用的物理计量单位。
*/
export const PhotometricTerm = Enum({
LUMINOUS_FLUX: 0,
LUMINANCE: 1,
});
const _color_tmp = new Vec3();
/**
* @en static light settings.
* @en Static light settings.
* @zh 静态灯光设置
*/
@ccclass('cc.StaticLightSettings')
@@ -58,7 +58,7 @@ class StaticLightSettings {
protected _castShadow = false;
/**
* @en editor only.
* @en Whether the light is editor only.
* @zh 是否只在编辑器里生效。
*/
@editable
@@ -70,7 +70,8 @@ class StaticLightSettings {
}
/**
* bake state
* @en Whether the light is baked
* @zh 光源是否被烘焙
*/
get baked () {
return this._baked;
@@ -81,8 +82,8 @@ class StaticLightSettings {
}
/**
* @en bakeable.
* @zh 是否可烘培。
* @en Whether the light is bake-able.
* @zh 光源是否可烘培。
*/
@editable
get bakeable () {
@@ -94,8 +95,8 @@ class StaticLightSettings {
}
/**
* @en cast shadow.
* @zh 是否投射阴影。
* @en Whether the light will cast shadow during baking process.
* @zh 光源在烘焙时是否投射阴影。
*/
@editable
get castShadow () {
@@ -112,9 +113,21 @@ export declare namespace Light {
export type PhotometricTerm = EnumAlias<typeof PhotometricTerm>;
}
/**
* @en The base class of all light components, contains basic light settings for both real time light and baked light.
* @zh 光源组件基类,包含实时光源和烘焙光源的基本配置信息。
*/
@ccclass('cc.Light')
export class Light extends Component {
/**
* @en The light type enumeration.
* @zh 光源类型枚举。
*/
public static Type = scene.LightType;
/**
* @en The physical term used for light.
* @zh 光源所使用的物理计量单位。
*/
public static PhotometricTerm = PhotometricTerm;
@serializable
@@ -131,10 +144,8 @@ export class Light extends Component {
protected _light: scene.Light | null = null;
/**
* @en
* Color of the light.
* @zh
* 光源颜色。
* @en The color of the light.
* @zh 光源颜色。
*/
@tooltip('i18n:lights.color')
get color (): Readonly<Color> {
@@ -200,17 +211,16 @@ export class Light extends Component {
}
/**
* @en
* The light type.
* @zh
* 光源类型。
* @en The light type.
* @zh 光源类型。
*/
get type () {
return this._type;
}
/**
* bake state
* @en Whether the light is baked
* @zh 光源是否被烘焙
*/
get baked () {
return this.staticSettings.baked;
+4 -4
View File
@@ -22,10 +22,6 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module component/light
*/
import { ccclass, help, executeInEditMode, menu, tooltip, type, displayOrder, serializable, formerlySerializedAs } from 'cc.decorator';
import { scene } from '../../core/renderer';
@@ -34,6 +30,10 @@ import { legacyCC } from '../../core/global-exports';
import { Camera } from '../../core/renderer/scene';
import { Root } from '../../core/root';
/**
* @en The sphere light component, multiple sphere lights can be added to one scene.
* @zh 球面光源组件,场景中可以添加多个球面光源。
*/
@ccclass('cc.SphereLight')
@help('i18n:cc.SphereLight')
@menu('Light/SphereLight')
+9 -10
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module component/light
*/
import { ccclass, range, slide, type, editable, displayOrder, help, executeInEditMode,
menu, tooltip, serializable, formerlySerializedAs, visible } from 'cc.decorator';
import { toRadian } from '../../core/math';
@@ -39,6 +34,10 @@ import { Camera, PCFType, ShadowType } from '../../core/renderer/scene';
import { property } from '../../core/data/class-decorator';
import { CCBoolean, CCFloat } from '../../core/data/utils/attribute';
/**
* @en The spot light component, multiple spot lights can be added to one scene.
* @zh 聚光灯光源组件,场景中可以添加多个聚光灯光源。
*/
@ccclass('cc.SpotLight')
@help('i18n:cc.SpotLight')
@menu('Light/SpotLight')
@@ -215,8 +214,8 @@ export class SpotLight extends Light {
}
/**
* @en get or set shadow pcf.
* @zh 获取或者设置阴影pcf等级。
* @en The pcf level of the shadow generation.
* @zh 获取或者设置阴影 pcf 等级。
*/
@visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap)
@property({ group: { name: 'DynamicShadowSettings', displayOrder: 2 } })
@@ -233,8 +232,8 @@ export class SpotLight extends Light {
}
/**
* @en get or set shadow map sampler offset
* @zh 获取或者设置阴影纹理偏移值
* @en The depth offset of shadow to avoid moire pattern artifacts
* @zh 阴影的深度偏移, 可以减弱跨像素导致的条纹状失真
*/
@visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap)
@property({ group: { name: 'DynamicShadowSettings', displayOrder: 3 } })
@@ -251,7 +250,7 @@ export class SpotLight extends Light {
}
/**
* @en get or set normal bias.
* @en The normal bias of the shadow map.
* @zh 设置或者获取法线偏移。
*/
@visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap)
+10 -5
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module core
*/
import { MeshRenderer } from '../framework/mesh-renderer';
import { Mesh } from '../assets/mesh';
import { Mat4 } from '../../core/math/mat4';
@@ -52,12 +47,19 @@ function checkMaterialisSame (comp1: MeshRenderer, comp2: MeshRenderer): boolean
*/
export class BatchingUtility {
/**
* @en
* Collect the Models under `staticModelRoot`,
* merge all the meshes statically into one (while disabling each component),
* and attach it to a new Model on `batchedRoot`.
* The world transform of each model is guaranteed to be preserved.
*
* For a more fine-grained control over the process, use `Mesh.merge` directly.
* @zh
* 在`staticModelRoot`下收集模型。
* 将所有的网格静态地合并成一个(同时禁用每个组件)。
* 并将其附加到 `batchedRoot` 上的一个新模型。
* 每个模型的世界变换都被保证保留下来。
* 如果要对这个过程进行更精细的控制,可以直接使用 `Mesh.merge`。
* @param staticModelRoot root of all the static models to be batched
* @param batchedRoot the target output node
*/
@@ -96,7 +98,10 @@ export class BatchingUtility {
}
/**
* @en
* Undoes everything `batchStaticModel` did.
* @zh
* 回退 `batchStaticModel` 做的工作
*
* @param staticModelRoot root of all the static models to be batched
* @param batchedRoot the target output node
+6
View File
@@ -24,7 +24,13 @@
*/
/**
* @en
* save a color buffer to a PPM file
* @zh
* 保存一个颜色缓冲到 PPM 文件中
* @param buffer color buffer
* @param w width
* @param h height
*/
export function toPPM (buffer: Uint8Array, w: number, h: number) {
return `P3 ${w} ${h} 255\n${buffer.filter((e, i) => i % 4 < 3).toString()}\n`;
+25 -9
View File
@@ -53,11 +53,15 @@ const myPatches = [
/**
* @en
* The skinning model that is using baked animation.
* The skinning model that is using GPU baked animation.
* @zh
* 预烘焙动画的蒙皮模型。
* GPU 预烘焙动画的蒙皮模型。
*/
export class BakedSkinningModel extends MorphModel {
/**
* @en The animation clip that have been uploaded
* @zh 已被上传的动画片段
*/
public uploadedAnim: AnimationClip | null | undefined = undefined; // uninitialized
private _jointsMedium: IJointsInfo;
@@ -87,6 +91,7 @@ export class BakedSkinningModel extends MorphModel {
super.destroy();
}
// Override
public bindSkeleton (skeleton: Skeleton | null = null, skinningRoot: Node | null = null, mesh: Mesh | null = null) {
this._skeleton = skeleton;
this._mesh = mesh;
@@ -104,6 +109,7 @@ export class BakedSkinningModel extends MorphModel {
}
}
// Override
public updateTransform (stamp: number) {
super.updateTransform(stamp);
@@ -118,7 +124,7 @@ export class BakedSkinningModel extends MorphModel {
}
}
// update fid buffer only when visible
// Override, update fid buffer only when visible
public updateUBOs (stamp: number) {
super.updateUBOs(stamp);
@@ -134,6 +140,21 @@ export class BakedSkinningModel extends MorphModel {
return true;
}
// Override
public getMacroPatches (subModelIndex: number): IMacroPatch[] | null {
const patches = super.getMacroPatches(subModelIndex);
return patches ? patches.concat(myPatches) : myPatches;
}
/**
* @en Pre-simulate and store the frames data of the given animation clip to a joint texture and upload it to GPU.
* Normally, it's automatically managed by [[SkeletalAnimationState]].
* But user can also use Joint Texture Layout Settings in the editor to manually organize the joint textures.
* @zh 预计算并存储一个指定动画片段的完整帧数据到一张骨骼贴图上,并将其上传到 GPU。
* 一般情况下 [[SkeletalAnimationState]] 会自动管理所有骨骼贴图,但用户也可以使用编辑器的骨骼贴图布局设置面板来手动管理所有骨骼贴图。
* @param anim @en The animation clip to be uploaded to the joint texture. @zh 需要上传到骨骼贴图上的动画片段。
* @returns void
*/
public uploadAnimation (anim: AnimationClip | null) {
if (!this._skeleton || !this._mesh || this.uploadedAnim === anim) { return; }
this.uploadedAnim = anim;
@@ -146,7 +167,7 @@ export class BakedSkinningModel extends MorphModel {
} else {
texture = resMgr.jointTexturePool.getDefaultPoseTexture(this._skeleton, this._mesh, this.transform);
this._jointsMedium.boundsInfo = null;
this._modelBounds = texture && texture.bounds.get(this._mesh.hash)![0];
this._modelBounds = texture && texture.bounds.get(this._mesh.hash)![0];
}
this._applyJointTexture(texture);
}
@@ -171,11 +192,6 @@ export class BakedSkinningModel extends MorphModel {
}
}
public getMacroPatches (subModelIndex: number): IMacroPatch[] | null {
const patches = super.getMacroPatches(subModelIndex);
return patches ? patches.concat(myPatches) : myPatches;
}
protected _updateLocalDescriptors (submodelIdx: number, descriptorSet: DescriptorSet) {
super._updateLocalDescriptors(submodelIdx, descriptorSet);
const { buffer, texture, animInfo } = this._jointsMedium;
+36 -5
View File
@@ -24,27 +24,47 @@
*/
import { Model } from '../../core/renderer/scene/model';
import { MorphRenderingInstance } from '../assets/morph';
import { MorphRenderingInstance } from '../assets/morph-rendering';
import { Material } from '../../core/assets/material';
import { RenderingSubMesh } from '../../core/assets/rendering-sub-mesh';
import { DescriptorSet } from '../../core/gfx';
import { IMacroPatch } from '../../core/renderer';
/**
* @en
* The model that support morph target rendering.
* @zh
* 支持渲染蒙皮形变的模型。
*/
export class MorphModel extends Model {
private _morphRenderingInstance: MorphRenderingInstance | null = null;
private _usedMaterials = new Set<Material>();
/**
* @en Acquire the material's macro patches for the given sub model.
* @zh 获取指定子模型的材质宏组合。
* @param subModelIndex @en The index for the requested sub model. @zh 子模型的序号。
* @returns @en The macro patches. @zh 材质宏组合
*/
public getMacroPatches (subModelIndex: number) : IMacroPatch[] | null {
const superMacroPatches = super.getMacroPatches(subModelIndex);
if (this._morphRenderingInstance) {
const morphInstanceMacroPatches = this._morphRenderingInstance.requiredPatches(subModelIndex);
if (morphInstanceMacroPatches) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return morphInstanceMacroPatches.concat(superMacroPatches ?? []);
}
}
return superMacroPatches;
}
/**
* @en Initialize a sub model with the sub mesh data and the material.
* @zh 用子网格数据和材质初始化一个子模型。
* @param idx @en The index of the sub model @zh 子模型的序号
* @param subMeshData @en The sub mesh data to be set @zh 需要设置的子网格
* @param mat sub material
*/
public initSubModel (subModelIndex: number, subMeshData: RenderingSubMesh, material: Material) {
return super.initSubModel(
subModelIndex,
@@ -58,10 +78,25 @@ export class MorphModel extends Model {
this._morphRenderingInstance = null;
}
/**
* @en Sets the material for a given sub model.
* @zh 给指定的子模型设置材质。
* @param subModelIndex @en The index of the sub model @zh 子模型的序号
* @param material @en The material to be set @zh 需要设置的材质
* @returns void
*/
public setSubModelMaterial (subModelIndex: number, material: Material) {
return super.setSubModelMaterial(subModelIndex, this._launderMaterial(material));
}
/**
* Sets morph rendering instance for the model, it's managed by the MeshRenderer
* @internal
*/
public setMorphRendering (morphRendering: MorphRenderingInstance) {
this._morphRenderingInstance = morphRendering;
}
protected _updateLocalDescriptors (submodelIdx: number, descriptorSet: DescriptorSet) {
super._updateLocalDescriptors(submodelIdx, descriptorSet);
@@ -81,8 +116,4 @@ export class MorphModel extends Model {
// return material;
// }
}
public setMorphRendering (morphRendering: MorphRenderingInstance) {
this._morphRenderingInstance = morphRendering;
}
}
+33 -2
View File
@@ -80,8 +80,6 @@ const ab_1 = new AABB();
* 实时计算动画的蒙皮模型。
*/
export class SkinningModel extends MorphModel {
public uploadAnimation = null;
private _buffers: Buffer[] = [];
private _dataArray: Float32Array[] = [];
private _joints: IJointInfo[] = [];
@@ -102,6 +100,20 @@ export class SkinningModel extends MorphModel {
super.destroy();
}
/**
* @en Abstract function for [[BakedSkinningModel]], empty implementation.
* @zh 由 [[BakedSkinningModel]] 继承的空函数。
*/
public uploadAnimation () {}
/**
* @en Bind the skeleton with its skinning root node and the mesh data.
* @zh 在模型中绑定一个骨骼,需要提供骨骼的蒙皮根节点和蒙皮网格数据。
* @param skeleton @en The skeleton to be bound @zh 要绑定的骨骼
* @param skinningRoot @en The skinning root of the skeleton @zh 骨骼的蒙皮根节点
* @param mesh @en The mesh @zh 蒙皮网格
* @returns void
*/
public bindSkeleton (skeleton: Skeleton | null = null, skinningRoot: Node | null = null, mesh: Mesh | null = null) {
for (let i = 0; i < this._joints.length; i++) {
deleteTransform(this._joints[i].target);
@@ -126,6 +138,11 @@ export class SkinningModel extends MorphModel {
}
}
/**
* @en Update world transform and bounding boxes for the model
* @zh 更新模型的世界矩阵和包围盒
* @param stamp @en The update time stamp @zh 更新的时间戳
*/
public updateTransform (stamp: number) {
const root = this.transform;
// @ts-expect-error TS2445
@@ -153,6 +170,12 @@ export class SkinningModel extends MorphModel {
}
}
/**
* @en Update uniform buffer objects for rendering.
* @zh 更新用于渲染的 UBO
* @param stamp @en The update time stamp @zh 更新的时间戳
* @returns @en successful or not @zh 更新是否成功
*/
public updateUBOs (stamp: number) {
super.updateUBOs(stamp);
for (let i = 0; i < this._joints.length; i++) {
@@ -168,6 +191,13 @@ export class SkinningModel extends MorphModel {
return true;
}
/**
* @en Initialize sub model with the sub mesh data and the material
* @zh 用子网格数据和材质初始化一个子模型
* @param idx @en The index of the sub model to be initialized @zh 需要初始化的子模型序号
* @param subMeshData @en The sub mesh data @zh 子网格数据
* @param mat @en The material @zh 子模型材质
*/
public initSubModel (idx: number, subMeshData: RenderingSubMesh, mat: Material) {
const original = subMeshData.vertexBuffers;
const iaInfo = subMeshData.iaInfo;
@@ -176,6 +206,7 @@ export class SkinningModel extends MorphModel {
iaInfo.vertexBuffers = original;
}
// override
public getMacroPatches (subModelIndex: number): IMacroPatch[] | null {
const superMacroPatches = super.getMacroPatches(subModelIndex);
@@ -23,8 +23,6 @@
THE SOFTWARE.
*/
import type { AnimationClip } from '../../core/animation/animation-clip';
import type { Skeleton } from '../assets';
import { Device } from '../../core/gfx';
-1
View File
@@ -23,7 +23,6 @@
THE SOFTWARE.
*/
import './data-pool-manager';
export * from './skeletal-animation-data-hub';
@@ -24,10 +24,10 @@
*/
import { DEBUG } from 'internal:constants';
import { Vec3, Quat, approx } from '../../core/math';
import { Vec3, Quat } from '../../core/math';
import { Node } from '../../core/scene-graph';
import { RuntimeBinding } from '../../core/animation/tracks/track';
import { assertIsNonNullable, assertIsTrue } from '../../core/data/utils/asserts';
import { assertIsTrue } from '../../core/data/utils/asserts';
import { MAX_ANIMATION_LAYER } from './limits';
export abstract class BlendStateBuffer<
@@ -31,8 +31,10 @@ import { BAKE_SKELETON_CURVE_SYMBOL } from '../../core/animation/internal-symbol
type BakeData = ReturnType<AnimationClip[typeof BAKE_SKELETON_CURVE_SYMBOL]>;
/**
* @en The data conversion tool for skeleton animation
* @zh 骨骼动画数据转换中心。
* @en
* The data conversion tool for skeleton animation
* @zh
* 骨骼动画数据转换中心。
* @internal
*/
export class SkelAnimDataHub {
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module animation
*/
import { Mat4, Quat, Vec3 } from '../../core/math';
import { IAnimInfo, JointAnimationInfo } from './skeletal-animation-utils';
import { Node } from '../../core/scene-graph/node';
@@ -52,6 +47,10 @@ interface ISocketData {
frames: ITransform[];
}
/**
* @en The animation state for skeletal animations.
* @zh 骨骼动画的动画状态控制对象。
*/
export class SkeletalAnimationState extends AnimationState {
protected _frames = 1;
@@ -104,6 +103,12 @@ export class SkeletalAnimationState extends AnimationState {
}
}
/**
* @en Rebuild animation curves and register the socket transforms per frame to the sockets. It will replace the internal sockets list.
* @zh 为所有指定挂点更新动画曲线运算结果,并存储所有挂点的逐帧变换矩阵。这个方法会用传入的挂点更新取代内部挂点列表。
* @param sockets @en The sockets need update @zh 需要重建的挂点列表
* @returns void
*/
public rebuildSocketCurves (sockets: Socket[]) {
this._sockets.length = 0;
if (!this._targetNode) { return; }
@@ -139,6 +139,10 @@ export interface ICustomJointTextureLayout {
// For (Infinity - Infinity) evaluates to NaN
const Inf = Number.MAX_SAFE_INTEGER;
/**
* The pool for joint textures.
* @internal
*/
export class JointTexturePool {
private _device: Device;
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module animation
*/
import {
ccclass, executeInEditMode, executionOrder, help, menu, tooltip, type, serializable, editable,
} from 'cc.decorator';
@@ -46,6 +41,10 @@ import type { AnimationState } from '../../core/animation/animation-state';
import { assertIsTrue } from '../../core/data/utils/asserts';
import { getGlobalAnimationManager } from '../../core/animation/global-animation-manager';
/**
* @en The socket to synchronize transform from skeletal joint to target node.
* @zh 骨骼动画的挂点,用于将骨骼树的挂点节点变化矩阵同步到目标节点上
*/
@ccclass('cc.SkeletalAnimation.Socket')
export class Socket {
/**
@@ -217,6 +216,11 @@ export class SkeletalAnimation extends Animation {
}
}
/**
* @en Query all socket paths
* @zh 获取所有挂点的骨骼路径
* @returns @en All socket paths @zh 所有挂点的骨骼路径
*/
public querySockets () {
const animPaths = (this._defaultClip && Object.keys(SkelAnimDataHub.getOrExtract(this._defaultClip).joints).sort()
.reduce((acc, cur) => (cur.startsWith(acc[acc.length - 1]) ? acc : (acc.push(cur), acc)), [] as string[])) || [];
@@ -232,6 +236,10 @@ export class SkeletalAnimation extends Animation {
return out;
}
/**
* @en Rebuild animations to synchronize immediately all sockets to their target node.
* @zh 重建动画并立即同步所有挂点的转换矩阵到它们的目标节点上。
*/
public rebuildSocketAnimations () {
for (const socket of this._sockets) {
const joint = this.node.getChildByPath(socket.path);
@@ -250,6 +258,14 @@ export class SkeletalAnimation extends Animation {
}
}
/**
* @en Create or get the target node from a socket.
* If a socket haven't been created for the corresponding path, this function will register a new socket.
* @zh 创建或获取一个挂点的同步目标节点。
* 如果对应路径还没有创建挂点,这个函数会创建一个新的挂点。
* @param path @en Path of the target joint. @zh 此挂点的骨骼路径。
* @returns @en The target node of the socket. @zh 挂点的目标节点
*/
public createSocket (path: string) {
const socket = this._sockets.find((s) => s.path === path);
if (socket) { return socket.target; }
@@ -286,7 +302,7 @@ export class SkeletalAnimation extends Animation {
* @internal This method only friends to skinned mesh renderer.
*/
public notifySkinnedMeshRemoved (skinnedMeshRenderer: SkinnedMeshRenderer) {
assertIsTrue(skinnedMeshRenderer.associatedAnimation === this);
assertIsTrue(skinnedMeshRenderer.associatedAnimation === this || skinnedMeshRenderer.associatedAnimation === null);
skinnedMeshRenderer.setUseBakedAnimation(false);
skinnedMeshRenderer.associatedAnimation = null;
this._users.delete(skinnedMeshRenderer);
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module component
*/
import { SkinnedMeshRenderer } from './skinned-mesh-renderer';
import { SkinnedMeshBatchRenderer, SkinnedMeshUnit } from './skinned-mesh-batch-renderer';
import { js } from '../../core/utils/js';
@@ -22,11 +22,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module model
*/
import { EDITOR } from 'internal:constants';
import {
ccclass, help, executeInEditMode, executionOrder, menu, tooltip, type, visible, override, serializable, editable,
@@ -73,6 +68,8 @@ export class SkinnedMeshUnit {
public material: Material | null = null;
/**
* @en Local transform matrix
* @zh 本地变换矩阵
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
*/
@serializable
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module model
*/
import {
ccclass, executeInEditMode, executionOrder, help, menu, tooltip, type,
} from 'cc.decorator';
@@ -77,7 +72,7 @@ export class SkinnedMeshRenderer extends MeshRenderer {
/**
* @en The skinning root. (The node where the controlling Animation is located)
* 骨骼根节点的引用,对应控制此模型的动画组件所在节点。
* @zh 骨骼根节点的引用,对应控制此模型的动画组件所在节点。
*/
@type(Node)
@tooltip('i18n:model.skinning_root')
-5
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module component/audio
*/
import {
ccclass, type, serializable, override,
} from 'cc.decorator';
-5
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module component/audio
*/
import { AudioPlayer } from 'pal/audio';
import { ccclass, help, menu, tooltip, type, range, serializable } from 'cc.decorator';
import { AudioState } from '../../pal/audio/type';
-2
View File
@@ -23,8 +23,6 @@
THE SOFTWARE.
*/
import { AudioSource } from './audio-source';
import { replaceProperty, markAsWarning } from '../core/utils/x-deprecated';
import { AudioClip } from './audio-clip';
-2
View File
@@ -23,8 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import './audio-downloader';
import { AudioSource } from './audio-source';
+32 -19
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module animation
*/
import { ccclass, serializable } from 'cc.decorator';
import { Asset } from '../assets/asset';
import { SpriteFrame } from '../../2d/assets/sprite-frame';
@@ -63,7 +58,7 @@ export declare namespace AnimationClip {
}
/**
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
* @internal
*/
export type { legacy as _legacy };
}
@@ -144,8 +139,7 @@ export class AnimationClip extends Asset {
/**
* Sets if node TRS curves in this animation can be blended.
* Normally this flag is enabled for model animation and disabled for other case.
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
* This is an internal slot. Never use it in your code.
* @internal This is an internal slot. Never use it in your code.
*/
@serializable
public enableTrsBlending = false;
@@ -163,14 +157,20 @@ export class AnimationClip extends Asset {
}
/**
* @en
* Gets the count of tracks this animation owns.
* @zh
* 获取此动画中的轨道数量。
*/
get tracksCount () {
return this._tracks.length;
}
/**
* @en
* Gets an iterable to tracks.
* @zh
* 获取可用于迭代轨道的对象。
*/
get tracks (): Iterable<Track> {
return this._tracks;
@@ -237,7 +237,10 @@ export class AnimationClip extends Asset {
}
/**
* Counts the time range this animation spans.
* @en
* Counts the time range that the tracks within this animation span.
* @zh
* 获取此动画所有轨道占据的时间范围。
* @returns The time range.
*/
public range () {
@@ -254,7 +257,10 @@ export class AnimationClip extends Asset {
}
/**
* @en
* Gets the specified track.
* @zh
* 获取指定的轨道。
* @param index Index to the track.
* @returns The track.
*/
@@ -263,7 +269,10 @@ export class AnimationClip extends Asset {
}
/**
* @en
* Adds a track into this animation.
* @zh
* 添加一个轨道到此动画中。
* @param track The track.
* @returns Index to the track.
*/
@@ -274,7 +283,10 @@ export class AnimationClip extends Asset {
}
/**
* @en
* Removes a track from this animation.
* @zh
* 移除此动画中的指定轨道。
* @param index Index to the track.
*/
public removeTrack (index: number) {
@@ -282,7 +294,10 @@ export class AnimationClip extends Asset {
}
/**
* @en
* Removes all tracks from this animation.
* @zh
* 移除此动画的所有轨道。
*/
public clearTracks () {
this._tracks.length = 0;
@@ -291,9 +306,7 @@ export class AnimationClip extends Asset {
/**
* Creates an event evaluator for this animation.
* @param targetNode Target node used to fire events.
* @returns
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
* Do not use this in your code.
* @internal Do not use this in your code.
*/
public createEventEvaluator (targetNode: Node) {
return new EventEvaluator(
@@ -308,8 +321,7 @@ export class AnimationClip extends Asset {
* Creates an evaluator for this animation.
* @param context The context.
* @returns The evaluator.
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
* Do not use this in your code.
* @internal Do not use this in your code.
*/
public createEvaluator (context: AnimationClipEvalContext) {
const {
@@ -419,8 +431,7 @@ export class AnimationClip extends Asset {
/**
* Convert all untyped tracks into typed ones and delete the original.
* @param refine How to decide the type on specified path.
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
* DO NOT USE THIS IN YOUR CODE.
* @internal DO NOT USE THIS IN YOUR CODE.
*/
public upgradeUntypedTracks (refine: UntypedTrackRefine) {
const newTracks: Track[] = [];
@@ -446,7 +457,7 @@ export class AnimationClip extends Asset {
}
/**
* Export for test.
* @internal Export for test.
*/
public [searchForRootBonePathSymbol] () {
return this._searchForRootBonePath();
@@ -498,6 +509,9 @@ export class AnimationClip extends Asset {
}
/**
* @en
* The animation's data.
* @zh
* 此动画的数据。
* @deprecated Since V3.3. Please reference to the track/channel/curve mechanism introduced in V3.3.
*/
@@ -513,7 +527,6 @@ export class AnimationClip extends Asset {
}
/**
* @protected
* @deprecated Since V3.3. Please reference to the track/channel/curve mechanism introduced in V3.3.
*/
get eventGroups (): readonly IAnimationEventGroup[] {
@@ -545,7 +558,7 @@ export class AnimationClip extends Asset {
* Migrates legacy data into tracks.
* NOTE: This method tend to be used as internal purpose or patch.
* DO NOT use it in your code since it might be removed for the future at any time.
* @deprecated Since V3.3. Please reference to the track/channel/curve mechanism introduced in V3.3.
* @internal Since V3.3. Please reference to the track/channel/curve mechanism introduced in V3.3.
*/
public syncLegacyData () {
if (this._legacyData) {
+22 -7
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module animation
*/
import { ccclass, executeInEditMode, executionOrder, help, menu, tooltip, type, serializable } from 'cc.decorator';
import { EDITOR, TEST } from 'internal:constants';
import { Component } from '../components/component';
@@ -107,7 +102,7 @@ export class Animation extends Eventify(Component) {
* @en
* Gets or sets the default clip.
* Two clips that both have same non-empty UUID are treat as equivalent.
* @en
* @zh
* 获取或设置默认剪辑。
* 设置时,若指定的剪辑不在 `this.clips` 中则会被自动添加至 `this.clips`。
* 具有相同的非空 UUID 的两个动画剪辑将被视为是相同的。
@@ -145,13 +140,25 @@ export class Animation extends Eventify(Component) {
@tooltip('i18n:animation.play_on_load')
public playOnLoad = false;
/**
* @internal
*/
protected _crossFade = new CrossFade();
/**
* @internal
*/
protected _nameToState: Record<string, AnimationState> = createMap(true);
/**
* @internal
*/
@type([AnimationClip])
protected _clips: (AnimationClip | null)[] = [];
/**
* @internal
*/
@serializable
protected _defaultClip: AnimationClip | null = null;
@@ -306,7 +313,10 @@ export class Animation extends Eventify(Component) {
}
/**
* @zh
* 添加一个动画剪辑到 `this.clips`中并以此剪辑创建动画状态。
* @en
* Adds an animation clip into this component and creates a animation state for this clip.
* @param clip The animation clip
* @param name The animation state name, if absent, the default clip's name will be used
* @returns The created animation state
@@ -423,10 +433,16 @@ export class Animation extends Eventify(Component) {
}
}
/**
* @internal
*/
protected _createState (clip: AnimationClip, name?: string) {
return new AnimationState(clip, name);
}
/**
* @internal
*/
protected _doCreateState (clip: AnimationClip, name: string) {
const state = this._createState(clip, name);
state._setEventTarget(this);
@@ -439,7 +455,6 @@ export class Animation extends Eventify(Component) {
}
/**
*
* @internal This method only friends to skeletal animation component.
*/
protected doPlayOrCrossFade (state: AnimationState, duration: number) {
+12 -9
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module animation
*/
import { binarySearchEpsilon as binarySearch } from '../algorithm/binary-search';
import { lerp, Quat } from '../math';
import { errorID } from '../platform/debug';
@@ -72,6 +67,9 @@ export class RatioSampler {
legacyCC.RatioSampler = RatioSampler;
/**
* @en
* Animation curve.
* @zh
* 动画曲线。
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
*/
@@ -236,11 +234,14 @@ export class EventInfo {
}
/**
* @zh
* 采样动画曲线。
* @en
* Samples an animation curve.
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
* @param curve 动画曲线。
* @param sampler 采样器。
* @param ratio 采样比率。
* @param curve @zh 动画曲线。@en The curve.
* @param sampler @zh 采样器。@en The sampler.
* @param ratio @zh 采样比率。@en Sample ratio([0, 1]).
*/
export function sampleAnimationCurve (curve: AnimCurve, sampler: RatioSampler, ratio: number) {
let index = sampler.sample(ratio);
@@ -263,7 +264,10 @@ export function sampleAnimationCurve (curve: AnimCurve, sampler: RatioSampler, r
legacyCC.sampleAnimationCurve = sampleAnimationCurve;
/**
* @en
* Compute a new ratio by curve type.
* @zh
* 根据曲线类型计算新的比例。
* @param ratio - The origin ratio
* @param type - If it's Array, then ratio will be computed with bezierByTime.
* If it's string, then ratio will be computed with cc.easing function
@@ -287,7 +291,6 @@ export function computeRatioByType (ratio: number, type: legacy.LegacyEasingMeth
/**
* Use this function if intervals between frames are same.
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
*/
function quickFindIndex (ratios: number[], ratio: number) {
const length = ratios.length - 1;
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module animation
*/
import { ccclass } from 'cc.decorator';
import System from '../components/system';
import { director, Director } from '../director';
+11 -10
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module animation
*/
import { EDITOR } from 'internal:constants';
import { Node } from '../scene-graph/node';
import { AnimationClip } from './animation-clip';
@@ -247,7 +242,10 @@ export class AnimationState extends Playable {
}
/**
* The weight.
* @en
* The weight of this animation state.
* @zh
* 此动画状态的权重。
*/
get weight () {
return this._weight;
@@ -263,12 +261,12 @@ export class AnimationState extends Playable {
public frameRate = 0;
/**
* This field is only visible from within internal.
* @internal This field is only visible from within internal.
*/
protected _targetNode: Node | null = null;
/**
* This field is only visible from within internal.
* @internal This field is only visible from within internal.
*/
protected _curveLoaded = false;
@@ -300,7 +298,7 @@ export class AnimationState extends Playable {
private _clipEval: ReturnType<AnimationClip['createEvaluator']> | undefined;
private _clipEventEval: ReturnType<AnimationClip['createEventEvaluator']> | undefined;
/**
* For internal usage. Really hack...
* @internal For internal usage. Really hack...
*/
protected _doNotCreateEval = false;
@@ -443,7 +441,7 @@ export class AnimationState extends Playable {
/**
* This method is used for internal purpose only.
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
* @internal
*/
public _setEventTarget (target) {
this._target = target;
@@ -515,6 +513,9 @@ export class AnimationState extends Playable {
this.emit(EventType.PAUSE, this);
}
/**
* @internal
*/
protected _sampleCurves (time: number) {
const { _poseOutput: poseOutput, _clipEval: clipEval } = this;
if (poseOutput) {
-2
View File
@@ -23,8 +23,6 @@
THE SOFTWARE.
*/
export * from './target-path';
export * from './value-proxy';
export { UniformProxyFactory } from './value-proxy-factories/uniform';
@@ -175,7 +175,7 @@ export class CompressedData {
}
/**
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
* @internal
*/
public _addQuatCurve (curve: QuatCurve): CompressedQuatCurvePointer {
const times = Array.from(curve.times());
-5
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module animation
*/
import { clamp01 } from '../math/utils';
import { remove } from '../utils/array';
import { AnimationState } from './animation-state';
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module animation
*/
import { ccclass, serializable } from 'cc.decorator';
import { Quat, Vec2, Vec3, Vec4 } from '../math';
import { ILerpable } from './types';
@@ -50,7 +50,7 @@ export class ExoticAnimation {
}
/**
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
* @internal
*/
public toHashString () {
return this._nodeAnimations.map((nodeAnimation) => nodeAnimation.toHashString()).join('\n');
@@ -116,7 +116,7 @@ class ExoticNodeAnimation {
}
/**
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
* @internal
*/
public toHashString (): string {
return `${this._path}\n${
@@ -183,7 +183,7 @@ class ExoticVectorLikeTrackValues {
}
/**
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
* @internal
*/
public toHashString (): string {
const { _isQuantized: isQuantized, _values: values } = this;
@@ -305,7 +305,7 @@ class ExoticTrack<TTrackValues extends { toHashString(): string; }> {
public values!: TTrackValues;
/**
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
* @internal
*/
public toHashString (): string {
const { times, values } = this;
@@ -802,7 +802,7 @@ class QuantizedFloatArray {
}
/**
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
* @internal
*/
public toHashString (): string {
const { originalPrecision, min, extent, values } = this;
+1
View File
@@ -42,3 +42,4 @@ export {
} from './animation-component';
export * from './transform-utils';
export { animation };
export type { ILerpable } from './types';
@@ -67,8 +67,8 @@ export class AnimationController extends Component {
/**
* @zh 设置动画图实例中变量的值。
* @en Sets the value of the variable in the animation graph instance.
* @param name 变量名称。
* @param value 变量的值。
* @param name @en Variable's name. @zh 变量的名称。
* @param value @en Variable's value. @zh 变量的值。
* @example
* ```ts
* animationController.setValue('speed', 3.14);
@@ -85,8 +85,8 @@ export class AnimationController extends Component {
/**
* @zh 获取动画图实例中变量的值。
* @en Gets the value of the variable in the animation graph instance.
* @param name 变量名称。
* @returns 变量当前的值。
* @param name @en Variable's name. @zh 变量的名称。
* @returns @en Variable's value. @zh 变量的值。
*/
public getValue (name: string) {
const { _graphEval: graphEval } = this;
@@ -97,8 +97,9 @@ export class AnimationController extends Component {
/**
* @zh 获取动画图实例中当前状态的运行状况。
* @en Gets the running status of the current state in the animation graph instance.
* @param layer 层级索引。(必须为 `0`)
* @returns 当前的状态运作状态对象。
* @param layer @en Index of the layer. @zh 层级索引。
* @returns @en The running status of the current state.
* @zh 当前的状态运作状态对象。
*/
public getCurrentStateStatus (layer: number) {
const { _graphEval: graphEval } = this;
@@ -109,8 +110,9 @@ export class AnimationController extends Component {
/**
* @zh 获取动画图实例中当前状态上包含的所有动画剪辑的运行状况。
* @en Gets the running status of all the animation clips added on the current state in the animation graph instance.
* @param layer 层级索引。(必须为 `0`)
* @returns 到动画剪辑运作状态的迭代器。
* @param layer @en Index of the layer. @zh 层级索引。
* @returns @en Iterable to the animation clip statuses on current state.
* @zh 到动画剪辑运作状态的迭代器。
*/
public getCurrentClipStatuses (layer: number) {
const { _graphEval: graphEval } = this;
@@ -121,8 +123,9 @@ export class AnimationController extends Component {
/**
* @zh 获取动画图实例中当前正在进行的过渡的运行状况。
* @en Gets the running status of the transition currently in progress in the animation graph instance.
* @param layer 层级索引。(必须为 `0`)
* @returns 当前正在进行的过渡,若没有进行任何过渡,则返回 `null`。
* @param layer @en Index of the layer. @zh 层级索引。
* @returns @en Current transition status. `null` is returned in case of no transition.
* @zh 当前正在进行的过渡,若没有进行任何过渡,则返回 `null`。
*/
public getCurrentTransition (layer: number) {
const { _graphEval: graphEval } = this;
@@ -133,8 +136,9 @@ export class AnimationController extends Component {
/**
* @zh 获取动画图实例中下一个状态的运行状况。
* @en Gets the running status of the next state in the animation graph instance.
* @param layer 层级索引。(必须为 `0`)
* @returns 下一状态运作状态对象,若未在进行过渡,则返回 `null`。
* @param layer @en Index of the layer. @zh 层级索引。
* @returns @en The running status of the next state. `null` is returned in case of no transition.
* @zh 下一状态运作状态对象,若未在进行过渡,则返回 `null`。
*/
public getNextStateStatus (layer: number) {
const { _graphEval: graphEval } = this;
@@ -145,8 +149,9 @@ export class AnimationController extends Component {
/**
* @zh 获取动画图实例中下一个状态上添加的所有动画剪辑的运行状况。
* @en Gets the running status of all the animation clips added on the next state in the animation graph instance.
* @param layer 层级索引。(必须为 `0`)
* @returns 到下一状态上包含的动画剪辑运作状态的迭代器,若未在进行过渡,则返回一个空的迭代器。
* @param layer @en Index of the layer. @zh 层级索引。
* @returns @en Iterable to the animation clip statuses on next state. An empty iterable is returned in case of no transition.
* @zh 到下一状态上包含的动画剪辑运作状态的迭代器,若未在进行过渡,则返回一个空的迭代器。
*/
public getNextClipStatuses (layer: number) {
const { _graphEval: graphEval } = this;
@@ -154,6 +159,11 @@ export class AnimationController extends Component {
return graphEval.getNextClipStatuses(layer);
}
/**
* @zh 设置层级权重。
* @en Sets the weight of specified layer.
* @param layer @en Index of the layer. @zh 层级索引。
*/
public setLayerWeight (layer: number, weight: number) {
const { _graphEval: graphEval } = this;
assertIsNonNullable(graphEval);
@@ -140,7 +140,7 @@ export class StateMachine extends EditorExtendable {
/**
* // TODO: HACK
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
* @internal
*/
public __callOnAfterDeserializeRecursive () {
this[onAfterDeserializedTag]();
@@ -631,7 +631,16 @@ class TriggerVariable implements BasicVariableDescription<VariableType.TRIGGER>
private _flags = TRIGGER_VARIABLE_DEFAULT_FLAGS;
}
/**
* @en
* An opacity type which denotes what the animation graph seems like outside the engine.
* @zh
* 一个非透明的类型,它是动画图在引擎外部的表示。
*/
export interface AnimationGraphRunTime {
/**
* @internal
*/
readonly __brand: 'AnimationGraph';
}
@@ -33,7 +33,7 @@ export class ClipMotion extends EditorExtendable implements Motion {
class ClipMotionEval implements MotionEval {
/**
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
* @internal
*/
public declare __DEBUG__ID__?: string;
+34 -1
View File
@@ -167,30 +167,60 @@ export class AnimationGraphEval {
private _hasAutoTrigger = false;
}
/**
* @en
* Runtime status of a transition.
* @zh
* 过渡的运行状态。
*/
export interface TransitionStatus {
/**
* @en
* The duration of the transition.
* @zh
* 过渡的周期。
*/
duration: number;
/**
* @en
* The progress of the transition.
* @zh
* 过渡的进度。
*/
time: number;
}
/**
* @en
* Runtime clip status of a motion state.
* @zh
* 动作状态中包含的剪辑的运行状态。
*/
export interface ClipStatus {
/**
* @en
* The clip object.
* @zh
* 剪辑对象。
*/
clip: AnimationClip;
/**
* @en
* The clip's weight.
* @zh
* 剪辑的权重。
*/
weight: number;
}
/**
* @en
* Runtime status of a motion state.
* @zh
* 动作状态的运行状态。
*/
export interface MotionStateStatus {
/**
* For testing.
@@ -200,7 +230,10 @@ export interface MotionStateStatus {
__DEBUG_ID__?: string;
/**
* @en
* The normalized time of the state.
* @zh
* 状态的规范化进度。
*/
progress: number;
}
@@ -1071,7 +1104,7 @@ enum NodeKind {
export class StateEval {
/**
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
* @internal
*/
public declare __DEBUG_ID__?: string;
@@ -2,10 +2,17 @@ import { ccclass } from 'cc.decorator';
import { CLASS_NAME_PREFIX_ANIM } from '../define';
import type { AnimationController, MotionStateStatus } from './animation-controller';
/**
* @en State machine component.
* @zh 状态机组件。
*/
@ccclass(`${CLASS_NAME_PREFIX_ANIM}StateMachineComponent`)
export class StateMachineComponent {
/**
* @en
* Called when a motion state right after it entered.
* @zh
* 在刚刚进入动作状态时调用。
* @param controller The animation controller it within.
* @param motionStateStatus The status of the motion.
*/
@@ -14,7 +21,10 @@ export class StateMachineComponent {
}
/**
* @en
* Called when a motion state is going to be exited.
* @zh
* 在即将退出动作状态时调用。
* @param controller The animation controller it within.
* @param motionStateStatus The status of the motion.
*/
@@ -23,7 +33,10 @@ export class StateMachineComponent {
}
/**
* @en
* Called when a motion state updated except for the first and last frame.
* @zh
* 在动作状态更新时调用,但不会在第一次和最后一次时调用。
* @param controller The animation controller it within.
* @param motionStateStatus The status of the motion.
*/
@@ -32,7 +45,10 @@ export class StateMachineComponent {
}
/**
* @en
* Called when a state machine right after it entered.
* @zh
* 在刚刚进入状态机时调用。
* @param controller The animation controller it within.
*/
public onStateMachineEnter (controller: AnimationController) {
@@ -40,7 +56,10 @@ export class StateMachineComponent {
}
/**
* @en
* Called when a state machine right after it entered.
* @zh
* 在即将退出状态机时调用。
* @param controller The animation controller it within.
*/
public onStateMachineExit (controller: AnimationController) {
@@ -1,25 +1,64 @@
/**
* @en
* Represents variable's value.
* @zh
* 表示变量的值。
*/
export type Value = number | string | boolean;
/**
* @en
* Represents animation graph variable types.
* @zh
* 表示动画图变量的类型。
*/
export enum VariableType {
/**
* @en
* A floating.
* @zh
* 浮点数。
*/
FLOAT,
/**
* @en
* A boolean.
* @zh
* 布尔值。
*/
BOOLEAN,
/**
* @en
* A trigger.
* @zh
* 触发器。
*/
TRIGGER,
/**
* @en
* An integer.
* @zh
* 整数。
*/
INTEGER,
}
/**
* @en The reset mode of boolean variables. It indicates when to reset the variable as `false`.
* @zh 布尔类型变量的重置模式,指示在哪些情况下将变量重置为 `false`。
*/
export enum TriggerResetMode {
/**
* @en The variable is reset when it's consumed by animation transition.
* @zh 在该变量被动画过渡消耗后自动重置。
*/
AFTER_CONSUMED,
/**
* @en The variable is reset in next frame or when it's consumed by animation transition.
* @zh 下一帧自动重置;在该变量被动画过渡消耗后也会自动重置。
*/
NEXT_FRAME_OR_AFTER_CONSUMED,
@@ -23,16 +23,12 @@
THE SOFTWARE.
*/
import { binarySearchEpsilon as binarySearch } from '../algorithm/binary-search';
import { errorID } from '../platform/debug';
import { Vec2, Vec3 } from '../math';
import { AnimCurve, computeRatioByType, CurveValue, EasingMethod } from './animation-curve';
import { bezier } from './bezier';
export class Curve {
public beziers: Bezier[] = [];
-5
View File
@@ -23,11 +23,6 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module animation
*/
import { getError } from '../platform/debug';
export class Playable {

Some files were not shown because too many files have changed in this diff Show More