mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
@@ -109,12 +109,15 @@ export class RenderingSubMesh {
|
||||
|
||||
private _iaInfo: InputAssemblerInfo;
|
||||
|
||||
private _isOwnerOfIndexBuffer = true;
|
||||
|
||||
private _init () {
|
||||
}
|
||||
|
||||
constructor (
|
||||
vertexBuffers: Buffer[], attributes: Attribute[], primitiveMode: PrimitiveMode,
|
||||
indexBuffer: Buffer | null = null, indirectBuffer: Buffer | null = null,
|
||||
isOwnerOfIndexBuffer = true,
|
||||
) {
|
||||
this._attributes = attributes;
|
||||
this._vertexBuffers = vertexBuffers;
|
||||
@@ -122,6 +125,7 @@ export class RenderingSubMesh {
|
||||
this._indirectBuffer = indirectBuffer;
|
||||
this._primitiveMode = primitiveMode;
|
||||
this._iaInfo = new InputAssemblerInfo(attributes, vertexBuffers, indexBuffer, indirectBuffer);
|
||||
this._isOwnerOfIndexBuffer = isOwnerOfIndexBuffer;
|
||||
this._init();
|
||||
}
|
||||
|
||||
@@ -306,7 +310,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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 || {};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -393,7 +393,7 @@ export class TerrainBlock {
|
||||
];
|
||||
|
||||
this._renderable._meshData = new RenderingSubMesh([vertexBuffer], gfxAttributes,
|
||||
PrimitiveMode.TRIANGLE_LIST, this._terrain._getSharedIndexBuffer());
|
||||
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) {
|
||||
|
||||
@@ -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
|
||||
},
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user