mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
Merge branch 'v3.4.0' of https://gitlab.cocos.net/publics/engine into v3.5.0
This commit is contained in:
@@ -17,8 +17,12 @@ jobs:
|
||||
working-directory: ./engine
|
||||
run: |
|
||||
git fetch origin ${{ github.base_ref }}
|
||||
git checkout -b ${{ github.base_ref }} remotes/origin/${{ github.base_ref }}
|
||||
git checkout -b ${{ github.base_ref }}_BASE remotes/origin/${{ github.base_ref }}
|
||||
git branch
|
||||
|
||||
- name: npm install BASE branch
|
||||
working-directory: ./engine
|
||||
run: |
|
||||
npm install --ignore-scripts
|
||||
|
||||
- name: build BASE declaration
|
||||
@@ -27,12 +31,32 @@ jobs:
|
||||
npm run build-declaration
|
||||
cp ./bin/.declarations/cc.d.ts ./bin/cc_base.d.ts
|
||||
|
||||
- name: rebase HEAD branch
|
||||
- name: clear dependencies
|
||||
working-directory: ./engine
|
||||
run: |
|
||||
git checkout .
|
||||
rm -r ./node_modules
|
||||
rm ./package-lock.json
|
||||
ls -la
|
||||
|
||||
- name: checkout HEAD branch
|
||||
working-directory: ./engine
|
||||
run: |
|
||||
git remote add HEAD_REPO https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git
|
||||
git pull --rebase HEAD_REPO ${{ github.head_ref }}
|
||||
git fetch HEAD_REPO ${{ github.head_ref }}
|
||||
git checkout -b ${{ github.head_ref }}_HEAD remotes/HEAD_REPO/${{ github.head_ref }}
|
||||
git branch
|
||||
|
||||
- name: rebase BASE branch
|
||||
working-directory: ./engine
|
||||
run: |
|
||||
git checkout .
|
||||
git pull --rebase origin ${{ github.base_ref }}
|
||||
|
||||
- name: npm install HEAD branch
|
||||
working-directory: ./engine
|
||||
run: |
|
||||
npm install --ignore-scripts
|
||||
|
||||
- name: build HEAD declaration
|
||||
working-directory: ./engine
|
||||
|
||||
@@ -621,7 +621,6 @@ Invalid index in MultiplexLayer switchTo message
|
||||
cc.Layer.addLayer(): layer should be non-null
|
||||
|
||||
### 2104
|
||||
|
||||
Layer collision. The name of layer (%s) is collided with the name or value of some layer
|
||||
|
||||
### 2200
|
||||
@@ -3185,7 +3184,3 @@ Graph update has been interrupted since too many transitions(greater than %s) oc
|
||||
### 14100
|
||||
|
||||
Pool.destroy no longer take a function as parameter, Please specify destruct function in the construction of Pool instead
|
||||
|
||||
### 14200
|
||||
|
||||
Batcher2D.commitComp could not be used for components without render data, please use commitPlainComp instead
|
||||
|
||||
@@ -34,7 +34,7 @@ import { Color, Rect } from '../../../core/math';
|
||||
import { IBatcher } from '../../renderer/i-batcher';
|
||||
import { Label } from '../../components/label';
|
||||
import { IAssembler } from '../../renderer/base';
|
||||
import { fillMeshVertices3D, updateCachedVertices } from '../utils';
|
||||
import { fillMeshVertices3D } from '../utils';
|
||||
import { bmfontUtils } from './bmfontUtils';
|
||||
|
||||
const tempColor = new Color(255, 255, 255, 255);
|
||||
@@ -55,13 +55,6 @@ export const bmfont: IAssembler = {
|
||||
fillMeshVertices3D(node, renderer, comp.renderData!, tempColor);
|
||||
},
|
||||
|
||||
fillCacheBuffer (comp: Label) {
|
||||
const node = comp.node;
|
||||
tempColor.set(comp.color);
|
||||
tempColor.a = node._uiProps.opacity * 255;
|
||||
updateCachedVertices(node, comp.renderData!, tempColor);
|
||||
},
|
||||
|
||||
appendQuad (comp: Label, spriteFrame: SpriteFrame, rect: Rect, rotated: boolean, x: number, y: number, scale: number) {
|
||||
const renderData = comp.renderData;
|
||||
if (!renderData) {
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
import { addon } from '../../../core/utils/js';
|
||||
import { IBatcher } from '../../renderer/i-batcher';
|
||||
import { Label } from '../../components/label';
|
||||
import { fillMeshVertices3D, updateCachedVertices } from '../utils';
|
||||
import { fillMeshVertices3D } from '../utils';
|
||||
import { bmfont } from './bmfont';
|
||||
import { letterFont } from './letter-font';
|
||||
import { Color } from '../../../core/math/color';
|
||||
@@ -57,16 +57,6 @@ export const letter = {
|
||||
fillMeshVertices3D(node, renderer, comp.renderData, WHITE);
|
||||
},
|
||||
|
||||
fillCacheBuffer (comp: Label) {
|
||||
if (!comp.renderData) {
|
||||
return;
|
||||
}
|
||||
|
||||
const node = comp.node;
|
||||
WHITE.a = node._uiProps.opacity * 255;
|
||||
updateCachedVertices(node, comp.renderData, WHITE);
|
||||
},
|
||||
|
||||
appendQuad: bmfont.appendQuad,
|
||||
};
|
||||
|
||||
|
||||
@@ -79,8 +79,6 @@ export const ttf: IAssembler = {
|
||||
vertexOffset = 0;
|
||||
}
|
||||
|
||||
renderData.cacheBuffer = buffer;
|
||||
renderData.bufferOffset = vertexOffset;
|
||||
// buffer data may be reallocated, need get reference after request.
|
||||
const vBuf = buffer.vData!;
|
||||
const iBuf = buffer.iData!;
|
||||
@@ -126,50 +124,6 @@ export const ttf: IAssembler = {
|
||||
iBuf[indicesOffset++] = vertexId + 3;
|
||||
},
|
||||
|
||||
fillCacheBuffer (comp: Label) {
|
||||
const renderData = comp.renderData!;
|
||||
const dataList: IRenderData[] = renderData.data;
|
||||
const node = comp.node;
|
||||
|
||||
const buffer = renderData.cacheBuffer!;
|
||||
const vertexOffset = renderData.bufferOffset;
|
||||
const vBuf = buffer.vData!;
|
||||
|
||||
const vData = renderData.vData!;
|
||||
const data0 = dataList[0];
|
||||
const data3 = dataList[3];
|
||||
/* */
|
||||
node.updateWorldTransform();
|
||||
// @ts-expect-error private property access
|
||||
const pos = node._pos; const rot = node._rot; const scale = node._scale;
|
||||
const ax = data0.x * scale.x; const bx = data3.x * scale.x;
|
||||
const ay = data0.y * scale.y; const by = data3.y * scale.y;
|
||||
const qx = rot.x; const qy = rot.y; const qz = rot.z; const qw = rot.w;
|
||||
const qxy = qx * qy; const qzw = qz * qw;
|
||||
const qxy2 = qx * qx - qy * qy;
|
||||
const qzw2 = qw * qw - qz * qz;
|
||||
const cx1 = qzw2 + qxy2;
|
||||
const cx2 = (qxy - qzw) * 2;
|
||||
const cy1 = qzw2 - qxy2;
|
||||
const cy2 = (qxy + qzw) * 2;
|
||||
const x = pos.x; const y = pos.y;
|
||||
// left bottom
|
||||
vData[0] = cx1 * ax + cx2 * ay + x;
|
||||
vData[1] = cy1 * ay + cy2 * ax + y;
|
||||
// right bottom
|
||||
vData[9] = cx1 * bx + cx2 * ay + x;
|
||||
vData[10] = cy1 * ay + cy2 * bx + y;
|
||||
// left top
|
||||
vData[18] = cx1 * ax + cx2 * by + x;
|
||||
vData[19] = cy1 * by + cy2 * ax + y;
|
||||
// right top
|
||||
vData[27] = cx1 * bx + cx2 * by + x;
|
||||
vData[28] = cy1 * by + cy2 * bx + y;
|
||||
|
||||
vBuf.set(vData, vertexOffset);
|
||||
buffer.setDirty();
|
||||
},
|
||||
|
||||
updateVertexData (comp: Label) {
|
||||
const renderData = comp.renderData;
|
||||
if (!renderData) {
|
||||
|
||||
@@ -352,7 +352,9 @@ export const ttfUtils = {
|
||||
_texture.rect = new Rect(0, 0, _canvas.width, _canvas.height);
|
||||
_texture._calculateUV();
|
||||
}
|
||||
comp.setTextureDirty();
|
||||
if (comp.renderData) {
|
||||
comp.renderData.textureDirty = true;
|
||||
}
|
||||
if (legacyCC.director.root && legacyCC.director.root.batcher2D) {
|
||||
legacyCC.director.root.batcher2D._releaseDescriptorSetCache(tex.getHash());
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ import { Mask, MaskType } from '../../components/mask';
|
||||
import { IAssembler, IAssemblerManager } from '../../renderer/base';
|
||||
import { StencilManager } from '../../renderer/stencil-manager';
|
||||
import { simple } from '../sprite';
|
||||
import { legacyCC } from '../../../core/global-exports';
|
||||
|
||||
const _stencilManager = StencilManager.sharedManager!;
|
||||
|
||||
@@ -54,17 +53,6 @@ function applyAreaMask (mask: Mask, renderer: IBatcher) {
|
||||
}
|
||||
}
|
||||
|
||||
function updateMaskForCacheBuffer (mask: Mask, renderer: IBatcher) {
|
||||
_stencilManager.enterLevel(mask);
|
||||
if (mask.type === MaskType.IMAGE_STENCIL) {
|
||||
simple.fillCacheBuffer(mask);
|
||||
const mat = mask.graphics!.getMaterialInstance(0)!;
|
||||
renderer.forceMergeBatches(mat, mask.spriteFrame, mask.graphics!);
|
||||
} else {
|
||||
mask.graphics!.updateAssembler(renderer);
|
||||
}
|
||||
}
|
||||
|
||||
export const maskAssembler: IAssembler = {
|
||||
createData (mask: Mask) {
|
||||
const renderData = mask.requestRenderData();
|
||||
@@ -94,29 +82,12 @@ export const maskAssembler: IAssembler = {
|
||||
_stencilManager.enableMask();
|
||||
}
|
||||
},
|
||||
|
||||
fillCacheBuffer (mask: Mask) {
|
||||
if (mask.type !== MaskType.IMAGE_STENCIL || mask.spriteFrame) {
|
||||
const renderer = legacyCC.director.root!.batcher2D;
|
||||
_stencilManager.pushMask(mask);
|
||||
|
||||
renderer.finishMergeBatches();
|
||||
applyClearMask(mask, renderer);
|
||||
updateMaskForCacheBuffer(mask, renderer);
|
||||
|
||||
_stencilManager.enableMask();
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export const maskEndAssembler: IAssembler = {
|
||||
fillBuffers (mask: Mask, ui: IBatcher) {
|
||||
_stencilManager.exitMask();
|
||||
},
|
||||
|
||||
fillCacheBuffer (mask: Mask) {
|
||||
_stencilManager.exitMask();
|
||||
},
|
||||
};
|
||||
|
||||
const StartAssembler: IAssemblerManager = {
|
||||
|
||||
@@ -33,7 +33,7 @@ import { IRenderData, RenderData } from '../../renderer/render-data';
|
||||
import { IBatcher } from '../../renderer/i-batcher';
|
||||
import { Sprite } from '../../components';
|
||||
import { IAssembler } from '../../renderer/base';
|
||||
import { fillVerticesWithoutCalc3D, updateCachedVerticesWithoutCalc3D } from '../utils';
|
||||
import { fillVerticesWithoutCalc3D } from '../utils';
|
||||
import { errorID } from '../../../core/platform/debug';
|
||||
import { dynamicAtlasManager } from '../../utils/dynamic-atlas/atlas-manager';
|
||||
|
||||
@@ -266,16 +266,6 @@ export const barFilled: IAssembler = {
|
||||
fillVerticesWithoutCalc3D(node, renderer, sprite.renderData!, tempColor);
|
||||
},
|
||||
|
||||
fillCacheBuffer (sprite: Sprite) {
|
||||
if (sprite.node.hasChangedFlags) {
|
||||
this.updateWorldVertexData(sprite);
|
||||
}
|
||||
const node = sprite.node;
|
||||
tempColor.set(sprite.color);
|
||||
tempColor.a = node._uiProps.opacity * 255;
|
||||
updateCachedVerticesWithoutCalc3D(node, sprite.renderData!, tempColor);
|
||||
},
|
||||
|
||||
updateColor (sprite: Sprite) {
|
||||
},
|
||||
};
|
||||
|
||||
@@ -34,7 +34,7 @@ import { IRenderData, RenderData } from '../../renderer/render-data';
|
||||
import { IBatcher } from '../../renderer/i-batcher';
|
||||
import { Sprite } from '../../components';
|
||||
import { IAssembler } from '../../renderer/base';
|
||||
import { fillVertices3D, updateCachedVertices } from '../utils';
|
||||
import { fillVertices3D } from '../utils';
|
||||
import { dynamicAtlasManager } from '../../utils/dynamic-atlas/atlas-manager';
|
||||
|
||||
const PI_2 = Math.PI * 2;
|
||||
@@ -372,14 +372,6 @@ export const radialFilled: IAssembler = {
|
||||
fillVertices3D(node, renderer, renderData, tempColor);
|
||||
},
|
||||
|
||||
fillCacheBuffer (comp: Sprite) {
|
||||
const node = comp.node;
|
||||
const renderData: RenderData = comp.renderData!;
|
||||
tempColor.set(comp.color);
|
||||
tempColor.a = node._uiProps.opacity * 255;
|
||||
updateCachedVertices(node, renderData, tempColor);
|
||||
},
|
||||
|
||||
updateColor (sprite: Sprite) {
|
||||
},
|
||||
};
|
||||
|
||||
@@ -186,9 +186,6 @@ export const simple: IAssembler = {
|
||||
const iBuf = buffer.iData!;
|
||||
|
||||
vBuf.set(vData, vertexOffset);
|
||||
const renderData = sprite.renderData!;
|
||||
renderData.cacheBuffer = buffer;
|
||||
renderData.bufferOffset = vertexOffset;
|
||||
|
||||
const index0 = vertexId; const index1 = vertexId + 1;
|
||||
const index2 = vertexId + 2; const index3 = vertexId + 3;
|
||||
@@ -202,22 +199,6 @@ export const simple: IAssembler = {
|
||||
iBuf[indicesOffset++] = index3;
|
||||
},
|
||||
|
||||
fillCacheBuffer (sprite: Sprite) {
|
||||
if (sprite === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const renderData = sprite.renderData!;
|
||||
const vData = renderData.vData!;
|
||||
if (sprite.node.hasChangedFlags) {
|
||||
this.updateWorldVerts(sprite, vData);
|
||||
}
|
||||
const meshBuffer = renderData.cacheBuffer!;
|
||||
const vBuf = meshBuffer.vData!;
|
||||
vBuf.set(vData, renderData.bufferOffset);
|
||||
meshBuffer.setDirty();
|
||||
},
|
||||
|
||||
updateVertexData (sprite: Sprite) {
|
||||
const renderData: RenderData | null = sprite.renderData;
|
||||
if (!renderData) {
|
||||
|
||||
@@ -145,9 +145,6 @@ export const sliced: IAssembler = {
|
||||
vertexId = 0;
|
||||
}
|
||||
|
||||
renderData!.cacheBuffer = buffer;
|
||||
renderData!.bufferOffset = vertexOffset;
|
||||
|
||||
// buffer data may be realloc, need get reference after request.
|
||||
const vBuf: Float32Array|null = buffer.vData;
|
||||
// const uintbuf = buffer._uintVData,
|
||||
@@ -180,35 +177,6 @@ export const sliced: IAssembler = {
|
||||
}
|
||||
},
|
||||
|
||||
fillCacheBuffer (sprite: Sprite) {
|
||||
if (sprite === null) {
|
||||
return;
|
||||
}
|
||||
if (sprite.node.hasChangedFlags) {
|
||||
this.updateWorldVertexData(sprite);
|
||||
}
|
||||
const renderData = sprite.renderData!;
|
||||
const dataList: IRenderData[] = renderData.data;
|
||||
const uvSliced: IUV[] = sprite.spriteFrame!.uvSliced;
|
||||
const meshBuffer = renderData.cacheBuffer!;
|
||||
const vBuf: Float32Array|null = meshBuffer.vData;
|
||||
let vertexOffset = renderData.bufferOffset;
|
||||
for (let i = 4; i < 20; ++i) {
|
||||
const vert = dataList[i];
|
||||
const uvs = uvSliced[i - 4];
|
||||
|
||||
vBuf![vertexOffset++] = vert.x;
|
||||
vBuf![vertexOffset++] = vert.y;
|
||||
vBuf![vertexOffset++] = vert.z;
|
||||
vBuf![vertexOffset++] = uvs.u;
|
||||
vBuf![vertexOffset++] = uvs.v;
|
||||
Color.toArray(vBuf!, dataList[i].color, vertexOffset);
|
||||
vertexOffset += 4;
|
||||
// uintbuf[vertexOffset++] = color;
|
||||
}
|
||||
meshBuffer.setDirty();
|
||||
},
|
||||
|
||||
updateWorldVertexData (sprite: Sprite) {
|
||||
const node = sprite.node;
|
||||
const dataList: IRenderData[] = sprite.renderData!.data;
|
||||
|
||||
@@ -145,9 +145,6 @@ export const tiled: IAssembler = {
|
||||
|
||||
const matrix = node.worldMatrix;
|
||||
|
||||
renderData.cacheBuffer = buffer;
|
||||
renderData.bufferOffset = vertexOffset;
|
||||
|
||||
const datalist = renderData.data;
|
||||
this.fillVertices(vBuf, vertexOffset, matrix, row, col, datalist);
|
||||
|
||||
@@ -273,157 +270,6 @@ export const tiled: IAssembler = {
|
||||
}
|
||||
},
|
||||
|
||||
fillCacheBuffer (sprite: Sprite) {
|
||||
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
|
||||
const buffer = renderData.cacheBuffer;
|
||||
// buffer data may be realloc, need get reference after request.
|
||||
let vertexOffset = renderData.bufferOffset;
|
||||
buffer!.setDirty();
|
||||
const vBuf = buffer!.vData!;
|
||||
|
||||
const frame = sprite.spriteFrame!;
|
||||
const rotated = frame.isRotated();
|
||||
const uv = frame.uv;
|
||||
const uvSliced: IUV[] = sprite.spriteFrame!.uvSliced;
|
||||
const rect = frame.getRect();
|
||||
const leftWidth = frame.insetLeft;
|
||||
const rightWidth = frame.insetRight;
|
||||
const centerWidth = rect.width - leftWidth - rightWidth;
|
||||
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;
|
||||
|
||||
const datalist = renderData.data;
|
||||
this.fillVertices(vBuf, vertexOffset, matrix, row, col, datalist);
|
||||
|
||||
const offset = _perVertexLength;
|
||||
const offset1 = offset; const offset2 = offset * 2; const offset3 = offset * 3; const offset4 = offset * 4;
|
||||
let coefU = 0; let coefV = 0;
|
||||
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 = vRepeat % 1;
|
||||
}
|
||||
} else {
|
||||
coefV = vRepeat;
|
||||
}
|
||||
for (let xIndex = 0, xLength = col; xIndex < xLength; ++xIndex) {
|
||||
if (sizableWidth > centerWidth) {
|
||||
if (sizableWidth >= xIndex * centerWidth) {
|
||||
coefU = 1;
|
||||
} else {
|
||||
coefU = hRepeat % 1;
|
||||
}
|
||||
} else {
|
||||
coefU = hRepeat;
|
||||
}
|
||||
|
||||
const vertexOffsetU = vertexOffset + 3;
|
||||
const vertexOffsetV = vertexOffsetU + 1;
|
||||
// UV
|
||||
if (rotated) {
|
||||
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 {
|
||||
if (xIndex === 0) {
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
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
|
||||
// Hack: the color is same
|
||||
Color.toArray(vBuf, datalist[0].color, vertexOffsetV + 1);
|
||||
Color.toArray(vBuf, datalist[0].color, vertexOffsetV + offset1 + 1);
|
||||
Color.toArray(vBuf, datalist[0].color, vertexOffsetV + offset2 + 1);
|
||||
Color.toArray(vBuf, datalist[0].color, vertexOffsetV + offset3 + 1);
|
||||
vertexOffset += offset4;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
fillVertices (vBuf: Float32Array, vertexOffset: number, matrix: Mat4, row: number, col: number, dataList: IRenderData[]) {
|
||||
let x = 0; let x1 = 0; let y = 0; let y1 = 0;
|
||||
for (let yIndex = 0, yLength = row; yIndex < yLength; ++yIndex) {
|
||||
|
||||
@@ -52,8 +52,6 @@ export function fillVertices3D (node: Node, renderer: IBatcher, renderData: Rend
|
||||
vertexId = 0;
|
||||
}
|
||||
|
||||
renderData.cacheBuffer = buffer;
|
||||
renderData.bufferOffset = vertexOffset;
|
||||
// buffer data may be realloc, need get reference after request.
|
||||
const vBuf = buffer.vData!;
|
||||
|
||||
@@ -79,31 +77,6 @@ export function fillVertices3D (node: Node, renderer: IBatcher, renderData: Rend
|
||||
}
|
||||
}
|
||||
|
||||
export function updateCachedVertices (node: Node, renderData: RenderData, color: Color) {
|
||||
const dataList = renderData.data;
|
||||
const buffer = renderData.cacheBuffer!;
|
||||
let vertexOffset = renderData.bufferOffset;
|
||||
|
||||
const vertexCount = renderData.vertexCount;
|
||||
const vBuf = buffer.vData!;
|
||||
|
||||
node.getWorldMatrix(_worldMatrix);
|
||||
|
||||
for (let i = 0; i < vertexCount; i++) {
|
||||
const vert = dataList[i];
|
||||
Vec3.set(vec3_temp, vert.x, vert.y, 0);
|
||||
Vec3.transformMat4(vec3_temp, vec3_temp, _worldMatrix);
|
||||
vBuf[vertexOffset++] = vec3_temp.x;
|
||||
vBuf[vertexOffset++] = vec3_temp.y;
|
||||
vBuf[vertexOffset++] = vec3_temp.z;
|
||||
vBuf[vertexOffset++] = vert.u;
|
||||
vBuf[vertexOffset++] = vert.v;
|
||||
Color.toArray(vBuf, color, vertexOffset);
|
||||
vertexOffset += 4;
|
||||
}
|
||||
buffer.setDirty();
|
||||
}
|
||||
|
||||
export function fillMeshVertices3D (node: Node, renderer: IBatcher, renderData: RenderData, color: Color) {
|
||||
const dataList = renderData.data;
|
||||
let buffer = renderer.acquireBufferBatch()!;
|
||||
@@ -121,8 +94,6 @@ export function fillMeshVertices3D (node: Node, renderer: IBatcher, renderData:
|
||||
vertexId = 0;
|
||||
}
|
||||
|
||||
renderData.cacheBuffer = buffer;
|
||||
renderData.bufferOffset = vertexOffset;
|
||||
// buffer data may be realloc, need get reference after request.
|
||||
const vBuf = buffer.vData!;
|
||||
const iBuf = buffer.iData!;
|
||||
@@ -171,8 +142,6 @@ export function fillVerticesWithoutCalc3D (node: Node, renderer: IBatcher, rende
|
||||
vertexId = 0;
|
||||
}
|
||||
|
||||
renderData.cacheBuffer = buffer;
|
||||
renderData.bufferOffset = vertexOffset;
|
||||
// buffer data may be realloc, need get reference after request.
|
||||
const vBuf = buffer.vData!;
|
||||
|
||||
@@ -196,24 +165,3 @@ export function fillVerticesWithoutCalc3D (node: Node, renderer: IBatcher, rende
|
||||
iBuf![indicesOffset++] = vertexId + 3;
|
||||
iBuf![indicesOffset++] = vertexId + 2;
|
||||
}
|
||||
|
||||
export function updateCachedVerticesWithoutCalc3D (node: Node, renderData: RenderData, color: Color) {
|
||||
const dataList = renderData.data;
|
||||
const buffer = renderData.cacheBuffer!;
|
||||
let vertexOffset = renderData.bufferOffset;
|
||||
const vertexCount = renderData.vertexCount;
|
||||
|
||||
const vBuf = buffer.vData!;
|
||||
|
||||
for (let i = 0; i < vertexCount; i++) {
|
||||
const vert = dataList[i];
|
||||
vBuf[vertexOffset++] = vert.x;
|
||||
vBuf[vertexOffset++] = vert.y;
|
||||
vBuf[vertexOffset++] = vert.z;
|
||||
vBuf[vertexOffset++] = vert.u;
|
||||
vBuf[vertexOffset++] = vert.v;
|
||||
Color.toArray(vBuf, color, vertexOffset);
|
||||
vertexOffset += 4;
|
||||
}
|
||||
buffer.setDirty();
|
||||
}
|
||||
|
||||
@@ -546,7 +546,6 @@ export class Graphics extends Renderable2D {
|
||||
|
||||
this._isDrawing = true;
|
||||
this._isNeedUploadData = true;
|
||||
director.root!.batcher2D._reloadBatch();
|
||||
(this._assembler as IAssembler).stroke!(this);
|
||||
}
|
||||
|
||||
@@ -564,7 +563,6 @@ export class Graphics extends Renderable2D {
|
||||
|
||||
this._isDrawing = true;
|
||||
this._isNeedUploadData = true;
|
||||
director.root!.batcher2D._reloadBatch();
|
||||
(this._assembler as IAssembler).fill!(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ import { CanvasPool, ISharedLabelData, LetterRenderTexture } from '../assembler/
|
||||
import { InstanceMaterialType, Renderable2D } from '../framework/renderable-2d';
|
||||
import { TextureBase } from '../../core/assets/texture-base';
|
||||
import { PixelFormat } from '../../core/assets/asset-enum';
|
||||
import { director } from '../../core/director';
|
||||
|
||||
/**
|
||||
* @en Enum for horizontal text alignment.
|
||||
@@ -766,11 +765,6 @@ export class Label extends Renderable2D {
|
||||
}
|
||||
}
|
||||
|
||||
public markForUpdateRenderData (enable = true) {
|
||||
super.markForUpdateRenderData(enable);
|
||||
director.root!.batcher2D._reloadBatch();
|
||||
}
|
||||
|
||||
protected _render (render: IBatcher) {
|
||||
render.commitComp(this, this._texture, this._assembler!, null);
|
||||
}
|
||||
@@ -826,7 +820,9 @@ export class Label extends Renderable2D {
|
||||
const spriteFrame = font.spriteFrame;
|
||||
if (spriteFrame && spriteFrame.texture) {
|
||||
this._texture = spriteFrame;
|
||||
this.setTextureDirty();
|
||||
if (this.renderData) {
|
||||
this.renderData.textureDirty = true;
|
||||
}
|
||||
this.changeMaterialForDefine();
|
||||
if (this._assembler) {
|
||||
this._assembler.updateRenderData(this);
|
||||
|
||||
@@ -378,7 +378,6 @@ export class Mask extends Renderable2D {
|
||||
super.updateMaterial();
|
||||
this._updateGraphics();
|
||||
this._renderFlag = this._canRender();
|
||||
director.root!.batcher2D._reloadBatch();
|
||||
}
|
||||
|
||||
public onDisable () {
|
||||
@@ -439,7 +438,7 @@ export class Mask extends Renderable2D {
|
||||
}
|
||||
|
||||
protected _render (render: IBatcher) {
|
||||
render.commitPlainComp(this, null, this._assembler!, null);
|
||||
render.commitComp(this, null, this._assembler!, null);
|
||||
}
|
||||
|
||||
protected _postRender (render: IBatcher) {
|
||||
@@ -447,7 +446,7 @@ export class Mask extends Renderable2D {
|
||||
return;
|
||||
}
|
||||
|
||||
render.commitPlainComp(this, null, this._postAssembler, null);
|
||||
render.commitComp(this, null, this._postAssembler, null);
|
||||
}
|
||||
|
||||
protected _nodeStateChange (type: TransformBit) {
|
||||
|
||||
@@ -791,6 +791,9 @@ export class RichText extends UIComponent {
|
||||
break;
|
||||
}
|
||||
|
||||
if (style.imageOffset) {
|
||||
segment.imageOffset = style.imageOffset;
|
||||
}
|
||||
segment.node.layer = this.node.layer;
|
||||
this.node.addChild(segment.node);
|
||||
this._segments.push(segment);
|
||||
|
||||
@@ -273,7 +273,6 @@ export class Sprite extends Renderable2D {
|
||||
if (this._type !== value) {
|
||||
this._type = value;
|
||||
this._flushAssembler();
|
||||
director.root!.batcher2D._reloadBatch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -576,14 +575,6 @@ export class Sprite extends Renderable2D {
|
||||
this.spriteFrame = sprite;
|
||||
}
|
||||
|
||||
public markForUpdateRenderData (enable = true) {
|
||||
super.markForUpdateRenderData(enable);
|
||||
// cause these type may change vertex count
|
||||
if (this._type === SpriteType.TILED || (this._type === SpriteType.FILLED && this._fillType === FillType.RADIAL)) {
|
||||
director.root!.batcher2D._reloadBatch();
|
||||
}
|
||||
}
|
||||
|
||||
public changeMaterialForDefine () {
|
||||
let texture;
|
||||
const lastInstanceMaterialType = this._instanceMaterialType;
|
||||
@@ -737,7 +728,7 @@ export class Sprite extends Renderable2D {
|
||||
textureChanged = true;
|
||||
}
|
||||
if (textureChanged) {
|
||||
this.setTextureDirty();
|
||||
if (this._renderData) this._renderData.textureDirty = true;
|
||||
this.changeMaterialForDefine();
|
||||
}
|
||||
this._applySpriteSize();
|
||||
|
||||
@@ -170,7 +170,7 @@ export class Renderable2D extends RenderableComponent {
|
||||
if (this._renderData) {
|
||||
this._renderData.material = this._customMaterial;
|
||||
this.markForUpdateRenderData();
|
||||
this.setPassDirty();
|
||||
this._renderData.passDirty = true;
|
||||
}
|
||||
this._blendHash = -1; // a flag to check merge
|
||||
if (UI_GPU_DRIVEN) {
|
||||
@@ -257,8 +257,6 @@ export class Renderable2D extends RenderableComponent {
|
||||
protected _renderData: RenderData | null = null;
|
||||
protected _renderDataFlag = true;
|
||||
protected _renderFlag = true;
|
||||
protected _renderFlagCache = true;
|
||||
public _renderDataDirty = true;
|
||||
// 特殊渲染节点,给一些不在节点树上的组件做依赖渲染(例如 mask 组件内置两个 graphics 来渲染)
|
||||
protected _delegateSrc: Node | null = null;
|
||||
protected _instanceMaterialType = -1;
|
||||
@@ -293,6 +291,7 @@ export class Renderable2D extends RenderableComponent {
|
||||
if (this._flushAssembler) {
|
||||
this._flushAssembler();
|
||||
}
|
||||
NodeUIProperties.markOpacityTree(this.node);
|
||||
}
|
||||
|
||||
public onEnable () {
|
||||
@@ -300,25 +299,18 @@ export class Renderable2D extends RenderableComponent {
|
||||
this.node.on(NodeEventType.SIZE_CHANGED, this._nodeStateChange, this);
|
||||
this.updateMaterial();
|
||||
this._renderFlag = this._canRender();
|
||||
this._renderFlagCache = this._renderFlag;
|
||||
director.root!.batcher2D._reloadBatch();
|
||||
}
|
||||
|
||||
// For Redo, Undo
|
||||
public onRestore () {
|
||||
this.updateMaterial();
|
||||
this._renderFlag = this._canRender();
|
||||
this._renderFlagCache = this._renderFlag;
|
||||
director.root!.batcher2D._reloadBatch();
|
||||
}
|
||||
|
||||
public onDisable () {
|
||||
this.node.off(NodeEventType.ANCHOR_CHANGED, this._nodeStateChange, this);
|
||||
this.node.off(NodeEventType.SIZE_CHANGED, this._nodeStateChange, this);
|
||||
this.getRenderMaterial(0)!.off('setProperty', this._onPropertyChange);
|
||||
this._renderFlag = false;
|
||||
this._renderFlagCache = this._renderFlag;
|
||||
director.root!.batcher2D._reloadBatch();
|
||||
}
|
||||
|
||||
public onDestroy () {
|
||||
@@ -354,10 +346,6 @@ export class Renderable2D extends RenderableComponent {
|
||||
} else if (!enable) {
|
||||
this._renderDataFlag = enable;
|
||||
}
|
||||
if (this._renderFlag !== this._renderFlagCache) {
|
||||
director.root!.batcher2D._reloadBatch();
|
||||
this._renderFlagCache = this._renderFlag;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -422,7 +410,6 @@ export class Renderable2D extends RenderableComponent {
|
||||
if (this._renderDataFlag) {
|
||||
this._assembler!.updateRenderData!(this);
|
||||
this._renderDataFlag = false;
|
||||
this._renderDataDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -430,7 +417,8 @@ export class Renderable2D extends RenderableComponent {
|
||||
return this.isValid
|
||||
&& this.getMaterial(0) !== null
|
||||
&& this.enabled
|
||||
&& (this._delegateSrc ? this._delegateSrc.activeInHierarchy : this.enabledInHierarchy);
|
||||
&& (this._delegateSrc ? this._delegateSrc.activeInHierarchy : this.enabledInHierarchy)
|
||||
&& this.node._uiProps.opacity > 0;
|
||||
}
|
||||
|
||||
protected _postCanRender () {}
|
||||
@@ -438,15 +426,17 @@ export class Renderable2D extends RenderableComponent {
|
||||
protected _updateColor () {
|
||||
if (UI_GPU_DRIVEN && this._canDrawByFourVertex) {
|
||||
if (this._colorDirty) {
|
||||
this._renderFlag = this._canRender();
|
||||
this._colorDirty = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Need update rendFlag when opacity changes from 0 to !0
|
||||
if (this._colorDirty && this._assembler && this._assembler.updateColor) {
|
||||
this._assembler.updateColor(this);
|
||||
// Need update rendFlag when opacity changes from 0 to !0 or 0 to !0
|
||||
this._renderFlag = this._canRender();
|
||||
this._colorDirty = false;
|
||||
this._renderDataDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -466,7 +456,9 @@ export class Renderable2D extends RenderableComponent {
|
||||
target.blendDstAlpha = BlendFactor.ONE_MINUS_SRC_ALPHA;
|
||||
target.blendDst = this._dstBlendFactor;
|
||||
target.blendSrc = this._srcBlendFactor;
|
||||
this.setPassDirty();
|
||||
if (this.renderData) {
|
||||
this.renderData.passDirty = true;
|
||||
}
|
||||
}
|
||||
this.updateBlendHash();
|
||||
}
|
||||
@@ -491,17 +483,11 @@ export class Renderable2D extends RenderableComponent {
|
||||
}
|
||||
|
||||
protected _onMaterialModified (idx: number, material: Material | null) {
|
||||
if (this._customMaterial) {
|
||||
this._customMaterial.off('setProperty', this._onPropertyChange);
|
||||
}
|
||||
if (this._renderData) {
|
||||
this.markForUpdateRenderData();
|
||||
this.setPassDirty();
|
||||
this._renderData.passDirty = true;
|
||||
}
|
||||
super._onMaterialModified(idx, material);
|
||||
if (this._customMaterial) {
|
||||
this.getRenderMaterial(0)!.on('setProperty', this._onPropertyChange);
|
||||
}
|
||||
}
|
||||
|
||||
// macro.UI_GPU_DRIVEN
|
||||
@@ -536,29 +522,16 @@ export class Renderable2D extends RenderableComponent {
|
||||
protected _flushAssembler? (): void;
|
||||
|
||||
public setNodeDirty () {
|
||||
director.root!.batcher2D._reloadBatch();
|
||||
if (this.renderData) {
|
||||
this.renderData.nodeDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public setTextureDirty () {
|
||||
director.root!.batcher2D._reloadBatch();
|
||||
if (this.renderData) {
|
||||
this.renderData.textureDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public setPassDirty () {
|
||||
director.root!.batcher2D._reloadBatch();
|
||||
if (this.renderData) {
|
||||
this.renderData.passDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected _onPropertyChange () {
|
||||
director.root!.batcher2D._reloadBatch();
|
||||
}
|
||||
}
|
||||
|
||||
legacyCC.internal.Renderable2D = Renderable2D;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
* @packageDocumentation
|
||||
* @hidden
|
||||
*/
|
||||
import { DEBUG, JSB } from 'internal:constants';
|
||||
import { JSB } from 'internal:constants';
|
||||
import { Camera, Model } from 'cocos/core/renderer/scene';
|
||||
import { UIStaticBatch } from '../components';
|
||||
import { Material } from '../../core/assets/material';
|
||||
@@ -49,7 +49,6 @@ import { TextureBase } from '../../core/assets/texture-base';
|
||||
import { sys } from '../../core/platform/sys';
|
||||
import { Mat4 } from '../../core/math';
|
||||
import { IBatcher } from './i-batcher';
|
||||
import { warnID } from '../../core';
|
||||
|
||||
const _dsInfo = new DescriptorSetInfo(null!);
|
||||
const m4_1 = new Mat4();
|
||||
@@ -152,13 +151,12 @@ export class Batcher2D implements IBatcher {
|
||||
private _currTransform: Node | null = null;
|
||||
private _currTextureHash = 0;
|
||||
private _currSamplerHash = 0;
|
||||
private _currBlendTargetHash = 0;
|
||||
private _currLayer = 0;
|
||||
private _currDepthStencilStateStage: any | null = null;
|
||||
private _currIsStatic = false;
|
||||
private _currHash = 0;
|
||||
|
||||
private _reloadBatchDirty: boolean;
|
||||
|
||||
// DescriptorSet Cache Map
|
||||
private _descriptorSetCache = new DescriptorSetCache();
|
||||
|
||||
@@ -166,7 +164,6 @@ export class Batcher2D implements IBatcher {
|
||||
this.device = _root.device;
|
||||
this._batches = new CachedArray(64);
|
||||
this._drawBatchPool = new Pool(() => new DrawBatch2D(), 128, (obj) => obj.destroy(this));
|
||||
this._reloadBatchDirty = true;
|
||||
}
|
||||
|
||||
public initialize () {
|
||||
@@ -247,15 +244,6 @@ export class Batcher2D implements IBatcher {
|
||||
|
||||
public update () {
|
||||
const screens = this._screens;
|
||||
for (let i = 0; i < screens.length; ++i) {
|
||||
const screen = screens[i].node;
|
||||
if (screen.hasChildTreeUpdated()) {
|
||||
this._reloadBatch();
|
||||
}
|
||||
}
|
||||
if (this._reloadBatchDirty) {
|
||||
this.resetWithReload();
|
||||
}
|
||||
for (let i = 0; i < screens.length; ++i) {
|
||||
const screen = screens[i];
|
||||
if (!screen.enabledInHierarchy) {
|
||||
@@ -291,6 +279,7 @@ export class Batcher2D implements IBatcher {
|
||||
buffers.forEach((value, key) => {
|
||||
value.forEach((bb) => {
|
||||
bb.uploadBuffers();
|
||||
bb.reset();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -303,35 +292,10 @@ export class Batcher2D implements IBatcher {
|
||||
});
|
||||
|
||||
this._descriptorSetCache.update();
|
||||
// upload
|
||||
this._reloadBatchDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
public reset () {
|
||||
this._currHash = 0;
|
||||
this._currLayer = 0;
|
||||
this._currMaterial = this._emptyMaterial;
|
||||
this._currTexture = null;
|
||||
this._currSampler = null;
|
||||
this._currComponent = null;
|
||||
this._currTransform = null;
|
||||
this._currScene = null;
|
||||
this._currMeshBuffer = null;
|
||||
StencilManager.sharedManager!.reset();
|
||||
this._descriptorSetCache.reset();
|
||||
}
|
||||
|
||||
private resetWithReload () {
|
||||
if (this._batches.length > 0) {
|
||||
const buffers = this._meshBuffers;
|
||||
buffers.forEach((value, key) => {
|
||||
value.forEach((bb) => {
|
||||
bb.reset();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
for (let i = 0; i < this._batches.length; ++i) {
|
||||
const batch = this._batches.array[i];
|
||||
if (batch.isStatic) {
|
||||
@@ -343,8 +307,19 @@ export class Batcher2D implements IBatcher {
|
||||
this._drawBatchPool.free(batch);
|
||||
}
|
||||
|
||||
this._currHash = 0;
|
||||
this._currLayer = 0;
|
||||
this._currMaterial = this._emptyMaterial;
|
||||
this._currTexture = null;
|
||||
this._currSampler = null;
|
||||
this._currComponent = null;
|
||||
this._currTransform = null;
|
||||
this._currScene = null;
|
||||
this._currMeshBuffer = null;
|
||||
this._meshBufferUseCount.clear();
|
||||
this._batches.clear();
|
||||
StencilManager.sharedManager!.reset();
|
||||
this._descriptorSetCache.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -362,28 +337,27 @@ export class Batcher2D implements IBatcher {
|
||||
* @param assembler - 当前组件渲染数据组装器。
|
||||
*/
|
||||
public commitComp (comp: Renderable2D, frame: TextureBase | SpriteFrame | null, assembler: any, transform: Node | null) {
|
||||
if (DEBUG) {
|
||||
if (!comp.renderData) {
|
||||
this.commitPlainComp(comp, frame, assembler, transform);
|
||||
warnID(14200);
|
||||
}
|
||||
const renderComp = comp;
|
||||
const renderData = comp.renderData;
|
||||
let dataHash = 0;
|
||||
let mat;
|
||||
if (renderData) {
|
||||
dataHash = renderData.dataHash;
|
||||
mat = renderData.material;
|
||||
}
|
||||
if (this._reloadBatchDirty) {
|
||||
const renderComp = comp;
|
||||
const renderData = comp.renderData!;
|
||||
const dataHash = renderData.dataHash;
|
||||
const mat = renderData.material;
|
||||
renderComp.stencilStage = StencilManager.sharedManager!.stage;
|
||||
const depthStencilStateStage = renderComp.stencilStage;
|
||||
renderComp.stencilStage = StencilManager.sharedManager!.stage;
|
||||
const depthStencilStateStage = renderComp.stencilStage;
|
||||
|
||||
if (this._currHash !== dataHash || this._currMaterial !== mat
|
||||
if (this._currHash !== dataHash || dataHash === 0 || this._currMaterial !== mat
|
||||
|| this._currDepthStencilStateStage !== depthStencilStateStage) {
|
||||
this.autoMergeBatches(this._currComponent!);
|
||||
this.autoMergeBatches(this._currComponent!);
|
||||
if (renderData) {
|
||||
this._currHash = renderData.dataHash;
|
||||
this._currScene = renderData.renderScene;
|
||||
this._currComponent = renderComp;
|
||||
this._currTransform = transform;
|
||||
this._currMaterial = renderData.material!;
|
||||
this._currBlendTargetHash = renderData.blendHash;
|
||||
this._currDepthStencilStateStage = depthStencilStateStage;
|
||||
this._currLayer = renderData.layer;
|
||||
const frame = renderData.frame;
|
||||
@@ -398,32 +372,14 @@ export class Batcher2D implements IBatcher {
|
||||
this._currTextureHash = 0;
|
||||
this._currSamplerHash = 0;
|
||||
}
|
||||
}
|
||||
|
||||
assembler.fillBuffers(renderComp, this);
|
||||
} else if (comp.node.hasChangedFlags || comp._renderDataDirty) {
|
||||
assembler.fillCacheBuffer(comp, this);
|
||||
comp._renderDataDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
public commitPlainComp (comp: Renderable2D, frame: TextureBase | SpriteFrame | null, assembler: any, transform: Node | null) {
|
||||
if (this._reloadBatchDirty) {
|
||||
const renderComp = comp;
|
||||
const dataHash = 0;
|
||||
let mat;
|
||||
renderComp.stencilStage = StencilManager.sharedManager!.stage;
|
||||
const depthStencilStateStage = renderComp.stencilStage;
|
||||
|
||||
if (this._currHash !== dataHash || this._currMaterial !== mat
|
||||
|| this._currDepthStencilStateStage !== depthStencilStateStage) {
|
||||
this.autoMergeBatches(this._currComponent!);
|
||||
// for Mask & middleware & Particle2D
|
||||
} else {
|
||||
// for Mask & spine
|
||||
this._currHash = dataHash;
|
||||
this._currScene = renderComp._getRenderScene();
|
||||
this._currComponent = renderComp;
|
||||
this._currTransform = transform;
|
||||
this._currMaterial = renderComp.getRenderMaterial(0)!;
|
||||
this._currBlendTargetHash = renderComp.blendHash;
|
||||
this._currDepthStencilStateStage = depthStencilStateStage;
|
||||
this._currLayer = renderComp.node.layer;
|
||||
if (frame) {
|
||||
@@ -438,11 +394,10 @@ export class Batcher2D implements IBatcher {
|
||||
this._currSamplerHash = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (assembler) {
|
||||
assembler.fillBuffers(renderComp, this);
|
||||
} else if (comp.node.hasChangedFlags || comp._renderDataDirty) {
|
||||
assembler.fillCacheBuffer(comp, this);
|
||||
comp._renderDataDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,9 +415,6 @@ export class Batcher2D implements IBatcher {
|
||||
* @param mat - 提交渲染的材质。
|
||||
*/
|
||||
public commitModel (comp: UIComponent | Renderable2D, model: Model | null, mat: Material | null) {
|
||||
if (!this._reloadBatchDirty) {
|
||||
return;
|
||||
}
|
||||
// if the last comp is spriteComp, previous comps should be batched.
|
||||
if (this._currMaterial !== this._emptyMaterial) {
|
||||
this.autoMergeBatches(this._currComponent!);
|
||||
@@ -643,6 +595,7 @@ export class Batcher2D implements IBatcher {
|
||||
}
|
||||
|
||||
public walk (node: Node, level = 0) {
|
||||
|
||||
const len = node.children.length;
|
||||
this._preProcess(node);
|
||||
if (len > 0 && !node._static) {
|
||||
@@ -738,10 +691,6 @@ export class Batcher2D implements IBatcher {
|
||||
private _releaseDescriptorSetCache (textureHash: number) {
|
||||
this._descriptorSetCache.releaseDescriptorSetCache(textureHash);
|
||||
}
|
||||
|
||||
public _reloadBatch () {
|
||||
this._reloadBatchDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
class LocalDescriptorSet {
|
||||
|
||||
@@ -37,7 +37,6 @@ export interface IBatcher {
|
||||
reset ();
|
||||
|
||||
commitComp (comp: Renderable2D, frame: TextureBase | SpriteFrame | null, assembler: any, transform: Node | null);
|
||||
commitPlainComp (comp: Renderable2D, frame: TextureBase | SpriteFrame | null, assembler: any, transform: Node | null);
|
||||
commitModel (comp: UIComponent | Renderable2D, model: Model | null, mat: Material | null);
|
||||
commitStaticBatch (comp: UIStaticBatch);
|
||||
|
||||
@@ -47,5 +46,4 @@ export interface IBatcher {
|
||||
flushMaterial (mat: Material);
|
||||
|
||||
walk (node: Node, level?: number);
|
||||
_reloadBatch ();
|
||||
}
|
||||
|
||||
@@ -115,10 +115,6 @@ export class MeshBuffer extends ScalableContainer {
|
||||
// ----------
|
||||
}
|
||||
|
||||
public setDirty () {
|
||||
this._dirty = true;
|
||||
}
|
||||
|
||||
public request (vertexCount = 4, indicesCount = 6) {
|
||||
this.lastByteOffset = this.byteOffset;
|
||||
const byteOffset = this.byteOffset + vertexCount * this._vertexFormatBytes;
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
* @hidden
|
||||
*/
|
||||
|
||||
import { MeshBuffer } from '..';
|
||||
import { Material } from '../../core/assets/material';
|
||||
import { TextureBase } from '../../core/assets/texture-base';
|
||||
import { Color } from '../../core/math';
|
||||
@@ -37,7 +36,6 @@ import { RenderScene } from '../../core/renderer/scene';
|
||||
import { murmurhash2_32_gc } from '../../core/utils/murmurhash2_gc';
|
||||
import { SpriteFrame } from '../assets/sprite-frame';
|
||||
import { Renderable2D } from '../framework/renderable-2d';
|
||||
import { DrawBatch2D } from './draw-batch';
|
||||
|
||||
export interface IRenderData {
|
||||
x: number;
|
||||
@@ -121,9 +119,6 @@ export class RenderData extends BaseRenderData {
|
||||
public hashDirty = true;
|
||||
public dataHash = 0;
|
||||
|
||||
public cacheBuffer: MeshBuffer | null = null;
|
||||
public bufferOffset = 0;
|
||||
|
||||
public updateNode (comp: Renderable2D) {
|
||||
this.renderScene = comp.node.scene ? comp._getRenderScene() : null;
|
||||
this.layer = comp.node.layer;
|
||||
@@ -237,9 +232,6 @@ export class MeshRenderData extends BaseRenderData {
|
||||
public lastFilledIndices = 0;
|
||||
public lastFilledVertex = 0;
|
||||
|
||||
public cacheBuffer: MeshBuffer | null = null;
|
||||
public bufferOffset = 0;
|
||||
|
||||
private _formatByte:number;
|
||||
|
||||
constructor (vertexFloatCnt = 9) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
import { EDITOR } from 'internal:constants';
|
||||
import { Filter } from '../../../core/assets/asset-enum';
|
||||
import { legacyCC } from '../../../core/global-exports';
|
||||
import { js } from '../../../core/utils/js';
|
||||
import { Atlas } from './atlas';
|
||||
@@ -141,6 +142,12 @@ export class DynamicAtlasManager {
|
||||
|
||||
if (!spriteFrame.packable) return null;
|
||||
|
||||
// hack for pixel game,should pack to different sampler atlas
|
||||
const sampler = spriteFrame.texture.getSamplerInfo();
|
||||
if (sampler.minFilter !== Filter.LINEAR || sampler.magFilter !== Filter.LINEAR || sampler.mipFilter !== Filter.NONE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let atlas = this._atlases[this._atlasIndex];
|
||||
if (!atlas) {
|
||||
atlas = this.newAtlas();
|
||||
|
||||
@@ -600,6 +600,9 @@ export class AnimationClip extends Asset {
|
||||
if (rootMotionTrackExcludes.includes(track)) {
|
||||
continue;
|
||||
}
|
||||
if (Array.from(track.channels()).every(({ curve }) => curve.keyFramesCount === 0)) {
|
||||
continue;
|
||||
}
|
||||
const trackTarget = binder(track[trackBindingTag]);
|
||||
if (!trackTarget) {
|
||||
continue;
|
||||
|
||||
@@ -206,12 +206,12 @@ export class StateMachine extends EditorExtendable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the transition between specified states.
|
||||
* Gets the transitions between specified states.
|
||||
* @param from Transition source.
|
||||
* @param to Transition target.
|
||||
* @returns The transition, if one existed.
|
||||
* @returns Iterator to the transitions
|
||||
*/
|
||||
public getTransition (from: State, to: State): Iterable<Transition> {
|
||||
public getTransitionsBetween (from: State, to: State): Iterable<Transition> {
|
||||
assertsOwnedBy(from, this);
|
||||
assertsOwnedBy(to, this);
|
||||
return from[outgoingsSymbol].filter((transition) => transition.to === to);
|
||||
@@ -322,19 +322,25 @@ export class StateMachine extends EditorExtendable {
|
||||
assertsOwnedBy(to, this);
|
||||
|
||||
const oTransitions = from[outgoingsSymbol];
|
||||
for (let iOTransition = 0; iOTransition < oTransitions.length; ++iOTransition) {
|
||||
const oTransition = oTransitions[iOTransition];
|
||||
if (oTransition.to === to) {
|
||||
assertIsTrue(
|
||||
remove(this._transitions, oTransition),
|
||||
);
|
||||
removeAt(oTransitions, iOTransition);
|
||||
assertIsNonNullable(
|
||||
removeIf(to[incomingsSymbol], (transition) => transition === oTransition),
|
||||
);
|
||||
markAsDangling(oTransition);
|
||||
break;
|
||||
}
|
||||
const iTransitions = to[incomingsSymbol];
|
||||
const transitions = this._transitions;
|
||||
|
||||
const oTransitionsToRemove = oTransitions
|
||||
.filter((oTransition) => oTransition.to === to);
|
||||
const nOTransitionToRemove = oTransitionsToRemove.length;
|
||||
for (let iOTransitionToRemove = 0;
|
||||
iOTransitionToRemove < nOTransitionToRemove;
|
||||
++iOTransitionToRemove
|
||||
) {
|
||||
const oTransition = oTransitionsToRemove[iOTransitionToRemove];
|
||||
remove(oTransitions, oTransition);
|
||||
assertIsTrue(
|
||||
remove(transitions, oTransition),
|
||||
);
|
||||
assertIsNonNullable(
|
||||
removeIf(iTransitions, (transition) => transition === oTransition),
|
||||
);
|
||||
markAsDangling(oTransition);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -270,7 +270,7 @@ export { TrackPath };
|
||||
* It's the basic unit of animation clip.
|
||||
*/
|
||||
@ccclass(`${CLASS_NAME_PREFIX_ANIM}Track`)
|
||||
export class Track {
|
||||
export abstract class Track {
|
||||
get path () {
|
||||
return this._binding.path;
|
||||
}
|
||||
@@ -304,9 +304,7 @@ export class Track {
|
||||
return range;
|
||||
}
|
||||
|
||||
public [createEvalSymbol] (runtimeBinding: RuntimeBinding): TrackEval {
|
||||
throw new Error(`No Impl`);
|
||||
}
|
||||
public abstract [createEvalSymbol] (runtimeBinding: RuntimeBinding): TrackEval;
|
||||
|
||||
@serializable
|
||||
private _binding = new TrackBinding();
|
||||
|
||||
@@ -306,7 +306,6 @@ export class Material extends Asset {
|
||||
if (!success) {
|
||||
console.warn(`illegal property name: ${name}.`);
|
||||
}
|
||||
this.emit('setProperty');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -600,7 +600,7 @@ export const effects = [
|
||||
"shaders": [
|
||||
{
|
||||
"name": "standard|standard-vs|standard-fs",
|
||||
"hash": 3964813306,
|
||||
"hash": 2864919663,
|
||||
"builtins": {
|
||||
"statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 221, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 64 },
|
||||
"globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }, { "name": "CCShadow", "defines": [] }], "samplerTextures": [{ "name": "cc_shadowMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_spotLightingMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_environment", "defines": ["CC_USE_IBL"] }, { "name": "cc_diffuseMap", "defines": ["CC_USE_IBL", "CC_USE_DIFFUSEMAP"] }], "buffers": [], "images": [] },
|
||||
@@ -693,7 +693,7 @@ export const effects = [
|
||||
},
|
||||
{
|
||||
"name": "standard|shadow-caster-vs:vert|shadow-caster-fs:frag",
|
||||
"hash": 4175746448,
|
||||
"hash": 1774012115,
|
||||
"builtins": {
|
||||
"statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 182, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 64 },
|
||||
"globals": { "blocks": [{ "name": "CCShadow", "defines": [] }, { "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [{ "name": "cc_shadowMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_spotLightingMap", "defines": ["CC_RECEIVE_SHADOW"] }], "buffers": [], "images": [] },
|
||||
@@ -763,7 +763,7 @@ export const effects = [
|
||||
"shaders": [
|
||||
{
|
||||
"name": "terrain|terrain-vs|terrain-fs",
|
||||
"hash": 3872556832,
|
||||
"hash": 1017881636,
|
||||
"builtins": {
|
||||
"statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 69, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 60 },
|
||||
"globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }, { "name": "CCShadow", "defines": [] }], "samplerTextures": [{ "name": "cc_shadowMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_spotLightingMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_environment", "defines": ["CC_USE_IBL"] }, { "name": "cc_diffuseMap", "defines": ["CC_USE_IBL", "CC_USE_DIFFUSEMAP"] }], "buffers": [], "images": [] },
|
||||
@@ -1108,7 +1108,7 @@ export const effects = [
|
||||
"shaders": [
|
||||
{
|
||||
"name": "deferred-lighting|lighting-vs|lighting-fs",
|
||||
"hash": 2008045986,
|
||||
"hash": 3340914951,
|
||||
"builtins": {
|
||||
"statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 39, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 58 },
|
||||
"globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }, { "name": "CCShadow", "defines": [] }], "samplerTextures": [{ "name": "cc_shadowMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_spotLightingMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_environment", "defines": ["CC_USE_IBL"] }, { "name": "cc_diffuseMap", "defines": ["CC_USE_IBL", "CC_USE_DIFFUSEMAP"] }], "buffers": [], "images": [] },
|
||||
|
||||
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
@@ -1,11 +1,11 @@
|
||||
import { EDITOR } from 'internal:constants';
|
||||
import { warnID } from '../platform/debug';
|
||||
import { errorID } from '../platform/debug';
|
||||
|
||||
export function reportMissingClass (id: string) {
|
||||
if (EDITOR && EditorExtends.UuidUtils.isUuid(id)) {
|
||||
id = EditorExtends.UuidUtils.decompressUuid(id);
|
||||
warnID(5301, id);
|
||||
errorID(5301, id);
|
||||
} else {
|
||||
warnID(5302, id);
|
||||
errorID(5302, id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ export class WebGL2Swapchain extends Swapchain {
|
||||
Format.RGBA8,
|
||||
2,
|
||||
2,
|
||||
TextureFlagBit.GEN_MIPMAP,
|
||||
TextureFlagBit.NONE,
|
||||
)) as WebGL2Texture;
|
||||
|
||||
this.nullTexCube = WebGL2DeviceManager.instance.createTexture(new TextureInfo(
|
||||
@@ -205,7 +205,7 @@ export class WebGL2Swapchain extends Swapchain {
|
||||
Format.RGBA8,
|
||||
2,
|
||||
2,
|
||||
TextureFlagBit.GEN_MIPMAP,
|
||||
TextureFlagBit.NONE,
|
||||
6,
|
||||
)) as WebGL2Texture;
|
||||
|
||||
|
||||
@@ -696,7 +696,7 @@ export class Pass {
|
||||
// guarantees these bindings to be consecutive, starting from 0 and non-array-typed
|
||||
this._blocks[binding] = new Float32Array(this._rootBlock!, _bufferViewInfo.offset,
|
||||
size / Float32Array.BYTES_PER_ELEMENT);
|
||||
this._blocksInt[binding] = new Int32Array(this._blocks[binding].buffer);
|
||||
this._blocksInt[binding] = new Int32Array(this._blocks[binding].buffer, this._blocks[binding].byteOffset, this._blocks[binding].length);
|
||||
this._descriptorSet.bindBuffer(binding, bufferView);
|
||||
}
|
||||
// store handles
|
||||
|
||||
@@ -334,8 +334,6 @@ export class BaseNode extends CCObject implements ISchedulable {
|
||||
// record scene's id when set this node as persist node
|
||||
public _originalSceneId = '';
|
||||
|
||||
private _childTreeVersion = 0;
|
||||
|
||||
/**
|
||||
* Set `_scene` field of this node.
|
||||
* The derived `Scene` overrides this method to behavior differently.
|
||||
@@ -442,7 +440,6 @@ export class BaseNode extends CCObject implements ISchedulable {
|
||||
}
|
||||
oldParent._children.splice(removeAt, 1);
|
||||
oldParent._updateSiblingIndex();
|
||||
oldParent._updateChildTreeVersion();
|
||||
if (oldParent.emit) {
|
||||
oldParent.emit(NodeEventType.CHILD_REMOVED, this);
|
||||
}
|
||||
@@ -455,7 +452,6 @@ export class BaseNode extends CCObject implements ISchedulable {
|
||||
}
|
||||
newParent._children.push(this);
|
||||
this._siblingIndex = newParent._children.length - 1;
|
||||
newParent._updateChildTreeVersion();
|
||||
if (newParent.emit) {
|
||||
newParent.emit(NodeEventType.CHILD_ADDED, this);
|
||||
}
|
||||
@@ -1245,15 +1241,10 @@ export class BaseNode extends CCObject implements ISchedulable {
|
||||
}
|
||||
|
||||
public _updateSiblingIndex () {
|
||||
let siblingChanged = false;
|
||||
for (let i = 0; i < this._children.length; ++i) {
|
||||
const child = this._children[i];
|
||||
if (child._siblingIndex !== i) {
|
||||
child._siblingIndex = i;
|
||||
siblingChanged = true;
|
||||
}
|
||||
this._children[i]._siblingIndex = i;
|
||||
}
|
||||
if (siblingChanged) { this._updateChildTreeVersion(); }
|
||||
|
||||
this.emit(NodeEventType.SIBLING_ORDER_CHANGED);
|
||||
}
|
||||
|
||||
@@ -1373,7 +1364,6 @@ export class BaseNode extends CCObject implements ISchedulable {
|
||||
if (parent.emit) {
|
||||
parent.emit(NodeEventType.CHILD_REMOVED, this);
|
||||
}
|
||||
parent._updateChildTreeVersion();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1401,19 +1391,6 @@ export class BaseNode extends CCObject implements ISchedulable {
|
||||
return destroyByParent;
|
||||
}
|
||||
|
||||
private _updateChildTreeVersion () {
|
||||
let cur: BaseNode | null = this as BaseNode;
|
||||
const totalFrames = legacyCC.director.getTotalFrames();
|
||||
while (cur && cur._childTreeVersion !== totalFrames) {
|
||||
cur._childTreeVersion = totalFrames;
|
||||
cur = cur._parent;
|
||||
}
|
||||
}
|
||||
|
||||
public hasChildTreeUpdated () {
|
||||
return this._childTreeVersion === legacyCC.director.getTotalFrames();
|
||||
}
|
||||
|
||||
protected _onSiblingIndexChanged? (siblingIndex: number): void;
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,7 +32,6 @@ import { UIComponent } from '../../2d/framework/ui-component';
|
||||
import { Renderable2D } from '../../2d/framework/renderable-2d';
|
||||
import { UITransform } from '../../2d/framework/ui-transform';
|
||||
import { warnID } from '../platform/debug';
|
||||
import { legacyCC } from '../global-exports';
|
||||
|
||||
/**
|
||||
* @en Node's UI properties abstraction
|
||||
@@ -106,8 +105,6 @@ export class NodeUIProperties {
|
||||
* @zh 为结点树的透明度状态设置脏标签
|
||||
*/
|
||||
public static markOpacityTree (node, isDirty = true) {
|
||||
// cause label opacity change need reload
|
||||
legacyCC.director.root!.batcher2D._reloadBatch();
|
||||
node._uiProps.opacityDirty = isDirty;
|
||||
for (let i = 0, l = node.children.length; i < l; i++) {
|
||||
const c = node.children[i];
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
* @module scene-graph
|
||||
*/
|
||||
|
||||
import { ccclass, visible, type, displayOrder, readOnly, slide, range, rangeStep, editable, serializable, rangeMin, tooltip, formerlySerializedAs } from 'cc.decorator';
|
||||
import { ccclass, visible, type, displayOrder, readOnly, slide, range, rangeStep, editable, serializable, rangeMin, tooltip, formerlySerializedAs, displayName, help } from 'cc.decorator';
|
||||
import { EDITOR } from 'internal:constants';
|
||||
import { TextureCube } from '../assets/texture-cube';
|
||||
import { CCFloat, CCBoolean, CCInteger } from '../data/utils/attribute';
|
||||
@@ -58,6 +58,7 @@ const normalizeHDRColor = (color : Vec4) => {
|
||||
* @zh 场景的环境光照相关信息
|
||||
*/
|
||||
@ccclass('cc.AmbientInfo')
|
||||
@help('i18n:cc.Ambient')
|
||||
export class AmbientInfo {
|
||||
@serializable
|
||||
@formerlySerializedAs('_skyColor')
|
||||
@@ -116,6 +117,7 @@ export class AmbientInfo {
|
||||
}
|
||||
})
|
||||
@editable
|
||||
@tooltip('i18n:ambient.skyLightingColor')
|
||||
set skyLightingColor (val: Color) {
|
||||
_v4.set(val.x, val.y, val.z, val.w);
|
||||
if ((legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR) {
|
||||
@@ -147,6 +149,7 @@ export class AmbientInfo {
|
||||
*/
|
||||
@editable
|
||||
@type(CCFloat)
|
||||
@tooltip('i18n:ambient.skyIllum')
|
||||
set skyIllum (val: number) {
|
||||
if ((legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR) {
|
||||
this._skyIllumHDR = val;
|
||||
@@ -178,6 +181,7 @@ export class AmbientInfo {
|
||||
}
|
||||
})
|
||||
@editable
|
||||
@tooltip('i18n:ambient.groundLightingColor')
|
||||
set groundLightingColor (val: Color) {
|
||||
_v4.set(val.x, val.y, val.z, val.w);
|
||||
if ((legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR) {
|
||||
@@ -215,6 +219,7 @@ legacyCC.AmbientInfo = AmbientInfo;
|
||||
* @zh 天空盒相关信息
|
||||
*/
|
||||
@ccclass('cc.SkyboxInfo')
|
||||
@help('i18n:cc.Skybox')
|
||||
export class SkyboxInfo {
|
||||
@serializable
|
||||
protected _applyDiffuseMap = false;
|
||||
@@ -251,6 +256,7 @@ export class SkyboxInfo {
|
||||
return false;
|
||||
})
|
||||
@editable
|
||||
@tooltip('i18n:skybox.applyDiffuseMap')
|
||||
set applyDiffuseMap (val) {
|
||||
this._applyDiffuseMap = val;
|
||||
|
||||
@@ -267,6 +273,7 @@ export class SkyboxInfo {
|
||||
* @zh 是否启用天空盒?
|
||||
*/
|
||||
@editable
|
||||
@tooltip('i18n:skybox.enabled')
|
||||
set enabled (val) {
|
||||
if (this._enabled === val) return;
|
||||
this._enabled = val;
|
||||
@@ -284,6 +291,7 @@ export class SkyboxInfo {
|
||||
* @zh 是否启用环境光照?
|
||||
*/
|
||||
@editable
|
||||
@tooltip('i18n:skybox.useIBL')
|
||||
set useIBL (val) {
|
||||
this._useIBL = val;
|
||||
|
||||
@@ -300,6 +308,7 @@ export class SkyboxInfo {
|
||||
* @zh 是否启用HDR?
|
||||
*/
|
||||
@editable
|
||||
@tooltip('i18n:skybox.useHDR')
|
||||
set useHDR (val) {
|
||||
(legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR = val;
|
||||
this._useHDR = val;
|
||||
@@ -327,6 +336,7 @@ export class SkyboxInfo {
|
||||
*/
|
||||
@editable
|
||||
@type(TextureCube)
|
||||
@tooltip('i18n:skybox.envmap')
|
||||
set envmap (val) {
|
||||
const isHDR = (legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR;
|
||||
if (isHDR) {
|
||||
@@ -406,6 +416,7 @@ legacyCC.SkyboxInfo = SkyboxInfo;
|
||||
* @en Global fog info
|
||||
*/
|
||||
@ccclass('cc.FogInfo')
|
||||
@help('i18n:cc.Fog')
|
||||
export class FogInfo {
|
||||
public static FogType = FogType;
|
||||
@serializable
|
||||
@@ -434,6 +445,7 @@ export class FogInfo {
|
||||
* @en Enable global fog
|
||||
*/
|
||||
@editable
|
||||
@tooltip('i18n:fog.enabled')
|
||||
set enabled (val: boolean) {
|
||||
if (this._enabled === val) return;
|
||||
this._enabled = val;
|
||||
@@ -454,6 +466,7 @@ export class FogInfo {
|
||||
* @en Enable accurate fog (pixel fog)
|
||||
*/
|
||||
@editable
|
||||
@tooltip('i18n:fog.accurate')
|
||||
set accurate (val: boolean) {
|
||||
if (this._accurate === val) return;
|
||||
this._accurate = val;
|
||||
@@ -474,6 +487,7 @@ export class FogInfo {
|
||||
* @en Global fog color
|
||||
*/
|
||||
@editable
|
||||
@tooltip('i18n:fog.fogColor')
|
||||
set fogColor (val: Color) {
|
||||
this._fogColor.set(val);
|
||||
if (this._resource) { this._resource.fogColor = this._fogColor; }
|
||||
@@ -489,6 +503,7 @@ export class FogInfo {
|
||||
*/
|
||||
@editable
|
||||
@type(FogType)
|
||||
@tooltip('i18n:fog.type')
|
||||
get type () {
|
||||
return this._type;
|
||||
}
|
||||
@@ -510,6 +525,7 @@ export class FogInfo {
|
||||
@rangeStep(0.01)
|
||||
@slide
|
||||
@displayOrder(3)
|
||||
@tooltip('i18n:fog.fogDensity')
|
||||
get fogDensity () {
|
||||
return this._fogDensity;
|
||||
}
|
||||
@@ -527,6 +543,7 @@ export class FogInfo {
|
||||
@type(CCFloat)
|
||||
@rangeStep(0.01)
|
||||
@displayOrder(4)
|
||||
@tooltip('i18n:fog.fogStart')
|
||||
get fogStart () {
|
||||
return this._fogStart;
|
||||
}
|
||||
@@ -544,6 +561,7 @@ export class FogInfo {
|
||||
@type(CCFloat)
|
||||
@rangeStep(0.01)
|
||||
@displayOrder(5)
|
||||
@tooltip('i18n:fog.fogEnd')
|
||||
get fogEnd () {
|
||||
return this._fogEnd;
|
||||
}
|
||||
@@ -562,6 +580,7 @@ export class FogInfo {
|
||||
@rangeMin(0.01)
|
||||
@rangeStep(0.01)
|
||||
@displayOrder(6)
|
||||
@tooltip('i18n:fog.fogAtten')
|
||||
get fogAtten () {
|
||||
return this._fogAtten;
|
||||
}
|
||||
@@ -579,6 +598,7 @@ export class FogInfo {
|
||||
@type(CCFloat)
|
||||
@rangeStep(0.01)
|
||||
@displayOrder(7)
|
||||
@tooltip('i18n:fog.fogTop')
|
||||
get fogTop () {
|
||||
return this._fogTop;
|
||||
}
|
||||
@@ -596,6 +616,7 @@ export class FogInfo {
|
||||
@type(CCFloat)
|
||||
@rangeStep(0.01)
|
||||
@displayOrder(8)
|
||||
@tooltip('i18n:fog.fogRange')
|
||||
get fogRange () {
|
||||
return this._fogRange;
|
||||
}
|
||||
@@ -617,6 +638,7 @@ export class FogInfo {
|
||||
* @zh 平面阴影相关信息
|
||||
*/
|
||||
@ccclass('cc.ShadowsInfo')
|
||||
@help('i18n:cc.Shadow')
|
||||
export class ShadowsInfo {
|
||||
@serializable
|
||||
protected _type = ShadowType.Planar;
|
||||
@@ -662,6 +684,7 @@ export class ShadowsInfo {
|
||||
* @zh 是否启用平面阴影?
|
||||
*/
|
||||
@editable
|
||||
@tooltip('i18n:shadow.enabled')
|
||||
set enabled (val: boolean) {
|
||||
if (this._enabled === val) return;
|
||||
this._enabled = val;
|
||||
@@ -704,6 +727,7 @@ export class ShadowsInfo {
|
||||
* @zh 阴影接收平面的法线
|
||||
*/
|
||||
@visible(function (this: ShadowsInfo) { return this._type === ShadowType.Planar; })
|
||||
@tooltip('i18n:shadow.normal')
|
||||
set normal (val: Vec3) {
|
||||
Vec3.copy(this._normal, val);
|
||||
if (this._resource) { this._resource.normal = val; }
|
||||
@@ -717,6 +741,7 @@ export class ShadowsInfo {
|
||||
* @zh 阴影接收平面与原点的距离
|
||||
*/
|
||||
@type(CCFloat)
|
||||
@tooltip('i18n:shadow.distance')
|
||||
@visible(function (this: ShadowsInfo) { return this._type === ShadowType.Planar; })
|
||||
set distance (val: number) {
|
||||
this._distance = val;
|
||||
@@ -734,6 +759,7 @@ export class ShadowsInfo {
|
||||
@range([0.0, 1.0, 0.01])
|
||||
@slide
|
||||
@type(CCFloat)
|
||||
@tooltip('i18n:shadow.saturation')
|
||||
@visible(function (this: ShadowsInfo) { return this._type === ShadowType.ShadowMap; })
|
||||
set saturation (val: number) {
|
||||
if (val > 1.0) {
|
||||
@@ -753,6 +779,7 @@ export class ShadowsInfo {
|
||||
* @zh 阴影接收平面的法线
|
||||
*/
|
||||
@type(PCFType)
|
||||
@tooltip('i18n:shadow.pcf')
|
||||
@visible(function (this: ShadowsInfo) { return this._type === ShadowType.ShadowMap; })
|
||||
set pcf (val) {
|
||||
this._pcf = val;
|
||||
@@ -781,6 +808,7 @@ export class ShadowsInfo {
|
||||
* @zh 获取或者设置阴影纹理偏移值
|
||||
*/
|
||||
@type(CCFloat)
|
||||
@tooltip('i18n:shadow.bias')
|
||||
@visible(function (this: ShadowsInfo) { return this._type === ShadowType.ShadowMap; })
|
||||
set bias (val: number) {
|
||||
this._bias = val;
|
||||
@@ -795,6 +823,7 @@ export class ShadowsInfo {
|
||||
* @zh 打开或者关闭自阴影。
|
||||
*/
|
||||
@type(CCFloat)
|
||||
@tooltip('i18n:shadow.normalBias')
|
||||
@visible(function (this: ShadowsInfo) { return this._type === ShadowType.ShadowMap; })
|
||||
set normalBias (val: number) {
|
||||
this._normalBias = val;
|
||||
@@ -809,6 +838,7 @@ export class ShadowsInfo {
|
||||
* @zh 获取或者设置阴影纹理大小
|
||||
*/
|
||||
@type(ShadowSize)
|
||||
@tooltip('i18n:shadow.shadowMapSize')
|
||||
@visible(function (this: ShadowsInfo) { return this._type === ShadowType.ShadowMap; })
|
||||
set shadowMapSize (value: number) {
|
||||
this._size.set(value, value);
|
||||
@@ -829,6 +859,7 @@ export class ShadowsInfo {
|
||||
* @zh 是否是固定区域阴影
|
||||
*/
|
||||
@type(CCBoolean)
|
||||
@tooltip('i18n:shadow.fixedArea')
|
||||
@visible(function (this: ShadowsInfo) { return this._type === ShadowType.ShadowMap; })
|
||||
set fixedArea (val) {
|
||||
this._fixedArea = val;
|
||||
@@ -843,6 +874,7 @@ export class ShadowsInfo {
|
||||
* @zh 获取或者设置阴影相机近裁剪面
|
||||
*/
|
||||
@type(CCFloat)
|
||||
@tooltip('i18n:shadow.near')
|
||||
@visible(function (this: ShadowsInfo) { return this._type === ShadowType.ShadowMap && this._fixedArea === true; })
|
||||
set near (val: number) {
|
||||
this._near = val;
|
||||
@@ -857,6 +889,7 @@ export class ShadowsInfo {
|
||||
* @zh 获取或者设置阴影相机远裁剪面
|
||||
*/
|
||||
@type(CCFloat)
|
||||
@tooltip('i18n:shadow.far')
|
||||
@visible(function (this: ShadowsInfo) { return this._type === ShadowType.ShadowMap && this._fixedArea === true; })
|
||||
set far (val: number) {
|
||||
this._far = Math.min(val, Shadows.MAX_FAR);
|
||||
@@ -871,10 +904,10 @@ export class ShadowsInfo {
|
||||
* @zh 获取或者设置潜在阴影产生的范围
|
||||
*/
|
||||
@editable
|
||||
@tooltip('if shadow has been culled, increase this value to fix it')
|
||||
@range([0.0, 2000.0, 0.1])
|
||||
@slide
|
||||
@type(CCFloat)
|
||||
@tooltip('i18n:shadow.invisibleOcclusionRange')
|
||||
@visible(function (this: ShadowsInfo) { return this._type === ShadowType.ShadowMap && this._fixedArea === false; })
|
||||
set invisibleOcclusionRange (val: number) {
|
||||
this._invisibleOcclusionRange = Math.min(val, Shadows.MAX_FAR);
|
||||
@@ -891,10 +924,10 @@ export class ShadowsInfo {
|
||||
* @zh 获取或者设置潜在阴影产生的范围
|
||||
*/
|
||||
@editable
|
||||
@tooltip('shadow visible distance: shadow quality is inversely proportional of the magnitude of this value')
|
||||
@range([0.0, 2000.0, 0.1])
|
||||
@slide
|
||||
@type(CCFloat)
|
||||
@tooltip('i18n:shadow.shadowDistance')
|
||||
@visible(function (this: ShadowsInfo) { return this._type === ShadowType.ShadowMap && this._fixedArea === false; })
|
||||
set shadowDistance (val: number) {
|
||||
this._shadowDistance = Math.min(val, Shadows.MAX_FAR);
|
||||
@@ -911,6 +944,7 @@ export class ShadowsInfo {
|
||||
* @zh 获取或者设置阴影相机正交大小
|
||||
*/
|
||||
@type(CCFloat)
|
||||
@tooltip('i18n:shadow.orthoSize')
|
||||
@visible(function (this: ShadowsInfo) { return this._type === ShadowType.ShadowMap && this._fixedArea === true; })
|
||||
set orthoSize (val: number) {
|
||||
this._orthoSize = val;
|
||||
@@ -963,6 +997,7 @@ export const DEFAULT_WORLD_MAX_POS = new Vec3(1024.0, 1024.0, 1024.0);
|
||||
export const DEFAULT_OCTREE_DEPTH = 8;
|
||||
|
||||
@ccclass('cc.OctreeInfo')
|
||||
@help('i18n:cc.OctreeCulling')
|
||||
export class OctreeInfo {
|
||||
@serializable
|
||||
protected _enabled = false;
|
||||
@@ -980,6 +1015,7 @@ export class OctreeInfo {
|
||||
* @zh 是否启用八叉树加速剔除?
|
||||
*/
|
||||
@editable
|
||||
@tooltip('i18n:octree_culling.enabled')
|
||||
set enabled (val: boolean) {
|
||||
if (this._enabled === val) return;
|
||||
this._enabled = val;
|
||||
@@ -992,6 +1028,8 @@ export class OctreeInfo {
|
||||
}
|
||||
|
||||
@editable
|
||||
@tooltip('i18n:octree_culling.minPos')
|
||||
@displayName('World MinPos')
|
||||
set minPos (val: Vec3) {
|
||||
this._minPos = val;
|
||||
if (this._resource) { this._resource.minPos = val; }
|
||||
@@ -1001,6 +1039,8 @@ export class OctreeInfo {
|
||||
}
|
||||
|
||||
@editable
|
||||
@tooltip('i18n:octree_culling.maxPos')
|
||||
@displayName('World MaxPos')
|
||||
set maxPos (val: Vec3) {
|
||||
this._maxPos = val;
|
||||
if (this._resource) { this._resource.maxPos = val; }
|
||||
@@ -1012,6 +1052,7 @@ export class OctreeInfo {
|
||||
@editable
|
||||
@range([4, 12, 1])
|
||||
@type(CCInteger)
|
||||
@tooltip('i18n:octree_culling.depth')
|
||||
set depth (val: number) {
|
||||
this._depth = val;
|
||||
if (this._resource) { this._resource.depth = val; }
|
||||
|
||||
@@ -7,7 +7,7 @@ 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, CCClass, Color, Enum, ccenum, errorID, Texture2D, js, CCObject, director } from '../core';
|
||||
import { Node, CCClass, Color, Enum, ccenum, errorID, Texture2D, js, CCObject } from '../core';
|
||||
import { EventTarget } from '../core/event';
|
||||
import { BlendFactor } from '../core/gfx';
|
||||
import { displayName, editable, override, serializable, tooltip, type, visible } from '../core/data/decorators';
|
||||
@@ -569,7 +569,7 @@ export class ArmatureDisplay extends Renderable2D {
|
||||
this.material = m.renderData.material;
|
||||
}
|
||||
if (m.texture) {
|
||||
ui.commitPlainComp(this, m.texture, this._assembler, null);
|
||||
ui.commitComp(this, m.texture, this._assembler, null);
|
||||
}
|
||||
this.material = mat;
|
||||
}
|
||||
@@ -1303,11 +1303,6 @@ export class ArmatureDisplay extends Renderable2D {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public markForUpdateRenderData (enable = true) {
|
||||
super.markForUpdateRenderData(enable);
|
||||
director.root!.batcher2D._reloadBatch();
|
||||
}
|
||||
}
|
||||
|
||||
legacyCC.internal.ArmatureDisplay = ArmatureDisplay;
|
||||
|
||||
@@ -154,9 +154,6 @@ export const simple: IAssembler = {
|
||||
const srcVIdx = renderData.vertexStart;
|
||||
const srcIBuf = renderData.iData;
|
||||
|
||||
renderData.cacheBuffer = buffer;
|
||||
renderData.bufferOffset = floatOffset;
|
||||
|
||||
// copy all vertexData
|
||||
vBuf.set(srcVBuf.slice(srcVIdx, srcVIdx + renderData.vertexCount * STRIDE_FLOAT), floatOffset);
|
||||
if (!comp._enableBatch) {
|
||||
@@ -175,40 +172,6 @@ export const simple: IAssembler = {
|
||||
iBuf[i + indicesOffset] = srcIBuf[i + srcIOffset] + vertexOffset;
|
||||
}
|
||||
},
|
||||
|
||||
fillCacheBuffer (comp: ArmatureDisplay) {
|
||||
if (!comp || comp.meshRenderDataArray.length === 0) return;
|
||||
|
||||
const dataArray = comp.meshRenderDataArray;
|
||||
const node = comp.node;
|
||||
|
||||
// 当前渲染的数据
|
||||
const data = dataArray[comp._meshRenderDataArrayIdx];
|
||||
const renderData = data.renderData;
|
||||
|
||||
const buffer = renderData.cacheBuffer!;
|
||||
const floatOffset = renderData.bufferOffset;
|
||||
|
||||
const vBuf = buffer.vData!;
|
||||
const matrix = node.worldMatrix;
|
||||
|
||||
const srcVBuf = renderData.vData;
|
||||
const srcVIdx = renderData.vertexStart;
|
||||
|
||||
// copy all vertexData
|
||||
vBuf.set(srcVBuf.slice(srcVIdx, srcVIdx + renderData.vertexCount * STRIDE_FLOAT), floatOffset);
|
||||
if (!comp._enableBatch) {
|
||||
for (let i = 0; i < renderData.vertexCount; i++) {
|
||||
const pOffset = floatOffset + i * STRIDE_FLOAT;
|
||||
_vec3u_temp.set(vBuf[pOffset], vBuf[pOffset + 1], vBuf[pOffset + 2]);
|
||||
_vec3u_temp.transformMat4(matrix);
|
||||
vBuf[pOffset] = _vec3u_temp.x;
|
||||
vBuf[pOffset + 1] = _vec3u_temp.y;
|
||||
vBuf[pOffset + 2] = _vec3u_temp.z;
|
||||
}
|
||||
}
|
||||
buffer.setDirty();
|
||||
},
|
||||
};
|
||||
|
||||
function realTimeTraverse (armature: Armature, parentMat: Mat4|undefined, parentOpacity: number) {
|
||||
|
||||
@@ -33,7 +33,7 @@ import { IAssembler, IAssemblerManager } from '../2d/renderer/base';
|
||||
import { MotionStreak } from './motion-streak-2d';
|
||||
import { Vec2, Color } from '../core/math';
|
||||
import { IBatcher } from '../2d/renderer/i-batcher';
|
||||
import { director, Texture2D } from '../core';
|
||||
import { Texture2D } from '../core';
|
||||
import { RenderData } from '../2d/renderer/render-data';
|
||||
|
||||
const _tangent = new Vec2();
|
||||
@@ -183,7 +183,6 @@ export const MotionStreakAssembler: IAssembler = {
|
||||
|
||||
renderData.vertexCount = verticesCount;
|
||||
renderData.indicesCount = indicesCount;
|
||||
director.root!.batcher2D._reloadBatch();
|
||||
},
|
||||
|
||||
updateRenderDataCache (comp: MotionStreak, renderData: RenderData) {
|
||||
@@ -227,9 +226,6 @@ export const MotionStreakAssembler: IAssembler = {
|
||||
const vertexCount = renderData.vertexCount;
|
||||
const indicesCount = renderData.indicesCount;
|
||||
|
||||
renderData.cacheBuffer = buffer;
|
||||
renderData.bufferOffset = vertexOffset;
|
||||
|
||||
for (let i = 0; i < vertexCount; i++) {
|
||||
const vert = dataList[i];
|
||||
vBuf[vertexOffset++] = vert.x;
|
||||
@@ -252,30 +248,6 @@ export const MotionStreakAssembler: IAssembler = {
|
||||
iBuf[indicesOffset++] = start + 3;
|
||||
}
|
||||
},
|
||||
|
||||
fillCacheBuffer (comp: MotionStreak) {
|
||||
const renderData = comp.renderData!;
|
||||
const dataList = renderData.data;
|
||||
|
||||
const buffer = renderData.cacheBuffer!;
|
||||
let vertexOffset = renderData.bufferOffset;
|
||||
|
||||
// buffer data may be reallocated, need get reference after request.
|
||||
const vBuf = buffer.vData!;
|
||||
const vertexCount = renderData.vertexCount;
|
||||
|
||||
for (let i = 0; i < vertexCount; i++) {
|
||||
const vert = dataList[i];
|
||||
vBuf[vertexOffset++] = vert.x;
|
||||
vBuf[vertexOffset++] = vert.y;
|
||||
vBuf[vertexOffset++] = vert.z;
|
||||
vBuf[vertexOffset++] = vert.u;
|
||||
vBuf[vertexOffset++] = vert.v;
|
||||
Color.toArray(vBuf, vert.color, vertexOffset);
|
||||
vertexOffset += 4;
|
||||
}
|
||||
buffer.setDirty();
|
||||
},
|
||||
};
|
||||
|
||||
export const MotionStreakAssemblerManager: IAssemblerManager = {
|
||||
|
||||
@@ -34,7 +34,6 @@ import { clampf, degreesToRadians, radiansToDegrees } from '../core/utils/misc';
|
||||
import { vfmtPosUvColor, getComponentPerVertex } from '../2d/renderer/vertex-format';
|
||||
import { PositionType, EmitterMode, START_SIZE_EQUAL_TO_END_SIZE, START_RADIUS_EQUAL_TO_END_RADIUS } from './define';
|
||||
import { ParticleSystem2D } from './particle-system-2d';
|
||||
import { director } from '../core';
|
||||
|
||||
const ZERO_VEC2 = new Vec2(0, 0);
|
||||
const _pos = new Vec2();
|
||||
@@ -471,8 +470,6 @@ export class Simulator {
|
||||
this.finished = true;
|
||||
psys._finishedSimulation();
|
||||
}
|
||||
|
||||
director.root!.batcher2D._reloadBatch();
|
||||
}
|
||||
|
||||
requestData (vertexCount: number, indicesCount: number) {
|
||||
|
||||
@@ -41,6 +41,9 @@ export const ParticleAssembler: IAssembler = {
|
||||
createData (comp: ParticleSystem2D) {
|
||||
return MeshRenderData.add();
|
||||
},
|
||||
removeData (data) {
|
||||
MeshRenderData.remove(data);
|
||||
},
|
||||
updateRenderData () {
|
||||
},
|
||||
fillBuffers (comp: ParticleSystem2D, renderer: IBatcher) {
|
||||
@@ -71,9 +74,6 @@ export const ParticleAssembler: IAssembler = {
|
||||
const vData = renderData.vData;
|
||||
const iData = renderData.iData as number[];
|
||||
|
||||
renderData.cacheBuffer = buffer;
|
||||
renderData.bufferOffset = vertexOffset;
|
||||
|
||||
const vLen = renderData.vertexCount * 9;
|
||||
for (let i = 0; i < vLen; i++) {
|
||||
vBuf[vertexOffset++] = vData[i];
|
||||
@@ -84,30 +84,6 @@ export const ParticleAssembler: IAssembler = {
|
||||
iBuf[indicesOffset++] = iData[i] + vertexId;
|
||||
}
|
||||
},
|
||||
fillCacheBuffer (comp: ParticleSystem2D) {
|
||||
if (comp === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const renderData = comp._simulator.renderData;
|
||||
if (renderData.vertexCount === 0 || renderData.indicesCount === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const buffer = renderData.cacheBuffer!;
|
||||
let vertexOffset = renderData.bufferOffset;
|
||||
|
||||
// buffer data may be realloc, need get reference after request.
|
||||
const vBuf = buffer.vData!;
|
||||
|
||||
const vData = renderData.vData;
|
||||
|
||||
const vLen = renderData.vertexCount * 9;
|
||||
for (let i = 0; i < vLen; i++) {
|
||||
vBuf[vertexOffset++] = vData[i];
|
||||
}
|
||||
buffer.setDirty();
|
||||
},
|
||||
};
|
||||
|
||||
export const ParticleSystem2DAssembler: IAssemblerManager = {
|
||||
|
||||
@@ -765,6 +765,10 @@ export class ParticleSystem2D extends Renderable2D {
|
||||
|
||||
// reset uv data so next time simulator will refill buffer uv info when exit edit mode from prefab.
|
||||
this._simulator.uvFilled = 0;
|
||||
|
||||
if (this._simulator.renderData && this._assembler) {
|
||||
this._assembler.removeData(this._simulator.renderData);
|
||||
}
|
||||
}
|
||||
|
||||
private initProperties () {
|
||||
@@ -1169,11 +1173,11 @@ export class ParticleSystem2D extends Renderable2D {
|
||||
|
||||
protected _render (render: IBatcher) {
|
||||
if (this._positionType === PositionType.RELATIVE) {
|
||||
render.commitPlainComp(this, this._renderSpriteFrame, this._assembler!, this.node.parent);
|
||||
render.commitComp(this, this._renderSpriteFrame, this._assembler!, this.node.parent);
|
||||
} else if (this.positionType === PositionType.GROUPED) {
|
||||
render.commitPlainComp(this, this._renderSpriteFrame, this._assembler!, this.node);
|
||||
render.commitComp(this, this._renderSpriteFrame, this._assembler!, this.node);
|
||||
} else {
|
||||
render.commitPlainComp(this, this._renderSpriteFrame, this._assembler!, null);
|
||||
render.commitComp(this, this._renderSpriteFrame, this._assembler!, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ export const simple: IAssembler = {
|
||||
},
|
||||
|
||||
fillBuffers (comp: Skeleton, renderer: IBatcher) {
|
||||
if (!comp || !comp.meshRenderDataArray || comp.meshRenderDataArray.length < 1) return;
|
||||
if (!comp || !comp.meshRenderDataArray) return;
|
||||
_comp = comp;
|
||||
const dataArray = comp.meshRenderDataArray;
|
||||
const node = comp.node;
|
||||
@@ -207,9 +207,6 @@ export const simple: IAssembler = {
|
||||
const srcVIdx = renderData.vertexStart;
|
||||
const srcIBuf = renderData.iData;
|
||||
|
||||
renderData.cacheBuffer = buffer;
|
||||
renderData.bufferOffset = floatOffset;
|
||||
|
||||
// copy all vertexData
|
||||
const strideFloat = renderData.floatStride;
|
||||
vBuf.set(srcVBuf.subarray(srcVIdx, srcVIdx + renderData.vertexCount * strideFloat), floatOffset);
|
||||
@@ -227,39 +224,6 @@ export const simple: IAssembler = {
|
||||
iBuf[i + indicesOffset] = srcIBuf[i + srcIOffset] + vertexOffset;
|
||||
}
|
||||
},
|
||||
|
||||
fillCacheBuffer (comp: Skeleton) {
|
||||
if (!comp || !comp.meshRenderDataArray || comp.meshRenderDataArray.length < 1) return;
|
||||
_comp = comp;
|
||||
const dataArray = comp.meshRenderDataArray;
|
||||
const node = comp.node;
|
||||
|
||||
// 当前渲染的数据
|
||||
const data = dataArray[comp._meshRenderDataArrayIdx];
|
||||
const renderData = data.renderData;
|
||||
|
||||
const buffer = renderData.cacheBuffer!;
|
||||
const floatOffset = renderData.bufferOffset;
|
||||
|
||||
const vBuf = buffer.vData!;
|
||||
const matrix = node.worldMatrix;
|
||||
|
||||
const srcVBuf = renderData.vData;
|
||||
const srcVIdx = renderData.vertexStart;
|
||||
|
||||
// copy all vertexData
|
||||
const strideFloat = renderData.floatStride;
|
||||
vBuf.set(srcVBuf.subarray(srcVIdx, srcVIdx + renderData.vertexCount * strideFloat), floatOffset);
|
||||
for (let i = 0; i < renderData.vertexCount; i++) {
|
||||
const pOffset = floatOffset + i * strideFloat;
|
||||
_vec3u_temp.set(vBuf[pOffset], vBuf[pOffset + 1], vBuf[pOffset + 2]);
|
||||
_vec3u_temp.transformMat4(matrix);
|
||||
vBuf[pOffset] = _vec3u_temp.x;
|
||||
vBuf[pOffset + 1] = _vec3u_temp.y;
|
||||
vBuf[pOffset + 2] = _vec3u_temp.z;
|
||||
}
|
||||
buffer.setDirty();
|
||||
},
|
||||
};
|
||||
|
||||
function updateComponentRenderData (comp: Skeleton, ui: IBatcher) {
|
||||
|
||||
@@ -10,7 +10,7 @@ import SkeletonCache, { AnimationCache, AnimationFrame } from './skeleton-cache'
|
||||
import { AttachUtil } from './attach-util';
|
||||
import { ccclass, executeInEditMode, help, menu } from '../core/data/class-decorator';
|
||||
import { Renderable2D } from '../2d/framework/renderable-2d';
|
||||
import { Node, CCClass, CCObject, Color, Enum, Material, Texture2D, builtinResMgr, ccenum, errorID, logID, warn, director } from '../core';
|
||||
import { Node, CCClass, CCObject, Color, Enum, Material, Texture2D, builtinResMgr, ccenum, errorID, logID, warn } from '../core';
|
||||
import { displayName, displayOrder, editable, override, serializable, tooltip, type, visible } from '../core/data/decorators';
|
||||
import { SkeletonData } from './skeleton-data';
|
||||
import { VertexEffectDelegate } from './vertex-effect-delegate';
|
||||
@@ -1372,7 +1372,7 @@ export class Skeleton extends Renderable2D {
|
||||
this.material = m.renderData.material;
|
||||
}
|
||||
if (m.texture) {
|
||||
ui.commitPlainComp(this, m.texture, this._assembler, null);
|
||||
ui.commitComp(this, m.texture, this._assembler, null);
|
||||
}
|
||||
this.material = mat;
|
||||
}
|
||||
@@ -1665,11 +1665,6 @@ export class Skeleton extends Renderable2D {
|
||||
}
|
||||
this._materialCache = {};
|
||||
}
|
||||
|
||||
public markForUpdateRenderData (enable = true) {
|
||||
super.markForUpdateRenderData(enable);
|
||||
director.root!.batcher2D._reloadBatch();
|
||||
}
|
||||
}
|
||||
|
||||
legacyCC.internal.SpineSkeleton = Skeleton;
|
||||
|
||||
+42
-15
@@ -41,7 +41,7 @@ import { director } from '../core/director';
|
||||
import { AttributeName, BufferUsageBit, Format, MemoryUsageBit, PrimitiveMode, Device, Attribute, Buffer, BufferInfo } from '../core/gfx';
|
||||
import { clamp, Rect, Size, Vec2, Vec3, Vec4 } from '../core/math';
|
||||
import { MacroRecord } from '../core/renderer/core/pass-utils';
|
||||
import { scene } from '../core/renderer';
|
||||
import { Pass, scene } from '../core/renderer';
|
||||
import { Camera } from '../core/renderer/scene/camera';
|
||||
import { Root } from '../core/root';
|
||||
import { HeightField } from './height-field';
|
||||
@@ -182,6 +182,7 @@ class TerrainRenderable extends RenderableComponent {
|
||||
public _model: scene.Model | null = null;
|
||||
public _meshData: RenderingSubMesh | null = null;
|
||||
|
||||
public _brushPass: Pass | null = null;
|
||||
public _brushMaterial: Material | null = null;
|
||||
public _currentMaterial: Material | null = null;
|
||||
public _currentMaterialLayers = 0;
|
||||
@@ -209,18 +210,9 @@ class TerrainRenderable extends RenderableComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._brushMaterial !== null && this._brushMaterial.passes !== null && this._brushMaterial.passes.length > 0) {
|
||||
const passes = this._currentMaterial.passes;
|
||||
for (let i = 0; i < passes.length; ++i) {
|
||||
if (passes[i] === this._brushMaterial.passes[0]) {
|
||||
passes.pop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this._clearMaterials();
|
||||
|
||||
this._brushPass = null;
|
||||
this._currentMaterial = null;
|
||||
if (this._model != null) {
|
||||
this._model.enabled = false;
|
||||
@@ -241,9 +233,18 @@ class TerrainRenderable extends RenderableComponent {
|
||||
defines: block._getMaterialDefines(nLayers),
|
||||
});
|
||||
|
||||
if (this._brushMaterial !== null && this._brushMaterial.passes !== null && this._brushMaterial.passes.length > 0) {
|
||||
const passes = this._currentMaterial.passes;
|
||||
passes.push(this._brushMaterial.passes[0]);
|
||||
if (this._brushMaterial !== null) {
|
||||
// 创建画刷材质实例,避免材质GC直接删除插入的画刷pass
|
||||
const brushMaterialInstance = new Material();
|
||||
brushMaterialInstance.copy(this._brushMaterial);
|
||||
|
||||
this._brushPass = null;
|
||||
if (brushMaterialInstance.passes !== null && brushMaterialInstance.passes.length > 0) {
|
||||
this._brushPass = brushMaterialInstance.passes[0];
|
||||
const passes = this._currentMaterial.passes;
|
||||
passes.push(this._brushPass);
|
||||
brushMaterialInstance.passes.pop();
|
||||
}
|
||||
}
|
||||
|
||||
if (init) {
|
||||
@@ -610,6 +611,14 @@ export class TerrainBlock {
|
||||
}
|
||||
}
|
||||
|
||||
public _getBrushMaterial () {
|
||||
return this._renderable ? this._renderable._brushMaterial : null;
|
||||
}
|
||||
|
||||
public _getBrushPass () {
|
||||
return this._renderable ? this._renderable._brushPass : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @en valid
|
||||
* @zh 是否有效
|
||||
@@ -629,6 +638,14 @@ export class TerrainBlock {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @en get current material
|
||||
* @zh 获得当前的材质
|
||||
*/
|
||||
get material () {
|
||||
return this._renderable ? this._renderable._currentMaterial : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @en get layers
|
||||
* @zh 获得纹理层索引
|
||||
@@ -1101,6 +1118,7 @@ export class Terrain extends Component {
|
||||
@disallowAnimation
|
||||
protected _lodBias = 0;
|
||||
|
||||
// when the terrain undo, __asset is changed by serialize, but the internal block is created by last asset, here saved last asset
|
||||
protected _buitinAsset : TerrainAsset|null = null;
|
||||
protected _tileSize = 1;
|
||||
protected _blockCount: number[] = [1, 1];
|
||||
@@ -1152,9 +1170,14 @@ export class Terrain extends Component {
|
||||
this._heights = new Uint16Array();
|
||||
this._weights = new Uint8Array();
|
||||
this._normals = [];
|
||||
this._layerList = [];
|
||||
this._layerBuffer = [];
|
||||
this._blocks = [];
|
||||
|
||||
// initialize layers
|
||||
this._layerList = [];
|
||||
for (let i = 0; i < TERRAIN_MAX_LAYER_COUNT; ++i) {
|
||||
this._layerList.push(null);
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure device is created
|
||||
@@ -2116,6 +2139,10 @@ export class Terrain extends Component {
|
||||
}
|
||||
|
||||
const terrainAsset = this.__asset;
|
||||
if (this._buitinAsset != terrainAsset) {
|
||||
this._buitinAsset = terrainAsset;
|
||||
}
|
||||
|
||||
if (!restore && terrainAsset !== null) {
|
||||
this._tileSize = terrainAsset.tileSize;
|
||||
this._blockCount = terrainAsset.blockCount;
|
||||
|
||||
@@ -172,9 +172,6 @@ export const simple: IAssembler = {
|
||||
const srcVBuf = renderData.vData;
|
||||
const srcVIdx = renderData.vertexStart;
|
||||
|
||||
renderData.cacheBuffer = buffer;
|
||||
renderData.bufferOffset = vertexOffset;
|
||||
|
||||
// copy all vertexData
|
||||
vBuf.set(srcVBuf.slice(srcVIdx, srcVIdx + renderData.vertexCount * 9), vertexOffset);
|
||||
for (let i = 0; i < renderData.vertexCount; i++) {
|
||||
@@ -198,37 +195,6 @@ export const simple: IAssembler = {
|
||||
vertexId += 4;
|
||||
}
|
||||
},
|
||||
|
||||
fillCacheBuffer (layer: TiledLayer) {
|
||||
if (!layer || !layer.meshRenderDataArray) return;
|
||||
|
||||
const dataArray = layer.meshRenderDataArray;
|
||||
const node = layer.node;
|
||||
|
||||
const data = dataArray[layer._meshRenderDataArrayIdx] as TiledMeshData;
|
||||
const renderData = data.renderData;
|
||||
|
||||
const buffer = renderData.cacheBuffer!;
|
||||
const vertexOffset = renderData.bufferOffset;
|
||||
|
||||
const vBuf = buffer.vData!;
|
||||
const matrix = node.worldMatrix;
|
||||
|
||||
const srcVBuf = renderData.vData;
|
||||
const srcVIdx = renderData.vertexStart;
|
||||
|
||||
// copy all vertexData
|
||||
vBuf.set(srcVBuf.slice(srcVIdx, srcVIdx + renderData.vertexCount * 9), vertexOffset);
|
||||
for (let i = 0; i < renderData.vertexCount; i++) {
|
||||
const pOffset = vertexOffset + i * 9;
|
||||
_vec3u_temp.set(vBuf[pOffset], vBuf[pOffset + 1], vBuf[pOffset + 2]);
|
||||
_vec3u_temp.transformMat4(matrix);
|
||||
vBuf[pOffset] = _vec3u_temp.x;
|
||||
vBuf[pOffset + 1] = _vec3u_temp.y;
|
||||
vBuf[pOffset + 2] = _vec3u_temp.z;
|
||||
}
|
||||
buffer.setDirty();
|
||||
},
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -1447,15 +1447,10 @@ export class TiledLayer extends Renderable2D {
|
||||
});
|
||||
} else if ((m as TiledMeshData).texture) {
|
||||
// NOTE: 由于 commitComp 只支持单张纹理, 故分多次提交
|
||||
ui.commitPlainComp(this, (m as TiledMeshData).texture, this._assembler, null);
|
||||
ui.commitComp(this, (m as TiledMeshData).texture, this._assembler, null);
|
||||
}
|
||||
}
|
||||
this.node._static = true;
|
||||
}
|
||||
}
|
||||
|
||||
public markForUpdateRenderData (enable = true) {
|
||||
super.markForUpdateRenderData(enable);
|
||||
director.root!.batcher2D._reloadBatch();
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 4.9 KiB |
@@ -24,10 +24,10 @@ float CCGetViewSpaceDepth(float depthHS)
|
||||
|
||||
#if CC_RECEIVE_SHADOW
|
||||
#pragma builtin(global)
|
||||
layout(set = 0, binding = 3) uniform sampler2D cc_shadowMap;
|
||||
layout(set = 0, binding = 3) uniform highp sampler2D cc_shadowMap;
|
||||
|
||||
#pragma builtin(global)
|
||||
layout(set = 0, binding = 5) uniform sampler2D cc_spotLightingMap;
|
||||
layout(set = 0, binding = 5) uniform highp sampler2D cc_spotLightingMap;
|
||||
|
||||
vec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ vec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {
|
||||
|
||||
vec4 fragTextureGrad (sampler2D tex, vec2 P, vec2 dPdx, vec2 dPdy) {
|
||||
#if __VERSION__ < 130
|
||||
#ifdef GL_EXT_shader_texture_Grad
|
||||
#ifdef GL_EXT_shader_texture_lod
|
||||
return texture2DGradEXT(tex, P, dPdx, dPdy);
|
||||
#else
|
||||
return texture2D(tex, P);
|
||||
@@ -40,7 +40,7 @@ vec4 fragTextureGrad (sampler2D tex, vec2 P, vec2 dPdx, vec2 dPdy) {
|
||||
|
||||
vec4 fragTextureGrad (samplerCube tex, vec3 P, vec3 dPdx, vec3 dPdy) {
|
||||
#if __VERSION__ < 130
|
||||
#ifdef GL_EXT_shader_texture_Grad
|
||||
#ifdef GL_EXT_shader_texture_lod
|
||||
return textureCubeGradEXT(tex, P, dPdx, dPdy);
|
||||
#else
|
||||
return textureCube(tex, P);
|
||||
|
||||
@@ -21,6 +21,10 @@ module.exports = {
|
||||
Canvas: `${url}/${version}/manual/en/ui-system/components/editor/canvas.html`,
|
||||
SkinnedMeshRenderer: `${url}/${version}/manual/en/engine/animation/skeletal-animation.html`,
|
||||
SkinnedMeshBatchRenderer: `${url}/${version}/manual/en/engine/animation/skeletal-animation.html`,
|
||||
Ambient: `${url}/${version}/manual/zh/concepts/scene/light/lighttype/ambient.html`,
|
||||
Skybox: `${url}/${version}/manual/zh/concepts/scene/skybox.html`,
|
||||
Fog: `${url}/${version}/manual/zh/concepts/scene/fog.html`,
|
||||
Shadow: `${url}/${version}/manual/zh/concepts/scene/light/shadow.html`,
|
||||
DirectionalLight: `${url}/${version}/manual/en/concepts/scene/light/dir-light.html`,
|
||||
SphereLight: `${url}/${version}/manual/en/concepts/scene/light/sphere-light.html`,
|
||||
SpotLight: `${url}/${version}/manual/en/concepts/scene/light/spot-light.html`,
|
||||
@@ -64,10 +68,51 @@ module.exports = {
|
||||
Terrain: `${url}/${version}/manual/en/editor/terrain/`,
|
||||
TiledMap: ``,
|
||||
Spine: ``,
|
||||
OctreeCulling: `${url}/${version}/manual/en/advanced-topics/native-scene-culling.html`,
|
||||
},
|
||||
},
|
||||
ambient: {
|
||||
skyLightingColor: 'Sky Color (Upper sphere lighting source).',
|
||||
groundLightingColor: 'Ground Color (Lower sphere lighting source).',
|
||||
skyIllum: 'Ambient lighting intensity.',
|
||||
},
|
||||
skybox: {
|
||||
applyDiffuseMap: 'When checking, scene objects will use accurate diffusion map instead of hemisphere lighting.',
|
||||
enabled: 'Enable or disable skybox rendering with Envmap cube texture settings.',
|
||||
useIBL: 'When checking, scene objects will calculate image based lighting from Envmap settings with diffuse and specular-reflections. Otherwise objects only calculate hemisphere diffuse lighting.',
|
||||
useHDR: 'Toggle HDR or LDR mode. Each mode has seperate light source settings, HDR mode uses physical luminosity unit with camera exposure attributes, and LDR mode uses none-unit without exposure calculations.',
|
||||
envmap: 'Set skybox texture and environment light source. Support cross / longitude and latitude / 6-separated cube textures. Support hdr / tga / png file type.',
|
||||
},
|
||||
fog: {
|
||||
enabled: 'Enable or disable global fog effect.',
|
||||
accurate: 'Toggle vertex fog and pixel fog. Pixel fog has more accurate visual effect with low vertex count objects, but vertex fog has better performance.',
|
||||
fogColor: 'Fog In-Scattering Color.',
|
||||
type: 'Different calculation models.',
|
||||
fogDensity: 'The larger the value, the more foggy it looks.',
|
||||
fogStart: 'Fog will start with this value (world space unit). Increase this value if you want more clarity nearby.',
|
||||
fogEnd: 'Further than this value (world space unit), will receive maximum fog effect.',
|
||||
fogAtten: 'The smaller the value, the more foggy it looks.',
|
||||
fogTop: 'Objects above this height value (world space unit) are not affected by fog.',
|
||||
fogRange: 'Fog extends down this range value (world space unit) from the top point.',
|
||||
},
|
||||
shadow: {
|
||||
enabled: 'Enable or disable real time shadows.',
|
||||
normal: 'The normal of the plane which receives shadow.',
|
||||
distance: 'The distance from coordinate origin to the receiving plane.',
|
||||
saturation: 'Shadow saturation. This value should be 1.0, we recommend that you\'d rather increase ambient lighting than modify this value. ',
|
||||
pcf: 'Enable soft shadows.',
|
||||
bias: 'Bias value (world space unit) that can avoid moire artifacts with shadows. The more the value, the more the light leakage.',
|
||||
normalBias: 'Bias value (world space unit) that can avoid moire artifacts with surfaces that parallel to the directional light.',
|
||||
shadowMapSize: 'Shadowmap resolutions.',
|
||||
fixedArea: 'Toggle CSM and fixed area shadows. When checking, shadow will not follow camera, it distributes around directional light position. It is a legacy mode that we do not recommend.',
|
||||
near: 'Fix area start.',
|
||||
far: 'Fix area end.',
|
||||
orthoSize: 'Fix area size, the larger value, the lower precision of shadows.',
|
||||
invisibleOcclusionRange: 'If some shadow near the camera is missing, increase this value (world space unit) to fix it.',
|
||||
shadowDistance: 'Shadows do not appear beyond this distance (world space unit).',
|
||||
},
|
||||
animation: {
|
||||
default_clip: 'When checking, the deault animation clip is automatically played.',
|
||||
default_clip: 'When checking, the default animation clip is automatically played.',
|
||||
clips: 'You can access and play animation clips via a script',
|
||||
play_on_load: 'Automatically play animation clip with the scene is loaded',
|
||||
use_baked_animation:
|
||||
@@ -900,4 +945,10 @@ module.exports = {
|
||||
localTorque: 'The torque applied to the rigid body in the local coordinate system',
|
||||
},
|
||||
},
|
||||
octree_culling: {
|
||||
enabled: 'The switch of octree culling, only available for native platforms.',
|
||||
minPos: 'The minimum position of the world bounding box.',
|
||||
maxPos: 'The maximum position of the world bounding box.',
|
||||
depth: 'The depth of octree.',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -21,6 +21,10 @@ module.exports = {
|
||||
Canvas: `${url}/${version}/manual/zh/ui-system/components/editor/canvas.html`,
|
||||
SkinnedMeshRenderer: `${url}/${version}/manual/zh/engine/animation/skeletal-animation.html`,
|
||||
SkinnedMeshBatchRenderer: `${url}/${version}/manual/zh/engine/animation/skeletal-animation.html`,
|
||||
Ambient: `${url}/${version}/manual/zh/concepts/scene/light/lighttype/ambient.html`,
|
||||
Skybox: `${url}/${version}/manual/zh/concepts/scene/skybox.html`,
|
||||
Fog: `${url}/${version}/manual/zh/concepts/scene/fog.html`,
|
||||
Shadow: `${url}/${version}/manual/zh/concepts/scene/light/shadow.html`,
|
||||
DirectionalLight: `${url}/${version}/manual/zh/concepts/scene/light/dir-light.html`,
|
||||
SphereLight: `${url}/${version}/manual/zh/concepts/scene/light/sphere-light.html`,
|
||||
SpotLight: `${url}/${version}/manual/zh/concepts/scene/light/spot-light.html`,
|
||||
@@ -64,8 +68,49 @@ module.exports = {
|
||||
Terrain: `${url}/${version}/manual/zh/editor/terrain/`,
|
||||
TiledMap: ``,
|
||||
Spine: ``,
|
||||
OctreeCulling: `${url}/${version}/manual/zh/advanced-topics/native-scene-culling.html`,
|
||||
},
|
||||
},
|
||||
ambient: {
|
||||
skyLightingColor: '天空颜色(上半球光照)',
|
||||
groundLightingColor: '地面颜色(下半球光照)',
|
||||
skyIllum: '环境光强度',
|
||||
},
|
||||
skybox: {
|
||||
applyDiffuseMap: '勾选后,场景物体将使用更精确的漫反射图来取代默认的半球光照。',
|
||||
enabled: '勾选后即可开启天空盒,使用设置的立方体贴图进行渲染',
|
||||
useIBL: '勾选后,场景物体将使用设置的立方体贴图来进行环境光漫反射及镜面反射计算.',
|
||||
useHDR: '切换高/低动态范围模式,每种模式都有自己独立的光源设定。\n高动态(HDR)模式会使用光度学灯光单位,配合相机镜头属性进行曝光计算,\n低动态(LDR)模式使用无单位光源和无曝光的镜头,更便于保留原图颜色',
|
||||
envmap: '设置一个立方体贴图作为环境光源和天空盒,贴图类型包括十字型 HDR 贴图、经纬度图、手动创建的 CubeMap 等。目前支持 HDR/TGA/PNG 等文件格式。',
|
||||
},
|
||||
fog: {
|
||||
enabled: '雾开关',
|
||||
accurate: '切换顶点雾和像素雾。勾选该项则使用像素雾,像素雾在顶点数少面积大的物体上有更精确的雾化效果;顶点雾则有更好的性能。',
|
||||
fogColor: '内散射颜色',
|
||||
type: '不同的计算雾化模型,目前包括 LINEAR(线性雾)、EXP(指数雾)、EXP_SQUARED(指数平房雾)、LAYERED(层雾)。',
|
||||
fogDensity: '该值越大雾气越浓',
|
||||
fogStart: '雾效影响的起始位置',
|
||||
fogEnd: '雾效影响的结束位置',
|
||||
fogAtten: '雾化衰减系数,该值越小则雾越浓',
|
||||
fogTop: '模型顶点在世界坐标系垂直方向上的位置,小于该位置时所有的顶点都会受到雾化效果的影响',
|
||||
fogRange: '雾化效果从设置的 fogTop 往下所影响的范围',
|
||||
},
|
||||
shadow: {
|
||||
enabled: '是否开启实时阴影',
|
||||
normal: '阴影接收平面的法线,垂直于阴影,用于调整阴影的倾斜度',
|
||||
distance: '阴影接收平面与原点的距离',
|
||||
saturation: '阴影饱和度,建议设置为 1.0。若需要减小方向光阴影的饱和程度,推荐通过增加环境光来实现,而不是调节该值。',
|
||||
pcf: '开启软阴影,目前支持 HARD(硬采样)、SOFT(4 倍采样)、SOFT_2X(9 倍采样)类型',
|
||||
bias: '增加深度偏移值(世界空间单位)可以有效消除阴影摩尔纹,但是过大的值可能造成漏光现象',
|
||||
normalBias: '法线深度偏移值(世界空间单位),可以消除物体表面朝向平行于阳光方向的阴影摩尔纹,防止曲面出现锯齿状;但是过大的值可能会造成阴影位置偏差',
|
||||
shadowMapSize: '阴影贴图分辨率,目前支持 Low_256x256、Medium_512x512、High_1024x1024、Ultra_2048x2048 四种精度的纹理',
|
||||
fixedArea: '切换固定区域和 CSM 模式。固定区域是一种旧模式,我们并不推荐使用。勾选该项则开启 CSM 模式,该模式下阴影会跟随方向光节点的位置,在方向光包围盒附近分布,而非跟随相机。',
|
||||
near: '固定区域开始值',
|
||||
far: '固定区域结束值',
|
||||
orthoSize: '固定区域大小,该值越大则阴影精度越低',
|
||||
invisibleOcclusionRange: '如果有背后的潜在投射物阴影丢失,请增大该值(世界空间单位)',
|
||||
shadowDistance: '阴影有效距离(世界空间单位),该值越大则阴影精度越低',
|
||||
},
|
||||
animation: {
|
||||
default_clip: '在勾选自动播放或调用 play() 时默认播放的动画 clip。',
|
||||
clips: '通过脚本可以访问并播放的 AnimationClip 列表',
|
||||
@@ -881,4 +926,10 @@ module.exports = {
|
||||
localTorque: '在本地坐标系中,对刚体施加的扭转力',
|
||||
},
|
||||
},
|
||||
octree_culling: {
|
||||
enabled: '八叉树剔除开关,仅在原生平台中生效',
|
||||
minPos: '世界包围盒最小顶点的坐标',
|
||||
maxPos: '世界包围盒最大顶点的坐标',
|
||||
depth: '八叉树深度',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -741,6 +741,8 @@ exports.methods = {
|
||||
fps,
|
||||
from,
|
||||
to,
|
||||
wrapMode: splitInfo.wrapMode,
|
||||
speed: splitInfo.speed || 1,
|
||||
};
|
||||
},
|
||||
getRightName(name) {
|
||||
|
||||
@@ -748,8 +748,8 @@ exports.methods = {
|
||||
'execute-model-preview-animation-operation',
|
||||
'setClipConfig',
|
||||
{
|
||||
wrapMode: clipInfo.userData.wrapMode,
|
||||
speed: clipInfo.userData.speed,
|
||||
wrapMode: clipInfo.wrapMode,
|
||||
speed: clipInfo.speed,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ exports.template = /* html*/`
|
||||
<!-- Render other data that has not taken over -->
|
||||
<div id="customProps">
|
||||
</div>
|
||||
<ui-section key="renderCulling" cache-expand="particle-system-cullingMode">
|
||||
<ui-section key="renderCulling" autoExpand cache-expand="particle-system-cullingMode">
|
||||
<ui-prop slot="header" class="header" empty="true" labelflag="renderCulling" key="renderCulling">
|
||||
<ui-label></ui-label>
|
||||
<ui-checkbox></ui-checkbox>
|
||||
@@ -308,13 +308,22 @@ const uiElements = {
|
||||
this.$.resetBounds.addEventListener('confirm', async () => {
|
||||
const nodeDumps = this.dump.value.node.values || [this.dump.value.node.value];
|
||||
const componentUUIDs = this.dump.value.uuid.values || [this.dump.value.uuid.value];
|
||||
await Promise.all(componentUUIDs.map(uuid =>
|
||||
Editor.Message.request('scene', 'execute-component-method', {
|
||||
uuid,
|
||||
name: '_calculateBounding',
|
||||
args: [true],
|
||||
}))
|
||||
);
|
||||
await Promise.all(componentUUIDs.map(uuid => {
|
||||
return new Promise((res) => {
|
||||
Editor.Message.request('scene', 'execute-component-method', {
|
||||
uuid,
|
||||
name: '_calculateBounding',
|
||||
args: [true],
|
||||
}).then(() => {
|
||||
Editor.Message.request('scene', 'execute-component-method', {
|
||||
uuid,
|
||||
name: 'gizmo.onNodeChanged',
|
||||
args: [],
|
||||
});
|
||||
res();
|
||||
});
|
||||
});
|
||||
}));
|
||||
nodeDumps.forEach(dump => {
|
||||
Editor.Message.broadcast('scene:change-node', dump.uuid);
|
||||
});
|
||||
@@ -328,6 +337,14 @@ const uiElements = {
|
||||
uiSections: {
|
||||
ready() {
|
||||
this.$.uiSections = this.$this.shadowRoot.querySelectorAll('ui-section');
|
||||
this.$.uiSections.forEach((element) => {
|
||||
// expand when checkbox enable
|
||||
if (element.hasAttribute('autoExpand')) {
|
||||
element.addEventListener('checkbox-enable', () => {
|
||||
element.setAttribute('expand', 'expand');
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
update() {
|
||||
this.$.uiSections.forEach((element) => {
|
||||
@@ -472,6 +489,9 @@ const uiElements = {
|
||||
});
|
||||
if (isEmpty) {
|
||||
if (isHeader) {
|
||||
/**
|
||||
* @type {HTMLInputElement}
|
||||
*/
|
||||
const checkbox = element.querySelector('ui-checkbox');
|
||||
if (checkbox) {
|
||||
checkbox.addEventListener('change', (event) => {
|
||||
@@ -482,6 +502,11 @@ const uiElements = {
|
||||
}
|
||||
dump.value = value;
|
||||
element.dispatch('change-dump');
|
||||
if (value) {
|
||||
// bubbles the event when value is true
|
||||
const event = new Event('checkbox-enable', { bubbles: true, cancelable: true });
|
||||
checkbox.dispatchEvent(event);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1186,13 +1186,18 @@ const computed = {
|
||||
},
|
||||
};
|
||||
exports.ready = function() {
|
||||
let requestAnimationFrameId = null;
|
||||
this.resizeObserver = new window.ResizeObserver(() => {
|
||||
const rect = this.$this.getBoundingClientRect();
|
||||
if (rect.width > 300) {
|
||||
this.layout = 'horizontal';
|
||||
} else {
|
||||
this.layout = 'vertical';
|
||||
}
|
||||
if (requestAnimationFrameId !== null) { return; }
|
||||
requestAnimationFrameId = window.requestAnimationFrame(() => {
|
||||
const rect = this.$this.getBoundingClientRect();
|
||||
if (rect.width > 300) {
|
||||
this.layout = 'horizontal';
|
||||
} else {
|
||||
this.layout = 'vertical';
|
||||
}
|
||||
requestAnimationFrameId = null;
|
||||
});
|
||||
});
|
||||
|
||||
this.resizeObserver.observe(this.$this);
|
||||
|
||||
@@ -794,7 +794,7 @@ const cacheManager = require('./jsb-cache-manager');
|
||||
middleware.resetIndicesStart = false;
|
||||
}
|
||||
|
||||
ui.commitPlainComp(this, realTexture, this._assembler, null);
|
||||
ui.commitComp(this, realTexture, this._assembler, null);
|
||||
this.material = mat;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -886,7 +886,7 @@ const cacheManager = require('./jsb-cache-manager');
|
||||
middleware.resetIndicesStart = false;
|
||||
}
|
||||
|
||||
ui.commitPlainComp(this, realTexture, this._assembler, null);
|
||||
ui.commitComp(this, realTexture, this._assembler, null);
|
||||
this.material = mat;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Node, RealKeyframeValue, Vec3 } from '../../cocos/core';
|
||||
import { ColorTrack, RealTrack, SizeTrack, TrackPath, VectorTrack } from '../../cocos/core/animation/animation';
|
||||
import { Color, Component, Node, Quat, RealKeyframeValue, Size, Vec3 } from '../../cocos/core';
|
||||
import { ColorTrack, ObjectTrack, QuatTrack, RealTrack, SizeTrack, TrackPath, VectorTrack } from '../../cocos/core/animation/animation';
|
||||
import { AnimationClip, searchForRootBonePathSymbol } from '../../cocos/core/animation/animation-clip';
|
||||
import { TargetPath } from '../../cocos/core/animation/target-path';
|
||||
|
||||
@@ -122,6 +122,35 @@ describe('Animation Clip', () => {
|
||||
expect(Vec3.equals(dummyRootJointNode.position, new Vec3(1.4))).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
test('Empty track does not take effect', () => {
|
||||
const trackAndInitValues = [
|
||||
[new RealTrack(), 6.6, (a: number, b: number) => a === b],
|
||||
[new ObjectTrack(), true, (a: boolean, b: boolean) => a === b],
|
||||
[new VectorTrack(), new Vec3(6.6, 6.6, 6.6), Vec3.equals],
|
||||
[new ColorTrack(), new Color(66, 66, 66, 66), Color.equals],
|
||||
[new SizeTrack(), new Size(6.6, 6.6), (a: Size, b: Size) => a.equals(b)],
|
||||
[new QuatTrack(), new Quat(6.6, 6.6, 6.6, 6.6), Quat.equals],
|
||||
] as const;
|
||||
|
||||
class TestComp extends Component {
|
||||
public properties: unknown[] = [];
|
||||
}
|
||||
|
||||
const node = new Node();
|
||||
const component = node.addComponent(TestComp) as TestComp;
|
||||
const clip = new AnimationClip();
|
||||
trackAndInitValues.forEach(([track, value], index) => {
|
||||
component.properties.push(value);
|
||||
track.path.toComponent(TestComp).toProperty('properties').toElement(index);
|
||||
});
|
||||
const evaluator = clip.createEvaluator({ target: node });
|
||||
evaluator.evaluate(0.0);
|
||||
trackAndInitValues.forEach(([, value, equals], index) => {
|
||||
expect((equals as (a: unknown, b: unknown) => boolean)(
|
||||
component.properties[index], value)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe(`Tracks`, () => {
|
||||
|
||||
@@ -160,29 +160,15 @@ describe('Custom track setter', () => {
|
||||
expect(mockSetValue).toBeCalled();
|
||||
});
|
||||
|
||||
test('get() got called if any of channels is empty', () => {
|
||||
const target = new Target();
|
||||
const mockGetValue = target.getValue = jest.fn(target.getValue);
|
||||
const mockSetValue = target.setValue = jest.fn(target.setValue);
|
||||
|
||||
const track = new VectorTrack();
|
||||
track.proxy = valueProxyWithGetSet;
|
||||
const clip = new AnimationClip();
|
||||
clip.addTrack(track);
|
||||
const clipEval = clip.createEvaluator({
|
||||
target,
|
||||
});
|
||||
clipEval.evaluate(0.0);
|
||||
expect(mockGetValue).toBeCalled();
|
||||
expect(mockSetValue).toBeCalled();
|
||||
});
|
||||
|
||||
test('If get() is not defined, the default channel value would be used', () => {
|
||||
const target = new Target();
|
||||
const mockSetValue = target.setValue = jest.fn(target.setValue);
|
||||
|
||||
const track = new VectorTrack();
|
||||
track.proxy = valueProxyWithOnlySet;
|
||||
track.channels().forEach(({ curve }) => {
|
||||
curve.assignSorted([[0.0, ({ value: 2.0 })]]);
|
||||
});
|
||||
const clip = new AnimationClip();
|
||||
clip.addTrack(track);
|
||||
const clipEval = clip.createEvaluator({
|
||||
|
||||
@@ -90,24 +90,26 @@ describe('NewGen Anim', () => {
|
||||
});
|
||||
|
||||
describe('Asset transition API', () => {
|
||||
const graph = new AnimationGraph();
|
||||
const layer = graph.addLayer();
|
||||
const layerGraph = layer.stateMachine;
|
||||
const n1 = layerGraph.addMotion();
|
||||
const n2 = layerGraph.addMotion();
|
||||
const trans1 = layerGraph.connect(n1, n2);
|
||||
expect([...layerGraph.getOutgoings(n1)].map((t) => t.to)).toContain(n2);
|
||||
expect([...layerGraph.getIncomings(n2)].map((t) => t.from)).toContain(n1);
|
||||
|
||||
// There may be multiple transitions between two nodes.
|
||||
const trans2 = layerGraph.connect(n1, n2);
|
||||
expect(trans2).not.toBe(trans1);
|
||||
expect([...layerGraph.getTransition(n1, n2)]).toEqual(expect.arrayContaining([trans1, trans2]));
|
||||
|
||||
// Self transitions are also allowed.
|
||||
const n3 = layerGraph.addMotion();
|
||||
const selfTransition = layerGraph.connect(n3, n3);
|
||||
expect([...layerGraph.getTransition(n3, n3)]).toMatchObject([selfTransition]);
|
||||
test('Connect', () => {
|
||||
const graph = new AnimationGraph();
|
||||
const layer = graph.addLayer();
|
||||
const layerGraph = layer.stateMachine;
|
||||
const n1 = layerGraph.addMotion();
|
||||
const n2 = layerGraph.addMotion();
|
||||
const trans1 = layerGraph.connect(n1, n2);
|
||||
expect([...layerGraph.getOutgoings(n1)].map((t) => t.to)).toContain(n2);
|
||||
expect([...layerGraph.getIncomings(n2)].map((t) => t.from)).toContain(n1);
|
||||
|
||||
// There may be multiple transitions between two nodes.
|
||||
const trans2 = layerGraph.connect(n1, n2);
|
||||
expect(trans2).not.toBe(trans1);
|
||||
expect([...layerGraph.getTransitionsBetween(n1, n2)]).toEqual(expect.arrayContaining([trans1, trans2]));
|
||||
|
||||
// Self transitions are also allowed.
|
||||
const n3 = layerGraph.addMotion();
|
||||
const selfTransition = layerGraph.connect(n3, n3);
|
||||
expect([...layerGraph.getTransitionsBetween(n3, n3)]).toMatchObject([selfTransition]);
|
||||
});
|
||||
|
||||
test('Remove transition by transition object', () => {
|
||||
const graph = new AnimationGraph();
|
||||
@@ -125,7 +127,7 @@ describe('NewGen Anim', () => {
|
||||
|
||||
layerGraph.removeTransition(trans2);
|
||||
{
|
||||
const transitions = Array.from(layerGraph.getTransition(n1, n2));
|
||||
const transitions = Array.from(layerGraph.getTransitionsBetween(n1, n2));
|
||||
expect(transitions).toHaveLength(2);
|
||||
expect(transitions[0]).toBe(trans1);
|
||||
expect(transitions[1]).toBe(trans3);
|
||||
@@ -133,17 +135,47 @@ describe('NewGen Anim', () => {
|
||||
|
||||
layerGraph.removeTransition(trans1);
|
||||
{
|
||||
const transitions = Array.from(layerGraph.getTransition(n1, n2));
|
||||
const transitions = Array.from(layerGraph.getTransitionsBetween(n1, n2));
|
||||
expect(transitions).toHaveLength(1);
|
||||
expect(transitions[0]).toBe(trans3);
|
||||
}
|
||||
|
||||
layerGraph.removeTransition(trans3);
|
||||
{
|
||||
const transitions = Array.from(layerGraph.getTransition(n1, n2));
|
||||
const transitions = Array.from(layerGraph.getTransitionsBetween(n1, n2));
|
||||
expect(transitions).toHaveLength(0);
|
||||
}
|
||||
});
|
||||
|
||||
test('disconnect()', () => {
|
||||
const graph = new AnimationGraph();
|
||||
const layer = graph.addLayer();
|
||||
const layerGraph = layer.stateMachine;
|
||||
const n1 = layerGraph.addMotion();
|
||||
const n2 = layerGraph.addMotion();
|
||||
const n3 = layerGraph.addMotion();
|
||||
const n4 = layerGraph.addMotion();
|
||||
|
||||
layerGraph.connect(n1, n1);
|
||||
layerGraph.disconnect(n1, n1);
|
||||
expect(Array.from(layerGraph.getTransitionsBetween(n1, n1))).toBeArrayOfSize(0);
|
||||
layerGraph.connect(n1, n1);
|
||||
layerGraph.connect(n1, n1);
|
||||
layerGraph.disconnect(n1, n1);
|
||||
expect(Array.from(layerGraph.getTransitionsBetween(n1, n1))).toBeArrayOfSize(0);
|
||||
|
||||
layerGraph.connect(n1, n2);
|
||||
layerGraph.disconnect(n1, n2);
|
||||
expect(Array.from(layerGraph.getTransitionsBetween(n1, n2))).toBeArrayOfSize(0);
|
||||
|
||||
layerGraph.connect(n1, n3);
|
||||
layerGraph.connect(n1, n3);
|
||||
layerGraph.connect(n1, n3);
|
||||
layerGraph.disconnect(n1, n3);
|
||||
expect(Array.from(layerGraph.getTransitionsBetween(n1, n3))).toBeArrayOfSize(0);
|
||||
|
||||
layerGraph.disconnect(n1, n4);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Transitions', () => {
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
import { SpriteFrame } from "../../cocos/2d/assets/sprite-frame";
|
||||
import { Sprite } from "../../cocos/2d/components/sprite";
|
||||
import { Batcher2D } from "../../cocos/2d/renderer/batcher-2d";
|
||||
import { assetManager, loader } from "../../cocos/core/asset-manager";
|
||||
import releaseManager from "../../cocos/core/asset-manager/release-manager";
|
||||
import { Texture2D } from "../../cocos/core/assets/texture-2d";
|
||||
import { isValid } from "../../cocos/core/data/object";
|
||||
import { director } from "../../cocos/core/director";
|
||||
import { Scene, Node } from "../../cocos/core/scene-graph";
|
||||
|
||||
director.root!._batcher = new Batcher2D(director.root);
|
||||
|
||||
describe('releaseManager', () => {
|
||||
|
||||
const libPath = './tests/fixtures/library';
|
||||
const libPath = './tests/fixtures/library';
|
||||
assetManager.init({importBase: libPath, nativeBase: libPath});
|
||||
|
||||
test('reference', function () {
|
||||
@@ -186,7 +182,7 @@ describe('releaseManager', () => {
|
||||
assetManager.dependUtil._depends.add('DDD', {deps: ['AAA']});
|
||||
// @ts-ignore
|
||||
releaseManager._free(texA);
|
||||
|
||||
|
||||
expect(assetManager.assets.count).toBe(0);
|
||||
assetManager.releaseAll();
|
||||
});
|
||||
|
||||
+1
-127
@@ -1,11 +1,8 @@
|
||||
import { Node, Scene } from "../../cocos/core/scene-graph"
|
||||
import { Vec3 } from "../../cocos/core/math"
|
||||
import { CCObject, director, game } from "../../cocos/core";
|
||||
import { director } from "../../cocos/core";
|
||||
import { NodeEventType } from "../../cocos/core/scene-graph/node-event";
|
||||
import { NodeUIProperties } from "../../cocos/core/scene-graph/node-ui-properties";
|
||||
import { Batcher2D } from "../../cocos/2d/renderer/batcher-2d";
|
||||
|
||||
director.root!._batcher = new Batcher2D(director.root);
|
||||
|
||||
describe(`Node`, () => {
|
||||
test('mark-opacity-tree',() => {
|
||||
@@ -138,127 +135,4 @@ describe(`Node`, () => {
|
||||
node.active = true;
|
||||
expect(node.active).toBe(true);
|
||||
});
|
||||
|
||||
test('hierarchy-changed', () => {
|
||||
const scene = new Scene('');
|
||||
director.runSceneImmediate(scene);
|
||||
const node = new Node();
|
||||
const childNode = new Node();
|
||||
node.addChild(childNode);
|
||||
expect(node.hasChildTreeUpdated()).toBeTruthy();
|
||||
|
||||
game.step();
|
||||
expect(node.hasChildTreeUpdated()).toBeFalsy();
|
||||
|
||||
// scene -|
|
||||
// |-node-|
|
||||
// |-childNode
|
||||
// insert node, scene will be notify
|
||||
scene.addChild(node);
|
||||
expect(node.hasChildTreeUpdated()).toBeFalsy();
|
||||
expect(childNode.hasChildTreeUpdated()).toBeFalsy();
|
||||
expect(scene.hasChildTreeUpdated()).toBeTruthy();
|
||||
|
||||
game.step();
|
||||
|
||||
const node1 = new Node();
|
||||
// scene -|
|
||||
// |- node -|
|
||||
// |-childNode
|
||||
// |- node1
|
||||
// insert node1, scene will be notify
|
||||
scene.addChild(node1);
|
||||
expect(node1.hasChildTreeUpdated()).toBeFalsy();
|
||||
expect(node.hasChildTreeUpdated()).toBeFalsy();
|
||||
expect(scene.hasChildTreeUpdated()).toBeTruthy();
|
||||
|
||||
game.step();
|
||||
|
||||
// scene -|
|
||||
// |- node1
|
||||
// |- node -|
|
||||
// |-childNode
|
||||
// change node sibling index, scene will be notify
|
||||
node.setSiblingIndex(1);
|
||||
expect(node1.hasChildTreeUpdated()).toBeFalsy();
|
||||
expect(node.hasChildTreeUpdated()).toBeFalsy();
|
||||
expect(scene.hasChildTreeUpdated()).toBeTruthy();
|
||||
|
||||
game.step();
|
||||
|
||||
const childNode2 = new Node();
|
||||
// scene -|
|
||||
// |- node1
|
||||
// |- node -|
|
||||
// |-childNode
|
||||
// |-childNode2
|
||||
// insert childNode2, node and scene will be notify
|
||||
node.addChild(childNode2);
|
||||
expect(node.hasChildTreeUpdated()).toBeTruthy();
|
||||
expect(node1.hasChildTreeUpdated()).toBeFalsy();
|
||||
expect(scene.hasChildTreeUpdated()).toBeTruthy();
|
||||
|
||||
game.step();
|
||||
|
||||
// scene -|
|
||||
// |- node1
|
||||
// |- node -|
|
||||
// |-childNode2
|
||||
// |-childNode
|
||||
// change childNode2 sibling, node and scene will be notify
|
||||
childNode2.setSiblingIndex(0);
|
||||
expect(node.hasChildTreeUpdated()).toBeTruthy();
|
||||
expect(node1.hasChildTreeUpdated()).toBeFalsy();
|
||||
expect(scene.hasChildTreeUpdated()).toBeTruthy();
|
||||
expect(childNode2.hasChildTreeUpdated()).toBeFalsy();
|
||||
expect(childNode.hasChildTreeUpdated()).toBeFalsy();
|
||||
|
||||
game.step();
|
||||
|
||||
const childNode3 = new Node();
|
||||
// scene -|
|
||||
// |- node1
|
||||
// |- node -|
|
||||
// |-childNode2
|
||||
// |-childNode
|
||||
// |-childNode3
|
||||
// insert childNode3, node and scene will be notify
|
||||
node.addChild(childNode3);
|
||||
expect(node.hasChildTreeUpdated()).toBeTruthy();
|
||||
expect(node1.hasChildTreeUpdated()).toBeFalsy();
|
||||
expect(scene.hasChildTreeUpdated()).toBeTruthy();
|
||||
expect(childNode2.hasChildTreeUpdated()).toBeFalsy();
|
||||
expect(childNode.hasChildTreeUpdated()).toBeFalsy();
|
||||
expect(childNode3.hasChildTreeUpdated()).toBeFalsy();
|
||||
|
||||
game.step();
|
||||
|
||||
// scene -|
|
||||
// |- node1
|
||||
// |- node -|
|
||||
// |-childNode2
|
||||
// |-childNode
|
||||
// remove childNode3, node and scene will be notify
|
||||
childNode3.removeFromParent();
|
||||
expect(node.hasChildTreeUpdated()).toBeTruthy();
|
||||
expect(node1.hasChildTreeUpdated()).toBeFalsy();
|
||||
expect(scene.hasChildTreeUpdated()).toBeTruthy();
|
||||
expect(childNode2.hasChildTreeUpdated()).toBeFalsy();
|
||||
expect(childNode.hasChildTreeUpdated()).toBeFalsy();
|
||||
expect(childNode3.hasChildTreeUpdated()).toBeFalsy();
|
||||
|
||||
game.step();
|
||||
|
||||
// scene -|
|
||||
// |- node1
|
||||
// |- node -|
|
||||
// |-childNode
|
||||
// destroy childNode2, node and scene will be notify
|
||||
childNode2.destroy();
|
||||
CCObject._deferredDestroy();
|
||||
expect(node.hasChildTreeUpdated()).toBeTruthy();
|
||||
expect(node1.hasChildTreeUpdated()).toBeFalsy();
|
||||
expect(scene.hasChildTreeUpdated()).toBeTruthy();
|
||||
expect(childNode.hasChildTreeUpdated()).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user