Merge pull request #8378 from holycanvas/develop

merge v3.0.1
This commit is contained in:
Santy-Wang
2021-03-18 16:41:33 +08:00
committed by GitHub
356 changed files with 20237 additions and 77588 deletions
+2 -2
View File
@@ -45,7 +45,7 @@ The engine is naturally integrated within Cocos Creator, designed to only be the
### Prerequisite
- Install [node.js v9.11.2 +](https://nodejs.org/)
- Install [gulp-cli v3.9.0 +](https://github.com/gulpjs/gulp/tree/master/docs/getting-started)
- Install [gulp-cli v2.3.0 +](https://github.com/gulpjs/gulp/tree/master/docs/getting-started)
### Install
@@ -65,7 +65,7 @@ This is all you have to do to setup engine development environment.
- Outside the editor, you need to run the following command to build:
```bash
npm run build:dev
npm run build
```
## Example Project
+2
View File
@@ -101,6 +101,8 @@ export const bmfontUtils = {
_uiTrans.setContentSize(_contentSize);
_comp.renderData!.vertDirty = _comp.renderData!.uvDirty = false;
// fix bmfont run updateRenderData twice bug
_comp.markForUpdateRenderData(false);
_comp = null;
+128 -121
View File
@@ -28,8 +28,9 @@
* @hidden
*/
import { IUV } from '../../assets';
import { Mat4, Vec3, Color } from '../../../core/math';
import { IRenderData } from '../../renderer/render-data';
import { IRenderData, RenderData } from '../../renderer/render-data';
import { Batcher2D } from '../../renderer/batcher-2d';
import { Sprite } from '../../components/sprite';
import { Renderable2D } from '../../framework/renderable-2d';
@@ -42,24 +43,7 @@ for (let i = 0; i < 4; i++) {
const _perVertexLength = 9;
interface ITiledAssembler extends IAssembler {
sizableWidth: number;
sizableHeight: number;
vRepeat: number;
hRepeat: number;
row: number;
col: number;
}
export const tiled: ITiledAssembler = {
useModel: false,
sizableWidth: 0,
sizableHeight: 0,
vRepeat: 0,
hRepeat: 0,
row: 0,
col: 0,
export const tiled: IAssembler = {
createData (sprite: Renderable2D) {
return sprite.requestRenderData();
},
@@ -83,29 +67,32 @@ export const tiled: ITiledAssembler = {
const bottomHeight = frame.insetBottom;
const centerHeight = rect.height - topHeight - bottomHeight;
this.sizableWidth = contentWidth - leftWidth - rightWidth;
this.sizableHeight = contentHeight - topHeight - bottomHeight;
this.sizableWidth = this.sizableWidth > 0 ? this.sizableWidth : 0;
this.sizableHeight = this.sizableHeight > 0 ? this.sizableHeight : 0;
let sizableWidth = contentWidth - leftWidth - rightWidth;
let sizableHeight = contentHeight - topHeight - bottomHeight;
sizableWidth = sizableWidth > 0 ? sizableWidth : 0;
sizableHeight = sizableHeight > 0 ? sizableHeight : 0;
this.hRepeat = centerWidth === 0 ? this.sizableWidth : this.sizableWidth / centerWidth;
this.vRepeat = centerHeight === 0 ? this.sizableHeight : this.sizableHeight / centerHeight;
this.row = Math.ceil(this.vRepeat + 2);
this.col = Math.ceil(this.hRepeat + 2);
const hRepeat = centerWidth === 0 ? sizableWidth : sizableWidth / centerWidth;
const vRepeat = centerHeight === 0 ? sizableHeight : sizableHeight / centerHeight;
const row = Math.ceil(vRepeat + 2);
const col = Math.ceil(hRepeat + 2);
renderData.dataLength = Math.max(8, this.row + 1, this.col + 1);
renderData.dataLength = Math.max(8, row + 1, col + 1);
this.updateVerts(sprite);
this.updateVerts(sprite, sizableWidth, sizableHeight, row, col);
// update data property
renderData.vertexCount = this.row * this.col * 4;
renderData.indicesCount = this.row * this.col * 6;
renderData.vertexCount = row * col * 4;
renderData.indicesCount = row * col * 6;
renderData.uvDirty = false;
renderData.vertDirty = false;
},
fillBuffers (sprite: Sprite, renderer: Batcher2D) {
const node = sprite.node;
const uiTrans = sprite.node._uiProps.uiTransformComp!;
const contentWidth = Math.abs(uiTrans.width);
const contentHeight = Math.abs(uiTrans.height);
const renderData = sprite.renderData!;
// buffer
@@ -130,7 +117,7 @@ export const tiled: ITiledAssembler = {
const frame = sprite.spriteFrame!;
const rotated = frame.isRotated();
const uv = frame.uv;
const uvSliced = frame.uvSliced;
const uvSliced: IUV[] = sprite.spriteFrame!.uvSliced;
const rect = frame.getRect();
const leftWidth = frame.insetLeft;
const rightWidth = frame.insetRight;
@@ -138,101 +125,120 @@ export const tiled: ITiledAssembler = {
const topHeight = frame.insetTop;
const bottomHeight = frame.insetBottom;
const centerHeight = rect.height - topHeight - bottomHeight;
let sizableWidth = contentWidth - leftWidth - rightWidth;
let sizableHeight = contentHeight - topHeight - bottomHeight;
sizableWidth = sizableWidth > 0 ? sizableWidth : 0;
sizableHeight = sizableHeight > 0 ? sizableHeight : 0;
const hRepeat = centerWidth === 0 ? sizableWidth : sizableWidth / centerWidth;
const vRepeat = centerHeight === 0 ? sizableHeight : sizableHeight / centerHeight;
const row = Math.ceil(vRepeat + 2);
const col = Math.ceil(hRepeat + 2);
const matrix = node.worldMatrix;
this.fillVertices(vBuf, vertexOffset, matrix, this.row, this.col, renderData.data);
this.fillVertices(vBuf, vertexOffset, matrix, row, col, renderData.data);
const offset = _perVertexLength;
const offset1 = offset; const offset2 = offset * 2; const offset3 = offset * 3; const offset4 = offset * 4;
let coefU = 0; let coefV = 0;
for (let yIndex = 0, yLength = this.row; yIndex < yLength; ++yIndex) {
if (this.sizableHeight > centerHeight) {
if (this.sizableHeight >= yIndex * centerHeight) {
const tempXVerts :any = [];
const tempYVerts :any = [];
for (let yIndex = 0, yLength = row; yIndex < yLength; ++yIndex) {
if (sizableHeight > centerHeight) {
if (sizableHeight >= yIndex * centerHeight) {
coefV = 1;
} else {
coefV = this.vRepeat % 1;
coefV = vRepeat % 1;
}
} else {
coefV = this.vRepeat;
coefV = vRepeat;
}
for (let xIndex = 0, xLength = this.col; xIndex < xLength; ++xIndex) {
if (this.sizableWidth > centerWidth) {
if (this.sizableWidth >= xIndex * centerWidth) {
for (let xIndex = 0, xLength = col; xIndex < xLength; ++xIndex) {
if (sizableWidth > centerWidth) {
if (sizableWidth >= xIndex * centerWidth) {
coefU = 1;
} else {
coefU = this.hRepeat % 1;
coefU = hRepeat % 1;
}
} else {
coefU = this.hRepeat;
coefU = hRepeat;
}
const vertexOffsetU = vertexOffset + 3;
const vertexOffsetV = vertexOffsetU + 1;
// UV
if (rotated) {
// lb
vBuf[vertexOffsetU] = uv[0];
vBuf[vertexOffsetV] = uv[1];
// rb
vBuf[vertexOffsetU + offset1] = uv[0];
vBuf[vertexOffsetV + offset1] = uv[1] + (uv[7] - uv[1]) * coefU;
// lt
vBuf[vertexOffsetU + offset2] = uv[0] + (uv[6] - uv[0]) * coefV;
vBuf[vertexOffsetV + offset2] = uv[1];
// rt
vBuf[vertexOffsetU + offset3] = vBuf[vertexOffsetU + offset2];
vBuf[vertexOffsetV + offset3] = vBuf[vertexOffsetV + offset1];
if (yIndex === 0) {
tempXVerts[0] = uvSliced[0].u;
tempXVerts[1] = uvSliced[0].u;
tempXVerts[2] = uvSliced[4].u + (uvSliced[8].u - uvSliced[4].u) * coefV;
} else if (yIndex < (row - 1)) {
tempXVerts[0] = uvSliced[4].u;
tempXVerts[1] = uvSliced[4].u;
tempXVerts[2] = uvSliced[4].u + (uvSliced[8].u - uvSliced[4].u) * coefV;
} else if (yIndex === (row - 1)) {
tempXVerts[0] = uvSliced[8].u;
tempXVerts[1] = uvSliced[8].u;
tempXVerts[2] = uvSliced[12].u;
}
if (xIndex === 0) {
tempYVerts[0] = uvSliced[0].v;
tempYVerts[1] = uvSliced[1].v + (uvSliced[2].v - uvSliced[1].v) * coefU;
tempYVerts[2] = uvSliced[0].v;
} else if (xIndex < (col - 1)) {
tempYVerts[0] = uvSliced[1].v;
tempYVerts[1] = uvSliced[1].v + (uvSliced[2].v - uvSliced[1].v) * coefU;
tempYVerts[2] = uvSliced[1].v;
} else if (xIndex === (col - 1)) {
tempYVerts[0] = uvSliced[2].v;
tempYVerts[1] = uvSliced[3].v;
tempYVerts[2] = uvSliced[2].v;
}
tempXVerts[3] = tempXVerts[2];
tempYVerts[3] = tempYVerts[1];
} else {
// lb
if (xIndex === 0) {
vBuf[vertexOffsetU] = uv[0];
} else if (xIndex > 0 && xIndex < (this.col - 1)) {
vBuf[vertexOffsetU] = uvSliced[1].u;
} else if (xIndex === (this.col - 1)) {
vBuf[vertexOffsetU] = uvSliced[2].u;
tempXVerts[0] = uvSliced[0].u;
tempXVerts[1] = uvSliced[1].u + (uvSliced[2].u - uvSliced[1].u) * coefU;
tempXVerts[2] = uv[0];
} else if (xIndex < (col - 1)) {
tempXVerts[0] = uvSliced[1].u;
tempXVerts[1] = uvSliced[1].u + (uvSliced[2].u - uvSliced[1].u) * coefU;
tempXVerts[2] = uvSliced[1].u;
} else if (xIndex === (col - 1)) {
tempXVerts[0] = uvSliced[2].u;
tempXVerts[1] = uvSliced[3].u;
tempXVerts[2] = uvSliced[2].u;
}
if (yIndex === 0) {
vBuf[vertexOffsetV] = uvSliced[0].v;
} else if (yIndex > 0 && yIndex < (this.row - 1)) {
vBuf[vertexOffsetV] = uvSliced[4].v;
} else if (yIndex === (this.row - 1)) {
vBuf[vertexOffsetV] = uvSliced[8].v;
tempYVerts[0] = uvSliced[0].v;
tempYVerts[1] = uvSliced[0].v;
tempYVerts[2] = uvSliced[4].v + (uvSliced[8].v - uvSliced[4].v) * coefV;
} else if (yIndex < (row - 1)) {
tempYVerts[0] = uvSliced[4].v;
tempYVerts[1] = uvSliced[4].v;
tempYVerts[2] = uvSliced[4].v + (uvSliced[8].v - uvSliced[4].v) * coefV;
} else if (yIndex === (row - 1)) {
tempYVerts[0] = uvSliced[8].v;
tempYVerts[1] = uvSliced[8].v;
tempYVerts[2] = uvSliced[12].v;
}
// rb
if (xIndex === 0) {
vBuf[vertexOffsetU + offset1] = uvSliced[1].u + (uvSliced[2].u - uvSliced[1].u) * coefU;
} else if (xIndex > 0 && xIndex < (this.col - 1)) {
vBuf[vertexOffsetU + offset1] = uvSliced[1].u + (uvSliced[2].u - uvSliced[1].u) * coefU;
} else if (xIndex === (this.col - 1)) {
vBuf[vertexOffsetU + offset1] = uvSliced[3].u;
}
if (yIndex === 0) {
vBuf[vertexOffsetV + offset1] = uvSliced[0].v;
} else if (yIndex > 0 && yIndex < (this.row - 1)) {
vBuf[vertexOffsetV + offset1] = uvSliced[4].v;
} else if (yIndex === (this.row - 1)) {
vBuf[vertexOffsetV + offset1] = uvSliced[8].v;
}
// lt
if (xIndex === 0) {
vBuf[vertexOffsetU + offset2] = uv[0];
} else if (xIndex > 0 && xIndex < (this.col - 1)) {
vBuf[vertexOffsetU + offset2] = uvSliced[1].u;
} else if (xIndex === (this.col - 1)) {
vBuf[vertexOffsetU + offset2] = uvSliced[2].u;
}
if (yIndex === 0) {
vBuf[vertexOffsetV + offset2] = uvSliced[4].v + (uvSliced[8].v - uvSliced[4].v) * coefV;
} else if (yIndex > 0 && yIndex < (this.row - 1)) {
vBuf[vertexOffsetV + offset2] = uvSliced[4].v + (uvSliced[8].v - uvSliced[4].v) * coefV;
} else if (yIndex === (this.row - 1)) {
vBuf[vertexOffsetV + offset2] = uvSliced[12].v;
}
// rt
vBuf[vertexOffsetU + offset3] = vBuf[vertexOffsetU + offset1];
vBuf[vertexOffsetV + offset3] = vBuf[vertexOffsetV + offset2];
tempXVerts[3] = tempXVerts[1];
tempYVerts[3] = tempYVerts[2];
}
// lb
vBuf[vertexOffsetU] = tempXVerts[0];
vBuf[vertexOffsetV] = tempYVerts[0];
// rb
vBuf[vertexOffsetU + offset1] = tempXVerts[1];
vBuf[vertexOffsetV + offset1] = tempYVerts[1];
// lt
vBuf[vertexOffsetU + offset2] = tempXVerts[2];
vBuf[vertexOffsetV + offset2] = tempYVerts[2];
// rt
vBuf[vertexOffsetU + offset3] = tempXVerts[3];
vBuf[vertexOffsetV + offset3] = tempYVerts[3];
// color
Color.toArray(vBuf, sprite.color, vertexOffsetV + 1);
Color.toArray(vBuf, sprite.color, vertexOffsetV + offset1 + 1);
@@ -282,9 +288,10 @@ export const tiled: ITiledAssembler = {
}
},
updateVerts (sprite: Sprite) {
updateVerts (sprite: Sprite, sizableWidth: number, sizableHeight: number, row: number, col: number) {
const uiTrans = sprite.node._uiProps.uiTransformComp!;
const data = sprite.renderData!.data;
const renderData: RenderData | null = sprite.renderData;
const data: IRenderData[] = renderData!.data;
const frame = sprite.spriteFrame!;
const rect = frame.getRect();
@@ -309,52 +316,52 @@ export const tiled: ITiledAssembler = {
* Because the float numerical calculation in javascript is not accurate enough,
* there is an expected result of 1.0, but the actual result is 1.000001.
*/
offsetWidth = Math.floor(this.sizableWidth * 1000) / 1000 % centerWidth === 0 ? centerWidth : this.sizableWidth % centerWidth;
offsetWidth = Math.floor(sizableWidth * 1000) / 1000 % centerWidth === 0 ? centerWidth : sizableWidth % centerWidth;
} else {
offsetWidth = this.sizableWidth;
offsetWidth = sizableWidth;
}
if (centerHeight > 0) {
offsetHeight = Math.floor(this.sizableHeight * 1000) / 1000 % centerHeight === 0 ? centerHeight : this.sizableHeight % centerHeight;
offsetHeight = Math.floor(sizableHeight * 1000) / 1000 % centerHeight === 0 ? centerHeight : sizableHeight % centerHeight;
} else {
offsetHeight = this.sizableHeight;
offsetHeight = sizableHeight;
}
for (let i = 0; i <= this.col; i++) {
for (let i = 0; i <= col; i++) {
if (i === 0) {
data[i].x = -appx;
} else if (i > 0 && i < this.col) {
} else if (i > 0 && i < col) {
if (i === 1) {
data[i].x = leftWidth * xScale + Math.min(centerWidth, this.sizableWidth) - appx;
data[i].x = leftWidth * xScale + Math.min(centerWidth, sizableWidth) - appx;
} else if (centerWidth > 0) {
if (i === (this.col - 1)) {
if (i === (col - 1)) {
data[i].x = leftWidth + offsetWidth + centerWidth * (i - 2) - appx;
} else {
data[i].x = leftWidth + Math.min(centerWidth, this.sizableWidth) + centerWidth * (i - 2) - appx;
data[i].x = leftWidth + Math.min(centerWidth, sizableWidth) + centerWidth * (i - 2) - appx;
}
} else {
data[i].x = leftWidth + this.sizableWidth - appx;
data[i].x = leftWidth + sizableWidth - appx;
}
} else if (i === this.col) {
data[i].x = Math.min(leftWidth + this.sizableWidth + rightWidth, contentWidth) - appx;
} else if (i === col) {
data[i].x = Math.min(leftWidth + sizableWidth + rightWidth, contentWidth) - appx;
}
}
for (let i = 0; i <= this.row; i++) {
for (let i = 0; i <= row; i++) {
if (i === 0) {
data[i].y = -appy;
} else if (i > 0 && i < this.row) {
} else if (i > 0 && i < row) {
if (i === 1) {
data[i].y = bottomHeight * yScale + Math.min(centerHeight, this.sizableHeight) - appy;
data[i].y = bottomHeight * yScale + Math.min(centerHeight, sizableHeight) - appy;
} else if (centerHeight > 0) {
if (i === (this.row - 1)) {
if (i === (row - 1)) {
data[i].y = bottomHeight + offsetHeight + (i - 2) * centerHeight - appy;
} else {
data[i].y = bottomHeight + Math.min(centerHeight, this.sizableHeight) + (i - 2) * centerHeight - appy;
data[i].y = bottomHeight + Math.min(centerHeight, sizableHeight) + (i - 2) * centerHeight - appy;
}
} else {
data[i].y = bottomHeight + this.sizableHeight - appy;
data[i].y = bottomHeight + sizableHeight - appy;
}
} else if (i === this.row) {
data[i].y = Math.min(bottomHeight + this.sizableHeight + topHeight, contentHeight) - appy;
} else if (i === row) {
data[i].y = Math.min(bottomHeight + sizableHeight + topHeight, contentHeight) - appy;
}
}
},
+5
View File
@@ -1,3 +1,8 @@
/**
* @packageDocumentation
* @module asset
*/
export * from './sprite-frame';
export { SpriteAtlas } from './sprite-atlas';
export { TTFFont } from './ttf-font';
+22 -25
View File
@@ -518,7 +518,7 @@ export class SpriteFrame extends Asset {
protected _capInsets = [0, 0, 0, 0];
protected _atlasUuid = '';
// @ts-expect-error
// @ts-expect-error not set value at there
protected _texture: TextureBase | RenderTexture;
protected _isFlipUVY = false;
@@ -811,15 +811,14 @@ export class SpriteFrame extends Asset {
const uvSliced = this.uvSliced;
uvSliced.length = 0;
if (this._rotated) {
// Canceling out the floating-point rounding errors by slightly nudging the UV coordinates
temp_uvs[0].u = (rect.x + 0.5) / atlasWidth;
temp_uvs[0].u = rect.x / atlasWidth;
temp_uvs[1].u = (rect.x + bottomHeight) / atlasWidth;
temp_uvs[2].u = (rect.x + bottomHeight + centerHeight) / atlasWidth;
temp_uvs[3].u = (rect.x + rect.height - 0.5) / atlasWidth;
temp_uvs[3].v = (rect.y + 0.5) / atlasHeight;
temp_uvs[3].u = (rect.x + rect.height) / atlasWidth;
temp_uvs[3].v = rect.y / atlasHeight;
temp_uvs[2].v = (rect.y + leftWidth) / atlasHeight;
temp_uvs[1].v = (rect.y + leftWidth + centerWidth) / atlasHeight;
temp_uvs[0].v = (rect.y + rect.width - 0.5) / atlasHeight;
temp_uvs[0].v = (rect.y + rect.width) / atlasHeight;
for (let row = 0; row < 4; ++row) {
const rowD = temp_uvs[row];
@@ -832,15 +831,14 @@ export class SpriteFrame extends Asset {
}
}
} else {
// Canceling out the floating-point rounding errors by slightly nudging the UV coordinates
temp_uvs[0].u = (rect.x + 0.5) / atlasWidth;
temp_uvs[0].u = rect.x / atlasWidth;
temp_uvs[1].u = (rect.x + leftWidth) / atlasWidth;
temp_uvs[2].u = (rect.x + leftWidth + centerWidth) / atlasWidth;
temp_uvs[3].u = (rect.x + rect.width - 0.5) / atlasWidth;
temp_uvs[3].v = (rect.y + 0.5) / atlasHeight;
temp_uvs[3].u = (rect.x + rect.width) / atlasWidth;
temp_uvs[3].v = rect.y / atlasHeight;
temp_uvs[2].v = (rect.y + topHeight) / atlasHeight;
temp_uvs[1].v = (rect.y + topHeight + centerHeight) / atlasHeight;
temp_uvs[0].v = (rect.y + rect.height - 0.5) / atlasHeight;
temp_uvs[0].v = (rect.y + rect.height) / atlasHeight;
for (let row = 0; row < 4; ++row) {
const rowD = temp_uvs[row];
@@ -865,11 +863,10 @@ export class SpriteFrame extends Asset {
const texh = tex.height;
if (this._rotated) {
// Canceling out the floating-point rounding errors by slightly nudging the UV coordinates
const l = texw === 0 ? 0 : (rect.x + 0.5) / texw;
const r = texw === 0 ? 0 : (rect.x + rect.height - 0.5) / texw;
const t = texh === 0 ? 0 : (rect.y + 0.5) / texh;
const b = texh === 0 ? 0 : (rect.y + rect.width - 0.5) / texh;
const l = texw === 0 ? 0 : rect.x / texw;
const r = texw === 0 ? 0 : (rect.x + rect.height) / texw;
const t = texh === 0 ? 0 : rect.y / texh;
const b = texh === 0 ? 0 : (rect.y + rect.width) / texh;
if (this._isFlipUVX && this._isFlipUVY) {
/*
@@ -929,9 +926,9 @@ export class SpriteFrame extends Asset {
uv[7] = b;
}
const ul = texw === 0 ? 0 : (rect.x) / texw;
const ul = texw === 0 ? 0 : rect.x / texw;
const ur = texw === 0 ? 0 : (rect.x + rect.height) / texw;
const ut = texh === 0 ? 0 : (rect.y) / texh;
const ut = texh === 0 ? 0 : rect.y / texh;
const ub = texh === 0 ? 0 : (rect.y + rect.width) / texh;
if (this._isFlipUVX && this._isFlipUVY) {
unbiasUV[0] = ur;
@@ -971,11 +968,10 @@ export class SpriteFrame extends Asset {
unbiasUV[7] = ub;
}
} else {
// Canceling out the floating-point rounding errors by slightly nudging the UV coordinates
const l = texw === 0 ? 0 : (rect.x + 0.5) / texw;
const r = texw === 0 ? 0 : (rect.x + rect.width - 0.5) / texw;
const b = texh === 0 ? 0 : (rect.y + rect.height - 0.5) / texh;
const t = texh === 0 ? 0 : (rect.y + 0.5) / texh;
const l = texw === 0 ? 0 : rect.x / texw;
const r = texw === 0 ? 0 : (rect.x + rect.width) / texw;
const b = texh === 0 ? 0 : (rect.y + rect.height) / texh;
const t = texh === 0 ? 0 : rect.y / texh;
if (this._isFlipUVX && this._isFlipUVY) {
/*
1 - 0
@@ -1033,10 +1029,10 @@ export class SpriteFrame extends Asset {
uv[6] = r;
uv[7] = t;
}
const ul = texw === 0 ? 0 : (rect.x) / texw;
const ul = texw === 0 ? 0 : rect.x / texw;
const ur = texw === 0 ? 0 : (rect.x + rect.width) / texw;
const ub = texh === 0 ? 0 : (rect.y + rect.height) / texh;
const ut = texh === 0 ? 0 : (rect.y) / texh;
const ut = texh === 0 ? 0 : rect.y / texh;
if (this._isFlipUVX && this._isFlipUVY) {
unbiasUV[0] = ur;
unbiasUV[1] = ut;
@@ -1183,6 +1179,7 @@ export class SpriteFrame extends Asset {
// 为 underfined 的数据则不在序列化文件里显示
return serialize;
}
return null;
}
public _deserialize (serializeData: any, handle: any) {
+10 -10
View File
@@ -99,7 +99,7 @@ export class Graphics extends Renderable2D {
* 用来设置2个长度不为0的相连部分(线段,圆弧,曲线)如何连接在一起的属性。
*/
@type(LineJoin)
@tooltip('两条线相交时,所创建的拐角类型')
@tooltip('i18n:graphics.lineJoin')
get lineJoin () {
return this._lineJoin;
}
@@ -121,7 +121,7 @@ export class Graphics extends Renderable2D {
* 指定如何绘制每一条线段末端。
*/
@type(LineCap)
@tooltip('线条的结束端点样式')
@tooltip('i18n:graphics.lineCap')
get lineCap () {
return this._lineCap;
}
@@ -137,12 +137,12 @@ export class Graphics extends Renderable2D {
/**
* @en
* Stroke color.
* Brush stroke color.
*
* @zh
* 线段颜色。
* 笔触的颜色。
*/
@tooltip('笔触的颜色')
@tooltip('i18n:graphics.strokeColor')
// @constget
get strokeColor (): Readonly<Color> {
return this._strokeColor;
@@ -159,12 +159,12 @@ export class Graphics extends Renderable2D {
/**
* @en
* Fill color.
* Fill paint color.
*
* @zh
* 填充颜色。
* 填充绘画的颜色。
*/
@tooltip('填充绘画的颜色')
@tooltip('i18n:graphics.fillColor')
// @constget
get fillColor (): Readonly<Color> {
return this._fillColor;
@@ -181,12 +181,12 @@ export class Graphics extends Renderable2D {
/**
* @en
* Sets the miter limit ratio.
* Set the miter limit ratio.
*
* @zh
* 设置斜接面限制比例。
*/
@tooltip('最大斜接长度')
@tooltip('i18n:graphics.miterLimit')
get miterLimit () {
return this._miterLimit;
}
+2 -2
View File
@@ -77,7 +77,7 @@ export class LabelOutline extends Component {
* outline.color = new Color(0.5, 0.3, 0.7, 1.0);
* ```
*/
@tooltip('描边的颜色')
@tooltip('i18n:labelOutline.color')
// @constget
get color (): Readonly<Color> {
return this._color;
@@ -104,7 +104,7 @@ export class LabelOutline extends Component {
* outline.width = 3;
* ```
*/
@tooltip('描边的宽度')
@tooltip('i18n:labelOutline.width')
get width () {
return this._width;
}
+3 -3
View File
@@ -73,7 +73,7 @@ export class LabelShadow extends Component {
* labelShadow.color = new Color(0.5, 0.3, 0.7, 1.0);
* ```
*/
@tooltip('描边的颜色')
@tooltip('i18n:labelShadow.color')
get color (): Readonly<Color> {
return this._color;
}
@@ -100,7 +100,7 @@ export class LabelShadow extends Component {
* labelShadow.offset = new Vec2(2, 2);
* ```
*/
@tooltip('字体与阴影的偏移')
@tooltip('i18n:labelShadow.offset')
get offset () {
return this._offset;
}
@@ -122,7 +122,7 @@ export class LabelShadow extends Component {
* labelShadow.blur = 2;
* ```
*/
@tooltip('阴影的模糊程度')
@tooltip('i18n:labelShadow.blur')
get blur () {
return this._blur;
}
+43 -15
View File
@@ -37,7 +37,9 @@ import { ccenum } from '../../core/value-types/enum';
import { Batcher2D } from '../renderer/batcher-2d';
import { FontAtlas } from '../assets/bitmap-font';
import { CanvasPool, ISharedLabelData, LetterRenderTexture } from '../assembler/label/font-utils';
import { Renderable2D } from '../framework/renderable-2d';
import { InstanceMaterialType, Renderable2D } from '../framework/renderable-2d';
import { TextureBase } from '../../core/assets/texture-base';
import { PixelFormat } from '../../core/assets/asset-enum';
/**
* @en Enum for horizontal text alignment.
@@ -198,7 +200,7 @@ export class Label extends Renderable2D {
* 标签显示的文本内容。
*/
@displayOrder(4)
@tooltip('Label 显示的文本内容字符串')
@tooltip('i18n:label.string')
@multiline
get string () {
return this._string;
@@ -222,7 +224,7 @@ export class Label extends Renderable2D {
*/
@type(HorizontalTextAlignment)
@displayOrder(5)
@tooltip('文字水平对齐模式')
@tooltip('i18n:label.horizontal_align')
get horizontalAlign () {
return this._horizontalAlign;
}
@@ -245,7 +247,7 @@ export class Label extends Renderable2D {
*/
@type(VerticalTextAlignment)
@displayOrder(6)
@tooltip('文字垂直对齐模式')
@tooltip('i18n:label.vertical_align')
get verticalAlign () {
return this._verticalAlign;
}
@@ -282,7 +284,7 @@ export class Label extends Renderable2D {
* 文本字体大小。
*/
@displayOrder(7)
@tooltip('文字尺寸,以 point 为单位')
@tooltip('i18n:label.font_size')
get fontSize () {
return this._fontSize;
}
@@ -305,7 +307,7 @@ export class Label extends Renderable2D {
*/
@displayOrder(8)
@visible(function (this: Label) { return !this._isSystemFontUsed; })
@tooltip('文字字体名字')
@tooltip('i18n:label.font_family')
get fontFamily () {
return this._fontFamily;
}
@@ -327,7 +329,7 @@ export class Label extends Renderable2D {
* 文本行高。
*/
@displayOrder(8)
@tooltip('文字行高,以 point 为单位')
@tooltip('i18n:label.line_height')
get lineHeight () {
return this._lineHeight;
}
@@ -349,7 +351,7 @@ export class Label extends Renderable2D {
*/
@type(Overflow)
@displayOrder(9)
@tooltip('文字排版模式,包括以下三种:\n 1. CLAMP: 节点约束框之外的文字会被截断 \n 2. SHRINK: 自动根据节点约束框缩小文字\n 3. RESIZE_HEIGHT: 根据文本内容自动更新节点的 height 属性.')
@tooltip('i18n:label.overflow')
get overflow () {
return this._overflow;
}
@@ -371,7 +373,7 @@ export class Label extends Renderable2D {
* 是否自动换行。
*/
@displayOrder(10)
@tooltip('自动换行')
@tooltip('i18n:label.wrap')
get enableWrapText () {
return this._enableWrapText;
}
@@ -394,7 +396,7 @@ export class Label extends Renderable2D {
@type(Font)
@displayOrder(11)
@visible(function (this: Label) { return !this._isSystemFontUsed; })
@tooltip('Label 使用的字体资源')
@tooltip('i18n:label.font')
get font () {
// return this._N$file;
return this._font;
@@ -434,7 +436,7 @@ export class Label extends Renderable2D {
* 是否使用系统字体。
*/
@displayOrder(12)
@tooltip('是否使用系统默认字体')
@tooltip('i18n:label.system_font')
get useSystemFont () {
return this._isSystemFontUsed;
}
@@ -472,7 +474,7 @@ export class Label extends Renderable2D {
*/
@type(CacheMode)
@displayOrder(13)
@tooltip('文本缓存模式,包括以下三种:\n 1. NONE: 不做任何缓存,文本内容进行一次绘制 \n 2. BITMAP: 将文本作为静态图像加入动态图集进行批次合并,但是不能频繁动态修改文本内容 \n 3. CHAR: 将文本拆分为字符并且把字符纹理缓存到一张字符图集中进行复用,适用于字符内容重复并且频繁更新的文本内容')
@tooltip('i18n:label.cache_mode')
get cacheMode () {
return this._cacheMode;
}
@@ -510,7 +512,7 @@ export class Label extends Renderable2D {
* 字体是否加粗。
*/
@displayOrder(15)
@tooltip('字体加粗')
@tooltip('i18n:label.font_bold')
get isBold () {
return this._isBold;
}
@@ -532,7 +534,7 @@ export class Label extends Renderable2D {
* 字体是否倾斜。
*/
@displayOrder(16)
@tooltip('字体倾斜')
@tooltip('i18n:label.font_italic')
get isItalic () {
return this._isItalic;
}
@@ -554,7 +556,7 @@ export class Label extends Renderable2D {
* 字体是否加下划线。
*/
@displayOrder(17)
@tooltip('字体加下划线')
@tooltip('i18n:label.font_underline')
get isUnderline () {
return this._isUnderline;
}
@@ -724,6 +726,8 @@ export class Label extends Renderable2D {
if (force) {
this._flushAssembler();
// Hack: Fixed the bug that richText wants to get the label length by _measureText, _assembler.updateRenderData will update the content size immediately.
if (this.renderData) this.renderData.vertDirty = true;
this._applyFontTexture();
}
}
@@ -780,6 +784,7 @@ export class Label extends Renderable2D {
const onBMFontTextureLoaded = () => {
// TODO: old texture in material have been released by loader
this._texture = spriteFrame;
this.changeMaterialForDefine();
if (this._assembler) {
this._assembler.updateRenderData(this);
}
@@ -808,6 +813,29 @@ export class Label extends Renderable2D {
// this._frame._refreshTexture(this._texture);
this._texture = this._ttfSpriteFrame;
}
this.changeMaterialForDefine();
this._assembler && this._assembler.updateRenderData(this);
}
}
protected changeMaterialForDefine () {
if (!this._texture) {
return;
}
let value = false;
if (this.cacheMode !== CacheMode.CHAR) {
const spriteFrame = this._texture as SpriteFrame;
const texture = spriteFrame.texture;
if (texture instanceof TextureBase) {
const format = texture.getPixelFormat();
value = (format === PixelFormat.RGBA_ETC1 || format === PixelFormat.RGB_A_PVRTC_4BPPV1 || format === PixelFormat.RGB_A_PVRTC_2BPPV1);
}
}
if (value) {
this._instanceMaterialType = InstanceMaterialType.USE_ALPHA_SEPARATED;
} else {
this._instanceMaterialType = InstanceMaterialType.ADD_COLOR_AND_TEXTURE;
}
this.updateMaterial();
}
}
+10 -13
View File
@@ -32,19 +32,20 @@
import { ccclass, help, executionOrder, menu, tooltip, displayOrder, type, visible, override, serializable, range, slide } from 'cc.decorator';
import { InstanceMaterialType, Renderable2D } from '../framework/renderable-2d';
import { clamp, Color, Mat4, Vec2, Vec3 } from '../../core/math';
import { warnID } from '../../core/platform';
import { SystemEventType, warnID } from '../../core/platform';
import { Batcher2D } from '../renderer/batcher-2d';
import { ccenum } from '../../core/value-types/enum';
import { Graphics } from './graphics';
import { TransformBit } from '../../core/scene-graph/node-enum';
import { SpriteFrame } from '../assets/sprite-frame';
import { Game, Material, builtinResMgr, director, RenderingSubMesh } from '../../core';
import { Game, Material, builtinResMgr, director, RenderingSubMesh, CCObject } from '../../core';
import { Device, BufferInfo, BufferUsageBit, MemoryUsageBit, PrimitiveMode } from '../../core/gfx';
import { legacyCC } from '../../core/global-exports';
import { MaterialInstance, scene } from '../../core/renderer';
import { Model } from '../../core/renderer/scene';
import { vfmt, getAttributeStride } from '../renderer/vertex-format';
import { Stage } from '../renderer/stencil-manager';
import { NodeEventProcessor } from '../../core/scene-graph/node-event-processor';
const _worldMatrix = new Mat4();
const _vec2_temp = new Vec2();
@@ -126,7 +127,7 @@ export class Mask extends Renderable2D {
*/
@type(MaskType)
@displayOrder(10)
@tooltip('遮罩类型')
@tooltip('i18n:mask.type')
get type () {
return this._type;
}
@@ -168,7 +169,7 @@ export class Mask extends Renderable2D {
* 反向遮罩(不支持 Canvas 模式)。
*/
@displayOrder(14)
@tooltip('反向遮罩')
@tooltip('i18n:mask.inverted')
get inverted () {
return this._inverted;
}
@@ -368,7 +369,6 @@ export class Mask extends Renderable2D {
public onEnable () {
super.onEnable();
this._updateGraphics();
this._broadcastToNode(this.node);
}
/**
@@ -377,7 +377,9 @@ export class Mask extends Renderable2D {
*/
public onRestore () {
this._createGraphics();
super.updateMaterial();
this._updateGraphics();
this._renderFlag = this._canRender();
}
public onDisable () {
@@ -481,6 +483,7 @@ export class Mask extends Renderable2D {
protected _createGraphics () {
if (!this._graphics) {
const graphics = this._graphics = new Graphics();
graphics._objFlags |= CCObject.Flags.IsOnLoadCalled;// hack for destroy
graphics.node = this.node;
graphics.node.getWorldMatrix();
graphics.lineWidth = 0;
@@ -605,14 +608,8 @@ export class Mask extends Renderable2D {
}
}
}
protected _broadcastToNode (node) {
const children = node.children;
node.eventProcessor.registerComponentHitList(Mask);
for (let i = 0, len = children.length; i < len; i++) {
this._broadcastToNode(children[i]);
}
}
}
NodeEventProcessor._comp = Mask;
legacyCC.Mask = Mask;
+11 -11
View File
@@ -157,7 +157,7 @@ export class RichText extends UIComponent {
* 富文本显示的文本内容。
*/
@multiline
@tooltip('富文本显示的文本内容')
@tooltip('i18n:richtext.string')
get string () {
return this._string;
}
@@ -178,7 +178,7 @@ export class RichText extends UIComponent {
* 文本内容的水平对齐方式。
*/
@type(HorizontalTextAlignment)
@tooltip('文本内容的水平对齐方式')
@tooltip('i18n:richtext.horizontal_align')
get horizontalAlign () {
return this._horizontalAlign;
}
@@ -200,7 +200,7 @@ export class RichText extends UIComponent {
* @zh
* 富文本字体大小。
*/
@tooltip('富文本字体大小')
@tooltip('i18n:richtext.font_size')
get fontSize () {
return this._fontSize;
}
@@ -222,7 +222,7 @@ export class RichText extends UIComponent {
* @zh
* 富文本定制系统字体
*/
@tooltip('富文本定制系统字体')
@tooltip('i18n:richtext.font_family')
get fontFamily () {
return this._fontFamily;
}
@@ -241,7 +241,7 @@ export class RichText extends UIComponent {
* 富文本定制字体。
*/
@type(Font)
@tooltip('富文本定制字体')
@tooltip('i18n:richtext.font')
get font () {
return this._font;
}
@@ -270,7 +270,7 @@ export class RichText extends UIComponent {
* @zh
* 是否使用系统字体。
*/
@tooltip('是否使用系统字体')
@tooltip('i18n:richtext.use_system_font')
get useSystemFont () {
return this._isSystemFontUsed;
}
@@ -301,7 +301,7 @@ export class RichText extends UIComponent {
* 文本缓存模式, 该模式只支持系统字体。
*/
@type(CacheMode)
@tooltip('文本缓存模式, 该模式只支持系统字体。')
@tooltip('i18n:richtext')
get cacheMode () {
return this._cacheMode;
}
@@ -320,7 +320,7 @@ export class RichText extends UIComponent {
* @zh
* 富文本的最大宽度。
*/
@tooltip('富文本的最大宽度')
@tooltip('i18n:richtext.max_width')
get maxWidth () {
return this._maxWidth;
}
@@ -342,7 +342,7 @@ export class RichText extends UIComponent {
* @zh
* 富文本行高。
*/
@tooltip('富文本行高')
@tooltip('i18n:richtext.line_height')
get lineHeight () {
return this._lineHeight;
}
@@ -365,7 +365,7 @@ export class RichText extends UIComponent {
* 对于 img 标签里面的 src 属性名称,都需要在 imageAtlas 里面找到一个有效的 spriteFrame,否则 img tag 会判定为无效。
*/
@type(SpriteAtlas)
@tooltip('对于 img 标签里面的 src 属性名称,都需要在 imageAtlas 里面找到一个有效的 spriteFrame,否则 img tag 会判定为无效')
@tooltip('i18n:richtext.image_atlas')
get imageAtlas () {
return this._imageAtlas;
}
@@ -388,7 +388,7 @@ export class RichText extends UIComponent {
* @zh
* 选中此选项后,RichText 将阻止节点边界框中的所有输入事件(鼠标和触摸),从而防止输入事件穿透到底层节点。
*/
@tooltip('选中此选项后,RichText 将阻止节点边界框中的所有输入事件(鼠标和触摸),从而防止输入事件穿透到底层节点')
@tooltip('i18n:richtext.handleTouchEvent')
get handleTouchEvent () {
return this._handleTouchEvent;
}
+9 -11
View File
@@ -187,7 +187,7 @@ export class Sprite extends Renderable2D {
*/
@type(SpriteAtlas)
@displayOrder(4)
@tooltip('图片资源所属的 Atlas 图集资源')
@tooltip('i18n:sprite.atlas')
get spriteAtlas () {
return this._atlas;
}
@@ -210,7 +210,7 @@ export class Sprite extends Renderable2D {
*/
@type(SpriteFrame)
@displayOrder(5)
@tooltip('渲染 Sprite 使用的 SpriteFrame 图片资源')
@tooltip('i18n:sprite.sprite_frame')
get spriteFrame () {
return this._spriteFrame;
}
@@ -245,9 +245,7 @@ export class Sprite extends Renderable2D {
*/
@type(SpriteType)
@displayOrder(6)
@tooltip('渲染模式:\n- 普通(Simple):修改尺寸会整体拉伸图像,适用于序列帧动画和普通图像 \n'
+ '- 九宫格(Sliced):修改尺寸时四个角的区域不会拉伸,适用于 UI 按钮和面板背景 \n'
+ '- 填充(Filled):设置一定的填充起始位置和方向,能够以一定比率剪裁显示图片')
@tooltip('i18n:sprite.type')
get type () {
return this._type;
}
@@ -272,7 +270,7 @@ export class Sprite extends Renderable2D {
* ```
*/
@type(FillType)
@tooltip('填充方向,可以选择横向(Horizontal),纵向(Vertical)和扇形(Radial)三种方向')
@tooltip('i18n:sprite.fill_type')
get fillType () {
return this._fillType;
}
@@ -303,7 +301,7 @@ export class Sprite extends Renderable2D {
* sprite.fillCenter = new Vec2(0, 0);
* ```
*/
@tooltip('扇形填充时,指定扇形的中心点,取值范围 0 ~ 1')
@tooltip('i18n:sprite.fill_center')
get fillCenter () {
return this._fillCenter;
}
@@ -329,7 +327,7 @@ export class Sprite extends Renderable2D {
* ```
*/
@range([0, 1, 0.1])
@tooltip('填充起始位置,输入一个 0 ~ 1 之间的小数表示起始位置的百分比')
@tooltip('i18n:sprite.fill_start')
get fillStart () {
return this._fillStart;
}
@@ -356,7 +354,7 @@ export class Sprite extends Renderable2D {
* ```
*/
@range([-1, 1, 0.1])
@tooltip('填充总量,取值范围 0 ~ 1 指定显示图像范围的百分比')
@tooltip('i18n:sprite.fill_range')
get fillRange () {
return this._fillRange;
}
@@ -381,7 +379,7 @@ export class Sprite extends Renderable2D {
* ```
*/
@displayOrder(8)
@tooltip('节点约束框内是否包括透明像素区域,勾选此项会去除节点约束框内的透明区域')
@tooltip('i18n:sprite.trim')
get trim () {
return this._isTrimmedMode;
}
@@ -430,7 +428,7 @@ export class Sprite extends Renderable2D {
*/
@type(SizeMode)
@displayOrder(7)
@tooltip('指定 Sprite 所在节点的尺寸,CUSTOM 表示自定义尺寸,TRIMMED 表示取原始图片剪裁透明像素后的尺寸,RAW 表示取原始图片未剪裁的尺寸')
@tooltip('i18n:sprite.size_mode')
get sizeMode () {
return this._sizeMode;
}
+2
View File
@@ -106,6 +106,7 @@ export class UIStaticBatch extends Renderable2D {
}
public updateAssembler (render: Batcher2D) {
render.currIsStatic = true;
if (this._dirty) {
render.finishMergeBatches();
this._lastMeshBuffer = render.currBufferBatch;
@@ -130,6 +131,7 @@ export class UIStaticBatch extends Renderable2D {
this._meshBuffer!.uploadBuffers();
}
render.currIsStatic = false;
}
/**
+2 -2
View File
@@ -95,7 +95,7 @@ export class Canvas extends RenderRoot2D {
}
@type(Camera)
@tooltip('2D渲染相机')
@tooltip('i18n:canvas.camera')
get cameraComponent () {
return this._cameraComponent;
}
@@ -108,7 +108,7 @@ export class Canvas extends RenderRoot2D {
this._onResizeCamera();
}
@tooltip('是否自动为 camera 计算参数')
@tooltip('i18n:canvas.align')
get alignCanvasWithScreen () {
return this._alignCanvasWithScreen;
}
+1 -1
View File
@@ -241,7 +241,7 @@ export class Renderable2D extends RenderableComponent {
* @zh 渲染颜色,一般情况下会和贴图颜色相乘。
*/
@displayOrder(2)
@tooltip('渲染颜色')
@tooltip('i18n:renderable2D.color')
get color (): Readonly<Color> {
return this._color;
}
+3 -3
View File
@@ -69,7 +69,7 @@ export class UITransform extends Component {
* 内容尺寸。
*/
@displayOrder(0)
@tooltip('内容尺寸')
@tooltip('i18n:ui_transform.conten_size')
// @constget
get contentSize (): Readonly<Size> {
return this._contentSize;
@@ -148,7 +148,7 @@ export class UITransform extends Component {
* 锚点位置。
*/
@displayOrder(1)
@tooltip('锚点位置')
@tooltip('i18n:ui_transform.anchor_point')
// @constget
get anchorPoint (): Readonly<Vec2> {
return this._anchorPoint;
@@ -197,7 +197,7 @@ export class UITransform extends Component {
* @zh
* 渲染先后顺序,按照广度渲染排列,按同级节点下进行一次排列。
*/
@tooltip('渲染排序优先级')
@tooltip('i18n:ui_transform.priority')
get priority () {
return this._priority;
}
+6 -1
View File
@@ -120,6 +120,10 @@ export class Batcher2D {
this._currStaticRoot = value;
}
set currIsStatic (value: boolean) {
this._currIsStatic = value;
}
public device: Device;
private _screens: RenderRoot2D[] = [];
private _bufferBatchPool: RecyclePool<MeshBuffer> = new RecyclePool(() => new MeshBuffer(this), 128);
@@ -143,6 +147,7 @@ export class Batcher2D {
private _currBlendTargetHash = 0;
private _currLayer = 0;
private _currDepthStencilStateStage: any|null = null;
private _currIsStatic = false;
private _parentOpacity = 1;
// DescriptorSet Cache Map
private _descriptorSetCache = new DescriptorSetCache();
@@ -517,7 +522,7 @@ export class Batcher2D {
// HACK: After sharing buffer between drawcalls, the performance degradation a lots on iOS 14 or iPad OS 14 device
// TODO: Maybe it can be removed after Apple fixes it?
if (sys.__isWebIOS14OrIPadOS14Env) {
if (sys.__isWebIOS14OrIPadOS14Env && !this._currIsStatic) {
this._currMeshBuffer = null;
}
}
+1 -1
View File
@@ -370,7 +370,7 @@ class CpuComputingRenderingInstance implements SubMeshMorphRenderingInstance {
valueView[4 * iVertex + 1] = targetDisplacements[3 * iVertex + 1] * weight;
valueView[4 * iVertex + 2] = targetDisplacements[3 * iVertex + 2] * weight;
}
} else {
} else if (weight !== 0.0) {
for (let iVertex = 0; iVertex < nVertices; ++iVertex) {
valueView[4 * iVertex + 0] += targetDisplacements[3 * iVertex + 0] * weight;
valueView[4 * iVertex + 1] += targetDisplacements[3 * iVertex + 1] * weight;
+8 -1
View File
@@ -23,6 +23,11 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module component/audio
*/
import { legacyCC } from '../../core/global-exports';
export abstract class AudioManager<AudioType> {
@@ -34,7 +39,9 @@ export abstract class AudioManager<AudioType> {
}
public addPlaying (audio: AudioType) {
this._playingAudios.push(audio);
if (!this._playingAudios.includes(audio)) {
this._playingAudios.push(audio);
}
}
public removePlaying (audio: AudioType) {
+4 -1
View File
@@ -135,7 +135,10 @@ export class AudioSource extends Component {
}
public onEnable () {
if (this._playOnAwake) { this.play(); }
// audio source component may be played before
if (this._playOnAwake && !this.playing) {
this.play();
}
}
public onDisable () {
+5
View File
@@ -23,6 +23,11 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module component/audio
*/
import { sys } from '../core/platform/sys';
export function createDomAudio (url: string): Promise<HTMLAudioElement> {
+3 -3
View File
@@ -70,7 +70,7 @@ export class Animation extends Eventify(Component) {
* 设置时,已有剪辑关联的动画状态将被停止;若默认剪辑不在新的动画剪辑中,将被重置为空。
*/
@type([AnimationClip])
@tooltip('此动画组件管理的动画剪辑')
@tooltip('i18n:animation.clips')
get clips () {
return this._clips;
}
@@ -111,7 +111,7 @@ export class Animation extends Eventify(Component) {
* @see [[playOnLoad]]
*/
@type(AnimationClip)
@tooltip('默认动画剪辑')
@tooltip('i18n:animation.default_clip')
get defaultClip () {
return this._defaultClip;
}
@@ -139,7 +139,7 @@ export class Animation extends Eventify(Component) {
* 注意,若在组件开始运行前调用了 `crossFade` 或 `play()`,此字段将不会生效。
*/
@serializable
@tooltip('是否在动画组件开始运行时自动播放默认动画剪辑')
@tooltip('i18n:animation.play_on_load')
public playOnLoad = false;
protected _crossFade = new CrossFade();
+3 -3
View File
@@ -155,7 +155,7 @@ class ReleaseManager {
}
// do auto release
public _autoRelease (oldScene: Scene, newScene: Scene, persistNodes: Node[]) {
public _autoRelease (oldScene: Scene, newScene: Scene, persistNodes: Record<string, Node>) {
if (oldScene) {
const childs = dependUtil.getDeps(oldScene.uuid);
for (let i = 0, l = childs.length; i < l; i++) {
@@ -184,8 +184,8 @@ class ReleaseManager {
// transfer refs from persist nodes to new scene
const sceneDeps = dependUtil._depends.get(newScene.uuid);
if (sceneDeps) { sceneDeps.persistDeps = []; }
for (let i = 0, l = persistNodes.length; i < l; i++) {
const node = persistNodes[i];
for (const key in persistNodes) {
const node = persistNodes[key];
const deps = this._persistNodeDeps.get(node.uuid) as string[];
for (const dep of deps) {
const dependAsset = assets.get(dep);
+2 -1
View File
@@ -24,7 +24,8 @@
*/
/**
* @category asset
* @packageDocumentation
* @module asset
*/
import { ccclass, override } from 'cc.decorator';
+9 -5
View File
@@ -212,12 +212,16 @@ export class EffectAsset extends Asset {
const shader = this.shaders[i];
const combination = this.combinations[i];
if (!combination) { continue; }
Object.keys(combination).reduce((out, name) => out.reduce((acc, cur) => {
const defines = Object.keys(combination).reduce((out, name) => out.reduce((acc, cur) => {
const choices = combination[name];
const next = [cur].concat([...Array(choices.length - 1)].map(() => ({ ...cur })));
next.forEach((defines, idx) => defines[name] = choices[idx]);
return acc.concat(next);
}, [] as MacroRecord[]), [{}] as MacroRecord[]).forEach(
for (let i = 0; i < choices.length; ++i) {
const defines = { ...cur };
defines[name] = choices[i];
acc.push(defines);
}
return acc;
}, [] as MacroRecord[]), [{}] as MacroRecord[]);
defines.forEach(
(defines) => programLib.getGFXShader(root.device, shader.name, defines, root.pipeline),
);
}
+1 -1
View File
@@ -37,7 +37,7 @@ import { Enum } from '../value-types';
import { Asset } from './asset';
import { legacyCC } from '../global-exports';
import { warnID } from '../platform/debug';
import * as utils from '../utils/prefab-utils';
import * as utils from '../utils/prefab';
/**
* @en An enumeration used with the [[Prefab.optimizationPolicy]] to specify how to optimize the instantiate operation.
+2 -2
View File
@@ -334,7 +334,7 @@ export default [
"shaders": [
{
"name": "standard|standard-vs:vert|standard-fs:frag",
"hash": 2668109714,
"hash": 624422912,
"builtins": {
"globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }, { "name": "CCShadow", "defines": [] }], "samplers": [{ "name": "cc_environment", "defines": ["CC_USE_IBL"] }, { "name": "cc_shadowMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_spotLightingMap", "defines": ["CC_RECEIVE_SHADOW"] }] },
"locals": { "blocks": [{ "name": "CCMorph", "defines": ["CC_USE_MORPH"] }, { "name": "CCSkinningTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinningAnimation", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinning", "defines": ["CC_USE_SKINNING", "!CC_USE_BAKED_ANIMATION"] }, { "name": "CCLocalBatched", "defines": ["!USE_INSTANCING", "USE_BATCHING"] }, { "name": "CCLocal", "defines": ["!USE_INSTANCING", "!USE_BATCHING"] }, { "name": "CCForwardLight", "defines": ["CC_FORWARD_ADD"] }], "samplers": [{ "name": "cc_PositionDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_POSITION"] }, { "name": "cc_NormalDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_NORMAL"] }, { "name": "cc_TangentDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_TANGENT"] }, { "name": "cc_jointTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "cc_lightingMap", "defines": ["USE_LIGHTMAP", "!USE_BATCHING", "!CC_FORWARD_ADD"] }] }
@@ -474,7 +474,7 @@ export default [
"shaders": [
{
"name": "terrain|terrain-vs:vert|terrain-fs:frag",
"hash": 2952542850,
"hash": 2164259680,
"builtins": {
"globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }, { "name": "CCShadow", "defines": [] }], "samplers": [{ "name": "cc_environment", "defines": ["CC_USE_IBL"] }, { "name": "cc_shadowMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_spotLightingMap", "defines": ["CC_RECEIVE_SHADOW"] }] },
"locals": { "blocks": [{ "name": "CCLocal", "defines": [] }, { "name": "CCForwardLight", "defines": ["CC_FORWARD_ADD"] }], "samplers": [] }
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -29,7 +29,7 @@
* @module event
*/
import { ccclass, type, serializable, editable } from 'cc.decorator';
import { ccclass, type, serializable, editable, tooltip } from 'cc.decorator';
import { Node } from '../scene-graph';
import { legacyCC } from '../global-exports';
@@ -97,7 +97,9 @@ export class EventHandler {
* @zh
* 事件响应组件和函数所在节点
*/
@serializable
@type(legacyCC.Node)
@tooltip('i18n:button.click_event.target')
public target: Node | null = null;
/**
* @en
@@ -108,6 +110,7 @@ export class EventHandler {
// only for deserializing old project component field
@serializable
@editable
@tooltip('i18n:button.click_event.component')
public component = '';
@serializable
@@ -121,6 +124,7 @@ export class EventHandler {
*/
@serializable
@editable
@tooltip('i18n:button.click_event.handler')
public handler = '';
/**
@@ -131,6 +135,7 @@ export class EventHandler {
*/
@serializable
@editable
@tooltip('i18n:button.click_event.customEventData')
public customEventData = '';
/**
+27 -25
View File
@@ -41,7 +41,7 @@ import * as RF from '../data/utils/requiring-frame';
import { Node } from '../scene-graph';
import { legacyCC } from '../global-exports';
import { errorID, warnID, assertID } from '../platform/debug';
import { CompPrefabInfo } from '../utils/prefab-utils';
import { CompPrefabInfo } from '../utils/prefab/prefab-info';
const idGenerator = new IDGenerator('Comp');
const IsOnLoadCalled = CCObject.Flags.IsOnLoadCalled;
@@ -351,7 +351,7 @@ class Component extends CCObject {
public destroy () {
if (EDITOR) {
// @ts-expect-error
// @ts-expect-error private function access
const depend = this.node._getDependComponent(this);
if (depend) {
errorID(3626,
@@ -374,7 +374,7 @@ class Component extends CCObject {
//
if (EDITOR && !TEST) {
// @ts-expect-error
// @ts-expect-error expected
_Scene.AssetsWatcher.stop(this);
}
@@ -385,11 +385,11 @@ class Component extends CCObject {
this.node._removeComponent(this);
}
public _instantiate (cloned) {
public _instantiate (cloned: Component) {
if (!cloned) {
cloned = legacyCC.instantiate._clone(this, this);
}
cloned.node = null;
cloned.node = NullNode;
return cloned;
}
@@ -418,7 +418,7 @@ class Component extends CCObject {
interval = interval || 0;
assertID(interval >= 0, 1620);
repeat = isNaN(repeat) ? legacyCC.macro.REPEAT_FOREVER : repeat;
repeat = Number.isNaN(repeat) ? legacyCC.macro.REPEAT_FOREVER : repeat;
delay = delay || 0;
const scheduler = legacyCC.director.getScheduler();
@@ -636,46 +636,46 @@ class Component extends CCObject {
}
const proto = Component.prototype;
// @ts-expect-error
// @ts-expect-error modify prototype
proto.update = null;
// @ts-expect-error
// @ts-expect-error modify prototype
proto.lateUpdate = null;
// @ts-expect-error
// @ts-expect-error modify prototype
proto.__preload = null;
// @ts-expect-error
// @ts-expect-error modify prototype
proto.onLoad = null;
// @ts-expect-error
// @ts-expect-error modify prototype
proto.start = null;
// @ts-expect-error
// @ts-expect-error modify prototype
proto.onEnable = null;
// @ts-expect-error
// @ts-expect-error modify prototype
proto.onDisable = null;
// @ts-expect-error
// @ts-expect-error modify prototype
proto.onDestroy = null;
// @ts-expect-error
// @ts-expect-error modify prototype
proto.onFocusInEditor = null;
// @ts-expect-error
// @ts-expect-error modify prototype
proto.onLostFocusInEditor = null;
// @ts-expect-error
// @ts-expect-error modify prototype
proto.resetInEditor = null;
// @ts-expect-error
// @ts-expect-error modify prototype
proto._getLocalBounds = null;
// @ts-expect-error
// @ts-expect-error modify prototype
proto.onRestore = null;
// @ts-expect-error
// @ts-expect-error modify class
Component._requireComponent = null;
// @ts-expect-error
// @ts-expect-error modify class
Component._executionOrder = 0;
if (EDITOR || TEST) {
// INHERITABLE STATIC MEMBERS
// @ts-expect-error
// @ts-expect-error modify static member
Component._executeInEditMode = false;
// @ts-expect-error
// @ts-expect-error modify static member
Component._playOnFocus = false;
// @ts-expect-error
// @ts-expect-error modify static member
Component._disallowMultiple = null;
// @ts-expect-error
// @ts-expect-error modify static member
Component._help = '';
// NON-INHERITED STATIC MEMBERS
@@ -729,6 +729,7 @@ value(Component, '_registerEditorProps', (cls, props) => {
break;
case 'menu':
{
const frame = RF.peek();
let menu = val;
if (frame) {
@@ -738,6 +739,7 @@ value(Component, '_registerEditorProps', (cls, props) => {
EDITOR && EditorExtends.Component.removeMenu(cls);
EDITOR && EditorExtends.Component.addMenu(cls, menu, props.menuPriority);
break;
}
case 'disallowMultiple':
cls._disallowMultiple = cls;
+4
View File
@@ -22,6 +22,10 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module decorator
*/
export { ccclass } from './ccclass';
export * from './component';
+11 -10
View File
@@ -307,7 +307,7 @@ export class Director extends EventTarget {
* @deprecated since v2.0
*/
public convertToGL (uiPoint: Vec2) {
const container = legacyCC.game.container;
const container = legacyCC.game.container as Element;
const view = legacyCC.view;
const box = container.getBoundingClientRect();
const left = box.left + window.pageXOffset - container.clientLeft;
@@ -326,7 +326,7 @@ export class Director extends EventTarget {
* @deprecated since v2.0
*/
public convertToUI (glPoint: Vec2) {
const container = legacyCC.game.container;
const container = legacyCC.game.container as Element;
const view = legacyCC.view;
const box = container.getBoundingClientRect();
const left = box.left + window.pageXOffset - container.clientLeft;
@@ -463,7 +463,7 @@ export class Director extends EventTarget {
if (BUILD && DEBUG) {
console.time('InitScene');
}
// @ts-expect-error
// @ts-expect-error run private method
scene._load(); // ensure scene initialized
if (BUILD && DEBUG) {
console.timeEnd('InitScene');
@@ -472,17 +472,18 @@ export class Director extends EventTarget {
if (BUILD && DEBUG) {
console.time('AttachPersist');
}
const persistNodeList = Object.keys(legacyCC.game._persistRootNodes).map((x) => legacyCC.game._persistRootNodes[x]);
const persistNodeList = Object.keys(legacyCC.game._persistRootNodes).map((x) => legacyCC.game._persistRootNodes[x] as Node);
for (let i = 0; i < persistNodeList.length; i++) {
const node = persistNodeList[i];
node.emit(legacyCC.Node.SCENE_CHANGED_FOR_PERSISTS, scene.renderScene);
const existNode = scene.getChildByUuid(node.uuid);
const existNode = scene.uuid === node._originalSceneId && scene.getChildByUuid(node.uuid);
if (existNode) {
// scene also contains the persist node, select the old one
const index = existNode.getSiblingIndex();
existNode._destroyImmediate();
scene.insertChild(node, index);
} else {
// @ts-expect-error insert to new scene
node.parent = scene;
}
}
@@ -503,7 +504,7 @@ export class Director extends EventTarget {
if (BUILD && DEBUG) {
console.time('AutoRelease');
}
legacyCC.assetManager._releaseManager._autoRelease(oldScene, scene, persistNodeList);
legacyCC.assetManager._releaseManager._autoRelease(oldScene, scene, legacyCC.game._persistRootNodes);
if (BUILD && DEBUG) {
console.timeEnd('AutoRelease');
}
@@ -526,7 +527,7 @@ export class Director extends EventTarget {
if (BUILD && DEBUG) {
console.time('Activate');
}
// @ts-expect-error
// @ts-expect-error run private method
scene._activate();
if (BUILD && DEBUG) {
console.timeEnd('Activate');
@@ -558,7 +559,7 @@ export class Director extends EventTarget {
assertID(scene instanceof Scene, 1216);
// ensure scene initialized
// @ts-expect-error
// @ts-expect-error run private method
scene._load();
// Delay run / replace scene to the end of the frame
@@ -580,7 +581,7 @@ export class Director extends EventTarget {
warnID(1208, sceneName, this._loadingScene);
return false;
}
const bundle = legacyCC.assetManager.bundles.find((bundle) => bundle.getSceneInfo(sceneName));
const bundle = legacyCC.assetManager.bundles.find((bundle) => !!bundle.getSceneInfo(sceneName));
if (bundle) {
this.emit(legacyCC.Director.EVENT_BEFORE_SCENE_LOADING, sceneName);
this._loadingScene = sceneName;
@@ -638,7 +639,7 @@ export class Director extends EventTarget {
onProgress?: Director.OnLoadSceneProgress | Director.OnSceneLoaded,
onLoaded?: Director.OnSceneLoaded,
) {
const bundle = legacyCC.assetManager.bundles.find((bundle) => bundle.getSceneInfo(sceneName));
const bundle = legacyCC.assetManager.bundles.find((bundle) => !!bundle.getSceneInfo(sceneName));
if (bundle) {
bundle.preloadScene(sceneName, null, onProgress, onLoaded);
} else {
+1 -1
View File
@@ -26,7 +26,7 @@
/**
* @packageDocumentation
* @hidden
* @module event
*/
export { default as Event } from './event';
+5 -2
View File
@@ -566,6 +566,8 @@ export class Game extends EventTarget {
} else if (node.parent !== scene) {
debug.warnID(3802);
return;
} else {
node._originalSceneId = scene.uuid;
}
}
this._persistRootNodes[id] = node;
@@ -579,11 +581,12 @@ export class Game extends EventTarget {
* @zh 取消常驻根节点。
* @param node - The node to be removed from persistent node list
*/
public removePersistRootNode (node: { uuid: string; _persistNode: boolean; }) {
public removePersistRootNode (node: Node) {
const id = node.uuid || '';
if (node === this._persistRootNodes[id]) {
delete this._persistRootNodes[id];
node._persistNode = false;
node._originalSceneId = '';
legacyCC.assetManager._releaseManager._removePersistNodeRef(node);
}
}
@@ -617,7 +620,7 @@ export class Game extends EventTarget {
this._lastTime = performance.now();
const frameRate = this.config.frameRate;
this._frameTime = 1000 / frameRate;
if (JSB || RUNTIME_BASED) {
if (JSB) {
// @ts-expect-error JSB Call
jsb.setPreferredFramesPerSecond(frameRate);
window.rAF = window.requestAnimationFrame;
+5
View File
@@ -23,6 +23,11 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module gfx
*/
/**
* Define gfx global classes here.
*/
+1 -1
View File
@@ -22,8 +22,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @hidden
*/
+5
View File
@@ -23,6 +23,11 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module gfx
*/
declare const gfx: any;
import * as Defines from './define';
+5
View File
@@ -23,6 +23,11 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module gfx
*/
declare const gfx: any;
declare type RecursivePartial<T> = {
+1
View File
@@ -24,6 +24,7 @@
*/
/**
* @packageDocumentation
* @hidden
*/
+15 -47
View File
@@ -1112,7 +1112,12 @@ export function WebGL2CmdFuncCreateTexture (device: WebGL2Device, gpuTexture: IW
glTexUnit.glTexture = gpuTexture.glTexture;
}
if (gpuTexture.flags & TextureFlagBit.IMMUTABLE) {
if (gpuTexture.glInternalFmt === WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL) {
// init 2 x 2 texture
const imgSize = FormatSize(gpuTexture.format, 2, 2, 1);
const view: Uint8Array = new Uint8Array(imgSize);
gl.compressedTexImage2D(gl.TEXTURE_2D, 0, gpuTexture.glInternalFmt, 2, 2, 0, view);
} else if (gpuTexture.flags & TextureFlagBit.IMMUTABLE) {
gl.texStorage2D(gl.TEXTURE_2D, gpuTexture.mipLevel, gpuTexture.glInternalFmt, w, h);
} else if (!FormatInfos[gpuTexture.format].isCompressed) {
for (let i = 0; i < gpuTexture.mipLevel; ++i) {
@@ -1120,7 +1125,7 @@ export function WebGL2CmdFuncCreateTexture (device: WebGL2Device, gpuTexture: IW
w = Math.max(1, w >> 1);
h = Math.max(1, h >> 1);
}
} else if (gpuTexture.glInternalFmt !== WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL) {
} else {
for (let i = 0; i < gpuTexture.mipLevel; ++i) {
const imgSize = FormatSize(gpuTexture.format, w, h, 1);
const view: Uint8Array = new Uint8Array(imgSize);
@@ -1128,27 +1133,7 @@ export function WebGL2CmdFuncCreateTexture (device: WebGL2Device, gpuTexture: IW
w = Math.max(1, w >> 1);
h = Math.max(1, h >> 1);
}
} else {
// init 2 x 2 texture
const imgSize = FormatSize(gpuTexture.format, 2, 2, 1);
const view: Uint8Array = new Uint8Array(imgSize);
gl.compressedTexImage2D(gl.TEXTURE_2D, 0, gpuTexture.glInternalFmt, 2, 2, 0, view);
}
/*
if (gpuTexture.isPowerOf2) {
gpuTexture.glWrapS = gl.REPEAT;
gpuTexture.glWrapT = gl.REPEAT;
} else {
gpuTexture.glWrapS = gl.CLAMP_TO_EDGE;
gpuTexture.glWrapT = gl.CLAMP_TO_EDGE;
}
gpuTexture.glMinFilter = gl.LINEAR;
gpuTexture.glMagFilter = gl.LINEAR;
gl.texParameteri(gpuTexture.glTarget, gl.TEXTURE_WRAP_S, gpuTexture.glWrapS);
gl.texParameteri(gpuTexture.glTarget, gl.TEXTURE_WRAP_T, gpuTexture.glWrapT);
gl.texParameteri(gpuTexture.glTarget, gl.TEXTURE_MIN_FILTER, gpuTexture.glMinFilter);
gl.texParameteri(gpuTexture.glTarget, gl.TEXTURE_MAG_FILTER, gpuTexture.glMagFilter);
*/
} else {
gl.deleteTexture(glTexture);
}
@@ -1185,7 +1170,13 @@ export function WebGL2CmdFuncCreateTexture (device: WebGL2Device, gpuTexture: IW
glTexUnit.glTexture = gpuTexture.glTexture;
}
if (gpuTexture.flags & TextureFlagBit.IMMUTABLE) {
if (gpuTexture.glInternalFmt === WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL) {
for (let f = 0; f < 6; ++f) {
const imgSize = FormatSize(gpuTexture.format, 2, 2, 1);
const view: Uint8Array = new Uint8Array(imgSize);
gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + f, 0, gpuTexture.glInternalFmt, 2, 2, 0, view);
}
} else if (gpuTexture.flags & TextureFlagBit.IMMUTABLE) {
gl.texStorage2D(gl.TEXTURE_CUBE_MAP, gpuTexture.mipLevel, gpuTexture.glInternalFmt, w, h);
} else if (!FormatInfos[gpuTexture.format].isCompressed) {
for (let i = 0; i < gpuTexture.mipLevel; ++i) {
@@ -1196,7 +1187,7 @@ export function WebGL2CmdFuncCreateTexture (device: WebGL2Device, gpuTexture: IW
w = Math.max(1, w >> 1);
h = Math.max(1, h >> 1);
}
} else if (gpuTexture.glInternalFmt !== WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL) {
} else {
for (let i = 0; i < gpuTexture.mipLevel; ++i) {
const imgSize = FormatSize(gpuTexture.format, w, h, 1);
const view: Uint8Array = new Uint8Array(imgSize);
@@ -1206,30 +1197,7 @@ export function WebGL2CmdFuncCreateTexture (device: WebGL2Device, gpuTexture: IW
w = Math.max(1, w >> 1);
h = Math.max(1, h >> 1);
}
} else {
for (let f = 0; f < 6; ++f) {
const imgSize = FormatSize(gpuTexture.format, 2, 2, 1);
const view: Uint8Array = new Uint8Array(imgSize);
gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + f, 0, gpuTexture.glInternalFmt, 2, 2, 0, view);
}
}
/*
if (gpuTexture.isPowerOf2) {
gpuTexture.glWrapS = gl.REPEAT;
gpuTexture.glWrapT = gl.REPEAT;
} else {
gpuTexture.glWrapS = gl.CLAMP_TO_EDGE;
gpuTexture.glWrapT = gl.CLAMP_TO_EDGE;
}
gpuTexture.glMinFilter = gl.LINEAR;
gpuTexture.glMagFilter = gl.LINEAR;
gl.texParameteri(gpuTexture.glTarget, gl.TEXTURE_WRAP_S, gpuTexture.glWrapS);
gl.texParameteri(gpuTexture.glTarget, gl.TEXTURE_WRAP_T, gpuTexture.glWrapT);
gl.texParameteri(gpuTexture.glTarget, gl.TEXTURE_MIN_FILTER, gpuTexture.glMinFilter);
gl.texParameteri(gpuTexture.glTarget, gl.TEXTURE_MAG_FILTER, gpuTexture.glMagFilter);
*/
}
break;
}
+1 -1
View File
@@ -173,7 +173,7 @@ if (DEV) {
legacyCC._Test = {};
}
const engineVersion = '3.0.0';
const engineVersion = '3.0.1';
/**
* The current version of Cocos2d being used.<br/>
* Please DO NOT remove this String, it is an important flag for bug tracking.<br/>
+2 -2
View File
@@ -27,7 +27,7 @@
* @packageDocumentation
* @module core
*/
import { legacyCC } from './global-exports';
import { legacyCC, VERSION } from './global-exports';
import * as geometry from './geometry';
import * as math from './math';
@@ -40,7 +40,7 @@ import './deprecated';
legacyCC.math = math;
legacyCC.geometry = geometry;
export { math, memop, geometry, gfx };
export { math, memop, geometry, gfx, VERSION };
export * from './math';
export * from './memop';
@@ -409,17 +409,15 @@ export class ForwardPipeline extends RenderPipeline {
}
cv[UBOCamera.CAMERA_POS_OFFSET + 3] = projectionSignY;
if (fog.enabled) {
cv.set(fog.colorArray, UBOCamera.GLOBAL_FOG_COLOR_OFFSET);
cv.set(fog.colorArray, UBOCamera.GLOBAL_FOG_COLOR_OFFSET);
cv[UBOCamera.GLOBAL_FOG_BASE_OFFSET] = fog.fogStart;
cv[UBOCamera.GLOBAL_FOG_BASE_OFFSET + 1] = fog.fogEnd;
cv[UBOCamera.GLOBAL_FOG_BASE_OFFSET + 2] = fog.fogDensity;
cv[UBOCamera.GLOBAL_FOG_BASE_OFFSET] = fog.fogStart;
cv[UBOCamera.GLOBAL_FOG_BASE_OFFSET + 1] = fog.fogEnd;
cv[UBOCamera.GLOBAL_FOG_BASE_OFFSET + 2] = fog.fogDensity;
cv[UBOCamera.GLOBAL_FOG_ADD_OFFSET] = fog.fogTop;
cv[UBOCamera.GLOBAL_FOG_ADD_OFFSET + 1] = fog.fogRange;
cv[UBOCamera.GLOBAL_FOG_ADD_OFFSET + 2] = fog.fogAtten;
}
cv[UBOCamera.GLOBAL_FOG_ADD_OFFSET] = fog.fogTop;
cv[UBOCamera.GLOBAL_FOG_ADD_OFFSET + 1] = fog.fogRange;
cv[UBOCamera.GLOBAL_FOG_ADD_OFFSET + 2] = fog.fogAtten;
this._commandBuffers[0].updateBuffer(this._descriptorSet.getBuffer(UBOCamera.BINDING), this._cameraUBO);
}
@@ -29,7 +29,7 @@ import { CommandBuffer, Device, RenderPass, Shader } from '../../gfx';
import { InstancedBuffer } from '../instanced-buffer';
import { PipelineStateManager } from '../pipeline-state-manager';
import { Model, Camera } from '../../renderer/scene';
import { DSPool, ShaderPool, PassPool, PassView, ShadowsPool, ShadowsView, SubModelView } from '../../renderer/core/memory-pools';
import { DSPool, ShaderPool, PassPool, PassView } from '../../renderer/core/memory-pools';
import { RenderInstancedQueue } from '../render-instanced-queue';
import { ForwardPipeline } from './forward-pipeline';
import { ShadowType } from '../../renderer/scene/shadows';
@@ -48,30 +48,34 @@ export class PlanarShadowQueue {
public gatherShadowPasses (camera: Camera, cmdBuff: CommandBuffer) {
const shadows = this._pipeline.shadows;
this._instancedQueue.clear();
this._pendingModels.length = 0;
if (!shadows.enabled || shadows.type !== ShadowType.Planar) { return; }
this._pipeline.updateShadowUBO(camera);
const scene = camera.scene!;
const frstm = camera.frustum;
const frustum = camera.frustum;
const shadowVisible = (camera.visibility & Layers.BitMask.DEFAULT) !== 0;
if (!scene.mainLight || !shadowVisible) { return; }
const models = this._pipeline.renderObjects;
const instancedBuffer = InstancedBuffer.get(shadows.instancingMaterial.passes[0]);
this._instancedQueue.clear(); this._instancedQueue.queue.add(instancedBuffer);
const renderObjects = this._pipeline.renderObjects;
for (let i = 0; i < models.length; i++) {
const model = models[i].model;
const instancedBuffer = InstancedBuffer.get(shadows.instancingMaterial.passes[0]);
this._instancedQueue.queue.add(instancedBuffer);
for (let i = 0; i < renderObjects.length; i++) {
const model = renderObjects[i].model;
if (!model.enabled || !model.node || !model.castShadow) { continue; }
if (model.worldBounds) {
AABB.transform(_ab, model.worldBounds, shadows.matLight);
if (!intersect.aabbFrustum(_ab, frstm)) { continue; }
if (!intersect.aabbFrustum(_ab, frustum)) { continue; }
}
if (model.isInstancingEnabled) {
for (let j = 0; j < model.subModels.length; j++) {
instancedBuffer.merge(model.subModels[j], model.instancedAttributes, 0);
const subModels = model.subModels;
for (let m = 0; m < subModels.length; m++) {
const subModel = subModels[m];
instancedBuffer.merge(subModel, model.instancedAttributes, 0, subModel.planarInstanceShaderHandle);
}
} else {
this._pendingModels.push(model);
@@ -82,10 +86,11 @@ export class PlanarShadowQueue {
public recordCommandBuffer (device: Device, renderPass: RenderPass, cmdBuff: CommandBuffer) {
const shadows = this._pipeline.shadows;
if (!shadows.enabled || shadows.type !== ShadowType.Planar || !this._pendingModels.length) { return; }
if (!shadows.enabled || shadows.type !== ShadowType.Planar) { return; }
this._instancedQueue.recordCommandBuffer(device, renderPass, cmdBuff);
if (!this._pendingModels.length) { return; }
const pass = shadows.material.passes[0];
const descriptorSet = DSPool.get(PassPool.get(pass.handle, PassView.DESCRIPTOR_SET));
cmdBuff.bindDescriptorSet(SetIndex.MATERIAL, descriptorSet);
@@ -97,7 +102,7 @@ export class PlanarShadowQueue {
const subModel = model.subModels[j];
// This is a temporary solution
// It should not be written in a fixed way, or modified by the user
const shader = ShaderPool.get(subModel.planarShaderHandel);
const shader = ShaderPool.get(subModel.planarShaderHandle);
const ia = subModel.inputAssembler;
const pso = PipelineStateManager.getOrCreatePipelineState(device, pass, shader, renderPass, ia);
cmdBuff.bindPipelineState(pso);
+4 -1
View File
@@ -85,7 +85,10 @@ export class InstancedBuffer {
if (!stride) { return; } // we assume per-instance attributes are always present
const sourceIA = subModel.inputAssembler;
const lightingMap = subModel.descriptorSet.getTexture(UNIFORM_LIGHTMAP_TEXTURE_BINDING);
const hShader = SubModelPool.get(subModel.handle, SubModelView.SHADER_0 + passIdx) as ShaderHandle;
let hShader = hShaderImplant;
if (!hShader) {
hShader = SubModelPool.get(subModel.handle, SubModelView.SHADER_0 + passIdx) as ShaderHandle;
}
const hDescriptorSet = SubModelPool.get(subModel.handle, SubModelView.DESCRIPTOR_SET);
for (let i = 0; i < this.instances.length; ++i) {
const instance = this.instances[i];
@@ -521,17 +521,15 @@ export class RenderAdditiveLightQueue {
cv.set(skyColor, UBOCamera.AMBIENT_SKY_OFFSET);
cv.set(ambient.albedoArray, UBOCamera.AMBIENT_GROUND_OFFSET);
if (fog.enabled) {
cv.set(fog.colorArray, UBOCamera.GLOBAL_FOG_COLOR_OFFSET);
cv.set(fog.colorArray, UBOCamera.GLOBAL_FOG_COLOR_OFFSET);
cv[UBOCamera.GLOBAL_FOG_BASE_OFFSET] = fog.fogStart;
cv[UBOCamera.GLOBAL_FOG_BASE_OFFSET + 1] = fog.fogEnd;
cv[UBOCamera.GLOBAL_FOG_BASE_OFFSET + 2] = fog.fogDensity;
cv[UBOCamera.GLOBAL_FOG_BASE_OFFSET] = fog.fogStart;
cv[UBOCamera.GLOBAL_FOG_BASE_OFFSET + 1] = fog.fogEnd;
cv[UBOCamera.GLOBAL_FOG_BASE_OFFSET + 2] = fog.fogDensity;
cv[UBOCamera.GLOBAL_FOG_ADD_OFFSET] = fog.fogTop;
cv[UBOCamera.GLOBAL_FOG_ADD_OFFSET + 1] = fog.fogRange;
cv[UBOCamera.GLOBAL_FOG_ADD_OFFSET + 2] = fog.fogAtten;
}
cv[UBOCamera.GLOBAL_FOG_ADD_OFFSET] = fog.fogTop;
cv[UBOCamera.GLOBAL_FOG_ADD_OFFSET + 1] = fog.fogRange;
cv[UBOCamera.GLOBAL_FOG_ADD_OFFSET + 2] = fog.fogAtten;
}
protected _updateUBOs (camera: Camera, cmdBuff: CommandBuffer) {
@@ -339,6 +339,9 @@ class EventManager {
let isFound = false;
const locListener = this._listenersMap;
if (listener === this._currentTouchListener) {
this._currentTouchListener = this._currentTouch = null;
}
for (const selKey in locListener) {
const listeners = locListener[selKey];
const fixedPriorityListeners = listeners.getFixedPriorityListeners();
@@ -956,7 +959,7 @@ class EventManager {
}
if (listener.onTouchBegan) {
isClaimed = listener.onTouchBegan(selTouch, event);
if (isClaimed && listener._isRegistered()) {
if (isClaimed && listener._isRegistered() && !listener._isPaused()) {
listener._claimedTouches.push(selTouch);
if (macro.ENABLE_MULTI_TOUCH || !eventManager._currentTouch) {
eventManager._currentTouch = selTouch;
+1 -1
View File
@@ -1042,7 +1042,7 @@ export const sys: Record<string, any> = {
}
}());
// HACK: this private property only needed on web
sys.__isWebIOS14OrIPadOS14Env = (sys.os === sys.OS_IOS || sys.os === sys.MACOS) && sys.isBrowser
sys.__isWebIOS14OrIPadOS14Env = (sys.os === sys.OS_IOS || sys.os === sys.OS_OSX) && sys.isBrowser
&& /(OS 1[4-9])|(Version\/1[4-9])/.test(window.navigator.userAgent);
},
};
+15 -12
View File
@@ -692,18 +692,19 @@ export const PassPool = new BufferPool<PoolType.PASS, typeof PassView, IPassView
export enum SubModelView {
PRIORITY,
PASS_COUNT,
PASS_0, // handle
PASS_1, // handle
PASS_2, // handle
PASS_3, // handle
SHADER_0, // handle
SHADER_1, // handle
SHADER_2, // handle
SHADER_3, // handle
PLANAR_SHADER, // handle
DESCRIPTOR_SET, // handle
INPUT_ASSEMBLER, // handle
SUB_MESH, // handle
PASS_0, // handle
PASS_1, // handle
PASS_2, // handle
PASS_3, // handle
SHADER_0, // handle
SHADER_1, // handle
SHADER_2, // handle
SHADER_3, // handle
PLANAR_SHADER, // handle
PLANAR_INSTANCE_SHADER, // handle
DESCRIPTOR_SET, // handle
INPUT_ASSEMBLER, // handle
SUB_MESH, // handle
COUNT,
}
interface ISubModelViewType extends BufferTypeManifest<typeof SubModelView> {
@@ -718,6 +719,7 @@ interface ISubModelViewType extends BufferTypeManifest<typeof SubModelView> {
[SubModelView.SHADER_2]: ShaderHandle;
[SubModelView.SHADER_3]: ShaderHandle;
[SubModelView.PLANAR_SHADER]: ShaderHandle;
[SubModelView.PLANAR_INSTANCE_SHADER]: ShaderHandle;
[SubModelView.DESCRIPTOR_SET]: DescriptorSetHandle;
[SubModelView.INPUT_ASSEMBLER]: InputAssemblerHandle;
[SubModelView.SUB_MESH]: SubMeshHandle;
@@ -735,6 +737,7 @@ const subModelViewDataType: BufferDataTypeManifest<typeof SubModelView> = {
[SubModelView.SHADER_2]: BufferDataType.UINT32,
[SubModelView.SHADER_3]: BufferDataType.UINT32,
[SubModelView.PLANAR_SHADER]: BufferDataType.UINT32,
[SubModelView.PLANAR_INSTANCE_SHADER]: BufferDataType.UINT32,
[SubModelView.DESCRIPTOR_SET]: BufferDataType.UINT32,
[SubModelView.INPUT_ASSEMBLER]: BufferDataType.UINT32,
[SubModelView.SUB_MESH]: BufferDataType.UINT32,
@@ -32,75 +32,8 @@ const _forward = new Vec3(0, 0, -1);
const _v3 = new Vec3();
export class DirectionalLight extends Light {
public set shadowRange (shadowRange: number) {
this._shadowRange = shadowRange;
}
public get shadowRange () {
return this._shadowRange;
}
public set shadowIntensitywRange (shadowIntensity: number) {
this._shadowIntensity = shadowIntensity;
}
public get shadowIntensity () {
return this._shadowIntensity;
}
public set shadowFadeDistance (shadowFadeDistance: number) {
this._shadowFadeDistance = shadowFadeDistance;
}
public get shadowFadeDistance () {
return this._shadowFadeDistance;
}
public set shadowDistance (shadowDistance: number) {
this._shadowDistance = shadowDistance;
}
public get shadowDistance () {
return this._shadowDistance;
}
public set fadeStart (fadeStart: number) {
this._fadeStart = fadeStart;
}
public get fadeStart () {
return this._fadeStart;
}
public set splits (splits: Vec4) {
this._splits = splits;
}
public get splits () {
return this._splits;
}
public set biasAutoAdjust (biasAutoAdjust: number) {
this._biasAutoAdjust = biasAutoAdjust;
}
public get biasAutoAdjust () {
return this._biasAutoAdjust;
}
protected _dir: Vec3 = new Vec3(1.0, -1.0, -1.0);
// shadow
private _shadowRange = 1000.0;
private _shadowIntensity = 0.0;
private _shadowFadeDistance = 0.0;
private _shadowDistance = 0.0;
// Cascaded shadow map parameters.
private _fadeStart = 0.8;
private _splits: Vec4 = new Vec4(1.0, 0.0, 0.0, 0.0);
private _biasAutoAdjust = 1.0;
set direction (dir: Vec3) {
Vec3.normalize(this._dir, dir);
LightPool.setVec3(this._handle, LightView.DIRECTION, this._dir);
+3
View File
@@ -364,9 +364,12 @@ export class Model {
this._subModels[idx].destroy();
}
this._subModels[idx].initialize(subMeshData, mat.passes, this.getMacroPatches(idx));
// This is a temporary solution
// It should not be written in a fixed way, or modified by the user
this._subModels[idx].initPlanarShadowShader();
this._subModels[idx].initPlanarShadowInstanceShader();
this._updateAttributesAndBinding(idx);
if (isNewSubModel) {
const hSubModelArray = ModelPool.get(this._handle, ModelView.SUB_MODEL_ARRAY);
+10 -5
View File
@@ -30,13 +30,8 @@ import { legacyCC } from '../../global-exports';
import { Enum } from '../../value-types';
import { ShadowsPool, NULL_HANDLE, ShadowsView, ShadowsHandle, ShaderHandle } from '../core/memory-pools';
import { ShadowsInfo } from '../../scene-graph/scene-globals';
import { API, Device } from '../../gfx';
import { IMacroPatch } from '../core/pass';
const multiPatches = [
{ name: 'CC_USE_SKINNING', value: true },
];
/**
* @zh 阴影类型。
* @en The shadow type
@@ -328,6 +323,16 @@ export class Shadows {
return this._material.passes[0].getShaderVariant(patches);
}
public getPlanarInstanceShader (patches: IMacroPatch[] | null): ShaderHandle {
if (!this._instancingMaterial) {
this._instancingMaterial = new Material();
this._instancingMaterial.initialize({ effectName: 'planar-shadow', defines: { USE_INSTANCING: true } });
ShadowsPool.set(this._handle, ShadowsView.INSTANCE_PASS, this._instancingMaterial.passes[0].handle);
}
return this._instancingMaterial.passes[0].getShaderVariant(patches);
}
public initialize (shadowsInfo: ShadowsInfo) {
ShadowsPool.set(this._handle, ShadowsView.TYPE, shadowsInfo.enabled ? shadowsInfo.type : SHADOW_TYPE_NONE);
ShadowsPool.set(this._handle, ShadowsView.NEAR, shadowsInfo.near);
+16 -1
View File
@@ -100,10 +100,16 @@ export class SubModel {
// This is a temporary solution
// It should not be written in a fixed way, or modified by the user
get planarShaderHandel (): ShaderHandle {
get planarShaderHandle (): ShaderHandle {
return SubModelPool.get(this._handle, SubModelView.PLANAR_SHADER);
}
// This is a temporary solution
// It should not be written in a fixed way, or modified by the user
get planarInstanceShaderHandle (): ShaderHandle {
return SubModelPool.get(this._handle, SubModelView.PLANAR_INSTANCE_SHADER);
}
public initialize (subMesh: RenderingSubMesh, passes: Pass[], patches: IMacroPatch[] | null = null): void {
this._device = legacyCC.director.root.device as Device;
@@ -136,6 +142,15 @@ export class SubModel {
SubModelPool.set(this._handle, SubModelView.PLANAR_SHADER, shaderHandle);
}
// This is a temporary solution
// It should not be written in a fixed way, or modified by the user
public initPlanarShadowInstanceShader () {
const pipeline = legacyCC.director.root.pipeline as ForwardPipeline;
const shadowInfo = pipeline.shadows;
const shaderHandle = shadowInfo.getPlanarInstanceShader(this._patches);
SubModelPool.set(this._handle, SubModelView.PLANAR_INSTANCE_SHADER, shaderHandle);
}
public destroy (): void {
DSPool.free(SubModelPool.get(this._handle, SubModelView.DESCRIPTOR_SET));
IAPool.free(SubModelPool.get(this._handle, SubModelView.INPUT_ASSEMBLER));
+4 -1
View File
@@ -43,7 +43,7 @@ import { baseNodePolyfill } from './base-node-dev';
import { legacyCC } from '../global-exports';
import { Node } from './node';
import type { Scene } from './scene';
import { PrefabInfo } from '../utils/prefab-utils';
import { PrefabInfo } from '../utils/prefab/prefab-info';
const Destroying = CCObject.Flags.Destroying;
const DontDestroy = CCObject.Flags.DontDestroy;
@@ -328,6 +328,9 @@ export class BaseNode extends CCObject implements ISchedulable {
protected _siblingIndex = 0;
// record scene's id when set this node as persist node
public _originalSceneId = '';
/**
* Set `_scene` field of this node.
* The derived `Scene` overrides this method to behavior differently.
@@ -80,7 +80,7 @@ function stableRemoveInactive (iterator, flagToClear) {
let next = iterator.i + 1;
while (next < array.length) {
const comp = array[next];
if (comp._enabled && comp.node._activeInHierarchy) {
if (comp.node._activeInHierarchy) {
++next;
} else {
iterator.removeAt(next);
+15 -15
View File
@@ -326,6 +326,8 @@ function _checkListeners (node: BaseNode, events: string[]) {
* 节点事件类。
*/
export class NodeEventProcessor {
public static _comp: Constructor<Component> | null = null;
public get node () {
return this._node;
}
@@ -353,26 +355,24 @@ export class NodeEventProcessor {
public mouseListener: EventListener | null = null;
private _node: BaseNode;
private _comp: Constructor<Component> | null = null;
constructor (node: BaseNode) {
this._node = node;
}
public reattach (): void {
if (!this._comp) return;
if (this.touchListener) {
const mask = this.touchListener.mask = _searchComponentsInParent(this._node as Node, this._comp);
if (this.mouseListener) {
this.mouseListener.mask = mask;
let currMask;
this.node.walk((node) => {
if (!currMask) {
currMask = _searchComponentsInParent(node as Node, NodeEventProcessor._comp);
}
} else if (this.mouseListener) {
this.mouseListener.mask = _searchComponentsInParent(this._node as Node, this._comp);
}
}
public registerComponentHitList (ctor: Constructor<Component>) {
this._comp = ctor;
if (node.eventProcessor.touchListener) {
node.eventProcessor.touchListener.mask = currMask;
}
if (node.eventProcessor.mouseListener) {
node.eventProcessor.mouseListener.mask = currMask;
}
});
}
public destroy (): void {
@@ -683,7 +683,7 @@ export class NodeEventProcessor {
event: legacyCC.EventListener.TOUCH_ONE_BY_ONE,
swallowTouches: true,
owner: this._node,
mask: _searchComponentsInParent(this._node as Node, this._comp),
mask: _searchComponentsInParent(this._node as Node, NodeEventProcessor._comp),
onTouchBegan: _touchStartHandler,
onTouchMoved: _touchMoveHandler,
onTouchEnded: _touchEndHandler,
@@ -699,7 +699,7 @@ export class NodeEventProcessor {
event: legacyCC.EventListener.MOUSE,
_previousIn: false,
owner: this._node,
mask: _searchComponentsInParent(this._node as Node, this._comp),
mask: _searchComponentsInParent(this._node as Node, NodeEventProcessor._comp),
onMouseDown: _mouseDownHandler,
onMouseMove: _mouseMoveHandler,
onMouseUp: _mouseUpHandler,
+6 -2
View File
@@ -44,7 +44,7 @@ import {
NULL_HANDLE, NodeHandle, NodePool, NodeView,
} from '../renderer/core/memory-pools';
import { NodeSpace, TransformBit } from './node-enum';
import { applyMountedChildren, applyPropertyOverrides, applyTargetOverrides, createNodeWithPrefab, generateTargetMap } from '../utils/prefab-utils';
import { applyMountedChildren, applyPropertyOverrides, applyTargetOverrides, createNodeWithPrefab, generateTargetMap } from '../utils/prefab/utils';
import { Component } from '../components';
const v3_a = new Vec3();
@@ -389,6 +389,11 @@ export class Node extends BaseNode {
this.invalidateChildren(TransformBit.TRS);
}
protected _onHierarchyChanged (oldParent: this | null) {
this.eventProcessor.reattach();
super._onHierarchyChangedBase(oldParent);
}
public _onBatchCreated (dontSyncChildPrefab: boolean) {
super._onBatchCreated(dontSyncChildPrefab);
@@ -428,7 +433,6 @@ export class Node extends BaseNode {
public _onPostActivated (active: boolean) {
if (active) { // activated
eventManager.resumeTarget(this);
this.eventProcessor.reattach();
// in case transform updated during deactivated period
this.invalidateChildren(TransformBit.TRS);
} else { // deactivated
+1 -1
View File
@@ -38,7 +38,7 @@ import { BaseNode } from './base-node';
import { legacyCC } from '../global-exports';
import { Component } from '../components/component';
import { SceneGlobals } from './scene-globals';
import { applyTargetOverrides } from '../utils/prefab-utils';
import { applyTargetOverrides } from '../utils/prefab/utils';
/**
* @en
+2
View File
@@ -0,0 +1,2 @@
export * from './prefab-info';
export * from './utils';
+175
View File
@@ -0,0 +1,175 @@
import { ccclass, serializable, editable, type } from 'cc.decorator';
import { EDITOR } from 'internal:constants';
import { legacyCC } from '../../global-exports';
import Prefab from '../../assets/prefab';
import { CCObject } from '../../data/object';
import { Component } from '../../components';
import { Node } from '../../scene-graph/node';
function compareStringArray (array1: string[]|undefined, array2: string[]|undefined) {
if (!array1 || !array2) {
return false;
}
if (array1.length !== array2.length) {
return false;
}
return array1.every((value, index) => value === array2[index]);
}
@ccclass('cc.TargetInfo')
export class TargetInfo {
// 用于标识目标在prefab 资源中的ID,区别于UUID
@serializable
public localID: string[] = [];
}
@ccclass('cc.TargetOverrideInfo')
export class TargetOverrideInfo {
@serializable
@type(CCObject)
public source: Component|Node|null = null;
// if owner is in a prefab, use TargetInfo to index it
@serializable
@type(TargetInfo)
public sourceInfo: TargetInfo|null = null;
@serializable
public propertyPath: string[] = [];
@serializable
@type(Node)
public target: Node|null = null;
// if target is in a prefab, use TargetInfo to index it
@serializable
@type(TargetInfo)
public targetInfo: TargetInfo|null = null;
}
@ccclass('cc.CompPrefabInfo')
export class CompPrefabInfo {
// To identify current component in a prefab asset, so only needs to be unique.
@serializable
@editable
public fileId = '';
}
@ccclass('CCPropertyOverrideInfo')
export class PropertyOverrideInfo {
@serializable
@type(TargetInfo)
public targetInfo: TargetInfo|null = null;
@serializable
public propertyPath: string[] = [];
@serializable
public value: any;
// eslint-disable-next-line consistent-return
public isTarget (localID: string[], propPath: string[]) {
if (EDITOR) {
return compareStringArray(this.targetInfo?.localID, localID)
&& compareStringArray(this.propertyPath, propPath);
}
}
}
@ccclass('cc.MountedChildrenInfo')
export class MountedChildrenInfo {
@serializable
@type(TargetInfo)
public targetInfo: TargetInfo|null = null;
@serializable
@type([Node])
public nodes: Node[] = [];
// eslint-disable-next-line consistent-return
public isTarget (localID: string[]) {
if (EDITOR) {
return compareStringArray(this.targetInfo?.localID, localID);
}
}
}
/**
* Prefab实例类
*/
@ccclass('cc.PrefabInstance')
export class PrefabInstance {
// Identify current prefabInstance;
@serializable
public fileId = '';
// 记录PrefabInstance所属的Prefab的Root节点信息
@serializable
@type(Node)
public prefabRootNode?: Node;
// 实例化的Prefab中额外增加的子节点数据
@serializable
@type([MountedChildrenInfo])
public mountedChildren: MountedChildrenInfo[] = [];
// 属性的覆盖数据
@serializable
@type([PropertyOverrideInfo])
public propertyOverrides: PropertyOverrideInfo[] = [];
@serializable
@type([TargetInfo])
public removedComponents: TargetInfo[] = [];
public targetMap: Record<string, any | Node | Component> = {};
// eslint-disable-next-line consistent-return
public findPropertyOverride (localID: string[], propPath: string[]) {
if (EDITOR) {
for (let i = 0; i < this.propertyOverrides.length; i++) {
const propertyOverride = this.propertyOverrides[i];
if (propertyOverride.isTarget(localID, propPath)) {
return propertyOverride;
}
}
return null;
}
}
public removePropertyOverride (localID: string[], propPath: string[]) {
if (EDITOR) {
for (let i = 0; i < this.propertyOverrides.length; i++) {
const propertyOverride = this.propertyOverrides[i];
if (propertyOverride.isTarget(localID, propPath)) {
this.propertyOverrides.splice(i, 1);
break;
}
}
}
}
}
@ccclass('cc.PrefabInfo')
export class PrefabInfo {
// the most top node of this prefab in the scene
@serializable
@type(Node)
public root?: Node;
// 所属的 prefab 资源对象 (cc.Prefab)
// In Editor, only asset._uuid is usable because asset will be changed.
@serializable
@type(legacyCC.Prefab)
public asset?: Prefab;
// 用来标识别该节点在 prefab 资源中的位置,因此这个 ID 只需要保证在 Assets 里不重复就行
@serializable
@editable
public fileId = '';
// Instance of a prefabAsset
@serializable
@type(PrefabInstance)
public instance?: PrefabInstance;
@serializable
@type([TargetOverrideInfo])
public targetOverrides?: TargetOverrideInfo[];
}
legacyCC._PrefabInfo = PrefabInfo;
@@ -29,181 +29,13 @@
* @hidden
*/
import { ccclass, serializable, editable, type } from 'cc.decorator';
import { EDITOR, SUPPORT_JIT } from 'internal:constants';
import { legacyCC } from '../global-exports';
import { Prefab } from '../assets';
import type { Node } from '../scene-graph/node';
import { errorID, warn } from '../platform/debug';
import { Component } from '../components';
import { CCObject } from '../data';
import type { BaseNode } from '../scene-graph/base-node';
function compareStringArray (array1: string[]|undefined, array2: string[]|undefined) {
if (!array1 || !array2) {
return false;
}
if (array1.length !== array2.length) {
return false;
}
return array1.every((value, index) => value === array2[index]);
}
@ccclass('cc.TargetInfo')
export class TargetInfo {
// 用于标识目标在prefab 资源中的ID,区别于UUID
@serializable
public localID: string[] = [];
}
@ccclass('cc.TargetOverrideInfo')
export class TargetOverrideInfo {
@serializable
@type(CCObject)
public source: Component|Node|null = null;
// if owner is in a prefab, use TargetInfo to index it
@serializable
@type(TargetInfo)
public sourceInfo: TargetInfo|null = null;
@serializable
public propertyPath: string[] = [];
@serializable
@type(legacyCC.Node)
public target: Node|null = null;
// if target is in a prefab, use TargetInfo to index it
@serializable
@type(TargetInfo)
public targetInfo: TargetInfo|null = null;
}
@ccclass('cc.PrefabInfo')
export class PrefabInfo {
// the most top node of this prefab in the scene
@serializable
@editable
public root?: Node;
// 所属的 prefab 资源对象 (cc.Prefab)
// In Editor, only asset._uuid is usable because asset will be changed.
@serializable
@editable
public asset?: Prefab;
// 用来标识别该节点在 prefab 资源中的位置,因此这个 ID 只需要保证在 Assets 里不重复就行
@serializable
@editable
public fileId = '';
// Instance of a prefabAsset
@serializable
public instance?: PrefabInstance;
@serializable
@type([TargetOverrideInfo])
public targetOverrides?: TargetOverrideInfo[];
}
legacyCC._PrefabInfo = PrefabInfo;
@ccclass('cc.CompPrefabInfo')
export class CompPrefabInfo {
// To identify current component in a prefab asset, so only needs to be unique.
@serializable
@editable
public fileId = '';
}
@ccclass('CCPropertyOverrideInfo')
export class PropertyOverrideInfo {
@serializable
@type(TargetInfo)
public targetInfo: TargetInfo|null = null;
@serializable
public propertyPath: string[] = [];
@serializable
public value: any;
// eslint-disable-next-line consistent-return
public isTarget (localID: string[], propPath: string[]) {
if (EDITOR) {
return compareStringArray(this.targetInfo?.localID, localID)
&& compareStringArray(this.propertyPath, propPath);
}
}
}
@ccclass('cc.MountedChildrenInfo')
export class MountedChildrenInfo {
@serializable
@type(TargetInfo)
public targetInfo: TargetInfo|null = null;
@serializable
@type([legacyCC.Node])
public nodes: Node[] = [];
// eslint-disable-next-line consistent-return
public isTarget (localID: string[]) {
if (EDITOR) {
return compareStringArray(this.targetInfo?.localID, localID);
}
}
}
/**
* Prefab实例类
*/
@ccclass('cc.PrefabInstance')
export class PrefabInstance {
// Identify current prefabInstance;
@serializable
public fileId = '';
// 记录PrefabInstance所属的Prefab的Root节点信息
@serializable
@type(legacyCC.Node)
public prefabRootNode?: Node;
// 实例化的Prefab中额外增加的子节点数据
@serializable
@type([MountedChildrenInfo])
public mountedChildren: MountedChildrenInfo[] = [];
// 属性的覆盖数据
@serializable
@type([PropertyOverrideInfo])
public propertyOverrides: PropertyOverrideInfo[] = [];
@serializable
@type([TargetInfo])
public removedComponents: TargetInfo[] = [];
public targetMap: Record<string, any | Node | Component> = {};
// eslint-disable-next-line consistent-return
public findPropertyOverride (localID: string[], propPath: string[]) {
if (EDITOR) {
for (let i = 0; i < this.propertyOverrides.length; i++) {
const propertyOverride = this.propertyOverrides[i];
if (propertyOverride.isTarget(localID, propPath)) {
return propertyOverride;
}
}
return null;
}
}
public removePropertyOverride (localID: string[], propPath: string[]) {
if (EDITOR) {
for (let i = 0; i < this.propertyOverrides.length; i++) {
const propertyOverride = this.propertyOverrides[i];
if (propertyOverride.isTarget(localID, propPath)) {
this.propertyOverrides.splice(i, 1);
break;
}
}
}
}
}
import { legacyCC } from '../../global-exports';
import type { Node } from '../../scene-graph/node';
import { errorID, warn } from '../../platform/debug';
import { Component } from '../../components';
import type { BaseNode } from '../../scene-graph/base-node';
import { MountedChildrenInfo, PropertyOverrideInfo } from './prefab-info';
export function createNodeWithPrefab (node: Node) {
// @ts-expect-error: private member access
@@ -225,8 +57,7 @@ export function createNodeWithPrefab (node: Node) {
errorID(3701, node.name);
}
// @ts-expect-error: private member access
prefabInfo.instance = null;
prefabInfo.instance = undefined;
return;
}
@@ -420,11 +251,11 @@ export function applyTargetOverrides (node: BaseNode) {
if (sourceInstance && sourceInstance.targetMap) {
source = getTarget(sourceInfo.localID, sourceInstance.targetMap);
}
}
if (!source) {
// Can't find source
continue;
}
if (!source) {
// Can't find source
continue;
}
let target: Node|Component|null = null;
@@ -455,6 +286,13 @@ export function applyTargetOverrides (node: BaseNode) {
for (let i = 0; i < propertyPath.length; i++) {
const propName = propertyPath[i];
targetPropOwner = targetPropOwner[propName];
if (!targetPropOwner) {
break;
}
}
if (!targetPropOwner) {
continue;
}
targetPropOwner[targetPropName] = target;
+38 -31
View File
@@ -29,6 +29,12 @@
* Note, naming this file with prefix `x-` exclude it from regular deprecated modules.
*/
/* eslint-disable @typescript-eslint/ban-types */
/* eslint-disable import/no-mutable-exports */
/* eslint-disable func-names */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable prefer-const */
import { error, warn } from '../platform/debug';
let defaultLogTimes = 10;
@@ -56,6 +62,8 @@ interface IReplacement {
customSetter?: (v: any) => void;
/** 自定义替换属性的 getter */
customGetter?: () => any;
/** 额外建议 */
suggest?: string;
}
interface IRemoveItem {
@@ -82,11 +90,11 @@ export let removeProperty: (owner: object, ownerName: string, properties: IRemov
export let markAsWarning: (owner: object, ownerName: string, properties: IMarkItem[]) => void;
let replacePropertyLog: (n: string, dp: string, n2: string, newp: string, f: Function, id: number) => void;
let replacePropertyLog: (n: string, dp: string, n2: string, newp: string, f: Function, id: number, s: string) => void;
let markAsWarningLog: (n: string, dp: string, f: Function, id: number, s?: string) => void;
let markAsWarningLog: (n: string, dp: string, f: Function, id: number, s: string) => void;
let removePropertyLog: (n: string, dp: string, f: Function, id: number, s?: string) => void;
let removePropertyLog: (n: string, dp: string, f: Function, id: number, s: string) => void;
// if (DEBUG) {
@@ -99,10 +107,10 @@ interface IMeessageItem {
let messageID = 0;
const messageMap: Map<number, IMeessageItem> = new Map<number, IMeessageItem>();
replacePropertyLog = (n: string, dp: string, n2: string, newp: string, f: Function, id: number) => {
replacePropertyLog = (n: string, dp: string, n2: string, newp: string, f: Function, id: number, s: string) => {
const item = messageMap.get(id);
if (item && item.logTimes > item.count) {
f('\'%s\' is deprecated, please use \'%s\' instead.', `${n}.${dp}`, `${n2}.${newp}`);
f(`'%s' is deprecated, please use '%s' instead. ${s}`, `${n}.${dp}`, `${n2}.${newp}`);
item.count++;
}
};
@@ -113,15 +121,14 @@ replaceProperty = (owner: object, ownerName: string, properties: IReplacement[])
properties.forEach((item: IReplacement) => {
const id = messageID++;
messageMap.set(id, { id, count: 0, logTimes: item.logTimes !== undefined ? item.logTimes : defaultLogTimes });
const target = item.target != null ? item.target : owner;
const newName = item.newName != null ? item.newName : item.name;
const targetName = item.targetName != null ? item.targetName : ownerName;
const sameTarget = target == owner;
const sameTarget = target === owner;
const suggest = item.suggest ? `(${item.suggest})` : '';
if (item.customFunction != null) {
owner[item.name] = function (this: any) {
replacePropertyLog(ownerName, item.name, targetName, newName, warn, id);
replacePropertyLog(ownerName, item.name, targetName, newName, warn, id, suggest);
return item.customFunction!.call(this, ...arguments);
};
} else if (item.customSetter != null || item.customGetter != null) {
@@ -130,11 +137,11 @@ replaceProperty = (owner: object, ownerName: string, properties: IReplacement[])
if (hasSetter && hasGetter) {
Object.defineProperty(owner, item.name, {
get (this) {
replacePropertyLog(ownerName, item.name, targetName, newName, warn, id);
replacePropertyLog(ownerName, item.name, targetName, newName, warn, id, suggest);
return item.customGetter!.call(this);
},
set (this, v: any) {
replacePropertyLog(ownerName, item.name, targetName, newName, warn, id);
replacePropertyLog(ownerName, item.name, targetName, newName, warn, id, suggest);
item.customSetter!.call(this, v);
},
enumerable: false,
@@ -142,7 +149,7 @@ replaceProperty = (owner: object, ownerName: string, properties: IReplacement[])
} else if (hasSetter) {
Object.defineProperty(owner, item.name, {
set (this, v: any) {
replacePropertyLog(ownerName, item.name, targetName, newName, warn, id);
replacePropertyLog(ownerName, item.name, targetName, newName, warn, id, suggest);
item.customSetter!.call(this, v);
},
enumerable: false,
@@ -150,7 +157,7 @@ replaceProperty = (owner: object, ownerName: string, properties: IReplacement[])
} else if (hasGetter) {
Object.defineProperty(owner, item.name, {
get (this) {
replacePropertyLog(ownerName, item.name, targetName, newName, warn, id);
replacePropertyLog(ownerName, item.name, targetName, newName, warn, id, suggest);
return item.customGetter!.call(this);
},
enumerable: false,
@@ -159,11 +166,11 @@ replaceProperty = (owner: object, ownerName: string, properties: IReplacement[])
} else {
Object.defineProperty(owner, item.name, {
get (this) {
replacePropertyLog(ownerName, item.name, targetName, newName, warn, id);
replacePropertyLog(ownerName, item.name, targetName, newName, warn, id, suggest);
return sameTarget ? this[newName] : target[newName];
},
set (this, v: any) {
replacePropertyLog(ownerName, item.name, targetName, newName, warn, id);
replacePropertyLog(ownerName, item.name, targetName, newName, warn, id, suggest);
if (sameTarget) {
this[newName] = v;
} else {
@@ -176,11 +183,10 @@ replaceProperty = (owner: object, ownerName: string, properties: IReplacement[])
});
};
removePropertyLog = (n: string, dp: string, f: Function, id: number, s?: string) => {
removePropertyLog = (n: string, dp: string, f: Function, id: number, s: string) => {
const item = messageMap.get(id);
const ss = s === undefined ? '' : `(${s})`;
if (item && item.logTimes > item.count) {
f(`'%s' has been removed. ${ss}`, `${n}.${dp}`);
f(`'%s' has been removed. ${s}`, `${n}.${dp}`);
item.count++;
}
};
@@ -191,24 +197,23 @@ removeProperty = (owner: object, ownerName: string, properties: IRemoveItem[]) =
properties.forEach((item: IRemoveItem) => {
const id = messageID++;
messageMap.set(id, { id, count: 0, logTimes: item.logTimes !== undefined ? item.logTimes : defaultLogTimes });
const suggest = item.suggest ? `(${item.suggest})` : '';
Object.defineProperty(owner, item.name, {
get (this) {
return removePropertyLog(ownerName, item.name, error, id, item.suggest);
return removePropertyLog(ownerName, item.name, error, id, suggest);
},
set (this) {
removePropertyLog(ownerName, item.name, error, id, item.suggest);
removePropertyLog(ownerName, item.name, error, id, suggest);
},
enumerable: false,
});
});
};
markAsWarningLog = (n: string, dp: string, f: Function, id: number, s?: string) => {
markAsWarningLog = (n: string, dp: string, f: Function, id: number, s: string) => {
const item = messageMap.get(id);
const ss = s === undefined ? '' : `(${s})`;
if (item && item.logTimes > item.count) {
f(`'%s' is deprecated. ${ss}`, `${n}.${dp}`);
f(`'%s' is deprecated. ${s}`, `${n}.${dp}`);
item.count++;
}
};
@@ -216,41 +221,43 @@ markAsWarningLog = (n: string, dp: string, f: Function, id: number, s?: string)
markAsWarning = (owner: object, ownerName: string, properties: IMarkItem[]) => {
if (owner == null) return;
const _defaultGetSet = (d: PropertyDescriptor, n: string, dp: string, f: Function, id: number, s?: string) => {
const _defaultGetSet = (d: PropertyDescriptor, n: string, dp: string, f: Function, id: number, s: string) => {
if (d.get) {
const oldGet = d.get();
const oldGet = d.get;
d.get = function (this) {
markAsWarningLog(n, dp, f, id, s);
return oldGet.call(this);
};
}
if (d.set) {
const oldSet = Object.create(d.set);
const oldSet = d.set;
d.set = function (this, v: any) {
markAsWarningLog(n, dp, f, id, s);
oldSet.call(this, v);
};
}
Object.defineProperty(owner, dp, d);
};
properties.forEach((item: IMarkItem) => {
const deprecatedProp = item.name;
const descriptor = Object.getOwnPropertyDescriptor(owner, deprecatedProp);
if (!descriptor) { return; }
if (!descriptor || !descriptor.configurable) { return; }
const id = messageID++;
messageMap.set(id, { id, count: 0, logTimes: item.logTimes !== undefined ? item.logTimes : defaultLogTimes });
const suggest = item.suggest ? `(${item.suggest})` : '';
if (descriptor.value != null) {
if (typeof descriptor.value === 'function') {
const oldValue = descriptor.value as Function;
owner[deprecatedProp] = function (this) {
markAsWarningLog(ownerName, deprecatedProp, warn, id, item.suggest);
markAsWarningLog(ownerName, deprecatedProp, warn, id, suggest);
return oldValue.call(this, ...arguments);
};
} else {
_defaultGetSet(descriptor, ownerName, deprecatedProp, warn, id, item.suggest);
_defaultGetSet(descriptor, ownerName, deprecatedProp, warn, id, suggest);
}
} else {
_defaultGetSet(descriptor, ownerName, deprecatedProp, warn, id, item.suggest);
_defaultGetSet(descriptor, ownerName, deprecatedProp, warn, id, suggest);
}
Object.defineProperty(owner, deprecatedProp, { enumerable: false });
});
+5
View File
@@ -1,3 +1,8 @@
/**
* @packageDocumentation
* @module dragonBones
*/
import { Armature, BlendMode, Matrix } from '@cocos/dragonbones-js';
import { Color, Mat4, RenderTexture } from '../core';
import { TextureBase } from '../core/assets/texture-base';
+67 -73
View File
@@ -1,8 +1,13 @@
/**
* @packageDocumentation
* @module dragonBones
*/
import { EDITOR } from 'internal:constants';
import { Armature, Bone, EventObject } from '@cocos/dragonbones-js';
import { ccclass, executeInEditMode, help, menu } from '../core/data/class-decorator';
import { Renderable2D } from '../2d/framework/renderable-2d';
import { Node, EventTarget, CCClass, Color, Enum, PrivateNode, ccenum, errorID, Texture2D, js, CCObject, SystemEventType } from '../core';
import { Node, EventTarget, CCClass, Color, Enum, PrivateNode, ccenum, errorID, Texture2D, js, CCObject } from '../core';
import { BlendFactor } from '../core/gfx';
import { displayName, editable, override, serializable, tooltip, type, visible } from '../core/data/decorators';
import { AnimationCache, ArmatureCache, ArmatureFrame } from './ArmatureCache';
@@ -36,26 +41,26 @@ ccenum(DefaultAnimsEnum);
export let timeScale = 1;
/**
* !#en Enum for cache mode type.
* !#zh Dragonbones渲染类型
* @en Enum for cache mode type.
* @zh Dragonbones渲染类型
* @enum ArmatureDisplay.AnimationCacheMode
*/
export enum AnimationCacheMode {
/**
* !#en The realtime mode.
* !#zh 实时计算模式。
* @en The realtime mode.
* @zh 实时计算模式。
* @property {Number} REALTIME
*/
REALTIME = 0,
/**
* !#en The shared cache mode.
* !#zh 共享缓存模式。
* @en The shared cache mode.
* @zh 共享缓存模式。
* @property {Number} SHARED_CACHE
*/
SHARED_CACHE = 1,
/**
* !#en The private cache mode.
* !#zh 私有缓存模式。
* @en The private cache mode.
* @zh 私有缓存模式。
* @property {Number} PRIVATE_CACHE
*/
PRIVATE_CACHE = 2
@@ -106,13 +111,13 @@ interface BoneIndex extends Number {
}
/**
* !#en
* @en
* The Armature Display of DragonBones <br/>
* <br/>
* Armature Display has a reference to a DragonBonesAsset and stores the state for ArmatureDisplay instance,
* which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible. <br/>
* Multiple Armature Display can use the same DragonBonesAsset which includes all animations, skins, and attachments. <br/>
* !#zh
* @zh
* DragonBones 骨骼动画 <br/>
* <br/>
* Armature Display 具有对骨骼数据的引用并且存储了骨骼实例的状态,
@@ -130,11 +135,11 @@ export class ArmatureDisplay extends Renderable2D {
static AnimationCacheMode = AnimationCacheMode;
/**
* !#en
* @en
* The DragonBones data contains the armatures information (bind pose bones, slots, draw order,
* attachments, skins, etc) and animations but does not hold any state.<br/>
* Multiple ArmatureDisplay can share the same DragonBones data.
* !#zh
* @zh
* 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序,
* attachments,皮肤等等)和动画但不持有任何状态。<br/>
* 多个 ArmatureDisplay 可以共用相同的骨骼数据。
@@ -156,9 +161,9 @@ export class ArmatureDisplay extends Renderable2D {
}
/**
* !#en
* @en
* The atlas asset for the DragonBones.
* !#zh
* @zh
* 骨骼数据所需的 Atlas Texture 数据。
* @property {DragonBonesAtlasAsset} dragonAtlasAsset
*/
@@ -173,8 +178,8 @@ export class ArmatureDisplay extends Renderable2D {
}
/**
* !#en The name of current armature.
* !#zh 当前的 Armature 名称。
* @en The name of current armature.
* @zh 当前的 Armature 名称。
* @property {String} armatureName
*/
@visible(false)
@@ -204,8 +209,8 @@ export class ArmatureDisplay extends Renderable2D {
}
/**
* !#en The name of current playing animation.
* !#zh 当前播放的动画名称。
* @en The name of current playing animation.
* @zh 当前播放的动画名称。
* @property {String} animationName
*/
@visible(false)
@@ -298,8 +303,8 @@ export class ArmatureDisplay extends Renderable2D {
this.setAnimationCacheMode(this._defaultCacheMode);
}
/**
* !#en The time scale of this armature.
* !#zh 当前骨骼中所有动画的时间缩放率。
* @en The time scale of this armature.
* @zh 当前骨骼中所有动画的时间缩放率。
* @property {Number} timeScale
* @default 1
*/
@@ -316,11 +321,11 @@ export class ArmatureDisplay extends Renderable2D {
}
/**
* !#en The play times of the default animation.
* @en The play times of the default animation.
* -1 means using the value of config file;
* 0 means repeat for ever
* >0 means repeat times
* !#zh 播放默认动画的循环次数
* @zh 播放默认动画的循环次数
* -1 表示使用配置文件中的默认值;
* 0 表示无限循环
* >0 表示循环次数
@@ -333,10 +338,10 @@ export class ArmatureDisplay extends Renderable2D {
public playTimes = -1;
/**
* !#en Indicates whether to enable premultiplied alpha.
* @en Indicates whether to enable premultiplied alpha.
* You should disable this option when image's transparent area appears to have opaque pixels,
* or enable this option when image's half transparent area appears to be darken.
* !#zh 是否启用贴图预乘。
* @zh 是否启用贴图预乘。
* 当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。
* @property {Boolean} premultipliedAlpha
* @default false
@@ -347,8 +352,8 @@ export class ArmatureDisplay extends Renderable2D {
public premultipliedAlpha = false;
/**
* !#en Indicates whether open debug bones.
* !#zh 是否显示 bone 的 debug 信息。
* @en Indicates whether open debug bones.
* @zh 是否显示 bone 的 debug 信息。
* @property {Boolean} debugBones
* @default false
*/
@@ -360,8 +365,8 @@ export class ArmatureDisplay extends Renderable2D {
this._updateDebugDraw();
}
/**
* !#en Enabled batch model, if skeleton is complex, do not enable batch, or will lower performance.
* !#zh 开启合批,如果渲染大量相同纹理,且结构简单的骨骼动画,开启合批可以降低drawcall,否则请不要开启,cpu消耗会上升。
* @en Enabled batch model, if skeleton is complex, do not enable batch, or will lower performance.
* @zh 开启合批,如果渲染大量相同纹理,且结构简单的骨骼动画,开启合批可以降低drawcall,否则请不要开启,cpu消耗会上升。
* @property {Boolean} enableBatch
* @default false
*/
@@ -554,12 +559,15 @@ export class ArmatureDisplay extends Renderable2D {
protected _render (ui: Batcher2D) {
if (this._meshRenderDataArray) {
for (let i = 0; i < this._meshRenderDataArray.length; i++) {
// HACK
const mat = this.material;
this._meshRenderDataArrayIdx = i;
const m = this._meshRenderDataArray[i];
this.material = m.renderData.material;
if (m.texture) {
ui.commitComp(this, m.texture, this._assembler, null);
}
this.material = mat;
}
}
}
@@ -647,9 +655,9 @@ export class ArmatureDisplay extends Renderable2D {
}
/**
* !#en
* @en
* The key of dragonbones cache data, which is regard as 'dragonbonesName', when you want to change dragonbones cloth.
* !#zh
* @zh
* 缓存龙骨数据的key值,换装的时会使用到该值,作为dragonbonesName使用
* @method getArmatureKey
* @return {String}
@@ -663,10 +671,10 @@ export class ArmatureDisplay extends Renderable2D {
}
/**
* !#en
* @en
* It's best to set cache mode before set property 'dragonAsset', or will waste some cpu time.
* If set the mode in editor, then no need to worry about order problem.
* !#zh
* @zh
* 若想切换渲染模式,最好在设置'dragonAsset'之前,先设置好渲染模式,否则有运行时开销。
* 若在编辑中设置渲染模式,则无需担心设置次序的问题。
*
@@ -688,8 +696,8 @@ export class ArmatureDisplay extends Renderable2D {
}
/**
* !#en Whether in cached mode.
* !#zh 当前是否处于缓存模式。
* @en Whether in cached mode.
* @zh 当前是否处于缓存模式。
* @method isAnimationCached
* @return {Boolean}
*/
@@ -707,20 +715,6 @@ export class ArmatureDisplay extends Renderable2D {
this._flushAssembler();
}
public _onSyncTransform () {
this.node.on(SystemEventType.TRANSFORM_CHANGED, this.syncTransform, this);
this.node.on(SystemEventType.SIZE_CHANGED, this.syncTransform, this);
}
public _offSyncTransform () {
this.node.off(SystemEventType.TRANSFORM_CHANGED, this.syncTransform, this);
this.node.off(SystemEventType.SIZE_CHANGED, this.syncTransform, this);
}
private syncTransform () {
}
onDisable () {
super.onDisable();
// If cache mode is cache, no need to update by dragonbones library.
@@ -1051,14 +1045,14 @@ export class ArmatureDisplay extends Renderable2D {
}
/**
* !#en
* @en
* Play the specified animation.
* Parameter animName specify the animation name.
* Parameter playTimes specify the repeat times of the animation.
* -1 means use the value of the config file.
* 0 means play the animation for ever.
* >0 means repeat times.
* !#zh
* @zh
* 播放指定的动画.
* animName 指定播放动画的名称。
* playTimes 指定播放动画的次数。
@@ -1094,11 +1088,11 @@ export class ArmatureDisplay extends Renderable2D {
}
/**
* !#en
* @en
* Updating an animation cache to calculate all frame data in the animation is a cost in
* performance due to calculating all data in a single frame.
* To update the cache, use the invalidAnimationCache method with high performance.
* !#zh
* @zh
* 更新某个动画缓存, 预计算动画中所有帧数据,由于在单帧计算所有数据,所以较消耗性能。
* 若想更新缓存,可使用 invalidAnimationCache 方法,具有较高性能。
* @method updateAnimationCache
@@ -1110,9 +1104,9 @@ export class ArmatureDisplay extends Renderable2D {
}
/**
* !#en
* @en
* Invalidates the animation cache, which is then recomputed on each frame..
* !#zh
* @zh
* 使动画缓存失效,之后会在每帧重新计算。
* @method invalidAnimationCache
*/
@@ -1122,9 +1116,9 @@ export class ArmatureDisplay extends Renderable2D {
}
/**
* !#en
* @en
* Get the all armature names in the DragonBones Data.
* !#zh
* @zh
* 获取 DragonBones 数据中所有的 armature 名称
* @method getArmatureNames
* @returns {Array}
@@ -1135,9 +1129,9 @@ export class ArmatureDisplay extends Renderable2D {
}
/**
* !#en
* @en
* Get the all animation names of specified armature.
* !#zh
* @zh
* 获取指定的 armature 的所有动画名称。
* @method getAnimationNames
* @param {String} armatureName
@@ -1161,9 +1155,9 @@ export class ArmatureDisplay extends Renderable2D {
}
/**
* !#en
* @en
* Add event listener for the DragonBones Event, the same to addEventListener.
* !#zh
* @zh
* 添加 DragonBones 事件监听器,与 addEventListener 作用相同。
* @method on
* @param {String} type - A string representing the event type to listen for.
@@ -1176,9 +1170,9 @@ export class ArmatureDisplay extends Renderable2D {
}
/**
* !#en
* @en
* Remove the event listener for the DragonBones Event, the same to removeEventListener.
* !#zh
* @zh
* 移除 DragonBones 事件监听器,与 removeEventListener 作用相同。
* @method off
* @param {String} type - A string representing the event type to listen for.
@@ -1190,9 +1184,9 @@ export class ArmatureDisplay extends Renderable2D {
}
/**
* !#en
* @en
* Add DragonBones one-time event listener, the callback will remove itself after the first time it is triggered.
* !#zh
* @zh
* 添加 DragonBones 一次性事件监听器,回调会在第一时间被触发后删除自身。
* @method once
* @param {String} type - A string representing the event type to listen for.
@@ -1205,9 +1199,9 @@ export class ArmatureDisplay extends Renderable2D {
}
/**
* !#en
* @en
* Add event listener for the DragonBones Event.
* !#zh
* @zh
* 添加 DragonBones 事件监听器。
* @method addEventListener
* @param {String} type - A string representing the event type to listen for.
@@ -1220,9 +1214,9 @@ export class ArmatureDisplay extends Renderable2D {
}
/**
* !#en
* @en
* Remove the event listener for the DragonBones Event.
* !#zh
* @zh
* 移除 DragonBones 事件监听器。
* @method removeEventListener
* @param {String} type - A string representing the event type to listen for.
@@ -1234,9 +1228,9 @@ export class ArmatureDisplay extends Renderable2D {
}
/**
* !#en
* @en
* Build the armature for specified name.
* !#zh
* @zh
* 构建指定名称的 armature 对象
* @method buildArmature
* @param {String} armatureName
@@ -1248,9 +1242,9 @@ export class ArmatureDisplay extends Renderable2D {
}
/**
* !#en
* @en
* Get the current armature object of the ArmatureDisplay.
* !#zh
* @zh
* 获取 ArmatureDisplay 当前使用的 Armature 对象
* @method armature
* @returns {Object}
+7 -6
View File
@@ -1,3 +1,8 @@
/**
* @packageDocumentation
* @module dragonBones
*/
import { Armature, Matrix } from '@cocos/dragonbones-js';
import { Node, Mat4, Vec3 } from '../core';
import { ccclass } from '../core/data/class-decorator';
@@ -7,12 +12,8 @@ import { ArmatureDisplay } from './ArmatureDisplay';
const _tempMat4 = new Mat4();
/**
* @module dragonBones
*/
/**
* !#en Attach node tool
* !#zh 挂点工具类
* @en Attach node tool
* @zh 挂点工具类
* @class dragonBones.AttachUtil
*/
+5
View File
@@ -1,5 +1,10 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/**
* @packageDocumentation
* @module dragonBones
*/
import { Armature, DisplayData, IEventDispatcher, Slot } from '@cocos/dragonbones-js';
import { ccclass } from '../core/data/class-decorator';
import { Vec2, EventTarget, Node, Vec3 } from '../core';
+5 -4
View File
@@ -1,3 +1,8 @@
/**
* @packageDocumentation
* @module dragonBones
*/
import { EDITOR } from 'internal:constants';
import { Armature, BaseObject, Animation, BaseFactory, DragonBones } from '@cocos/dragonbones-js';
import { Component, director, Game, game, ISchedulable, Node, RenderTexture, Scheduler, systemEvent, SystemEventType } from '../core';
@@ -8,10 +13,6 @@ import { CCSlot } from './CCSlot';
import { ArmatureDisplay } from './ArmatureDisplay';
import { CCArmatureDisplay } from './CCArmatureDisplay';
/**
* @module dragonBones
*/
/**
* DragonBones factory
* @class CCFactory
+5
View File
@@ -1,3 +1,8 @@
/**
* @packageDocumentation
* @module dragonBones
*/
import { BoneType, BinaryOffset, Slot } from '@cocos/dragonbones-js';
import { Color, ImageAsset, mat4, Mat4, Texture2D } from '../core';
import { ccclass } from '../core/data/class-decorator';
+5
View File
@@ -1,3 +1,8 @@
/**
* @packageDocumentation
* @module dragonBones
*/
import { BaseObject, TextureAtlasData, TextureData } from '@cocos/dragonbones-js';
import { RenderTexture, Size, Vec2 } from '../core';
import { SpriteFrame } from '../2d';
+10 -4
View File
@@ -1,4 +1,10 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/**
* @packageDocumentation
* @module dragonBones
*/
import { EDITOR } from 'internal:constants';
import { BinaryDataParser, DragonBonesData } from '@cocos/dragonbones-js';
import { Asset } from '../core/assets';
@@ -10,8 +16,8 @@ import { property } from '../core/data/class-decorator';
import { legacyCC } from '../core/global-exports';
/**
* !#en The skeleton data of dragonBones.
* !#zh dragonBones 的 骨骼数据。
* @en The skeleton data of dragonBones.
* @zh dragonBones 的 骨骼数据。
* @class DragonBonesAsset
* @extends Asset
*/
@@ -20,8 +26,8 @@ export class DragonBonesAsset extends Asset {
static preventDeferredLoadDependents = true;
/**
* !#en See http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html
* !#zh 可查看 DragonBones 官方文档 http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html
* @en See http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html
* @zh 可查看 DragonBones 官方文档 http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html
* @property {string} dragonBonesJson
*/
@serializable
+3 -2
View File
@@ -1,4 +1,5 @@
/**
* @packageDocumentation
* @module dragonBones
*/
import { JSB } from 'internal:constants';
@@ -11,8 +12,8 @@ import { CCFactory } from './CCFactory';
import { legacyCC } from '../core/global-exports';
/**
* !#en The skeleton atlas data of dragonBones.
* !#zh dragonBones 的骨骼纹理数据。
* @en The skeleton atlas data of dragonBones.
* @zh dragonBones 的骨骼纹理数据。
* @class DragonBonesAtlasAsset
* @extends Asset
*/
+5
View File
@@ -1,3 +1,8 @@
/**
* @packageDocumentation
* @module dragonBones
*/
import { IAssemblerManager } from '../../2d/renderer/base';
import { ArmatureDisplay } from '../ArmatureDisplay';
import { simple } from './simple';
+5
View File
@@ -1,3 +1,8 @@
/**
* @packageDocumentation
* @module dragonBones
*/
import { Armature, BlendMode } from '@cocos/dragonbones-js';
import { Color, Mat4, RenderTexture, Node, Texture2D, Vec3 } from '../../core';
import { BlendFactor } from '../../core/gfx';
+7 -2
View File
@@ -1,9 +1,14 @@
/**
* @packageDocumentation
* @module dragonBones
*/
import { EDITOR } from 'internal:constants';
/**
* !#en
* @en
* The global time scale of DragonBones.
* !#zh
* @zh
* DragonBones 全局时间缩放率。
* @example
* dragonBones.timeScale = 0.8;
+5
View File
@@ -23,6 +23,11 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module particle2d
*/
import { Enum } from '../core/value-types';
/**
+1 -1
View File
@@ -25,7 +25,7 @@
/**
* @packageDocumentation
* @hidden
* @module particle2d
*/
import { ParticleSystem2D } from './particle-system-2d';
@@ -24,6 +24,11 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module particle2d
*/
import { IAssembler, IAssemblerManager } from '../2d/renderer/base';
import { MotionStreak } from './motion-streak-2d';
import { Vec2, Color } from '../core/math';
+5
View File
@@ -24,6 +24,11 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module particle2d
*/
import { ccclass, executeInEditMode, serializable, playOnFocus, menu, help, editable, type } from 'cc.decorator';
import { EDITOR } from 'internal:constants';
import { Renderable2D } from '../2d/framework';
+1 -1
View File
@@ -26,7 +26,7 @@
/**
* @packageDocumentation
* @module ParticleAsset
* @module asset
*/
import { ccclass, serializable, editable } from '../core/data/decorators';
@@ -22,6 +22,12 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module particle2d
*/
import { Vec2, Color } from '../core/math';
import Pool from '../core/utils/pool';
import { clampf, degreesToRadians, radiansToDegrees } from '../core/utils/misc';
@@ -455,6 +461,8 @@ export class Simulator {
}
pool.put(deadParticle);
particles.length--;
renderData.indicesCount -= 6;
renderData.vertexCount -= 4;
}
}
@@ -24,6 +24,11 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module particle2d
*/
import { IAssembler, IAssemblerManager } from '../2d/renderer/base';
import { ParticleSystem2D } from './particle-system-2d';
import { MeshRenderData } from '../2d/renderer/render-data';
+12 -12
View File
@@ -25,7 +25,8 @@
*/
/**
* @category particle2d
* @packageDocumentation
* @module particle2d
*/
import { ccclass, editable, type, menu, executeInEditMode, serializable, playOnFocus, tooltip } from 'cc.decorator';
@@ -672,15 +673,6 @@ export class ParticleSystem2D extends Renderable2D {
public declare _renderSpriteFrame: SpriteFrame | null;
public declare _simulator: Simulator;
/**
* @en Play particle in edit mode.
* @zh 在编辑器模式下预览粒子,启用后选中粒子时,粒子将自动播放。
*/
@serializable
@editable
@tooltip('i18n:particle_system.preview')
private preview = true;
/**
* @en If set to true, the particle system will automatically start playing on onLoad.
* @zh 如果设置为 true 运行时会自动发射粒子。
@@ -688,7 +680,7 @@ export class ParticleSystem2D extends Renderable2D {
@serializable
@editable
@tooltip('i18n:particle_system.playOnLoad')
private playOnLoad = true;
public playOnLoad = true;
/**
* @en Indicate whether the owner node will be auto-removed when it has no particles left.
@@ -697,8 +689,16 @@ export class ParticleSystem2D extends Renderable2D {
@serializable
@editable
@tooltip('i18n:particle_system.autoRemoveOnFinish')
private autoRemoveOnFinish = false;
public autoRemoveOnFinish = false;
/**
* @en Play particle in edit mode.
* @zh 在编辑器模式下预览粒子,启用后选中粒子时,粒子将自动播放。
*/
@serializable
@editable
@tooltip('i18n:particle_system.preview')
private preview = true;
@serializable
private _custom = false;
@serializable
+5
View File
@@ -26,6 +26,11 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module particle2d
*/
import { getError } from '../core/platform/debug';
import zlib from '../../external/compression/zlib.min';
+5 -2
View File
@@ -29,6 +29,11 @@
THE SOFTWARE.
*/
/**
* @packageDocumentation
* @module particle2d
*/
import { getError, logID } from '../core/platform/debug';
interface IFile {
@@ -90,7 +95,6 @@ export class TiffReader {
// Check for towel.
if (this.getUint16(2) !== 42) {
throw RangeError(getError(6020));
return false;
}
return true;
@@ -570,7 +574,6 @@ export class TiffReader {
// Unknown Photometric Interpretation
default:
throw RangeError(getError(6028, photometricInterpretation));
break;
}
ctx.fillStyle = `rgba(${red}, ${green}, ${blue}, ${opacity})`;
+4 -4
View File
@@ -66,7 +66,7 @@ export default class ForceOvertimeModule extends ParticleModuleBase {
@serializable
@range([-1, 1])
@displayOrder(2)
@tooltip('X 轴方向上的加速度分量')
@tooltip('i18n:forceOvertimeModule.x')
public x = new CurveRange();
/**
@@ -76,7 +76,7 @@ export default class ForceOvertimeModule extends ParticleModuleBase {
@serializable
@range([-1, 1])
@displayOrder(3)
@tooltip('Y 轴方向上的加速度分量')
@tooltip('i18n:forceOvertimeModule.y')
public y = new CurveRange();
/**
@@ -86,7 +86,7 @@ export default class ForceOvertimeModule extends ParticleModuleBase {
@serializable
@range([-1, 1])
@displayOrder(4)
@tooltip('Z 轴方向上的加速度分量')
@tooltip('i18n:forceOvertimeModule.z')
public z = new CurveRange();
/**
@@ -95,7 +95,7 @@ export default class ForceOvertimeModule extends ParticleModuleBase {
@type(Space)
@serializable
@displayOrder(1)
@tooltip('加速度计算时采用的坐标')
@tooltip('i18n:forceOvertimeModule.space')
public space = Space.Local;
// TODO:currently not supported
@@ -66,7 +66,7 @@ export default class LimitVelocityOvertimeModule extends ParticleModuleBase {
@serializable
@range([-1, 1])
@displayOrder(4)
@tooltip('X 轴方向上的速度下限')
@tooltip('i18n:limitVelocityOvertimeModule.limitX')
public limitX = new CurveRange();
/**
@@ -76,7 +76,7 @@ export default class LimitVelocityOvertimeModule extends ParticleModuleBase {
@serializable
@range([-1, 1])
@displayOrder(5)
@tooltip('Y 轴方向上的速度下限')
@tooltip('i18n:limitVelocityOvertimeModule.limitY')
public limitY = new CurveRange();
/**
@@ -86,7 +86,7 @@ export default class LimitVelocityOvertimeModule extends ParticleModuleBase {
@serializable
@range([-1, 1])
@displayOrder(6)
@tooltip('Z 轴方向上的速度下限')
@tooltip('i18n:limitVelocityOvertimeModule.limitZ')
public limitZ = new CurveRange();
/**
@@ -96,7 +96,7 @@ export default class LimitVelocityOvertimeModule extends ParticleModuleBase {
@serializable
@range([-1, 1])
@displayOrder(3)
@tooltip('速度下限')
@tooltip('i18n:limitVelocityOvertimeModule.limit')
public limit = new CurveRange();
/**
@@ -104,7 +104,7 @@ export default class LimitVelocityOvertimeModule extends ParticleModuleBase {
*/
@serializable
@displayOrder(7)
@tooltip('当前速度与速度下限的插值')
@tooltip('i18n:limitVelocityOvertimeModule.dampen')
public dampen = 3;
/**
@@ -112,7 +112,7 @@ export default class LimitVelocityOvertimeModule extends ParticleModuleBase {
*/
@serializable
@displayOrder(2)
@tooltip('是否三个轴分开限制')
@tooltip('i18n:limitVelocityOvertimeModule.separateAxes')
public separateAxes = false;
/**
@@ -121,7 +121,7 @@ export default class LimitVelocityOvertimeModule extends ParticleModuleBase {
@type(Space)
@serializable
@displayOrder(1)
@tooltip('计算速度下限时采用的坐标系')
@tooltip('i18n:limitVelocityOvertimeModule.space')
public space = Space.Local;
// TODO:functions related to drag are temporarily not supported
+4 -4
View File
@@ -62,7 +62,7 @@ export default class RotationOvertimeModule extends ParticleModuleBase {
* @zh 是否三个轴分开设定旋转(暂不支持)。
*/
@displayOrder(1)
@tooltip('是否三个轴分开设定旋转(暂不支持)')
@tooltip('i18n:rotationOvertimeModule.separateAxes')
get separateAxes () {
return this._separateAxes;
}
@@ -79,7 +79,7 @@ export default class RotationOvertimeModule extends ParticleModuleBase {
@range([-1, 1])
@radian
@displayOrder(2)
@tooltip('绕 X 轴设定旋转')
@tooltip('i18n:rotationOvertimeModule.x')
public x = new CurveRange();
/**
@@ -90,7 +90,7 @@ export default class RotationOvertimeModule extends ParticleModuleBase {
@range([-1, 1])
@radian
@displayOrder(3)
@tooltip('绕 Y 轴设定旋转')
@tooltip('i18n:rotationOvertimeModule.y')
public y = new CurveRange();
/**
@@ -101,7 +101,7 @@ export default class RotationOvertimeModule extends ParticleModuleBase {
@range([-1, 1])
@radian
@displayOrder(4)
@tooltip('绕 Z 轴设定旋转')
@tooltip('i18n:rotationOvertimeModule.z')
public z = new CurveRange();
public name = PARTICLE_MODULE_NAME.ROTATION;
+5 -5
View File
@@ -60,7 +60,7 @@ export default class SizeOvertimeModule extends ParticleModuleBase {
*/
@serializable
@displayOrder(1)
@tooltip('决定是否在每个轴上独立控制粒子大小')
@tooltip('i18n:sizeOvertimeModule.separateAxes')
public separateAxes = false;
/**
@@ -69,7 +69,7 @@ export default class SizeOvertimeModule extends ParticleModuleBase {
@type(CurveRange)
@serializable
@displayOrder(2)
@tooltip('定义一条曲线来决定粒子在其生命周期中的大小变化')
@tooltip('i18n:sizeOvertimeModule.size')
public size = new CurveRange();
/**
@@ -78,7 +78,7 @@ export default class SizeOvertimeModule extends ParticleModuleBase {
@type(CurveRange)
@serializable
@displayOrder(3)
@tooltip('定义一条曲线来决定粒子在其生命周期中 X 轴方向上的大小变化')
@tooltip('i18n:sizeOvertimeModule.x')
public x = new CurveRange();
/**
@@ -87,7 +87,7 @@ export default class SizeOvertimeModule extends ParticleModuleBase {
@type(CurveRange)
@serializable
@displayOrder(4)
@tooltip('定义一条曲线来决定粒子在其生命周期中 Y 轴方向上的大小变化')
@tooltip('i18n:sizeOvertimeModule.y')
public y = new CurveRange();
/**
@@ -96,7 +96,7 @@ export default class SizeOvertimeModule extends ParticleModuleBase {
@type(CurveRange)
@serializable
@displayOrder(5)
@tooltip('定义一条曲线来决定粒子在其生命周期中 Z 轴方向上的大小变化')
@tooltip('i18n:sizeOvertimeModule.z')
public z = new CurveRange();
public name = PARTICLE_MODULE_NAME.SIZE;
+9 -9
View File
@@ -104,7 +104,7 @@ export default class TextureAnimationModule extends ParticleModuleBase {
*/
@type(Mode)
@displayOrder(1)
@tooltip('设定粒子贴图动画的类型(暂只支持 Grid 模式)')
@tooltip('i18n:textureAnimationModule.mode')
get mode () {
return this._mode;
}
@@ -119,7 +119,7 @@ export default class TextureAnimationModule extends ParticleModuleBase {
* @zh X 方向动画帧数。
*/
@displayOrder(2)
@tooltip('X 方向动画帧数')
@tooltip('i18n:textureAnimationModule.numTilesX')
get numTilesX () {
return this._numTilesX;
}
@@ -135,7 +135,7 @@ export default class TextureAnimationModule extends ParticleModuleBase {
* @zh Y 方向动画帧数。
*/
@displayOrder(3)
@tooltip('Y 方向动画帧数')
@tooltip('i18n:textureAnimationModule.numTilesY')
get numTilesY () {
return this._numTilesY;
}
@@ -153,7 +153,7 @@ export default class TextureAnimationModule extends ParticleModuleBase {
@type(Animation)
@serializable
@displayOrder(4)
@tooltip('动画播放方式')
@tooltip('i18n:textureAnimationModule.animation')
public animation = Animation.WholeSheet;
/**
@@ -162,7 +162,7 @@ export default class TextureAnimationModule extends ParticleModuleBase {
@type(CurveRange)
@serializable
@displayOrder(7)
@tooltip('一个周期内动画播放的帧与时间变化曲线')
@tooltip('i18n:textureAnimationModule.frameOverTime')
public frameOverTime = new CurveRange();
/**
@@ -171,7 +171,7 @@ export default class TextureAnimationModule extends ParticleModuleBase {
@type(CurveRange)
@serializable
@displayOrder(8)
@tooltip('从第几帧开始播放,时间为整个粒子系统的生命周期')
@tooltip('i18n:textureAnimationModule.startFrame')
public startFrame = new CurveRange();
/**
@@ -179,7 +179,7 @@ export default class TextureAnimationModule extends ParticleModuleBase {
*/
@serializable
@displayOrder(9)
@tooltip('一个生命周期内播放循环的次数')
@tooltip('i18n:textureAnimationModule.cycleCount')
public cycleCount = 0;
@serializable
@@ -224,7 +224,7 @@ export default class TextureAnimationModule extends ParticleModuleBase {
*/
@serializable
@displayOrder(5)
@tooltip('随机从动画贴图中选择一行以生成动画。\n此选项仅在动画播放方式为 SingleRow 时生效')
@tooltip('i18n:textureAnimationModule.randomRow')
public randomRow = false;
/**
@@ -233,7 +233,7 @@ export default class TextureAnimationModule extends ParticleModuleBase {
*/
@serializable
@displayOrder(6)
@tooltip('从动画贴图中选择特定行以生成动画。\n此选项仅在动画播放方式为 SingleRow 时且禁用 randomRow 时可用')
@tooltip('i18n:textureAnimationModule.rowIndex')
public rowIndex = 0;
public name = PARTICLE_MODULE_NAME.TEXTURE;
+5 -5
View File
@@ -67,7 +67,7 @@ export default class VelocityOvertimeModule extends ParticleModuleBase {
@serializable
@range([-1, 1])
@displayOrder(2)
@tooltip('X 轴方向上的速度分量')
@tooltip('i18n:velocityOvertimeModule.x')
public x = new CurveRange();
/**
@@ -77,7 +77,7 @@ export default class VelocityOvertimeModule extends ParticleModuleBase {
@serializable
@range([-1, 1])
@displayOrder(3)
@tooltip('Y 轴方向上的速度分量')
@tooltip('i18n:velocityOvertimeModule.y')
public y = new CurveRange();
/**
@@ -87,7 +87,7 @@ export default class VelocityOvertimeModule extends ParticleModuleBase {
@serializable
@range([-1, 1])
@displayOrder(4)
@tooltip('Z 轴方向上的速度分量')
@tooltip('i18n:velocityOvertimeModule.z')
public z = new CurveRange();
/**
@@ -97,7 +97,7 @@ export default class VelocityOvertimeModule extends ParticleModuleBase {
@serializable
@range([-1, 1])
@displayOrder(5)
@tooltip('速度修正系数(只支持 CPU 粒子)')
@tooltip('i18n:velocityOvertimeModule.speedModifier')
public speedModifier = new CurveRange();
/**
@@ -106,7 +106,7 @@ export default class VelocityOvertimeModule extends ParticleModuleBase {
@type(Space)
@serializable
@displayOrder(1)
@tooltip('速度计算时采用的坐标系')
@tooltip('i18n:velocityOvertimeModule.space')
public space = Space.Local;
private rotation: Quat;
+5 -5
View File
@@ -51,7 +51,7 @@ export class Billboard extends Component {
* @zh Billboard纹理。
*/
@type(Texture2D)
@tooltip('billboard显示的贴图')
@tooltip('i18n:billboard.texture')
get texture () {
return this._texture;
}
@@ -69,7 +69,7 @@ export class Billboard extends Component {
/**
* @zh 高度。
*/
@tooltip('billboard的高度')
@tooltip('i18n:billboard.height')
get height () {
return this._height;
}
@@ -88,7 +88,7 @@ export class Billboard extends Component {
/**
* @zh 宽度。
*/
@tooltip('billboard的宽度')
@tooltip('i18n:billboard.width')
public get width () {
return this._width;
}
@@ -105,9 +105,9 @@ export class Billboard extends Component {
private _rotation = 0;
/**
* @zh 角度。
* @zh billboard绕中心点旋转的角度
*/
@tooltip('billboard绕中心点旋转的角度')
@tooltip('i18n:billboard.rotation')
public get rotation () {
return Math.round(toDegree(this._rotation) * 100) / 100;
}
+18 -18
View File
@@ -47,7 +47,7 @@ export default class ShapeModule {
* @zh 粒子发射器位置。
*/
@displayOrder(13)
@tooltip('粒子发射器位置')
@tooltip('i18n:shapeModule.position')
get position () {
return this._position;
}
@@ -60,7 +60,7 @@ export default class ShapeModule {
* @zh 粒子发射器旋转角度。
*/
@displayOrder(14)
@tooltip('粒子发射器旋转角度')
@tooltip('i18n:shapeModule.rotation')
get rotation () {
return this._rotation;
}
@@ -73,7 +73,7 @@ export default class ShapeModule {
* @zh 粒子发射器缩放比例。
*/
@displayOrder(15)
@tooltip('粒子发射器缩放比例')
@tooltip('i18n:shapeModule.scale')
get scale () {
return this._scale;
}
@@ -86,7 +86,7 @@ export default class ShapeModule {
* @zh 粒子发射器在一个扇形范围内发射。
*/
@displayOrder(6)
@tooltip('粒子发射器在一个扇形范围内发射')
@tooltip('i18n:shapeModule.arc')
get arc () {
return toDegree(this._arc);
}
@@ -100,7 +100,7 @@ export default class ShapeModule {
* 决定圆锥发射器的开合程度。
*/
@displayOrder(5)
@tooltip('圆锥的轴与母线的夹角\n决定圆锥发射器的开合程度')
@tooltip('i18n:shapeModule.angle')
get angle () {
return Math.round(toDegree(this._angle) * 100) / 100;
}
@@ -132,7 +132,7 @@ export default class ShapeModule {
public _shapeType = ShapeType.Cone;
@type(ShapeType)
@tooltip('粒子发射器类型')
@tooltip('i18n:shapeModule.shapeType')
public get shapeType () {
return this._shapeType;
}
@@ -165,7 +165,7 @@ export default class ShapeModule {
@type(EmitLocation)
@serializable
@displayOrder(2)
@tooltip('粒子从发射器哪个部位发射')
@tooltip('i18n:shapeModule.emitFrom')
public emitFrom = EmitLocation.Volume;
/**
@@ -173,7 +173,7 @@ export default class ShapeModule {
*/
@serializable
@displayOrder(16)
@tooltip('根据粒子的初始方向决定粒子的移动方向')
@tooltip('i18n:shapeModule.alignToDirection')
public alignToDirection = false;
/**
@@ -181,7 +181,7 @@ export default class ShapeModule {
*/
@serializable
@displayOrder(17)
@tooltip('粒子生成方向随机设定')
@tooltip('i18n:shapeModule.randomDirectionAmount')
public randomDirectionAmount = 0;
/**
@@ -189,7 +189,7 @@ export default class ShapeModule {
*/
@serializable
@displayOrder(18)
@tooltip('表示当前发射方向与当前位置到结点中心连线方向的插值')
@tooltip('i18n:shapeModule.sphericalDirectionAmount')
public sphericalDirectionAmount = 0;
/**
@@ -197,7 +197,7 @@ export default class ShapeModule {
*/
@serializable
@displayOrder(19)
@tooltip('粒子生成位置随机设定(设定此值为非 0 会使粒子生成位置超出生成器大小范围)')
@tooltip('i18n:shapeModule.randomPositionAmount')
public randomPositionAmount = 0;
/**
@@ -205,7 +205,7 @@ export default class ShapeModule {
*/
@serializable
@displayOrder(3)
@tooltip('粒子发射器半径')
@tooltip('i18n:shapeModule.radius')
public radius = 1;
/**
@@ -216,7 +216,7 @@ export default class ShapeModule {
*/
@serializable
@displayOrder(4)
@tooltip('粒子发射器发射位置(对 Box 类型的发射器无效):\n - 0 表示从表面发射;\n - 1 表示从中心发射;\n - 0 ~ 1 之间表示在中心到表面之间发射。')
@tooltip('i18n:shapeModule.radiusThickness')
public radiusThickness = 1;
/**
@@ -225,7 +225,7 @@ export default class ShapeModule {
@type(ArcMode)
@serializable
@displayOrder(7)
@tooltip('粒子在扇形范围内的发射方式')
@tooltip('i18n:shapeModule.arcMode')
public arcMode = ArcMode.Random;
/**
@@ -233,7 +233,7 @@ export default class ShapeModule {
*/
@serializable
@displayOrder(9)
@tooltip('控制可能产生粒子的弧周围的离散间隔')
@tooltip('i18n:shapeModule.arcSpread')
public arcSpread = 0;
/**
@@ -242,7 +242,7 @@ export default class ShapeModule {
@type(CurveRange)
@serializable
@displayOrder(10)
@tooltip('粒子沿圆周发射的速度')
@tooltip('i18n:shapeModule.arcSpeed')
public arcSpeed = new CurveRange();
/**
@@ -251,7 +251,7 @@ export default class ShapeModule {
*/
@serializable
@displayOrder(11)
@tooltip('圆锥顶部截面距离底部的轴长\n决定圆锥发射器的高度')
@tooltip('i18n:shapeModule.length')
public length = 5;
/**
@@ -259,7 +259,7 @@ export default class ShapeModule {
*/
@serializable
@displayOrder(12)
@tooltip('粒子发射器发射位置(针对 Box 类型的粒子发射器)')
@tooltip('i18n:shapeModule.boxThickness')
public boxThickness = new Vec3(0, 0, 0);
@serializable
+7 -7
View File
@@ -61,7 +61,7 @@ export class Line extends Component {
*/
@type(Texture2D)
@displayOrder(0)
@tooltip('线段中显示的贴图')
@tooltip('i18n:line.texture')
get texture () {
return this._texture;
}
@@ -83,7 +83,7 @@ export class Line extends Component {
* @zh positions是否为世界空间坐标。
*/
@displayOrder(1)
@tooltip('线段中各个点的坐标采用哪个坐标系,勾选使用世界坐标系,不选使用本地坐标系')
@tooltip('i18n:line.worldSpace')
get worldSpace () {
return this._worldSpace;
}
@@ -107,7 +107,7 @@ export class Line extends Component {
*/
@type([Vec3])
@displayOrder(2)
@tooltip('每个线段端点的坐标')
@tooltip('i18n:line.positions')
get positions () {
return this._positions;
}
@@ -127,7 +127,7 @@ export class Line extends Component {
*/
@type(CurveRange)
@displayOrder(3)
@tooltip('线段宽度,如果采用曲线,则表示沿着线段方向上的曲线变化')
@tooltip('i18n:line.width')
get width () {
return this._width;
}
@@ -147,7 +147,7 @@ export class Line extends Component {
*/
@type(Vec2)
@displayOrder(4)
@tooltip('贴图平铺次数')
@tooltip('i18n:line.tile')
get tile () {
return this._tile;
}
@@ -166,7 +166,7 @@ export class Line extends Component {
@type(Vec2)
@displayOrder(5)
@tooltip('贴图坐标的偏移')
@tooltip('i18n:line.offset')
get offset () {
return this._offset;
}
@@ -188,7 +188,7 @@ export class Line extends Component {
*/
@type(GradientRange)
@displayOrder(6)
@tooltip('线段颜色,如果采用渐变色,则表示沿着线段方向上的颜色渐变')
@tooltip('i18n:line.color')
get color () {
return this._color;
}
+45 -45
View File
@@ -71,7 +71,7 @@ export class ParticleSystem extends RenderableComponent {
* @zh 粒子系统能生成的最大粒子数量。
*/
@displayOrder(1)
@tooltip('粒子系统能生成的最大粒子数量')
@tooltip('i18n:particle_system.capacity')
public get capacity () {
return this._capacity;
}
@@ -91,18 +91,18 @@ export class ParticleSystem extends RenderableComponent {
@type(GradientRange)
@serializable
@displayOrder(8)
@tooltip('粒子初始颜色')
@tooltip('i18n:particle_system.startColor')
public startColor = new GradientRange();
@type(Space)
@serializable
@displayOrder(9)
@tooltip('选择缩放坐标系')
@tooltip('i18n:particle_system.scaleSpace')
public scaleSpace = Space.Local;
@serializable
@displayOrder(10)
@tooltip('粒子初始大小')
@tooltip('i18n:particle_system.startSize3D')
public startSize3D = false;
/**
@@ -111,7 +111,7 @@ export class ParticleSystem extends RenderableComponent {
@formerlySerializedAs('startSize')
@type(CurveRange)
@displayOrder(10)
@tooltip('粒子初始大小')
@tooltip('i18n:particle_system.startSizeX')
public startSizeX = new CurveRange();
/**
@@ -120,7 +120,7 @@ export class ParticleSystem extends RenderableComponent {
@type(CurveRange)
@serializable
@displayOrder(10)
@tooltip('粒子初始大小')
@tooltip('i18n:particle_system.startSizeY')
public startSizeY = new CurveRange();
/**
@@ -129,7 +129,7 @@ export class ParticleSystem extends RenderableComponent {
@type(CurveRange)
@serializable
@displayOrder(10)
@tooltip('粒子初始大小')
@tooltip('i18n:particle_system.startSizeZ')
public startSizeZ = new CurveRange();
/**
@@ -139,12 +139,12 @@ export class ParticleSystem extends RenderableComponent {
@serializable
@range([-1, 1])
@displayOrder(11)
@tooltip('粒子初始速度')
@tooltip('i18n:particle_system.startSpeed')
public startSpeed = new CurveRange();
@serializable
@displayOrder(12)
@tooltip('粒子初始旋转角度')
@tooltip('i18n:particle_system.startRotation3D')
public startRotation3D = false;
/**
@@ -155,7 +155,7 @@ export class ParticleSystem extends RenderableComponent {
@range([-1, 1])
@radian
@displayOrder(12)
@tooltip('粒子初始旋转角度')
@tooltip('i18n:particle_system.startRotationX')
public startRotationX = new CurveRange();
/**
@@ -166,7 +166,7 @@ export class ParticleSystem extends RenderableComponent {
@range([-1, 1])
@radian
@displayOrder(12)
@tooltip('粒子初始旋转角度')
@tooltip('i18n:particle_system.startRotationY')
public startRotationY = new CurveRange();
/**
@@ -177,7 +177,7 @@ export class ParticleSystem extends RenderableComponent {
@range([-1, 1])
@radian
@displayOrder(12)
@tooltip('粒子初始旋转角度')
@tooltip('i18n:particle_system.startRotationZ')
public startRotationZ = new CurveRange();
/**
@@ -186,7 +186,7 @@ export class ParticleSystem extends RenderableComponent {
@type(CurveRange)
@serializable
@displayOrder(6)
@tooltip('粒子系统开始运行后,延迟粒子发射的时间')
@tooltip('i18n:particle_system.startDelay')
public startDelay = new CurveRange();
/**
@@ -195,7 +195,7 @@ export class ParticleSystem extends RenderableComponent {
@type(CurveRange)
@serializable
@displayOrder(7)
@tooltip('粒子生命周期')
@tooltip('i18n:particle_system.startLifetime')
public startLifetime = new CurveRange();
/**
@@ -203,7 +203,7 @@ export class ParticleSystem extends RenderableComponent {
*/
@serializable
@displayOrder(0)
@tooltip('粒子系统运行时间')
@tooltip('i18n:particle_system.duration')
public duration = 5.0;
/**
@@ -211,14 +211,14 @@ export class ParticleSystem extends RenderableComponent {
*/
@serializable
@displayOrder(2)
@tooltip('粒子系统是否循环播放')
@tooltip('i18n:particle_system.loop')
public loop = true;
/**
* @zh 选中之后,粒子系统会以已播放完一轮之后的状态开始播放(仅当循环播放启用时有效)。
*/
@displayOrder(3)
@tooltip('选中之后,粒子系统会以已播放完一轮之后的状态开始播放(仅当循环播放启用时有效)')
@tooltip('i18n:particle_system.prewarm')
get prewarm () {
return this._prewarm;
}
@@ -236,7 +236,7 @@ export class ParticleSystem extends RenderableComponent {
@type(Space)
@serializable
@displayOrder(4)
@tooltip('控制粒子坐标计算所在的坐标系')
@tooltip('i18n:particle_system.simulationSpace')
get simulationSpace () {
return this._simulationSpace;
}
@@ -256,7 +256,7 @@ export class ParticleSystem extends RenderableComponent {
*/
@serializable
@displayOrder(5)
@tooltip('控制整个粒子系统的更新速度')
@tooltip('i18n:particle_system.simulationSpeed')
public simulationSpeed = 1.0;
/**
@@ -264,7 +264,7 @@ export class ParticleSystem extends RenderableComponent {
*/
@serializable
@displayOrder(2)
@tooltip('粒子系统加载后是否自动开始播放')
@tooltip('i18n:particle_system.playOnAwake')
public playOnAwake = true;
/**
@@ -274,7 +274,7 @@ export class ParticleSystem extends RenderableComponent {
@serializable
@range([-1, 1])
@displayOrder(13)
@tooltip('粒子受重力影响的重力系数')
@tooltip('i18n:particle_system.gravityModifier')
public gravityModifier = new CurveRange();
// emission module
@@ -284,7 +284,7 @@ export class ParticleSystem extends RenderableComponent {
@type(CurveRange)
@serializable
@displayOrder(14)
@tooltip('每秒发射的粒子数')
@tooltip('i18n:particle_system.rateOverTime')
public rateOverTime = new CurveRange();
/**
@@ -293,7 +293,7 @@ export class ParticleSystem extends RenderableComponent {
@type(CurveRange)
@serializable
@displayOrder(15)
@tooltip('每移动单位距离发射的粒子数')
@tooltip('i18n:particle_system.rateOverDistance')
public rateOverDistance = new CurveRange();
/**
@@ -302,14 +302,14 @@ export class ParticleSystem extends RenderableComponent {
@type([Burst])
@serializable
@displayOrder(16)
@tooltip('在某个时间点发射给定数量的粒子')
@tooltip('i18n:particle_system.bursts')
public bursts: Burst[] = [];
@override
@visible(false)
@type(Material)
@serializable
@displayName('Materials')
@visible(false)
get sharedMaterials () {
// if we don't create an array copy, the editor will modify the original array directly.
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
@@ -323,13 +323,13 @@ export class ParticleSystem extends RenderableComponent {
// color over lifetime module
@type(ColorOverLifetimeModule)
_colorOverLifetimeModule:ColorOverLifetimeModule | null = null;
_colorOverLifetimeModule: ColorOverLifetimeModule | null = null;
/**
* @zh 颜色控制模块。
*/
@type(ColorOverLifetimeModule)
@displayOrder(23)
@tooltip('颜色模块')
@tooltip('i18n:particle_system.colorOverLifetimeModule')
public get colorOverLifetimeModule () {
if (EDITOR) {
if (!this._colorOverLifetimeModule) {
@@ -347,13 +347,13 @@ export class ParticleSystem extends RenderableComponent {
// shape module
@type(ShapeModule)
_shapeModule:ShapeModule | null = null;
_shapeModule: ShapeModule | null = null;
/**
* @zh 粒子发射器模块。
*/
@type(ShapeModule)
@displayOrder(17)
@tooltip('发射器模块')
@tooltip('i18n:particle_system.shapeModule')
public get shapeModule () {
if (EDITOR) {
if (!this._shapeModule) {
@@ -371,13 +371,13 @@ export class ParticleSystem extends RenderableComponent {
// size over lifetime module
@type(SizeOvertimeModule)
_sizeOvertimeModule:SizeOvertimeModule | null = null;
_sizeOvertimeModule: SizeOvertimeModule | null = null;
/**
* @zh 粒子大小模块。
*/
@type(SizeOvertimeModule)
@displayOrder(21)
@tooltip('大小模块')
@tooltip('i18n:particle_system.sizeOvertimeModule')
public get sizeOvertimeModule () {
if (EDITOR) {
if (!this._sizeOvertimeModule) {
@@ -395,13 +395,13 @@ export class ParticleSystem extends RenderableComponent {
// velocity overtime module
@type(VelocityOvertimeModule)
_velocityOvertimeModule:VelocityOvertimeModule | null = null;
_velocityOvertimeModule: VelocityOvertimeModule | null = null;
/**
* @zh 粒子速度模块。
*/
@type(VelocityOvertimeModule)
@displayOrder(18)
@tooltip('速度模块')
@tooltip('i18n:particle_system.velocityOvertimeModule')
public get velocityOvertimeModule () {
if (EDITOR) {
if (!this._velocityOvertimeModule) {
@@ -419,13 +419,13 @@ export class ParticleSystem extends RenderableComponent {
// force overTime module
@type(ForceOvertimeModule)
_forceOvertimeModule:ForceOvertimeModule | null = null;
_forceOvertimeModule: ForceOvertimeModule | null = null;
/**
* @zh 粒子加速度模块。
*/
@type(ForceOvertimeModule)
@displayOrder(19)
@tooltip('加速度模块')
@tooltip('i18n:particle_system.forceOvertimeModule')
public get forceOvertimeModule () {
if (EDITOR) {
if (!this._forceOvertimeModule) {
@@ -443,14 +443,14 @@ export class ParticleSystem extends RenderableComponent {
// limit velocity overtime module
@type(LimitVelocityOvertimeModule)
_limitVelocityOvertimeModule:LimitVelocityOvertimeModule | null = null;
_limitVelocityOvertimeModule: LimitVelocityOvertimeModule | null = null;
/**
* @zh 粒子限制速度模块(只支持 CPU 粒子)。
*/
@type(LimitVelocityOvertimeModule)
@displayOrder(20)
@tooltip('限速模块')
@tooltip('i18n:particle_system.limitVelocityOvertimeModule')
public get limitVelocityOvertimeModule () {
if (EDITOR) {
if (!this._limitVelocityOvertimeModule) {
@@ -468,13 +468,13 @@ export class ParticleSystem extends RenderableComponent {
// rotation overtime module
@type(RotationOvertimeModule)
_rotationOvertimeModule:RotationOvertimeModule | null = null;
_rotationOvertimeModule: RotationOvertimeModule | null = null;
/**
* @zh 粒子旋转模块。
*/
@type(RotationOvertimeModule)
@displayOrder(22)
@tooltip('旋转模块')
@tooltip('i18n:particle_system.rotationOvertimeModule')
public get rotationOvertimeModule () {
if (EDITOR) {
if (!this._rotationOvertimeModule) {
@@ -492,13 +492,13 @@ export class ParticleSystem extends RenderableComponent {
// texture animation module
@type(TextureAnimationModule)
_textureAnimationModule:TextureAnimationModule | null = null;
_textureAnimationModule: TextureAnimationModule | null = null;
/**
* @zh 贴图动画模块。
*/
@type(TextureAnimationModule)
@displayOrder(24)
@tooltip('贴图动画模块')
@tooltip('i18n:particle_system.textureAnimationModule')
public get textureAnimationModule () {
if (EDITOR) {
if (!this._textureAnimationModule) {
@@ -516,13 +516,13 @@ export class ParticleSystem extends RenderableComponent {
// trail module
@type(TrailModule)
_trailModule:TrailModule | null = null;
_trailModule: TrailModule | null = null;
/**
* @zh 粒子轨迹模块。
*/
@type(TrailModule)
@displayOrder(25)
@tooltip('拖尾模块')
@tooltip('i18n:particle_system.trailModule')
public get trailModule () {
if (EDITOR) {
if (!this._trailModule) {
@@ -543,13 +543,13 @@ export class ParticleSystem extends RenderableComponent {
@type(ParticleSystemRenderer)
@serializable
@displayOrder(26)
@tooltip('渲染模块')
@tooltip('i18n:particle_system.renderer')
public renderer: ParticleSystemRenderer = new ParticleSystemRenderer();
// serilized culling
@serializable
@displayOrder(27)
@tooltip('是否剔除非 enable 的模块数据')
@tooltip('i18n:particle_system.enableCulling')
public enableCulling = false;
/**
@@ -50,7 +50,7 @@ export default class ParticleSystemRenderer {
*/
@type(RenderMode)
@displayOrder(0)
@tooltip('设定粒子生成模式')
@tooltip('i18n:particleSystemRenderer.renderMode')
public get renderMode () {
return this._renderMode;
}
@@ -60,21 +60,25 @@ export default class ParticleSystemRenderer {
return;
}
this._renderMode = val;
this._particleSystem.processor.updateRenderMode();
if (this._particleSystem) {
this._particleSystem.processor.updateRenderMode();
}
}
/**
* @zh 在粒子生成方式为 StrecthedBillboard 时,对粒子在运动方向上按速度大小进行拉伸。
*/
@displayOrder(1)
@tooltip('在粒子生成方式为 StrecthedBillboard 时,对粒子在运动方向上按速度大小进行拉伸')
@tooltip('i18n:particleSystemRenderer.velocityScale')
public get velocityScale () {
return this._velocityScale;
}
public set velocityScale (val) {
this._velocityScale = val;
this._particleSystem.processor.updateMaterialParams();
if (this._particleSystem) {
this._particleSystem.processor.updateMaterialParams();
}
// this._updateModel();
}
@@ -82,14 +86,16 @@ export default class ParticleSystemRenderer {
* @zh 在粒子生成方式为 StrecthedBillboard 时,对粒子在运动方向上按粒子大小进行拉伸。
*/
@displayOrder(2)
@tooltip('在粒子生成方式为 StrecthedBillboard 时,对粒子在运动方向上按粒子大小进行拉伸')
@tooltip('i18n:particleSystemRenderer.lengthScale')
public get lengthScale () {
return this._lengthScale;
}
public set lengthScale (val) {
this._lengthScale = val;
this._particleSystem.processor.updateMaterialParams();
if (this._particleSystem) {
this._particleSystem.processor.updateMaterialParams();
}
// this._updateModel();
}
@@ -111,14 +117,16 @@ export default class ParticleSystemRenderer {
*/
@type(Mesh)
@displayOrder(7)
@tooltip('粒子发射的模型')
@tooltip('i18n:particleSystemRenderer.mesh')
public get mesh () {
return this._mesh;
}
public set mesh (val) {
this._mesh = val;
this._particleSystem.processor.setVertexAttributes();
if (this._particleSystem) {
this._particleSystem.processor.setVertexAttributes();
}
}
/**
@@ -126,16 +134,19 @@ export default class ParticleSystemRenderer {
*/
@type(Material)
@displayOrder(8)
@tooltip('粒子使用的材质')
@tooltip('i18n:particleSystemRenderer.particleMaterial')
public get particleMaterial () {
if (!this._particleSystem) {
return null;
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return this._particleSystem.getMaterial(0);
}
public set particleMaterial (val) {
this._particleSystem.setMaterial(val, 0);
if (this._particleSystem) {
this._particleSystem.setMaterial(val, 0);
}
}
/**
@@ -143,11 +154,12 @@ export default class ParticleSystemRenderer {
*/
@type(Material)
@displayOrder(9)
@tooltip('拖尾使用的材质')
@tooltip('i18n:particleSystemRenderer.trailMaterial')
public get trailMaterial () {
if (!this._particleSystem) {
return null;
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return this._particleSystem.getMaterial(1)!;
}
@@ -170,7 +182,7 @@ export default class ParticleSystemRenderer {
private _useGPU = false;
@displayOrder(10)
@tooltip('是否启用GPU粒子')
@tooltip('i18n:particleSystemRenderer.useGPU')
public get useGPU () {
return this._useGPU;
}
+10 -10
View File
@@ -205,7 +205,7 @@ export default class TrailModule {
@type(TrailMode)
@serializable
@displayOrder(1)
@tooltip('Particle在每个粒子的运动轨迹上形成拖尾效果')
@tooltip('i18n:trailSegment.mode')
public mode = TrailMode.Particles;
/**
@@ -214,7 +214,7 @@ export default class TrailModule {
@type(CurveRange)
@serializable
@displayOrder(3)
@tooltip('拖尾的生命周期')
@tooltip('i18n:trailSegment.lifeTime')
public lifeTime = new CurveRange();
@serializable
@@ -224,7 +224,7 @@ export default class TrailModule {
* 每个轨迹粒子之间的最小间距。
*/
@displayOrder(5)
@tooltip('粒子每生成一个拖尾节点所运行的最短距离')
@tooltip('i18n:trailSegment.minParticleDistance')
public get minParticleDistance () {
return this._minParticleDistance;
}
@@ -236,7 +236,7 @@ export default class TrailModule {
@type(Space)
@displayOrder(6)
@tooltip('拖尾所在的坐标系,World在世界坐标系中运行,Local在本地坐标系中运行')
@tooltip('i18n:trailSegment.space')
public get space () {
return this._space;
}
@@ -260,12 +260,12 @@ export default class TrailModule {
@type(TextureMode)
@serializable
@displayOrder(8)
@tooltip('贴图在拖尾上的展开形式,Stretch贴图覆盖在整条拖尾上,Repeat贴图覆盖在一段拖尾上')
@tooltip('i18n:trailSegment.textureMode')
public textureMode = TextureMode.Stretch;
@serializable
@displayOrder(9)
@tooltip('拖尾宽度继承自粒子大小')
@tooltip('i18n:trailSegment.widthFromParticle')
public widthFromParticle = true;
/**
@@ -274,24 +274,24 @@ export default class TrailModule {
@type(CurveRange)
@serializable
@displayOrder(10)
@tooltip('拖尾宽度,如果继承自粒子则是粒子大小的比例')
@tooltip('i18n:trailSegment.widthRatio')
public widthRatio = new CurveRange();
@serializable
@displayOrder(11)
@tooltip('拖尾颜色是否继承自粒子')
@tooltip('i18n:trailSegment.colorFromParticle')
public colorFromParticle = false;
@type(GradientRange)
@serializable
@displayOrder(12)
@tooltip('拖尾颜色随拖尾自身长度的颜色渐变')
@tooltip('i18n:trailSegment.colorOverTrail')
public colorOverTrail = new GradientRange();
@type(GradientRange)
@serializable
@displayOrder(13)
@tooltip('拖尾颜色随时间的颜色渐变')
@tooltip('i18n:trailSegment.colorOvertime')
public colorOvertime = new GradientRange();
/**
+5
View File
@@ -1,3 +1,8 @@
/**
* @packageDocumentation
* @hidden
*/
import { select } from '../framework/physics-selector';
import { b2PhysicsWorld } from './physics-world';
import { b2RigidBody2D } from './rigid-body';
@@ -1,3 +1,7 @@
/**
* @packageDocumentation
* @hidden
*/
import b2 from '@cocos/box2d';
import { IDistanceJoint } from '../../spec/i-physics-joint';
import { b2Joint } from './joint-2d';

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