Merge pull request #11256 from minggo/v3.6.0-merge-v3.5.1

V3.6.0 merge v3.5.1
This commit is contained in:
minggo
2022-05-30 11:48:34 +08:00
committed by GitHub
76 changed files with 886 additions and 354 deletions
+24 -13
View File
@@ -183,19 +183,24 @@ export class HtmlTextParser {
// skip the invalid tags at first
attribute = attribute.substring(attribute.indexOf(header[0]));
tagName = attribute.substr(0, header[0].length);
// remove space and = character
remainingArgument = attribute.substring(tagName.length).trim();
rightQuot = this.getRightQuotationIndex(remainingArgument);
nextSpace = remainingArgument.indexOf(' ', rightQuot + 1 >= remainingArgument.length ? -1 : rightQuot + 1);
tagValue = (nextSpace > -1) ? remainingArgument.substr(0, nextSpace) : remainingArgument;
const originTagNameLength = tagName.length;
tagName = tagName.replace(/[^a-zA-Z]/g, '').trim();
tagName = tagName.toLowerCase();
// remove space and = character
remainingArgument = attribute.substring(originTagNameLength).trim();
if (tagName === 'src') {
rightQuot = this.getRightQuotationIndex(remainingArgument);
} else {
rightQuot = -1;
}
nextSpace = remainingArgument.indexOf(' ', rightQuot + 1 >= remainingArgument.length ? -1 : rightQuot + 1);
tagValue = (nextSpace > -1) ? remainingArgument.substr(0, nextSpace) : remainingArgument;
attribute = remainingArgument.substring(nextSpace).trim();
if (tagValue.endsWith('/')) tagValue = tagValue.slice(0, -1);
if (tagValue.endsWith('/')) {
tagValue = tagValue.slice(0, -1);
}
if (tagName === 'src') {
switch (tagValue.charCodeAt(0)) {
case 34: // "
@@ -312,15 +317,21 @@ export class HtmlTextParser {
return obj;
}
// find the right part of the first pair of following quotations.
private getRightQuotationIndex (remainingArgument: string) {
let leftQuot = -1;
let rightQuot = -1;
// Skip a pair of quotations for avoiding spaces in image name are detected.
leftQuot = remainingArgument.indexOf('\'');
if (leftQuot > -1) {
const leftSingleQuot = remainingArgument.indexOf('\'');
const leftDoubleQuot = remainingArgument.indexOf('"');
const useSingleQuot = leftSingleQuot > -1 && (leftSingleQuot < leftDoubleQuot || leftDoubleQuot === -1);
const useDoubleQuot = leftDoubleQuot > -1 && (leftDoubleQuot < leftSingleQuot || leftSingleQuot === -1);
if (useSingleQuot) {
leftQuot = leftSingleQuot;
rightQuot = remainingArgument.indexOf('\'', leftQuot + 1 >= remainingArgument.length ? -1 : leftQuot + 1);
} else {
leftQuot = remainingArgument.indexOf('"');
} else if (useDoubleQuot) {
leftQuot = leftDoubleQuot;
rightQuot = remainingArgument.indexOf('"', leftQuot + 1 >= remainingArgument.length ? -1 : leftQuot + 1);
}
@@ -81,7 +81,9 @@ class ClipMotionEval implements MotionEval {
if (weight === 0.0) {
return;
}
pushWeight(this._state.name, weight);
if (GRAPH_DEBUG_ENABLED) {
pushWeight(this._state.name, weight);
}
const time = this._state.duration * progress;
this._state.time = time;
this._state.weight = weight;
+7 -1
View File
@@ -121,6 +121,8 @@ export class RenderingSubMesh {
private _iaInfo: InputAssemblerInfo;
private _isOwnerOfIndexBuffer = true;
private _drawInfo?: DrawInfo | null = null;
/**
@@ -137,6 +139,7 @@ export class RenderingSubMesh {
constructor (
vertexBuffers: Buffer[], attributes: Attribute[], primitiveMode: PrimitiveMode,
indexBuffer: Buffer | null = null, indirectBuffer: Buffer | null = null,
isOwnerOfIndexBuffer = true,
) {
this._attributes = attributes;
this._vertexBuffers = vertexBuffers;
@@ -144,6 +147,7 @@ export class RenderingSubMesh {
this._indirectBuffer = indirectBuffer;
this._primitiveMode = primitiveMode;
this._iaInfo = new InputAssemblerInfo(attributes, vertexBuffers, indexBuffer, indirectBuffer);
this._isOwnerOfIndexBuffer = isOwnerOfIndexBuffer;
}
/**
@@ -357,7 +361,9 @@ export class RenderingSubMesh {
}
this.vertexBuffers.length = 0;
if (this._indexBuffer) {
this._indexBuffer.destroy();
if (this._isOwnerOfIndexBuffer) {
this._indexBuffer.destroy();
}
this._indexBuffer = null;
}
if (this._jointMappedBuffers && this._jointMappedBufferIndices) {
+104 -97
View File
@@ -47,9 +47,9 @@ import { scene } from '../renderer';
* ray-plane intersect detect.
* @zh
* 射线与平面的相交性检测。
* @param {Ray} ray 射线
* @param {Plane} plane 平面
* @return {number} 0 或 非0
* @param ray @zh 射线 @en The ray to test
* @param plane @zh 平面 @en The plane to test
* @return @zh 0 或 非0 @en 0 or not 0, 0 indicates there is no intersection
*/
const rayPlane = (function () {
const pt = new Vec3(0, 0, 0);
@@ -70,10 +70,10 @@ const rayPlane = (function () {
* ray-triangle intersect detect.
* @zh
* 射线与三角形的相交性检测。
* @param {Ray} ray 射线
* @param {Triangle} triangle 三角形
* @param {boolean} doubleSided 三角形是否为双面
* @return {number} 0 或 非0
* @param ray @zh 射线 @en The ray to test
* @param triangle @zh 三角形 @en The triangle to test
* @param doubleSided @zh 三角形是否为双面 @en Indicates whether it is double sided
* @return @zh 0 或 非0 @en 0 or not 0, 0 indicates there is no intersection
*/
const rayTriangle = (function () {
const ab = new Vec3(0, 0, 0);
@@ -110,9 +110,9 @@ const rayTriangle = (function () {
* ray-sphere intersect detect.
* @zh
* 射线和球的相交性检测。
* @param {Ray} ray 射线
* @param {Sphere} sphere 球
* @return {number} 0 或 非0
* @param ray @zh 射线 @en The ray to test
* @param sphere @zh 球 @en The sphere to test
* @return @zh 0 或 非0 @en 0 or not 0, 0 indicates there is no intersection
*/
const raySphere = (function () {
const e = new Vec3(0, 0, 0);
@@ -141,9 +141,9 @@ const raySphere = (function () {
* ray-aabb intersect detect.
* @zh
* 射线和轴对齐包围盒的相交性检测。
* @param {Ray} ray 射线
* @param {AABB} aabb 轴对齐包围盒
* @return {number} 0 或 非0
* @param ray @zh 射线 @en The ray to test
* @param aabb @zh 轴对齐包围盒 @en The aabb to test
* @return @zh 0 或 非0 @en 0 or not 0, 0 indicates there is no intersection
*/
const rayAABB = (function () {
const min = new Vec3();
@@ -175,9 +175,9 @@ function rayAABB2 (ray: Ray, min: IVec3Like, max: IVec3Like) {
* ray-obb intersect detect.
* @zh
* 射线和方向包围盒的相交性检测。
* @param {Ray} ray 射线
* @param {OBB} obb 方向包围盒
* @return {number} 0 或 非0
* @param ray @zh 射线 @en The ray
* @param obb @zh 方向包围盒 @en The obb to test
* @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection
*/
const rayOBB = (function () {
let center = new Vec3();
@@ -255,9 +255,9 @@ const rayOBB = (function () {
* ray-capsule intersect detect.
* @zh
* 射线和胶囊体的相交性检测。
* @param {Ray} ray 射线
* @param {Capsule} capsule 胶囊体
* @return {number} 0 或 非0
* @param ray @zh 射线 @en The ray to test
* @param capsule @zh 胶囊体 @en The capsule to test
* @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection
*/
const rayCapsule = (function () {
const v3_0 = new Vec3();
@@ -341,10 +341,10 @@ const rayCapsule = (function () {
* ray-subMesh intersect detect, in model space.
* @zh
* 在模型空间中,射线和子三角网格的相交性检测。
* @param {Ray} ray
* @param {RenderingSubMesh} subMesh
* @param {IRaySubMeshOptions} options
* @return {number} 0 or !0
* @param ray @zh 射线 @en The ray to test
* @param subMesh @zh 子网格 @en The sub mesh to test
* @param options @zh 额外选项 @en Optional params
* @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection
*/
const raySubMesh = (function () {
const tri = Triangle.create();
@@ -437,10 +437,10 @@ const raySubMesh = (function () {
* ray-mesh intersect detect, in model space.
* @zh
* 在模型空间中,射线和三角网格资源的相交性检测。
* @param {Ray} ray
* @param {Mesh} mesh
* @param {IRayMeshOptions} options
* @return {number} 0 or !0
* @param ray @zh 射线 @en The ray to test
* @param mesh @zh 网格 @en The mesh to test
* @param options @zh 可选参数 @en Optional param
* @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection
*/
const rayMesh = (function () {
let minDis = 0;
@@ -486,10 +486,10 @@ const rayMesh = (function () {
* ray-model intersect detect, in world space.
* @zh
* 在世界空间中,射线和渲染模型的相交性检测。
* @param ray
* @param model
* @param options
* @return 0 or !0
* @param ray @zh 射线 @en The ray to test
* @param model @zh model @en The model to test
* @param options @zh 可选参数 @en Optional param
* @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection
*/
const rayModel = (function () {
let minDis = 0;
@@ -542,9 +542,9 @@ const rayModel = (function () {
* line-plane intersect detect.
* @zh
* 线段与平面的相交性检测。
* @param {line} line 线段
* @param {Plane} plane 平面
* @return {number} 0 或 非0
* @param line @zh 线段 @en The line to test
* @param plane @zh 平面 @en The plane to test
* @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection
*/
const linePlane = (function () {
const ab = new Vec3(0, 0, 0);
@@ -562,10 +562,10 @@ const linePlane = (function () {
* line-triangle intersect detect.
* @zh
* 线段与三角形的相交性检测。
* @param {line} line 线段
* @param {Triangle} triangle 三角形
* @param {Vec3} outPt 可选,相交点
* @return {number} 0 或 非0
* @param line @zh 线段 @en The line to test
* @param triangle @zh 三角形 @en The triangle to test
* @param outPt @zh 可选,相交点 @en Optional out param, indicates the intersection point
* @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection
*/
const lineTriangle = (function () {
const ab = new Vec3(0, 0, 0);
@@ -627,9 +627,9 @@ const r_t = new Ray();
* line-aabb intersect detect.
* @zh
* 线段与轴对齐包围盒的相交性检测
* @param line 线段
* @param aabb 轴对齐包围盒
* @return {number} 0 或 非0
* @param line @zh 线段 @en The line to test
* @param aabb @zh 轴对齐包围盒 @en The aabb to test
* @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection
*/
function lineAABB (line: Line, aabb: AABB): number {
r_t.o.set(line.s);
@@ -649,9 +649,9 @@ function lineAABB (line: Line, aabb: AABB): number {
* line-obb intersect detect.
* @zh
* 线段与方向包围盒的相交性检测
* @param line 线段
* @param obb 方向包围盒
* @return {number} 0 或 非0
* @param line @zh 线段 @en The line to test
* @param obb @zh 方向包围盒 @en The obb
* @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection
*/
function lineOBB (line: Line, obb: OBB): number {
r_t.o.set(line.s);
@@ -671,9 +671,9 @@ function lineOBB (line: Line, obb: OBB): number {
* line-sphere intersect detect.
* @zh
* 线段与球的相交性检测
* @param line 线段
* @param sphere 球
* @return {number} 0 或 非0
* @param line @zh 线段 @en The line to test
* @param sphere @zh 球 @en The sphere to test
* @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection
*/
function lineSphere (line: Line, sphere: Sphere): number {
r_t.o.set(line.s);
@@ -693,9 +693,9 @@ function lineSphere (line: Line, sphere: Sphere): number {
* aabb-aabb intersect detect.
* @zh
* 轴对齐包围盒和轴对齐包围盒的相交性检测。
* @param {AABB} aabb1 轴对齐包围盒1
* @param {AABB} aabb2 轴对齐包围盒2
* @return {number} 0 或 非0
* @param aabb1 @zh 轴对齐包围盒1 @en aabb 1 to test
* @param aabb2 @zh 轴对齐包围盒2 @en aabb 2 to test
* @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection
*/
const aabbWithAABB = (function () {
const aMin = new Vec3();
@@ -774,9 +774,9 @@ function getInterval (vertices: any[] | Vec3[], axis: Vec3) {
* aabb-obb intersect detect.
* @zh
* 轴对齐包围盒和方向包围盒的相交性检测。
* @param {AABB} aabb 轴对齐包围盒
* @param {OBB} obb 方向包围盒
* @return {number} 0 或 非0
* @param aabb @zh 轴对齐包围盒 @en The aabb to test
* @param obb @zh 方向包围盒 @en The obb to test
* @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection
*/
const aabbWithOBB = (function () {
const test = new Array(15);
@@ -827,9 +827,9 @@ const aabbWithOBB = (function () {
* aabb-plane intersect detect.
* @zh
* 轴对齐包围盒和平面的相交性检测。
* @param {AABB} aabb 轴对齐包围盒
* @param {Plane} plane 平面
* @return {number} inside(back) = -1, outside(front) = 0, intersect = 1
* @param aabb @zh 轴对齐包围盒 @en The aabb to test
* @param plane @zh 平面 @en The plane to test
* @return @zh 检测结果, 包含为 -1, 不包含为 0, 相交为 1 @en Test result, inside(back) = -1, outside(front) = 0, intersect = 1
*/
const aabbPlane = function (aabb: AABB, plane: Plane): number {
const r = aabb.halfExtents.x * Math.abs(plane.n.x)
@@ -845,9 +845,9 @@ const aabbPlane = function (aabb: AABB, plane: Plane): number {
* aabb-frustum intersect detect, faster but has false positive corner cases.
* @zh
* 轴对齐包围盒和锥台相交性检测,速度快,但有错误情况。
* @param {AABB} aabb 轴对齐包围盒
* @param {Frustum} frustum 锥台
* @return {number} 0 或 非0
* @param aabb @zh 轴对齐包围盒 @en The aabb to test
* @param frustum @zh 锥台 @en The frustum to test
* @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection
*/
const aabbFrustum = function (aabb: AABB, frustum: Frustum): number {
for (let i = 0; i < frustum.planes.length; i++) {
@@ -865,9 +865,9 @@ const aabbFrustum = function (aabb: AABB, frustum: Frustum): number {
* aabb-frustum intersect, handles most of the false positives correctly.
* @zh
* 轴对齐包围盒和锥台相交性检测,正确处理大多数错误情况。
* @param {AABB} aabb 轴对齐包围盒
* @param {Frustum} frustum 锥台
* @return {number}
* @param aabb @zh 轴对齐包围盒 @en The aabb to test
* @param frustum @zh 锥台 @en The frustum to test
* @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection
*/
const aabbFrustumAccurate = (function () {
const tmp = new Array(8);
@@ -914,9 +914,9 @@ const aabbFrustumAccurate = (function () {
* obb contains the point.
* @zh
* 方向包围盒和点的相交性检测。
* @param {OBB} obb 方向包围盒
* @param {Vec3} point 点
* @return {boolean} true or false
* @param obb @zh 方向包围盒 @en The obb to test
* @param point @zh 点 @en The point to test
* @return @zh 布尔值 @en The value indicates if there is a intersection
*/
const obbPoint = (function () {
const tmp = new Vec3(0, 0, 0); const m3 = new Mat3();
@@ -933,9 +933,9 @@ const obbPoint = (function () {
* obb-plane intersect detect.
* @zh
* 方向包围盒和平面的相交性检测。
* @param {OBB} obb 方向包围盒
* @param {Plane} plane 平面
* @return {number} inside(back) = -1, outside(front) = 0, intersect = 1
* @param obb @zh 方向包围盒 @en The obb to test
* @param plane @zh 平面 @en The plane to test
* @return @zh 检测结果, 包含为 -1, 不包含为 0, 相交为 1 @en Test result, inside(back) = -1, outside(front) = 0, intersect = 1
*/
const obbPlane = (function () {
const absDot = function (n: Vec3, x: number, y: number, z: number) {
@@ -958,9 +958,9 @@ const obbPlane = (function () {
* obb-frustum intersect, faster but has false positive corner cases.
* @zh
* 方向包围盒和锥台相交性检测,速度快,但有错误情况。
* @param {OBB} obb 方向包围盒
* @param {Frustum} frustum 锥台
* @return {number} 0 或 非0
* @param obb @zh 方向包围盒 @en The obb to test
* @param frustum @zh 锥台 @en The frustum to test
* @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection
*/
const obbFrustum = function (obb: OBB, frustum: Frustum): number {
for (let i = 0; i < frustum.planes.length; i++) {
@@ -978,9 +978,9 @@ const obbFrustum = function (obb: OBB, frustum: Frustum): number {
* obb-frustum intersect, handles most of the false positives correctly.
* @zh
* 方向包围盒和锥台相交性检测,正确处理大多数错误情况。
* @param {OBB} obb 方向包围盒
* @param {Frustum} frustum 锥台
* @return {number} 0 或 非0
* @param obb @zh 方向包围盒 @en The obb to test
* @param frustum @zh 锥台 @en The frustum to test
* @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection
*/
const obbFrustumAccurate = (function () {
const tmp = new Array(8);
@@ -1033,9 +1033,9 @@ const obbFrustumAccurate = (function () {
* obb-obb intersect detect.
* @zh
* 方向包围盒和方向包围盒的相交性检测。
* @param {OBB} obb1 方向包围盒1
* @param {OBB} obb2 方向包围盒2
* @return {number} 0 或 非0
* @param obb1 @zh 方向包围盒1 @en Obb 1 to test
* @param obb2 @zh 方向包围盒2 @en Obb 2 to test
* @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection
*/
const obbWithOBB = (function () {
const test = new Array(15);
@@ -1085,8 +1085,9 @@ const obbWithOBB = (function () {
* obb-capsule intersect detect.
* @zh
* 方向包围盒和胶囊体的相交性检测。
* @param obb 方向包围盒
* @param capsule 胶囊体
* @param obb @zh 方向包围盒 @en The obb to test
* @param capsule @zh 胶囊体 @en The capsule to test
* @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection
*/
const obbCapsule = (function () {
const sphere_0 = new Sphere();
@@ -1150,9 +1151,9 @@ const obbCapsule = (function () {
* plane normal to factor out the unnomalized plane distance.
* @zh
* 球与平面的相交性检测。
* @param {Sphere} sphere 球
* @param {Plane} plane 平面
* @return {number} inside(back) = -1, outside(front) = 0, intersect = 1
* @param sphere @zh 球 @en The sphere to test
* @param plane @zh 平面 @en The plane to test
* @return @zh 检测结果, 包含为 -1, 不包含为 0, 相交为 1 @en Test result, inside(back) = -1, outside(front) = 0, intersect = 1
*/
const spherePlane = function (sphere: Sphere, plane: Plane): number {
const dot = Vec3.dot(plane.n, sphere.center);
@@ -1166,9 +1167,9 @@ const spherePlane = function (sphere: Sphere, plane: Plane): number {
* sphere-frustum intersect, faster but has false positive corner cases.
* @zh
* 球和锥台的相交性检测,速度快,但有错误情况。
* @param {Sphere} sphere 球
* @param {Frustum} frustum 锥台
* @return {number} 0 或 非0
* @param sphere @zh 球 @en The sphere to test
* @param frustum @zh 锥台 @en The frustum to test
* @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection
*/
const sphereFrustum = function (sphere: Sphere, frustum: Frustum): number {
for (let i = 0; i < frustum.planes.length; i++) {
@@ -1186,9 +1187,9 @@ const sphereFrustum = function (sphere: Sphere, frustum: Frustum): number {
* sphere-frustum intersect, handles the false positives correctly.
* @zh
* 球和锥台的相交性检测,正确处理大多数错误情况。
* @param {Sphere} sphere 球
* @param {Frustum} frustum 锥台
* @return {number} 0 或 非0
* @param sphere @zh 球 @en The sphere to test
* @param frustum @zh 锥台 @en The frustum to test
* @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection
*/
const sphereFrustumAccurate = (function () {
const pt = new Vec3(0, 0, 0); const map = [1, -1, 1, -1, 1, -1];
@@ -1219,9 +1220,9 @@ const sphereFrustumAccurate = (function () {
* sphere-sphere intersect detect.
* @zh
* 球和球的相交性检测。
* @param {Sphere} sphere0 球0
* @param {Sphere} sphere1 球1
* @return {boolean} true or false
* @param sphere0 @zh 球 0 @en The sphere A to test
* @param sphere1 @zh 球 1 @en The sphere B to test
* @return @zh 是否发生碰撞 @en true or false which indicates if there is a intersection
*/
const sphereWithSphere = function (sphere0: Sphere, sphere1: Sphere): boolean {
const r = sphere0.radius + sphere1.radius;
@@ -1233,9 +1234,9 @@ const sphereWithSphere = function (sphere0: Sphere, sphere1: Sphere): boolean {
* sphere-aabb intersect detect.
* @zh
* 球和轴对齐包围盒的相交性检测。
* @param {Sphere} sphere 球
* @param {AABB} aabb 轴对齐包围盒
* @return {boolean} true or false
* @param sphere @zh 球 @en The sphere to test
* @param aabb @zh 轴对齐包围盒 @en The aabb to test
* @return @zh 是否发生碰撞 @en true or false which indicates if there is a intersection
*/
const sphereAABB = (function () {
const pt = new Vec3();
@@ -1250,9 +1251,9 @@ const sphereAABB = (function () {
* sphere-obb intersect detect.
* @zh
* 球和方向包围盒的相交性检测。
* @param {Sphere} sphere 球
* @param {OBB} obb 方向包围盒
* @return {boolean} true or false
* @param sphere @zh 球 @en The sphere to test
* @param obb @zh 方向包围盒 @en The obb to test
* @return @zh 是否发生碰撞 @en true or false which indicates if there is a intersection
*/
const sphereOBB = (function () {
const pt = new Vec3();
@@ -1267,6 +1268,9 @@ const sphereOBB = (function () {
* sphere-capsule intersect detect.
* @zh
* 球和胶囊体的相交性检测。
* @param sphere @zh 球 @en The sphere to test
* @param capsule @zh 胶囊体 @en The capsule to test
* @return @zh 是否发生碰撞 @en true or false which indicates if there is a intersection
*/
const sphereCapsule = (function () {
const v3_0 = new Vec3();
@@ -1299,6 +1303,9 @@ const sphereCapsule = (function () {
* capsule-capsule intersect detect.
* @zh
* 胶囊体和胶囊体的相交性检测。
* @param capsuleA @zh 胶囊体 A @en The capsule A to test
* @param capsuleB @zh 胶囊体 B @en The capsule B to test
* @return @zh 是否发生碰撞 @en true or false which indicates if there is a intersection
*/
const capsuleWithCapsule = (function () {
const v3_0 = new Vec3();
@@ -89,6 +89,24 @@ function getLightPassIndices (subModels: SubModel[], lightPassIndices: number[])
return hasValidLightPass;
}
function isInstancedOrBatched (model: Model) {
const subModels = model.subModels;
for (let m = 0; m < subModels.length; ++m) {
const passes = subModels[m].passes;
for (let p = 0; p < passes.length; ++p) {
const pass = passes[p];
const batchingScheme = pass.batchingScheme;
if (batchingScheme === BatchingSchemes.INSTANCING) {
return true;
}
if (batchingScheme === BatchingSchemes.VB_MERGING) {
return true;
}
}
}
return false;
}
/**
* @zh 叠加光照队列。
*/
@@ -235,15 +253,16 @@ export class RenderAdditiveLightQueue {
// light culling
protected _lightCulling (model:Model, validPunctualLights: Light[]) {
let isCulled = false;
const isNeedCulling = !isInstancedOrBatched(model);
for (let l = 0; l < validPunctualLights.length; l++) {
const light = validPunctualLights[l];
let isCulled = false;
switch (light.type) {
case LightType.SPHERE:
isCulled = cullSphereLight(light as SphereLight, model);
if (isNeedCulling) { isCulled = cullSphereLight(light as SphereLight, model); }
break;
case LightType.SPOT:
isCulled = cullSpotLight(light as SpotLight, model);
if (isNeedCulling) { isCulled = cullSpotLight(light as SpotLight, model); }
break;
default:
}
@@ -454,7 +473,7 @@ export class RenderAdditiveLightQueue {
_vec4Array[0] = (light as SpotLight).size;
_vec4Array[1] = (light as SpotLight).range;
_vec4Array[2] = (light as SpotLight).spotAngle;
_vec4Array[3] = ((light as SpotLight).shadowEnabled && shadowInfo.type === ShadowType.ShadowMap) ? 1 : 0;
_vec4Array[3] = (shadowInfo.enabled && (light as SpotLight).shadowEnabled && shadowInfo.type === ShadowType.ShadowMap) ? 1 : 0;
this._lightBufferData.set(_vec4Array, offset + UBOForwardLight.LIGHT_SIZE_RANGE_ANGLE_OFFSET);
Vec3.toArray(_vec4Array, (light as SpotLight).direction);
+2 -1
View File
@@ -186,7 +186,8 @@ export function applyMountedChildren (node: Node, mountedChildren: MountedChildr
for (let i = 0; i < childInfo.nodes.length; i++) {
const childNode = childInfo.nodes[i];
if (!childNode) {
// @ts-expect-error private member access
if (!childNode || target._children.includes(childNode)) {
continue;
}
+1 -1
View File
@@ -100,7 +100,7 @@ export enum SystemEventType {
* @en
* The event type for mouse wheel events
*
* @zh 手指开始触摸事件
* @zh 当滚动鼠标滚轮或操作其它类似输入设备时会触发滚轮事件。
*/
MOUSE_WHEEL = 'mouse-wheel',
@@ -10,8 +10,10 @@ import { IPhysicsConfig, ICollisionMatrix } from '../../physics/framework/physic
import { CollisionMatrix } from '../../physics/framework/collision-matrix';
import { ERaycast2DType, RaycastResult2D, PHYSICS_2D_PTM_RATIO, PhysicsGroup } from './physics-types';
import { Collider2D } from './components/colliders/collider-2d';
import { legacyCC } from '../../core/global-exports';
let instance: PhysicsSystem2D | null = null;
legacyCC.internal.PhysicsGroup2D = PhysicsGroup;
export class PhysicsSystem2D extends Eventify(System) {
/**
+1 -1
View File
@@ -88,7 +88,7 @@ interface IBoxOptions extends RecursivePartial<IGeometryOptions> {
* but may be repositioned through the `center` option.
* @zh
* 生成一个立方体,其大小是定义的范围且中心在原点。
* @param options 参数选项。
* @param options @zh 参数选项。@en The optional creation parameters of the box
*/
export default function box (options?: IBoxOptions): IGeometry {
options = options || {};
+3 -3
View File
@@ -46,9 +46,9 @@ const temp2 = new Vec3(0, 0, 0);
* but may be repositioned through the `center` option.
* @zh
* 生成一个胶囊体。
* @param radiusTop 顶部半径。
* @param radiusBottom 底部半径。
* @param opts 胶囊体参数选项。
* @param radiusTop @zh 顶部半径。 @en The radius of top sphere
* @param radiusBottom @zh 底部半径。@en The radius of bottom sphere
* @param opts @zh 胶囊体参数选项。@en The optional creation parameters of the capsule
*/
export default function capsule (radiusTop = 0.5, radiusBottom = 0.5, height = 2, opts: RecursivePartial<ICapsuteOptions> = {}) {
const torsoHeight = height - radiusTop - radiusBottom;
+1 -1
View File
@@ -54,7 +54,7 @@ function applyDefaultCircleOptions (options?: RecursivePartial<ICircleOptions>):
* but may be repositioned through the `center` option.
* @zh
* 生成一个圆,其半径是单位1,中心点在原点。
* @param options 参数选项。
* @param options @zh 参数选项。 @en The optional creation parameters of the circle
*/
export default function circle (options?: RecursivePartial<ICircleOptions> | ICircleOptions): IGeometry {
const normalizedOptions = applyDefaultCircleOptions(options);
+3 -3
View File
@@ -34,9 +34,9 @@ type IConeOptions = ICylinderOptions;
* but may be repositioned through the `center` option.
* @zh
* 生成一个圆锥。
* @param radius 圆锥半径。
* @param height 圆锥高度。
* @param opts 圆锥参数选项。
* @param radius @zh 圆锥半径。 @en The radius of cone
* @param height @zh 圆锥高度。 @en The height of cone
* @param opts @zh 圆锥参数选项。@en The optional creation parameters of the cone
*/
export default function cone (
radius = 0.5,
+1 -1
View File
@@ -51,7 +51,7 @@ const temp2 = new Vec3(0, 0, 0);
* @param radiusTop @en Radius of top plane. @zh 顶部半径。
* @param radiusBottom @en Radius of bottom plane. @zh 底部半径。
* @param height @en The cylinder height. @zh 圆柱的高
* @param opts @en Options of cylinder. @zh 圆柱参数选项。
* @param opts @en The optional creation parameters of the cylinder. @zh 圆柱参数选项。
*/
export default function cylinder (radiusTop = 0.5, radiusBottom = 0.5, height = 2, opts: RecursivePartial<ICylinderOptions> = {}): IGeometry {
const halfHeight = height * 0.5;
+1 -1
View File
@@ -81,7 +81,7 @@ const c01 = new Vec3(0, 0, 0);
* This function generates a plane on XOZ plane with positive Y direction.
* @zh
* 生成一个平面,其位于XOZ平面,方向为Y轴正方向。
* @param options 平面参数选项。
* @param options @zh 平面参数选项。@en The optional creation parameters of the plane
*/
export default function plane (options?: IPlaneOptions): IGeometry {
const normalizedOptions = applyDefaultPlaneOptions(options);
+1 -1
View File
@@ -30,7 +30,7 @@ import { applyDefaultGeometryOptions, IGeometry, IGeometryOptions } from './defi
* Generate a quad with width and height both to 1, centered at origin.
* @zh
* 生成一个四边形,宽高都为1,中心在原点。
* @param options 参数选项。
* @param options @zh 参数选项。 @en The optional creation parameters of the quad
*/
export default function quad (options?: IGeometryOptions): IGeometry {
const normalizedOptions = applyDefaultGeometryOptions(options);
+6 -4
View File
@@ -29,6 +29,8 @@ import { IGeometryOptions } from './define';
/**
* @zh
* 环面参数选项。
* @en
* The options about torus
*/
interface ITorusOptions extends IGeometryOptions {
radialSegments: number;
@@ -38,12 +40,12 @@ interface ITorusOptions extends IGeometryOptions {
/**
* @en
* Generate a torus with raidus 0.4, tube 0.1 and centered at origin.
* Generate a torus with radius 0.4, tube 0.1 and centered at origin.
* @zh
* 生成一个环面。
* @param radius 环面半径。
* @param tube 管形大小。
* @param opts 参数选项。
* @param radius @zh 环面半径。@en The radius fo torus
* @param tube @zh 管形大小。@en The radius of tube
* @param opts @zh 参数选项。@en The optional creation parameters of the torus
*/
export default function torus (radius = 0.4, tube = 0.1, opts: RecursivePartial<ITorusOptions> = {}) {
const radialSegments = opts.radialSegments || 32;
+5 -5
View File
@@ -31,8 +31,8 @@ import { IGeometry } from './define';
* Translate the geometry.
* @zh
* 平移几何体。
* @param geometry 几何体信息。
* @param offset 偏移量。
* @param geometry @zh 几何体信息。@en The geometry to be translated
* @param offset @zh 偏移量。@en The translation
*/
export function translate (geometry: IGeometry, offset: { x?: number; y?: number; z?: number; }) {
const x = offset.x || 0;
@@ -65,8 +65,8 @@ export function translate (geometry: IGeometry, offset: { x?: number; y?: number
* Scale the geometry.
* @zh
* 缩放几何体。
* @param geometry 几何体信息。
* @param value 缩放量。
* @param geometry @zh 几何体信息。 @en The geometry to be scaled
* @param value @zh 缩放量。@en The scaling size
*/
export function scale (geometry: IGeometry, value: { x?: number; y?: number; z?: number }) {
const x = value.x || 0;
@@ -100,7 +100,7 @@ export function scale (geometry: IGeometry, value: { x?: number; y?: number; z?:
* Converts geometry to wireframe mode. Only geometry with triangle topology is supported.
* @zh
* 将几何体转换为线框模式,仅支持三角形拓扑的几何体。
* @param geometry 几何体信息。
* @param geometry @zh 几何体信息。@en The geometry to be converted to wireframe
*/
export function wireframed (geometry: IGeometry) {
const { indices } = geometry;
+3 -3
View File
@@ -393,7 +393,7 @@ export class TerrainBlock {
];
this._renderable._meshData = new RenderingSubMesh([vertexBuffer], gfxAttributes,
PrimitiveMode.TRIANGLE_LIST, this._terrain._createSharedIndexBuffer());
PrimitiveMode.TRIANGLE_LIST, this._terrain._getSharedIndexBuffer(), null, false);
this._renderable._model = (legacyCC.director.root as Root).createModel(scene.Model);
this._renderable._model.createBoundingShape(this._bbMin, this._bbMax);
this._renderable._model.node = this._renderable._model.transform = this._node;
@@ -691,8 +691,8 @@ export class TerrainBlock {
}
/**
* @en 地形块的可见性
* @zh block visible
* @zh 地形块的可见性
* @en The visibility of the block
*/
set visible (val) {
if (this._renderable._model !== null) {
+1 -1
View File
@@ -61,7 +61,7 @@ export interface ITweenOption {
/**
* @en
* Interpolation functin, you can pass in a custom function.
* Interpolation function, you can pass in a custom function.
* @zh
* 插值函数,参数的意义 start:起始值,end:目标值,current:当前值,ratio:当前进度
*/
+2 -2
View File
@@ -65,10 +65,10 @@ export class TweenSystem extends System {
/**
* @en
* The update will auto execute after all compnents update.
* The update will auto execute after all components update.
* @zh
* 此方法会在组件 update 之后自动执行。
* @param dt 间隔时间
* @param dt @en The delta time @zh 间隔时间
*/
update (dt: number) {
if (!EDITOR || legacyCC.GAME_VIEW || this._executeInEditMode) {
+31 -19
View File
@@ -47,7 +47,7 @@ type ConstructorType<T> = OmitType<T, Function>;
* @zh
* Tween 提供了一个简单灵活的方法来缓动目标,从 creator 移植而来。
* @class Tween
* @param {Object} [target]
* @param [target]
* @example
* tween(this.node)
* .to(1, {scale: new Vec3(2, 2, 2), position: new Vec3(5, 5, 5)})
@@ -68,6 +68,8 @@ export class Tween<T> {
/**
* @en Sets tween tag
* @zh 设置缓动的标签
* @method tag
* @param tag @en The tag set for this tween @zh 为当前缓动设置的标签
*/
tag (tag: number) {
this._tag = tag;
@@ -79,6 +81,8 @@ export class Tween<T> {
* Insert an action or tween to this sequence.
* @zh
* 插入一个 tween 到队列中。
* @method then
* @param other @en The rear tween of this tween @zh 当前缓动的后置缓动
*/
then (other: Tween<T>): Tween<T> {
if (other instanceof Action) {
@@ -94,6 +98,8 @@ export class Tween<T> {
* Sets tween target.
* @zh
* 设置 tween 的 target。
* @method target
* @param target @en The target of this tween @zh 当前缓动的目标对象
*/
target (target: T): Tween<T | undefined> {
this._target = target;
@@ -138,6 +144,8 @@ export class Tween<T> {
* Clone a tween.
* @zh
* 克隆当前 tween。
* @method clone
* @param target @en The target of clone tween @zh 克隆缓动的目标对象
*/
clone (target: T): Tween<T> {
const action = this._union();
@@ -163,11 +171,11 @@ export class Tween<T> {
* @zh
* 添加一个对属性进行绝对值计算的 action。
* @method to
* @param {number} duration 缓动时间,单位为秒
* @param {Object} props 缓动的属性列表
* @param {Object} [opts] 可选的缓动功能
* @param {Function} [opts.progress]
* @param {Function|String} [opts.easing]
* @param duration @en Tween time, in seconds @zh 缓动时间,单位为秒
* @param props @en List of properties of tween @zh 缓动的属性列表
* @param opts @en Optional functions of tween @zh 可选的缓动功能
* @param opts.progress @en Interpolation function @zh 缓动的速度插值函数
* @param opts.easing @en Tween function or a lambda @zh 缓动的曲线函数或lambda表达式
*/
to (duration: number, props: ConstructorType<T>, opts?: ITweenOption): Tween<T> {
opts = opts || Object.create(null);
@@ -183,11 +191,11 @@ export class Tween<T> {
* @zh
* 添加一个对属性进行相对值计算的 action。
* @method by
* @param {number} duration 缓动时间,单位为秒
* @param {Object} props 缓动的属性列表
* @param {Object} [opts] 可选的缓动功能
* @param {Function} [opts.progress]
* @param {Function|String} [opts.easing]
* @param duration @en Tween time, in seconds @zh 缓动时间,单位为秒
* @param props @en List of properties of tween @zh 缓动的属性列表
* @param opts @en Optional functions of tween @zh 可选的缓动功能
* @param [opts.progress]
* @param [opts.easing]
* @return {Tween}
*/
by (duration: number, props: ConstructorType<T>, opts?: ITweenOption): Tween<T> {
@@ -204,7 +212,7 @@ export class Tween<T> {
* @zh
* 直接设置 target 的属性。
* @method set
* @param {Object} props
* @param props @en List of properties of tween @zh 缓动的属性列表
* @return {Tween}
*/
set (props: ConstructorType<T>): Tween<T> {
@@ -219,7 +227,7 @@ export class Tween<T> {
* @zh
* 添加一个延时 action。
* @method delay
* @param {number} duration
* @param duration @en Delay time of this tween @zh 当前缓动的延迟时间
* @return {Tween}
*/
delay (duration: number): Tween<T> {
@@ -234,7 +242,7 @@ export class Tween<T> {
* @zh
* 添加一个回调 action。
* @method call
* @param {Function} callback
* @param callback @en Callback function at the end of this tween @zh 当前缓动结束时的回调函数
* @return {Tween}
*/
// eslint-disable-next-line @typescript-eslint/ban-types
@@ -249,6 +257,8 @@ export class Tween<T> {
* Add an sequence action.
* @zh
* 添加一个队列 action。
* @method sequence
* @param args @en All tween that make up the sequence @zh 组成队列的所有缓动
*/
sequence (...args: Tween<T>[]): Tween<T> {
const action = Tween._wrappedSequence(...args);
@@ -261,6 +271,8 @@ export class Tween<T> {
* Add an parallel action.
* @zh
* 添加一个并行 action。
* @method parallel
* @param args @en The tween parallel to this tween @zh 与当前缓动并行的缓动
*/
parallel (...args: Tween<T>[]): Tween<T> {
const action = Tween._wrappedParallel(...args);
@@ -274,8 +286,8 @@ export class Tween<T> {
* This action will integrate before actions to a sequence action as their parameters.
* @zh
* 添加一个重复 action,这个 action 会将前一个动作作为他的参数。
* @param {number} repeatTimes 重复次数
* @param {Tween<T>} embedTween 可选,嵌入 Tween
* @param repeatTimes @en The repeat times of this tween @zh 重复次数
* @param embedTween @en Optional, embedded tween of this tween @zh 可选,嵌入缓动
*/
repeat (repeatTimes: number, embedTween?: Tween<T>): Tween<T> {
/** adapter */
@@ -303,7 +315,7 @@ export class Tween<T> {
* @zh
* 添加一个永久重复 action,这个 action 会将前一个动作作为他的参数。
* @method repeatForever
* @param {Tween<T>} embedTween 可选,嵌入 Tween
* @param embedTween @en Optional, embedded tween of this tween @zh 可选,嵌入缓动
*/
repeatForever (embedTween?: Tween<T>): Tween<T> {
const actions = this._actions;
@@ -326,7 +338,7 @@ export class Tween<T> {
* @zh
* 添加一个倒置时间 action,这个 action 会将前一个动作作为他的参数。
* @method reverseTime
* @param {Tween<T>} embedTween 可选,嵌入 Tween
* @param embedTween @en Optional, embedded tween of this tween @zh 可选,嵌入缓动
*/
reverseTime (embedTween?: Tween<T>): Tween<T> {
const actions = this._actions;
@@ -459,7 +471,7 @@ legacyCC.Tween = Tween;
* tween is a utility function that helps instantiate Tween instances.
* @zh
* tween 是一个工具函数,帮助实例化 Tween 实例。
* @param target 缓动的目标
* @param target @en The target of the result tween @zh 缓动的目标
* @returns Tween 实例
* @example
* tween(this.node)
+2 -2
View File
@@ -101,7 +101,7 @@ export class PageViewIndicator extends Component {
* @zh
* 页面标记摆放方向
*
* @param direction 摆放方向
* @param direction @en The direction of the PageViewIndicator @zh 页面标记的摆放方向
*/
@type(Direction)
@tooltip('i18n:pageview_indicator.direction')
@@ -169,7 +169,7 @@ export class PageViewIndicator extends Component {
* @zh
* 设置页面视图
*
* @param target 页面视图对象
* @param target @en The page view which is attached with this indicator @zh 当前标记对象附着到的页面视图对象
*/
public setPageView (target: PageView) {
this._pageView = target;
+12 -12
View File
@@ -350,7 +350,7 @@ export class PageView extends ScrollView {
* @zh
* 返回当前页面索引。
*
* @returns 当前页面索引。
* @returns @en Current page index of this page view @zh 当前页面索引。
*/
public getCurrentPageIndex () {
return this._curPageIdx;
@@ -362,7 +362,7 @@ export class PageView extends ScrollView {
*
* @zh
* 设置当前页面索引。
* @param index 索引。
* @param index @en The page index to scroll to @zh 需要滚动到的页面索引
*/
public setCurrentPageIndex (index: number) {
this.scrollToPage(index, 1);
@@ -375,7 +375,7 @@ export class PageView extends ScrollView {
* @zh
* 返回视图中的所有页面。
*
* @returns 输=视图所有页面。
* @returns @en return all pages of this page view @zh 返回当前视图所有页面
*/
public getPages () {
return this._pages;
@@ -388,7 +388,7 @@ export class PageView extends ScrollView {
* @zh
* 在当前页面视图的尾部插入一个新视图。
*
* @param page 新视图。
* @param page @en New page to add to this page view @zh 新加入的视图
*/
public addPage (page: Node) {
if (!page || this._pages.indexOf(page) !== -1 || !this.content) {
@@ -410,8 +410,8 @@ export class PageView extends ScrollView {
* @zh
* 将页面插入指定位置中。
*
* @param page 新视图。
* @param index 指定位置。
* @param page @en New page to insert to this page view @zh 新插入的视图
* @param index @en The index of new page to be inserted @zh 新插入视图的索引
*/
public insertPage (page: Node, index: number) {
if (index < 0 || !page || this._pages.indexOf(page) !== -1 || !this.content) {
@@ -438,7 +438,7 @@ export class PageView extends ScrollView {
* @zh
* 移除指定页面。
*
* @param page 指定页面。
* @param page @en The page to be removed @zh 将被移除的页面
*/
public removePage (page: Node) {
if (!page || !this.content) { return; }
@@ -457,7 +457,7 @@ export class PageView extends ScrollView {
* @zh
* 移除指定下标的页面。
*
* @param index 页面下标。
* @param index @en The index of the page to be removed @zh 将被移除界面的页面下标
*/
public removePageAtIndex (index: number) {
const pageList = this._pages;
@@ -493,8 +493,8 @@ export class PageView extends ScrollView {
* @zh
* 滚动到指定页面
*
* @param idx index of page.
* @param timeInSecond scrolling time.
* @param idx @en The index of page to be scroll to @zh 希望滚动到的页面下标
* @param timeInSecond @en How long time to scroll to the page, in seconds @zh 滚动到指定页面所需时间,单位:秒
*/
public scrollToPage (idx: number, timeInSecond = 0.3) {
if (idx < 0 || idx >= this._pages.length) {
@@ -772,8 +772,8 @@ export class PageView extends ScrollView {
* @zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event page-turning
* @param {Event.EventCustom} event
* @param {PageView} pageView - The PageView component.
* @param event
* @param pageView - The PageView component.
*/
legacyCC.PageView = PageView;
+5 -2
View File
@@ -224,7 +224,7 @@ export class ScrollBar extends Component {
* @zh
* 重置滚动条位置。
*
* @param outOfBoundary - 滚动位移。
* @param outOfBoundary @en Rolling displacement @zh 滚动位移。
*/
public onScroll (outOfBoundary: Vec2 | Readonly<Vec2>) {
if (!this._scrollView) {
@@ -284,10 +284,13 @@ export class ScrollBar extends Component {
}
/**
* @en
* Sets the scroll view.
*
* @zh
* 滚动视窗设置。
*
* @param scrollView - 滚动视窗。
* @param scrollView @en The scroll view which is attached with this scroll bar @zh 当前滚动条附着的滚动视窗
*/
public setScrollView (scrollView: ScrollView) {
this._scrollView = scrollView;
+50 -32
View File
@@ -442,8 +442,9 @@ export class ScrollView extends ViewGroup {
* @zh
* 视图内容将在规定时间内滚动到视图底部。
*
* @param timeInSecond - 滚动时间(s)。 如果超时,内容将立即跳到底部边界。
* @param attenuated - 滚动加速是否衰减,默认为 true。
* @param timeInSecond
* @en The rolling time(in seconds). If time is up, the content will slide to the bottom border. @zh 滚动时间(s)。 如果超时,内容将立即跳到底部边界。
* @param attenuated @en Whether the rolling acceleration is attenuated(The default is true) @zh 滚动加速是否衰减,默认为 true
* @example
* ```ts
* // Scroll to the bottom of the view.
@@ -471,8 +472,9 @@ export class ScrollView extends ViewGroup {
* @zh
* 视图内容将在规定时间内滚动到视图顶部。
*
* @param timeInSecond - 滚动时间(s)。 如果超时,内容将立即跳到顶部边界。
* @param attenuated - 滚动加速是否衰减,默认为 true。
* @param timeInSecond
* @en The rolling time(in seconds). If time is up, the content will slide to the bottom border. @zh 滚动时间(s)。 如果超时,内容将立即跳到底部边界。
* @param attenuated @en Whether the rolling acceleration is attenuated(The default is true) @zh 滚动加速是否衰减,默认为 true
* @example
* ```ts
* // Scroll to the top of the view.
@@ -500,8 +502,9 @@ export class ScrollView extends ViewGroup {
* @zh
* 视图内容将在规定时间内滚动到视图左边。
*
* @param timeInSecond - 滚动时间(s)。 如果超时,内容将立即跳到左边边界。
* @param attenuated - 滚动加速是否衰减,默认为 true。
* @param timeInSecond
* @en The rolling time(in seconds). If time is up, the content will slide to the bottom border. @zh 滚动时间(s)。 如果超时,内容将立即跳到底部边界。
* @param attenuated @en Whether the rolling acceleration is attenuated(The default is true) @zh 滚动加速是否衰减,默认为 true
* @example
* ```ts
* // Scroll to the left of the view.
@@ -529,8 +532,9 @@ export class ScrollView extends ViewGroup {
* @zh
* 视图内容将在规定时间内滚动到视图右边。
*
* @param timeInSecond - 滚动时间(s)。 如果超时,内容将立即跳到右边边界。
* @param attenuated - 滚动加速是否衰减,默认为 true。
* @param timeInSecond
* @en The rolling time(in seconds). If time is up, the content will slide to the bottom border. @zh 滚动时间(s)。 如果超时,内容将立即跳到底部边界。
* @param attenuated @en Whether the rolling acceleration is attenuated(The default is true) @zh 滚动加速是否衰减,默认为 true
* @example
* ```ts
* // Scroll to the right of the view.
@@ -558,8 +562,9 @@ export class ScrollView extends ViewGroup {
* @zh
* 视图内容将在规定时间内滚动到视图左上角。
*
* @param timeInSecond - 滚动时间(s)。 如果超时,内容将立即跳到左上边边界。
* @param attenuated - 滚动加速是否衰减,默认为 true。
* @param timeInSecond
* @en The rolling time(in seconds). If time is up, the content will slide to the bottom border. @zh 滚动时间(s)。 如果超时,内容将立即跳到底部边界。
* @param attenuated @en Whether the rolling acceleration is attenuated(The default is true) @zh 滚动加速是否衰减,默认为 true
* @example
* ```ts
* // Scroll to the upper left corner of the view.
@@ -587,8 +592,9 @@ export class ScrollView extends ViewGroup {
* @zh
* 视图内容将在规定时间内滚动到视图右上角。
*
* @param timeInSecond - 滚动时间(s)。 如果超时,内容将立即跳到右上边界。
* @param attenuated - 滚动加速是否衰减,默认为 true。
* @param timeInSecond
* @en The rolling time(in seconds). If time is up, the content will slide to the bottom border. @zh 滚动时间(s)。 如果超时,内容将立即跳到底部边界。
* @param attenuated @en Whether the rolling acceleration is attenuated(The default is true) @zh 滚动加速是否衰减,默认为 true
* @example
* ```ts
* // Scroll to the top right corner of the view.
@@ -616,8 +622,9 @@ export class ScrollView extends ViewGroup {
* @zh
* 视图内容将在规定时间内滚动到视图左下角。
*
* @param timeInSecond - 滚动时间(s)。 如果超时,内容将立即跳到左下边界。
* @param attenuated - 滚动加速是否衰减,默认为 true。
* @param timeInSecond
* @en The rolling time(in seconds). If time is up, the content will slide to the bottom border. @zh 滚动时间(s)。 如果超时,内容将立即跳到底部边界。
* @param attenuated @en Whether the rolling acceleration is attenuated(The default is true) @zh 滚动加速是否衰减,默认为 true
* @example
* ```ts
* // Scroll to the lower left corner of the view.
@@ -645,8 +652,9 @@ export class ScrollView extends ViewGroup {
* @zh
* 视图内容将在规定时间内滚动到视图右下角。
*
* @param timeInSecond - 滚动时间(s)。 如果超时,内容将立即跳到右边下边界。
* @param attenuated - 滚动加速是否衰减,默认为 true。
* @param timeInSecond
* @en The rolling time(in seconds). If time is up, the content will slide to the bottom border. @zh 滚动时间(s)。 如果超时,内容将立即跳到底部边界。
* @param attenuated @en Whether the rolling acceleration is attenuated(The default is true) @zh 滚动加速是否衰减,默认为 true
* @example
* ```ts
* // Scroll to the lower right corner of the view.
@@ -669,14 +677,17 @@ export class ScrollView extends ViewGroup {
/**
* @en
* Scroll with an offset related to the ScrollView's top left origin, if timeInSecond is omitted, then it will jump to the specific offset immediately.
* Scroll with an offset related to the ScrollView's top left origin, if timeInSecond is omitted,
* then it will jump to the specific offset immediately.
*
* @zh
* 视图内容在规定时间内将滚动到 ScrollView 相对左上角原点的偏移位置, 如果 timeInSecond 参数不传,则立即滚动到指定偏移位置。
*
* @param offset - 滚动视图后,视图内容(content)相对于视图窗口(viewport)的位置。
* @param timeInSecond - 滚动时间(s)。 如果超时,内容将立即跳到指定偏移量处。
* @param attenuated - 滚动加速是否衰减,默认为 true。
* @param offset
* @en After scrolling the view, the position of the view content relative to the view window. @zh 滚动视图后,视图内容(content)相对于视图窗口(viewport)的位置。
* @param timeInSecond
* @en Scroll time (s). If it times out, the content immediately jumps to the specified offset. @zh 滚动时间(s)。 如果超时,内容将立即跳到指定偏移量处。
* @param attenuated @en Whether the rolling acceleration is attenuated(The default is true) @zh 滚动加速是否衰减,默认为 true
* @example
* ```ts
* // Scroll to middle position in 0.1 second in x-axis
@@ -711,7 +722,7 @@ export class ScrollView extends ViewGroup {
* @zh
* 获取滚动视图相对于视图窗口左上角原点的位置。
*
* @return - 当前滚动偏移量。
* @return @en Current rolling offset @zh 当前滚动偏移量
*/
public getScrollOffset () {
const topDelta = this._getContentTopBoundary() - this._topBoundary;
@@ -727,7 +738,7 @@ export class ScrollView extends ViewGroup {
* @zh
* 获取滚动视图最大可以滚动的偏移量。
*
* @return - 最大可滚动偏移量。
* @return @en Maximum scrollable offset @zh 最大可滚动偏移量
*/
public getMaxScrollOffset () {
if (!this._content || !this.view) {
@@ -749,9 +760,11 @@ export class ScrollView extends ViewGroup {
* @zh
* 视图内容在规定时间内将滚动到 ScrollView 水平方向的百分比位置上。
*
* @param percent - 0 - 之间的百分比。
* @param timeInSecond - 滚动时间(s)。 如果超时,内容将立即跳到指定水平百分比位置。
* @param attenuated - 滚动加速是否衰减,默认为 true。
* @param percent
* @en Scroll to the destination which is located at the percent interpolation from left border to the right border @zh 滚动到从左到右指定百分比插值的位置
* @param timeInSecond
* @en Scroll time (s). If it times out, the content immediately jumps to the specified offset. @zh 滚动时间(s)。 如果超时,内容将立即跳到指定偏移量处。
* @param attenuated @en Whether the rolling acceleration is attenuated(The default is true) @zh 滚动加速是否衰减,默认为 true
* @example
* ```ts
* // Scroll to middle position.
@@ -779,9 +792,12 @@ export class ScrollView extends ViewGroup {
* @zh
* 视图内容在规定时间内进行垂直方向和水平方向的滚动,并且滚动到指定百分比位置上。
*
* @param anchor - 在 new Vec2(0,0) and new Vec2(1,1) 上取差值的一个点。
* @param timeInSecond - 滚动时间(s)。 如果超时,内容将立即跳到指定水平或垂直百分比位置。
* @param attenuated - 滚动加速是否衰减,默认为 true。
* @param anchor
* @en Scroll to the destination which is located at the anchor interpolation from left/top border to the right/bottom border
* @zh 滚动到从左/上到右/下指定锚点对应分量插值的位置
* @param timeInSecond
* @en Scroll time (s). If it times out, the content immediately jumps to the specified offset. @zh 滚动时间(s)。 如果超时,内容将立即跳到指定偏移量处。
* @param attenuated @en Whether the rolling acceleration is attenuated(The default is true) @zh 滚动加速是否衰减,默认为 true
* @example
* ```ts
* // Vertical scroll to the bottom of the view.
@@ -812,9 +828,11 @@ export class ScrollView extends ViewGroup {
* @zh
* 视图内容在规定时间内滚动到 ScrollView 垂直方向的百分比位置上。
*
* @param percent - 0 - 1 之间的百分比。
* @param timeInSecond - 滚动时间(s)。 如果超时,内容将立即跳到指定垂直百分比位置。
* @param attenuated - 滚动加速是否衰减,默认为 true。
* @param percent
* @en Scroll to the destination which is located at the percent interpolation from top border to the bottom border @zh 滚动到从上到下指定百分比插值的位置
* @param timeInSecond
* @en Scroll time (s). If it times out, the content immediately jumps to the specified offset. @zh 滚动时间(s)。 如果超时,内容将立即跳到指定偏移量处。
* @param attenuated @en Whether the rolling acceleration is attenuated(The default is true) @zh 滚动加速是否衰减,默认为 true
* @example
* ```ts
* scrollView.scrollToPercentVertical(0.5, 0.1);
@@ -853,7 +871,7 @@ export class ScrollView extends ViewGroup {
* @zh
* 设置当前视图内容的坐标点。
*
* @param position - current content position.
* @param position @en Current content position @zh 希望设置内容框体的位置
* @deprecated Since 3.1.0, setContentPosition is deprecated, please use scrollToOffset instead.
*/
public setContentPosition (position: Vec3) {
+2 -2
View File
@@ -122,8 +122,8 @@ export class ToggleContainer extends Component {
* @zh
* 刷新管理的 toggle 状态。
*
* @param toggle - 需要被更新的 toggle。
* @param emitEvent - 是否需要触发事件
* @param toggle @en The toggle to be updated @zh 需要被更新的切换键
* @param emitEvent @en Whether events are needed to be emitted @zh 是否需要触发事件
*/
public notifyToggleCheck (toggle: Toggle, emitEvent = true) {
if (!this.enabledInHierarchy) { return; }
+3 -3
View File
@@ -164,7 +164,7 @@ export class Toggle extends Button {
* @zh
* 设置 isChecked 而不调用 checkEvents 回调。
*
* @param value - 是否被按下
* @param value @en Whether this toggle is pressed @zh 是否被按下
*/
public setIsCheckedWithoutNotify (value: boolean) {
this._set(value, false);
@@ -207,8 +207,8 @@ export class Toggle extends Button {
* @zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event toggle
* @param {Event.EventCustom} event
* @param {Toggle} toggle - The Toggle component.
* @param event @en The event when toggle is pressed up or down @zh 切换键被按下或抬起时发送的事件
* @param toggle @en The Toggle component @zh 切换键组件
*/
legacyCC.Toggle = Toggle;
@@ -0,0 +1,22 @@
#include <cc-global>
#include <common/effect/fog>
// Fog helper functions
void CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)
{
#if CC_USE_FOG == CC_FOG_LINEAR
factor = LinearFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.y);
#elif CC_USE_FOG == CC_FOG_EXP
factor = ExpFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z);
#elif CC_USE_FOG == CC_FOG_EXP_SQUARED
factor = ExpSquaredFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z);
#elif CC_USE_FOG == CC_FOG_LAYERED
factor = LayeredFog(pos, cc_cameraPos.xyz, cc_fogAdd.x, cc_fogAdd.y, cc_fogAdd.z);
#else
factor = 1.0;
#endif
}
void CC_APPLY_FOG_BASE(inout vec4 color, float factor) {
color = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a);
}
@@ -2,7 +2,7 @@
"ver": "1.0.4",
"importer": "effect-header",
"imported": true,
"uuid": "345abc7e-5211-479e-854e-03600d86f2cd",
"uuid": "02a04bf3-4c27-4596-81fd-dfc35224f1d1",
"files": [],
"subMetas": {},
"userData": {}
@@ -0,0 +1,13 @@
#include <common>
#include <cc-global>
#include <cc-shadow>
#include <packing>
#include <cc-local>
#include <cc-shadow-map-base>
#if CC_RECEIVE_SHADOW
//#include <builtin/uniforms/cc-shadow-map>
//#include <common/shadow/shadow>
#endif
@@ -2,7 +2,7 @@
"ver": "1.0.4",
"importer": "effect-header",
"imported": true,
"uuid": "6b061492-5e48-4193-b4f0-97f5aacae05d",
"uuid": "d4c26490-0a2d-4b6a-9a52-55b5741f18a4",
"files": [],
"subMetas": {},
"userData": {}
@@ -0,0 +1,2 @@
#pragma builtin(local)
layout(set = 2, binding = 10) uniform sampler2D cc_lightingMap;
@@ -0,0 +1,9 @@
{
"ver": "1.0.4",
"importer": "effect-header",
"imported": true,
"uuid": "fa1c0cd1-03c6-45dd-8294-bf7a1e21aad4",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -0,0 +1,5 @@
#pragma builtin(global)
layout(set = 0, binding = 3) uniform highp sampler2D cc_shadowMap;
#pragma builtin(global)
layout(set = 0, binding = 5) uniform highp sampler2D cc_spotLightingMap;
@@ -0,0 +1,9 @@
{
"ver": "1.0.4",
"importer": "effect-header",
"imported": true,
"uuid": "e8411010-e411-43ab-8f2e-4f4865dca4cf",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -19,11 +19,6 @@ float CCGetLinearDepth(vec3 worldPos) {
return CCGetLinearDepthFromViewSpace(viewStartPos.xyz);
}
float CCGetViewSpaceDepth(float depthHS)
{
return cc_shadowProjDepthInfo.y / (depthHS - cc_shadowProjDepthInfo.x);
}
#if CC_RECEIVE_SHADOW
#pragma builtin(global)
layout(set = 0, binding = 3) uniform highp sampler2D cc_shadowMap;
@@ -96,52 +96,3 @@
*/
// move to common.chunk
#pragma define equalf(data1, data2) (abs(float(data1) - float(data2)) < EPSILON)
// define.ts: 增加PipelineGlobalBindings.UBO_DEBUGVIEW, cc_shadowMap / cc_spotLightingMap / cc_environment / cc_diffuseMap的binding加1
/**
* @en The uniform buffer object for debug view
* @zh 渲染调试 UBO。
*/
/*
export class UBODebugView {
public static readonly SINGLE_MODE = 0;
public static readonly LIGHTING_ENABLE_WITH_ALBEDO = UBODebugView.SINGLE_MODE + 1;
public static readonly MISC_ENABLE_CSM_LAYER_COLORATION = UBODebugView.LIGHTING_ENABLE_WITH_ALBEDO + 1;
public static readonly COMPOSITE_ENABLE_DIRECT_DIFFUSE = UBODebugView.MISC_ENABLE_CSM_LAYER_COLORATION + 1;
public static readonly COMPOSITE_ENABLE_DIRECT_SPECULAR = UBODebugView.COMPOSITE_ENABLE_DIRECT_DIFFUSE + 1;
public static readonly COMPOSITE_ENABLE_ENV_DIFFUSE = UBODebugView.COMPOSITE_ENABLE_DIRECT_SPECULAR + 1;
public static readonly COMPOSITE_ENABLE_ENV_SPECULAR = UBODebugView.COMPOSITE_ENABLE_ENV_DIFFUSE + 1;
public static readonly COMPOSITE_ENABLE_EMISSIVE = UBODebugView.COMPOSITE_ENABLE_ENV_SPECULAR + 1;
public static readonly COMPOSITE_ENABLE_LIGHT_MAP = UBODebugView.COMPOSITE_ENABLE_EMISSIVE + 1;
public static readonly COMPOSITE_ENABLE_SHADOW = UBODebugView.COMPOSITE_ENABLE_LIGHT_MAP + 1;
public static readonly COMPOSITE_ENABLE_AO = UBODebugView.COMPOSITE_ENABLE_SHADOW + 1;
public static readonly COMPOSITE_ENABLE_NORMAL_MAP = UBODebugView.COMPOSITE_ENABLE_AO + 1;
public static readonly COMPOSITE_ENABLE_FOG = UBODebugView.COMPOSITE_ENABLE_NORMAL_MAP + 1;
public static readonly COMPOSITE_ENABLE_TONE_MAPPING = UBODebugView.COMPOSITE_ENABLE_FOG + 1;
public static readonly COMPOSITE_ENABLE_GAMMA_CORRECTION = UBODebugView.COMPOSITE_ENABLE_TONE_MAPPING + 1;
public static readonly COUNT : number = UBODebugView.COMPOSITE_ENABLE_GAMMA_CORRECTION + 1;
public static readonly SIZE = UBODebugView.COUNT * 4;
public static readonly NAME = 'CCDebugView';
public static readonly BINDING = PipelineGlobalBindings.UBO_DEBUGVIEW;
public static readonly DESCRIPTOR = new DescriptorSetLayoutBinding(UBODebugView.BINDING, DescriptorType.UNIFORM_BUFFER, 1, ShaderStageFlagBit.ALL);
public static readonly LAYOUT = new UniformBlock(SetIndex.GLOBAL, UBODebugView.BINDING, UBODebugView.NAME, [
new Uniform('cc_debug_view_single_mode', Type.INT, 1),
new Uniform('cc_debug_view_lighting_enable_with_albedo', Type.FLOAT, 1),
new Uniform('cc_debug_view_misc_enable_csm_layer_coloration', Type.FLOAT, 1),
new Uniform('cc_debug_view_composite_enable_direct_diffuse', Type.FLOAT, 1),
new Uniform('cc_debug_view_composite_enable_direct_specular', Type.FLOAT, 1),
new Uniform('cc_debug_view_composite_enable_env_diffuse', Type.FLOAT, 1),
new Uniform('cc_debug_view_composite_enable_env_specular', Type.FLOAT, 1),
new Uniform('cc_debug_view_composite_enable_emissive', Type.FLOAT, 1),
new Uniform('cc_debug_view_composite_enable_light_map', Type.FLOAT, 1),
new Uniform('cc_debug_view_composite_enable_shadow', Type.FLOAT, 1),
new Uniform('cc_debug_view_composite_enable_ao', Type.FLOAT, 1),
new Uniform('cc_debug_view_composite_enable_normal_map', Type.FLOAT, 1),
new Uniform('cc_debug_view_composite_enable_fog', Type.FLOAT, 1),
new Uniform('cc_debug_view_composite_enable_tone_mapping', Type.FLOAT, 1),
new Uniform('cc_debug_view_composite_enable_gamma_correction', Type.FLOAT, 1),
], 1);
}
globalDescriptorSetLayout.layouts[UBODebugView.NAME] = UBODebugView.LAYOUT;
globalDescriptorSetLayout.bindings[UBODebugView.BINDING] = UBODebugView.DESCRIPTOR;
*/
+6 -6
View File
@@ -1,28 +1,28 @@
// fog related calculations
//pos, cc_cameraPos, cc_fogBase.x, cc_fogBase.y
//pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.y
float LinearFog(vec4 pos, vec3 cameraPos, float fogStart, float fogEnd) {
vec4 wPos = pos;
float cam_dis = distance(cameraPos, wPos);
float cam_dis = distance(cameraPos, wPos.xyz);
return clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);
}
//pos, cc_cameraPos, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z
//pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z
float ExpFog(vec4 pos, vec3 cameraPos, float fogStart, float fogDensity, float fogAtten) {
vec4 wPos = pos;
float cam_dis = max(distance(cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;
float cam_dis = max(distance(cameraPos, wPos.xyz) - fogStart, 0.0) / fogAtten * 4.;
float f = exp(-cam_dis * fogDensity);
return f;
}
float ExpSquaredFog(vec4 pos, vec3 cameraPos, float fogStart, float fogDensity, float fogAtten) {
vec4 wPos = pos;
float cam_dis = max(distance(cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;
float cam_dis = max(distance(cameraPos, wPos.xyz) - fogStart, 0.0) / fogAtten * 4.;
float f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);
return f;
}
//pos, cc_cameraPos, cc_fogAdd.x, cc_fogAdd.y, cc_fogAdd.z
//pos, cc_cameraPos.xyz, cc_fogAdd.x, cc_fogAdd.y, cc_fogAdd.z
float LayeredFog(vec4 pos, vec3 cameraPos, float fogTop, float fogRange, float fogAtten) {
vec4 wPos = pos;
vec3 camWorldProj = cameraPos.xyz;
@@ -0,0 +1,14 @@
vec4 GetLightMapColor(sampler2D lightingMap, vec2 luv, float lum)
{
vec4 lightmap = texture(lightingMap, luv);
lightmap.rgb *= lum;
#if CC_USE_HDR
// convert from standard camera exposure parameters to current exposure value
// baked in LDR scene still regarded as exposured with standard camera parameters
lightmap.rgb *= cc_exposure.w * cc_exposure.x;
#endif
return lightmap;
}
@@ -0,0 +1,9 @@
{
"ver": "1.0.4",
"importer": "effect-header",
"imported": true,
"uuid": "00e591cd-469d-4611-adb9-a5ca965a0552",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -1,16 +0,0 @@
#pragma builtin(local)
layout(set = 2, binding = 10) uniform sampler2D cc_lightingMap;
vec4 GetLightMapColor(vec2 luv, float lum)
{
vec4 lightmap = texture(cc_lightingMap, luv);
lightmap.rgb *= lum;
#if CC_USE_HDR
// convert from standard camera exposure parameters to current exposure value
// baked in LDR scene still regarded as exposured with standard camera parameters
lightmap.rgb *= cc_exposure.w * cc_exposure.x;
#endif
return lightmap;
}
@@ -1,3 +1,26 @@
// depthHS = ndc depth()
float GetCameraDepthRH(float depthHS, mat4 matProj)
{
return -matProj[3][2] / (depthHS + matProj[2][2]);
}
float GetCameraDepthRH(float depthHS, float matProj32, float matProj22)
{
return -matProj32 / (depthHS + matProj22);
}
// posHS = ndc pos (xyz: -1 ~ +1)
vec4 GetViewPosFromScreenPos(vec3 posHS, mat4 matProj, mat4 matProjInv)
{
float w = -GetCameraDepthRH(posHS.z, matProj);
return matProjInv * vec4(posHS * w, w);
}
vec4 GetWorldPosFromScreenPos(vec3 posHS, mat4 matProj, mat4 matViewProjInv)
{
float w = -GetCameraDepthRH(posHS.z, matProj);
return matViewProjInv * vec4(posHS * w, w);
}
// params must be normalized
vec3 CalculateBinormal(vec3 normal, vec3 tangent, float mirrorNormal)
{
@@ -76,7 +76,7 @@
// CCSurfacesLightingCalculateBaked:
lightingResult.lightmapColor = vec3(0.0);
#if CC_SURFACES_USE_LIGHT_MAP && !CC_SURFACES_USE_BATCHING && !CC_FORWARD_ADD
vec4 lightmap = GetLightMapColor(FSInput_lightMapUV.xy, FSInput_lightMapUV.z);
vec4 lightmap = GetLightMapColor(cc_lightingMap, FSInput_lightMapUV.xy, FSInput_lightMapUV.z);
lightingResult.lightmapColor = lightmap.rgb;
// lightingResult.shadow/ao *= lightmap.a;
#endif
@@ -8,13 +8,15 @@ void main () {
// Color output
#if CC_USE_HDR
#if !CC_SURFACES_DEBUG_VIEW_COMPOSITE_MODE || (CC_SURFACES_DEBUG_VIEW_COMPOSITE_MODE & CC_SURFACES_DEBUG_VIEW_COMPOSITE_TONE_MAPPING)
color.rgb = ACESToneMap(color.rgb);
#if CC_SURFACES_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC
if (cc_debug_view_composite_enable_tone_mapping > 0.0)
#endif
color.rgb = ACESToneMap(color.rgb);
#endif
#if CC_SURFACES_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC
if (cc_debug_view_composite_enable_gamma_correction > 0.0)
#endif
#if !CC_SURFACES_DEBUG_VIEW_COMPOSITE_MODE || (CC_SURFACES_DEBUG_VIEW_COMPOSITE_MODE & CC_SURFACES_DEBUG_VIEW_COMPOSITE_GAMMA_CORRECTION)
color.rgb = LinearToSRGB(color.rgb);
#endif
fragColorX = color;
}
@@ -1 +1,4 @@
#include <shading-entries/main-functions/render-to-scene/vs>
#include <surfaces/default-functions/common-vs>
#include <surfaces/module-functions/common-vs>
#include <shading-entries/main-functions/render-to-scene/vs>
@@ -0,0 +1,30 @@
// default functions
#ifndef CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TRANSPARENCY
vec4 SurfacesFragmentModifyBaseColorAndTransparency()
{
return vec4(cc_ambientSky.xyz * cc_ambientSky.w, 1.0);
}
#endif
// no structure and module functions needed
layout(location = 0) out vec4 fragColorX;
void main() {
vec4 color = SurfacesFragmentModifyBaseColorAndTransparency();
color.a = 1.0;
#if CC_USE_HDR
#if CC_SURFACES_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC
if (cc_debug_view_composite_enable_tone_mapping > 0.0)
#endif
color.rgb = ACESToneMap(color.rgb);
#endif
#if CC_SURFACES_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC
if (cc_debug_view_composite_enable_gamma_correction > 0.0)
#endif
color.rgb = LinearToSRGB(color.rgb);
fragColorX = color;
}
@@ -0,0 +1,9 @@
{
"ver": "1.0.4",
"importer": "effect-header",
"imported": true,
"uuid": "6a27185f-415d-419c-95b0-85337e21eff9",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -0,0 +1,56 @@
#include <surfaces/default-functions/common-vs>
#include <surfaces/module-functions/common-vs>
vec4 CalcSkyClipPos(vec3 viewDir)
{
vec4 clipPos;
// Clip Space
mat4 matViewRotOnly = mat4(mat3(cc_matView));
vec4 pos = matViewRotOnly * vec4(viewDir, 1.0);
// orthographic projection adaptation
if (cc_matProj[3].w > 0.0) {
mat4 matProj = cc_matProj;
// default ortho height 10 approximate to default FOV 45
// stretch x by 2 to remedy perspective effect
// w = sin(45/2), h = 2 * w, _11 = 2 / w, _22 = 2 / h
matProj[0].x = 5.2;
matProj[1].y = 2.6;
matProj[2].zw = vec2(-1.0);
matProj[3].zw = vec2(0.0);
// position is modified inside branches to work around a vk driver bug seen in
// low-end Qualcomm devices (Adreno 512, Oppo R11, cocos-creator/3d-tasks#9236)
clipPos = matProj * pos;
}
else {
clipPos = cc_matProj * pos;
}
clipPos.z = 0.99999 * clipPos.w;
return clipPos;
}
void main()
{
SurfacesStandardVertexIntermediate In;
// Local Space
CCSurfacesVertexInput(In);
// Can apply uniform scaling for atmosphere effects
// can not apply translation
mat4 matRotScaleOnly = mat4(mat3(cc_matWorld));
In.worldPos = (matRotScaleOnly * In.position).xyz;
In.clipPos = CalcSkyClipPos(In.worldPos.xyz);
In.worldNormal.w = 1.0;
In.worldNormal.xyz = normalize(In.worldPos.xyz);
// Other Data
#if !CC_USE_ACCURATE_FOG
In.fogFactor = 0.0;
#endif
CCSurfacesVertexOutput(In);
}
@@ -0,0 +1,9 @@
{
"ver": "1.0.4",
"importer": "effect-header",
"imported": true,
"uuid": "070d960d-b2b5-437c-99da-0aeb502f7273",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -158,7 +158,8 @@ void main() {
color.rgb *= colDebugCSMLayer.rgb;
}
#endif
#endif
#if CC_USE_HDR
#if CC_SURFACES_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC
if (cc_debug_view_composite_enable_tone_mapping > 0.0)
@@ -172,7 +173,6 @@ void main() {
//-----------------------------------------------
CCSurfacesDebugDisplayInvalidNumber(color);
#endif
fragColorX = color;
}
@@ -1,3 +1,5 @@
// Copyright (c) 2017-2022 Xiamen Yaji Software Co., Ltd.
#pragma define-meta USE_INSTANCING editor(elevated: true)
#pragma define-meta USE_BATCHING editor(elevated: true)
// these two macros must be non-const
@@ -8,15 +10,10 @@
// all material->internal macros
// varying-dependent macros
#ifndef CC_SURFACES_USE_SECOND_UV
#define CC_SURFACES_USE_SECOND_UV 0
#endif
#ifndef CC_SURFACES_USE_TWO_SIDED
#define CC_SURFACES_USE_TWO_SIDED 0
#endif
#ifndef CC_SURFACES_USE_REFLECTION_DENOISE
#define CC_SURFACES_USE_REFLECTION_DENOISE 0
#endif
#ifndef CC_SURFACES_USE_TANGENT_SPACE
#define CC_SURFACES_USE_TANGENT_SPACE 0
#endif
@@ -26,15 +23,6 @@
#ifndef CC_SURFACES_TRANSFER_LOCAL_POS
#define CC_SURFACES_TRANSFER_LOCAL_POS 0
#endif
#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC
#define CC_SURFACES_LIGHTING_ANISOTROPIC 0
#endif
#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT
#define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0
#endif
#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING
#define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0
#endif
#if CC_USE_LIGHTMAP
#ifndef CC_SURFACES_USE_LIGHT_MAP
@@ -45,3 +33,20 @@
#define CC_SURFACES_USE_LIGHT_MAP 0
#endif
#endif
// varying-undependent macros
#ifndef CC_SURFACES_USE_TWO_SIDED
#define CC_SURFACES_USE_TWO_SIDED 0
#endif
#ifndef CC_SURFACES_USE_REFLECTION_DENOISE
#define CC_SURFACES_USE_REFLECTION_DENOISE 0
#endif
#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC
#define CC_SURFACES_LIGHTING_ANISOTROPIC 0
#endif
#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT
#define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0
#endif
#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING
#define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0
#endif
@@ -5,8 +5,7 @@
#define CC_SURFACES_USE_TANGENT_SPACE 0
#define CC_SURFACES_USE_VERTEX_COLOR 0
#define CC_SURFACES_USE_SECOND_UV 0
#define CC_SURFACES_USE_TWO_SIDED 0
#define CC_SURFACES_USE_REFLECTION_DENOISE 0
#define CC_SURFACES_USE_LIGHT_MAP 0
#define CC_SURFACES_TRANSFER_LOCAL_POS 0
#include <surfaces/effect-macros/common-macros>
@@ -5,8 +5,7 @@
#define CC_SURFACES_USE_TANGENT_SPACE 0
#define CC_SURFACES_USE_VERTEX_COLOR 0
#define CC_SURFACES_USE_SECOND_UV 0
#define CC_SURFACES_USE_TWO_SIDED 0
#define CC_SURFACES_USE_REFLECTION_DENOISE 0
#define CC_SURFACES_USE_LIGHT_MAP 0
#define CC_SURFACES_TRANSFER_LOCAL_POS 0
#include <surfaces/effect-macros/common-macros>
@@ -0,0 +1,14 @@
// Copyright (c) 2017-2022 Xiamen Yaji Software Co., Ltd.
#pragma define USE_INSTANCING 0
#pragma define USE_BATCHING 0
// use #define to rename a macro without editor flag
#define CC_SURFACES_USE_INSTANCING USE_INSTANCING
#define CC_SURFACES_USE_BATCHING USE_BATCHING
// Disable unused functionality and varying data
#define CC_SURFACES_USE_TANGENT_SPACE 0
#define CC_SURFACES_USE_VERTEX_COLOR 0
#define CC_SURFACES_USE_SECOND_UV 0
#define CC_SURFACES_USE_LIGHT_MAP 0
#define CC_SURFACES_TRANSFER_LOCAL_POS 0
@@ -0,0 +1,9 @@
{
"ver": "1.0.4",
"importer": "effect-header",
"imported": true,
"uuid": "dc6e17a4-b3b4-4316-8f1e-c925b6fab67c",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -37,16 +37,17 @@
#include <gamma>
#include <common/math/number>
#include <common/math/coordinates>
#include <common/mesh/material>
#include <octahedron-transform>
#include <common/mesh/material>
#include <common/texture/cubemap>
// Functional
#include <cc-shadow-map-base>
#include <cc-fog-base>
#include <builtin/internal-functions/shadow-map>
#include <builtin/internal-functions/fog>
#if CC_SURFACES_USE_LIGHT_MAP && !CC_SURFACES_USE_BATCHING && !CC_FORWARD_ADD
#include <common/lighting/lightmap>
#include <builtin/uniforms/cc-light-map>
#include <common/lighting/light-map>
#endif
@@ -1,2 +0,0 @@
#include <surfaces/default-functions/common-vs>
#include <surfaces/module-functions/common-vs>
+4 -4
View File
@@ -273,19 +273,19 @@
},
"_firstSetCSM": false,
"_fixedArea": false,
"_pcf": 0,
"_pcf": 1,
"_bias": 0.00001,
"_normalBias": 0,
"_near": 0.1,
"_far": 10,
"_shadowDistance": 100,
"_shadowDistance": 10,
"_invisibleOcclusionRange": 200,
"_orthoSize": 5,
"_maxReceived": 4,
"_size": {
"__type__": "cc.Vec2",
"x": 512,
"y": 512
"x": 1024,
"y": 1024
},
"_saturation": 0.75
},
+12
View File
@@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "2201b77a-5090-48dd-8dc0-48503a9be474",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}
@@ -0,0 +1,115 @@
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"persistent": false,
"asyncLoadAssets": false
},
{
"__type__": "cc.Node",
"_name": "Camera",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
}
],
"_prefab": {
"__id__": 4
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.Camera",
"_name": "Camera<CameraComponent>",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 3
},
"_projection": 0,
"_priority": 0,
"_fov": 45,
"_fovAxis": 0,
"_orthoHeight": 10,
"_near": 0,
"_far": 1000,
"_color": {
"__type__": "cc.Color",
"r": 51,
"g": 76,
"b": 120,
"a": 255
},
"_depth": 1,
"_stencil": 0,
"_clearFlags": 7,
"_rect": {
"__type__": "cc.Rect",
"x": 0,
"y": 0,
"width": 1,
"height": 1
},
"_aperture": 19,
"_shutter": 7,
"_iso": 0,
"_screenScale": 1,
"_visibility": 1108344832,
"_targetTexture": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "da2BI3+SxOmYFitcPWPxAg"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "04zH6qlZ9EeJlFO7H23rXj"
}
]
@@ -0,0 +1,13 @@
{
"ver": "1.1.38",
"importer": "prefab",
"imported": true,
"uuid": "3487d118-0158-4983-93fe-c3822790e7c5",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "Camera"
}
}
@@ -22,7 +22,7 @@ CCEffect %{
emissiveScaleMap: { value: grey, editor: { displayName: EmissiveMap } }
emissive: { value: [0.0, 0.0, 0.0, 1.0], linear: true, editor: { displayName: EmissiveColor, type: color} }
emissiveMap: { value: grey, editor: { displayName: EmissiveColorMap } }
alphaSource: { value: 0.0, editor: { slide: true, range: [0, 1.0], step: 0.001 } }
alphaSource: { value: 1.0, editor: { slide: true, range: [0, 1.0], step: 0.001 } }
alphaSourceMap: { value: grey, editor: { parent: USE_OPACITY_MAP } }
alphaThreshold: { value: 0.5, target: albedoScaleAndCutoff.w, editor: { parent: USE_ALPHA_TEST, slide: true, range: [0, 1.0], step: 0.001 } }
normalStrength: { value: 1.0, editor: { parent: USE_NORMAL_MAP, slide: true, range: [0, 1.0], step: 0.001 } }
@@ -270,7 +270,7 @@ CCProgram standard-fs %{
#if USE_ALBEDO_MAP
vec4 texColor = texture(albedoMap, TEXTURE_UV);
texColor.rgb = SRGBToLinear(texColor.rgb);
baseColor *= texColor;
baseColor = texColor;
#endif
#if USE_WEIGHT_MAP
@@ -301,7 +301,8 @@ CCProgram standard-fs %{
roughnessValue = roughnessColor.ROUGHNESS_CHANNEL;
#endif
#endif
s.roughness = roughnessValue;
//fit specular ior=1.5
s.roughness = max(0.02, roughnessValue);
float occlusionValue = occlusion;
@@ -295,7 +295,7 @@ bool GetMetallicAlbedoFromDiffuseSpecularWithoutColor(out float metallic, out ve
#if USE_ALBEDO_MAP
vec4 texColor = texture(albedoMap, TEXTURE_UV);
texColor.rgb = SRGBToLinear(texColor.rgb);
baseColor *= texColor;
baseColor = texColor;
diffuseScale = 1.0;
#endif
baseColor.rgb *= diffuseScale;
+52
View File
@@ -0,0 +1,52 @@
// Copyright (c) 2017-2022 Xiamen Yaji Software Co., Ltd.
CCEffect %{
techniques:
- name: opaque
passes:
- vert: sky-vs
frag: sky-fs
priority : max - 10
rasterizerState :
cullMode : none
depthStencilState :
depthTest: true
depthWrite : false
}%
CCProgram surface-fragment %{
#define CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TRANSPARENCY
vec4 SurfacesFragmentModifyBaseColorAndTransparency()
{
vec3 c = cc_ambientSky.xyz;
#if CC_USE_IBL
vec3 normal = normalize(FSInput_worldNormal);
#if USE_RGBE_CUBEMAP
c *= unpackRGBE(texture(cc_environment, normal.xyz));
#else
c *= SRGBToLinear(texture(cc_environment, normal.xyz).rgb);
#endif
#endif
return vec4(c * cc_ambientSky.w, 1.0);
}
}%
CCProgram sky-vs %{
precision highp float;
#include <surfaces/effect-macros/sky>
#include <surfaces/includes/common-vs>
#include <shading-entries/main-functions/misc/sky-vs>
}%
CCProgram sky-fs %{
precision highp float;
#include <surfaces/effect-macros/sky>
#include <surfaces/includes/common-fs>
#include <surface-fragment>
#include <shading-entries/main-functions/misc/sky-fs>
}%
@@ -0,0 +1,11 @@
{
"ver": "1.5.6",
"importer": "effect",
"imported": true,
"uuid": "6308c013-7d49-4160-9516-562dd205b480",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}
@@ -269,7 +269,7 @@ CCProgram standard-vs %{
#include <macro-remapping>
#include <surfaces/effect-macros/common-macros>
// 2. common include with corresponding shader stage
// 2. common include with corresponding shader stage, include before surface functions
#include <surfaces/includes/common-vs>
// 3. user surface functions that can use user (effect) parameters (ubo Constants)
@@ -307,7 +307,7 @@ CCProgram standard-fs %{
#include <macro-remapping>
#include <surfaces/effect-macros/common-macros>
// 2. common include with corresponding shader stage
// 2. common include with corresponding shader stage, include before surface functions
#include <surfaces/includes/common-fs>
// 3. user surface functions that can use user (effect) parameters (ubo Constants)
@@ -378,7 +378,6 @@ CCProgram silhouette-edge-vs %{
#include <surfaces/effect-macros/silhouette-edge>
#include <surfaces/includes/common-vs>
#include <surface-vertex-silhouette-edge>
#include <surfaces/includes/silhouette-edge-vs>
#include <shading-entries/main-functions/misc/silhouette-edge-vs>
}%
+1 -1
View File
@@ -325,7 +325,7 @@ module.exports = {
smartMaterialEnabled: {
name: 'Smart Material Conversion',
title: 'Convert DCC materials to engine builtin materials which match the internal lighting model.',
warn: 'The laboratory feature "Smart Material Conversion" in the preferences is turned off, please enable this feature to modify model level settings.',
warn: 'The model feature "Smart Material Conversion" in the project settings is turned off, please enable this feature to modify model level settings.',
},
},
textureCube: {
+1 -1
View File
@@ -317,7 +317,7 @@ module.exports = {
smartMaterialEnabled: {
name: '材质智能转换',
title: '将 DCC 材质转化为引擎材质, 并匹对 DCC 材质的光照模型',
warn: '偏好设置里的实验室功能 "材质智能转换" 已关闭,请启用此项功能来修改模型级别设置。',
warn: '项目设置里的模型配置 "材质智能转换" 已关闭,请启用此项功能来修改模型级别设置。',
},
},
textureCube: {
+1 -1
View File
@@ -185,7 +185,7 @@ const Elements = {
async update() {
const panel = this;
const laboratoryExpectedValue = await Editor.Profile.getConfig('engine', 'asset.fbx.material.smart');
const laboratoryExpectedValue = await Editor.Profile.getProject('project', 'fbx.material.smart');
if (!laboratoryExpectedValue) {
panel.$.smartMaterialEnabledProp.setAttribute('readonly', '');
} else {
+19 -6
View File
@@ -38,26 +38,36 @@ namespace cc {
RenderingSubMesh::RenderingSubMesh(const gfx::BufferList &vertexBuffers,
const gfx::AttributeList &attributes,
gfx::PrimitiveMode primitiveMode)
: RenderingSubMesh(vertexBuffers, attributes, primitiveMode, nullptr, nullptr) {
: RenderingSubMesh(vertexBuffers, attributes, primitiveMode, nullptr, nullptr, true) {
}
RenderingSubMesh::RenderingSubMesh(const gfx::BufferList &vertexBuffers,
const gfx::AttributeList &attributes,
gfx::PrimitiveMode primitiveMode,
gfx::Buffer *indexBuffer)
: RenderingSubMesh(vertexBuffers, attributes, primitiveMode, indexBuffer, nullptr) {
: RenderingSubMesh(vertexBuffers, attributes, primitiveMode, indexBuffer, nullptr, true) {
}
RenderingSubMesh::RenderingSubMesh(const gfx::BufferList &vertexBuffers,
const gfx::AttributeList &attributes,
gfx::PrimitiveMode primitiveMode,
gfx::Buffer *indexBuffer /* = nullptr*/,
gfx::Buffer *indirectBuffer /* = nullptr*/)
gfx::Buffer *indexBuffer,
gfx::Buffer *indirectBuffer)
: RenderingSubMesh(vertexBuffers, attributes, primitiveMode, indexBuffer, indirectBuffer, true) {
}
RenderingSubMesh::RenderingSubMesh(const gfx::BufferList &vertexBuffers,
const gfx::AttributeList &attributes,
gfx::PrimitiveMode primitiveMode,
gfx::Buffer *indexBuffer,
gfx::Buffer *indirectBuffer,
bool isOwnerOfIndexBuffer)
: _vertexBuffers(vertexBuffers),
_attributes(attributes),
_primitiveMode(primitiveMode),
_indexBuffer(indexBuffer),
_indirectBuffer(indirectBuffer) {
_indirectBuffer(indirectBuffer),
_isOwnerOfIndexBuffer(isOwnerOfIndexBuffer) {
_iaInfo.attributes = attributes;
_iaInfo.vertexBuffers = vertexBuffers;
_iaInfo.indexBuffer = indexBuffer;
@@ -203,7 +213,10 @@ bool RenderingSubMesh::destroy() {
}
_vertexBuffers.clear();
CC_SAFE_DESTROY_NULL(_indexBuffer);
if (_indexBuffer && _isOwnerOfIndexBuffer) {
_indexBuffer->destroy();
_indexBuffer = nullptr;
}
if (!_jointMappedBuffers.empty() && !_jointMappedBufferIndices.empty()) {
for (uint32_t index : _jointMappedBufferIndices) {
@@ -100,6 +100,13 @@ public:
gfx::PrimitiveMode primitiveMode,
gfx::Buffer *indexBuffer,
gfx::Buffer *indirectBuffer);
RenderingSubMesh(const gfx::BufferList &vertexBuffers,
const gfx::AttributeList &attributes,
gfx::PrimitiveMode primitiveMode,
gfx::Buffer *indexBuffer,
gfx::Buffer *indirectBuffer,
bool isOwnerOfIndexBuffer);
~RenderingSubMesh() override;
@@ -185,6 +192,8 @@ public:
private:
gfx::Buffer *allocVertexIdBuffer(gfx::Device *device);
bool _isOwnerOfIndexBuffer{true};
// Mesh will includes RenderingSubMesh, so use Mesh* here.
Mesh *_mesh{nullptr};
@@ -179,6 +179,26 @@ bool RenderAdditiveLightQueue::cullSpotLight(const scene::SpotLight *light, cons
return model->getWorldBounds() && (!model->getWorldBounds()->aabbAabb(light->getAABB()) || !model->getWorldBounds()->aabbFrustum(light->getFrustum()));
}
bool RenderAdditiveLightQueue::isInstancedOrBatched(const scene::Model* model) {
const auto & subModels = model->getSubModels();
const auto subModelCount = subModels.size();
for (uint subModelIdx = 0; subModelIdx < subModelCount; ++subModelIdx) {
const auto &subModel = subModels[subModelIdx];
const auto &passes = subModel->getPasses();
const auto passCount = passes.size();
for (uint passIdx = 0; passIdx < passCount; ++passIdx) {
const auto &pass = passes[passIdx];
if (pass->getBatchingScheme() == scene::BatchingSchemes::INSTANCING) {
return true;
}
if (pass->getBatchingScheme() == scene::BatchingSchemes::VB_MERGING) {
return true;
}
}
}
return false;
}
void RenderAdditiveLightQueue::addRenderQueue(const scene::Pass *pass, const scene::SubModel *subModel, const scene::Model *model, uint lightPassIdx) {
const auto batchingScheme = pass->getBatchingScheme();
if (batchingScheme == scene::BatchingSchemes::INSTANCING) { // instancing
@@ -274,7 +294,10 @@ void RenderAdditiveLightQueue::updateUBOs(const scene::Camera *camera, gfx::Comm
case scene::LightType::SPOT: {
_lightBufferData[offset + UBOForwardLight::LIGHT_POS_OFFSET + 3] = 1.0F;
_lightBufferData[offset + UBOForwardLight::LIGHT_SIZE_RANGE_ANGLE_OFFSET + 2] = spotLight->getSpotAngle();
_lightBufferData[offset + UBOForwardLight::LIGHT_SIZE_RANGE_ANGLE_OFFSET + 3] = (spotLight->isShadowEnabled() && shadowInfo->getType() == scene::ShadowType::SHADOW_MAP) ? 1.0F : 0.0F;
_lightBufferData[offset + UBOForwardLight::LIGHT_SIZE_RANGE_ANGLE_OFFSET + 3] = (shadowInfo->isEnabled() &&
spotLight->isShadowEnabled() &&
shadowInfo->getType() == scene::ShadowType::SHADOW_MAP) ? 1.0F
: 0.0F;
index = offset + UBOForwardLight::LIGHT_DIR_OFFSET;
const auto &direction = spotLight->getDirection();
@@ -409,14 +432,19 @@ bool RenderAdditiveLightQueue::getLightPassIndex(const scene::Model *model, ccst
void RenderAdditiveLightQueue::lightCulling(const scene::Model *model) {
bool isCulled = false;
const auto isNeedCulling = !isInstancedOrBatched(model);
for (size_t i = 0; i < _validPunctualLights.size(); i++) {
const auto *const light = _validPunctualLights[i];
switch (light->getType()) {
case scene::LightType::SPHERE:
isCulled = cullSphereLight(static_cast<const scene::SphereLight *>(light), model);
if (isNeedCulling) {
isCulled = cullSphereLight(static_cast<const scene::SphereLight *>(light), model);
}
break;
case scene::LightType::SPOT:
isCulled = cullSpotLight(static_cast<const scene::SpotLight *>(light), model);
if (isNeedCulling) {
isCulled = cullSpotLight(static_cast<const scene::SpotLight *>(light), model);
}
break;
default:
isCulled = false;
@@ -62,6 +62,7 @@ public:
private:
static bool cullSphereLight(const scene::SphereLight *light, const scene::Model *model);
static bool cullSpotLight(const scene::SpotLight *light, const scene::Model *model);
static bool isInstancedOrBatched(const scene::Model *model);
void clear();
void addRenderQueue(const scene::Pass *pass, const scene::SubModel *subModel, const scene::Model *model, uint lightPassIdx);
+2 -2
View File
@@ -291,8 +291,8 @@ export function load (app: Application) {
continue;
}
const printUnableResolve = (iSegment: number) => {
_context.logger.error(`Failed to resolve ${segments[iSegment]} in ${match[0]} `
+ `referenced in ${getLocation()}`);
_context.logger.warn(`Failed to resolve ${segments[iSegment]} in ${match[0]} `
+ `referenced in ${!node ? '<unknown-location>' : node.getText()}`);
};
let targetReflection = resolveUnqualifiedReflection(segments[0]);
if (!targetReflection) {
+27 -2
View File
@@ -35,12 +35,37 @@ test('parse-richtext', () => {
expect(htmlAttrArray[0].style.imageHeight).toStrictEqual(89);
expect(htmlAttrArray[0].style.imageAlign).toStrictEqual('top');
expect(htmlAttrArray[1].text).toStrictEqual(' 前面有三个空格,这是一段文本');
attribute = "<img src='1 23'/>";
attribute = "<img src= '12 3' width = 80 height= 89 align =top click='onClick' />文本中有两组单引号,但是图片名仅包含在第一组单引号内";
htmlAttrArray = htmlTextParser.parse(attribute);
expect(htmlAttrArray.length).toStrictEqual(2);
expect(htmlAttrArray[0].style.src).toStrictEqual('12 3');
expect(htmlAttrArray[0].style.imageWidth).toStrictEqual(80);
expect(htmlAttrArray[0].style.imageHeight).toStrictEqual(89);
expect(htmlAttrArray[0].style.imageAlign).toStrictEqual('top');
expect(htmlAttrArray[0].style.event.click).toStrictEqual('onClick');
expect(htmlAttrArray[1].text).toStrictEqual('文本中有两组单引号,但是图片名仅包含在第一组单引号内');
attribute = "<img src=\"12 3\" width = 80 height= 89 align =top click='onClick' />文本中有一组单引号和一组双引号,但是图片名仅包含在前面这组双引号内";
htmlAttrArray = htmlTextParser.parse(attribute);
expect(htmlAttrArray.length).toStrictEqual(2);
expect(htmlAttrArray[0].style.src).toStrictEqual('12 3');
expect(htmlAttrArray[0].style.imageWidth).toStrictEqual(80);
expect(htmlAttrArray[0].style.imageHeight).toStrictEqual(89);
expect(htmlAttrArray[0].style.imageAlign).toStrictEqual('top');
expect(htmlAttrArray[0].style.event.click).toStrictEqual('onClick');
expect(htmlAttrArray[1].text).toStrictEqual('文本中有一组单引号和一组双引号,但是图片名仅包含在前面这组双引号内');
attribute = "<img src = '1 23'/>";
htmlAttrArray = htmlTextParser.parse(attribute);
expect(htmlAttrArray.length).toStrictEqual(1);
expect(htmlAttrArray[0].style.src).toStrictEqual('1 23');
attribute = "<img src = click = 'onclick' />文本中没有图片名,无法生成style对象";
htmlAttrArray = htmlTextParser.parse(attribute);
expect(htmlAttrArray.length).toStrictEqual(1);
expect(htmlAttrArray[0].text).toStrictEqual('文本中没有图片名,无法生成style对象');
// following tests are exceptional writing
attribute = "<img ='1 23'/>"; // 'src' missing