@babylonjs/core 7.46.0 → 7.47.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cameras/arcRotateCamera.d.ts +13 -0
- package/Cameras/arcRotateCamera.js +28 -12
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheSampler.js +8 -2
- package/Engines/WebGPU/webgpuCacheSampler.js.map +1 -1
- package/Engines/WebGPU/webgpuSnapshotRendering.d.ts +2 -0
- package/Engines/WebGPU/webgpuSnapshotRendering.js +22 -6
- package/Engines/WebGPU/webgpuSnapshotRendering.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/engine.d.ts +1 -1
- package/Engines/engine.js.map +1 -1
- package/Engines/thinEngine.functions.d.ts +1 -0
- package/Engines/thinEngine.functions.js +1 -1
- package/Engines/thinEngine.functions.js.map +1 -1
- package/Engines/thinEngine.js +2 -1
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +2 -1
- package/Engines/webgpuEngine.js.map +1 -1
- package/Loading/loadingScreen.js +2 -2
- package/Loading/loadingScreen.js.map +1 -1
- package/Materials/effect.d.ts +6 -1
- package/Materials/effect.functions.d.ts +5 -0
- package/Materials/effect.functions.js +6 -2
- package/Materials/effect.functions.js.map +1 -1
- package/Materials/effect.js +3 -1
- package/Materials/effect.js.map +1 -1
- package/Materials/effect.webgl.functions.js +1 -0
- package/Materials/effect.webgl.functions.js.map +1 -1
- package/Materials/materialHelper.functions.js +1 -1
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Meshes/Node/Blocks/Textures/geometryTextureBlock.d.ts +1 -1
- package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js.map +1 -1
- package/Meshes/mesh.d.ts +2 -2
- package/Meshes/mesh.js.map +1 -1
- package/Misc/greasedLineTools.d.ts +1 -1
- package/Misc/greasedLineTools.js.map +1 -1
- package/Misc/snapshotRenderingHelper.d.ts +12 -0
- package/Misc/snapshotRenderingHelper.js +74 -20
- package/Misc/snapshotRenderingHelper.js.map +1 -1
- package/Particles/pointsCloudSystem.d.ts +3 -3
- package/Particles/pointsCloudSystem.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.d.ts +2 -5
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/package.json +1 -1
|
@@ -192,7 +192,7 @@ export declare class GreasedLineTools {
|
|
|
192
192
|
* @param colors Arrray of Color3
|
|
193
193
|
* @returns Uin8Array of colors [r, g, b, a, r, g, b, a, ...]
|
|
194
194
|
*/
|
|
195
|
-
static Color3toRGBAUint8(colors: Color3[]): Uint8Array
|
|
195
|
+
static Color3toRGBAUint8(colors: Color3[]): Uint8Array;
|
|
196
196
|
/**
|
|
197
197
|
* Creates a RawTexture from an RGBA color array and sets it on the plugin material instance.
|
|
198
198
|
* @param name name of the texture
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"greasedLineTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/greasedLineTools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAItE,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAE9D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,sDAAsD,CAAC;AAEnG;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACzB;;;;;OAKG;IACI,MAAM,CAAC,aAAa,CAAC,MAAyB,EAAE,OAAkC;QACrF,IAAI,MAAM,CAAC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,MAA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;QACnF,CAAC;QACD,MAAM,WAAW,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC/D,MAAM,aAAa,GAAG,IAAI,UAAU,CAAC,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,kBAAkB,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;QAChI,aAAa,CAAC,IAAI,GAAG,IAAI,CAAC;QAC1B,OAAO,aAAa,CAAC;IACzB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,yBAAyB,CAAC,KAAY;QAChD,IAAI,CAAC,2BAA2B,CAAC,kBAAkB,EAAE,CAAC;YAClD,MAAM,WAAW,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;YACtC,2BAA2B,CAAC,kBAAkB,GAAG,IAAI,UAAU,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,kBAAkB,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC;YAC/J,2BAA2B,CAAC,kBAAkB,CAAC,IAAI,GAAG,uBAAuB,CAAC;QAClF,CAAC;QAED,OAAO,2BAA2B,CAAC,kBAAkB,CAAC;IAC1D,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,yBAAyB;QACnC,2BAA2B,CAAC,kBAAkB,EAAE,OAAO,EAAE,CAAC;QAC1D,2BAA2B,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAC1D,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,eAAe,CAAC,IAAc;QACxC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC;CACJ","sourcesContent":["import { Curve3 } from \"../Maths/math.path\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { TmpVectors, Vector3 } from \"../Maths/math.vector\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { IFontData } from \"../Meshes/Builders/textBuilder\";\r\nimport { CreateTextShapePaths } from \"../Meshes/Builders/textBuilder\";\r\nimport type { FloatArray, IndicesArray } from \"../types\";\r\nimport type { GreasedLinePoints, GreasedLinePointsOptions } from \"../Meshes/GreasedLine/greasedLineBaseMesh\";\r\nimport type { Color3 } from \"../Maths/math.color\";\r\nimport { RawTexture } from \"../Materials/Textures/rawTexture\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Engine } from \"../Engines/engine\";\r\nimport { GreasedLineMaterialDefaults } from \"../Materials/GreasedLine/greasedLineMaterialDefaults\";\r\n\r\n/**\r\n * Tool functions for GreasedLine\r\n */\r\nexport class GreasedLineTools {\r\n /**\r\n * Converts GreasedLinePoints to number[][]\r\n * @param points GreasedLinePoints\r\n * @param options GreasedLineToolsConvertPointsOptions\r\n * @returns number[][] with x, y, z coordinates of the points, like [[x, y, z, x, y, z, ...], [x, y, z, ...]]\r\n */\r\n public static ConvertPoints(points: GreasedLinePoints, options?: GreasedLinePointsOptions): number[][] {\r\n if (points.length && Array.isArray(points) && typeof points[0] === \"number\") {\r\n return [<number[]>points];\r\n } else if (points.length && Array.isArray(points[0]) && typeof points[0][0] === \"number\") {\r\n return <number[][]>points;\r\n } else if (points.length && !Array.isArray(points[0]) && points[0] instanceof Vector3) {\r\n const positions: number[] = [];\r\n for (let j = 0; j < points.length; j++) {\r\n const p = points[j] as Vector3;\r\n positions.push(p.x, p.y, p.z);\r\n }\r\n return [positions];\r\n } else if (points.length > 0 && Array.isArray(points[0]) && points[0].length > 0 && points[0][0] instanceof Vector3) {\r\n const positions: number[][] = [];\r\n const vectorPoints = points as Vector3[][];\r\n vectorPoints.forEach((p) => {\r\n positions.push(p.flatMap((p2) => [p2.x, p2.y, p2.z]));\r\n });\r\n return positions;\r\n } else if (points instanceof Float32Array) {\r\n if (options?.floatArrayStride) {\r\n const positions: number[][] = [];\r\n const stride = options.floatArrayStride * 3;\r\n for (let i = 0; i < points.length; i += stride) {\r\n const linePoints = new Array(stride); // Pre-allocate memory for the line\r\n for (let j = 0; j < stride; j++) {\r\n linePoints[j] = points[i + j];\r\n }\r\n positions.push(linePoints);\r\n }\r\n return positions;\r\n } else {\r\n return [Array.from(points)];\r\n }\r\n } else if (points.length && points[0] instanceof Float32Array) {\r\n const positions: number[][] = [];\r\n points.forEach((p) => {\r\n positions.push(Array.from(p as Float32Array));\r\n });\r\n\r\n return positions;\r\n }\r\n\r\n return [];\r\n }\r\n\r\n /**\r\n * Omit zero length lines predicate for the MeshesToLines function\r\n * @param p1 point1 position of the face\r\n * @param p2 point2 position of the face\r\n * @param p3 point3 position of the face\r\n * @returns original points or null if any edge length is zero\r\n */\r\n public static OmitZeroLengthPredicate(p1: Vector3, p2: Vector3, p3: Vector3) {\r\n const fileredPoints = [];\r\n // edge1\r\n if (p2.subtract(p1).lengthSquared() > 0) {\r\n fileredPoints.push([p1, p2]);\r\n }\r\n // edge2\r\n if (p3.subtract(p2).lengthSquared() > 0) {\r\n fileredPoints.push([p2, p3]);\r\n }\r\n // edge3\r\n if (p1.subtract(p3).lengthSquared() > 0) {\r\n fileredPoints.push([p3, p1]);\r\n }\r\n return fileredPoints.length === 0 ? null : fileredPoints;\r\n }\r\n\r\n /**\r\n * Omit duplicate lines predicate for the MeshesToLines function\r\n * @param p1 point1 position of the face\r\n * @param p2 point2 position of the face\r\n * @param p3 point3 position of the face\r\n * @param points array of points to search in\r\n * @returns original points or null if any edge length is zero\r\n */\r\n public static OmitDuplicatesPredicate(p1: Vector3, p2: Vector3, p3: Vector3, points: Vector3[][]) {\r\n const fileredPoints = [];\r\n // edge1\r\n if (!GreasedLineTools._SearchInPoints(p1, p2, points)) {\r\n fileredPoints.push([p1, p2]);\r\n }\r\n // edge2\r\n if (!GreasedLineTools._SearchInPoints(p2, p3, points)) {\r\n fileredPoints.push([p2, p3]);\r\n }\r\n // edge3\r\n if (!GreasedLineTools._SearchInPoints(p3, p1, points)) {\r\n fileredPoints.push([p3, p1]);\r\n }\r\n return fileredPoints.length === 0 ? null : fileredPoints;\r\n }\r\n\r\n private static _SearchInPoints(p1: Vector3, p2: Vector3, points: Vector3[][]) {\r\n for (const ps of points) {\r\n for (let i = 0; i < ps.length; i++) {\r\n if (ps[i]?.equals(p1)) {\r\n // find the first point\r\n // if it has a sibling of p2 the line already exists\r\n if (ps[i + 1]?.equals(p2) || ps[i - 1]?.equals(p2)) {\r\n return true;\r\n }\r\n }\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Gets mesh triangles as line positions\r\n * @param meshes array of meshes\r\n * @param predicate predicate function which decides whether to include the mesh triangle/face in the ouput\r\n * @returns array of arrays of points\r\n */\r\n public static MeshesToLines(\r\n meshes: AbstractMesh[],\r\n predicate?: (\r\n p1: Vector3,\r\n p2: Vector3,\r\n p3: Vector3,\r\n points: Vector3[][],\r\n indiceIndex: number,\r\n vertexIndex: number,\r\n mesh: AbstractMesh,\r\n meshIndex: number,\r\n vertices: FloatArray,\r\n indices: IndicesArray\r\n ) => Vector3[][]\r\n ) {\r\n const points: Vector3[][] = [];\r\n\r\n meshes.forEach((m, meshIndex) => {\r\n const vertices = m.getVerticesData(VertexBuffer.PositionKind);\r\n const indices = m.getIndices();\r\n if (vertices && indices) {\r\n for (let i = 0, ii = 0; i < indices.length; i++) {\r\n const vi1 = indices[ii++] * 3;\r\n const vi2 = indices[ii++] * 3;\r\n const vi3 = indices[ii++] * 3;\r\n\r\n const p1 = new Vector3(vertices[vi1], vertices[vi1 + 1], vertices[vi1 + 2]);\r\n const p2 = new Vector3(vertices[vi2], vertices[vi2 + 1], vertices[vi2 + 2]);\r\n const p3 = new Vector3(vertices[vi3], vertices[vi3 + 1], vertices[vi3 + 2]);\r\n\r\n if (predicate) {\r\n const pointsFromPredicate = predicate(p1, p2, p3, points, i, vi1, m, meshIndex, vertices, indices);\r\n if (pointsFromPredicate) {\r\n for (const p of pointsFromPredicate) {\r\n points.push(p);\r\n }\r\n }\r\n } else {\r\n points.push([p1, p2], [p2, p3], [p3, p1]);\r\n }\r\n }\r\n }\r\n });\r\n\r\n return points;\r\n }\r\n\r\n /**\r\n * Converts number coordinates to Vector3s\r\n * @param points number array of x, y, z, x, y z, ... coordinates\r\n * @returns Vector3 array\r\n */\r\n public static ToVector3Array(points: number[] | number[][]) {\r\n if (Array.isArray(points[0])) {\r\n const array: Vector3[][] = [];\r\n const inputArray = points as number[][];\r\n for (const subInputArray of inputArray) {\r\n const subArray: Vector3[] = [];\r\n for (let i = 0; i < subInputArray.length; i += 3) {\r\n subArray.push(new Vector3(subInputArray[i], subInputArray[i + 1], subInputArray[i + 2]));\r\n }\r\n array.push(subArray);\r\n }\r\n return array;\r\n }\r\n\r\n const inputArray = points as number[];\r\n const array: Vector3[] = [];\r\n for (let i = 0; i < inputArray.length; i += 3) {\r\n array.push(new Vector3(inputArray[i], inputArray[i + 1], inputArray[i + 2]));\r\n }\r\n return array;\r\n }\r\n\r\n /**\r\n * Gets a number array from a Vector3 array.\r\n * You can you for example to convert your Vector3[] offsets to the required number[] for the offsets option.\r\n * @param points Vector3 array\r\n * @returns an array of x, y, z coordinates as numbers [x, y, z, x, y, z, x, y, z, ....]\r\n */\r\n public static ToNumberArray(points: Vector3[]) {\r\n return points.flatMap((v) => [v.x, v.y, v.z]);\r\n }\r\n\r\n /**\r\n * Calculates the sum of points of every line and the number of points in each line.\r\n * This function is useful when you are drawing multiple lines in one mesh and you want\r\n * to know the counts. For example for creating an offsets table.\r\n * @param points point array\r\n * @returns points count info\r\n */\r\n public static GetPointsCountInfo(points: number[][]): { total: number; counts: number[] } {\r\n const counts = new Array(points.length);\r\n let total = 0;\r\n for (let n = points.length; n--; ) {\r\n counts[n] = points[n].length / 3;\r\n total += counts[n];\r\n }\r\n return { total, counts };\r\n }\r\n\r\n /**\r\n * Gets the length of the line counting all it's segments length\r\n * @param data array of line points\r\n * @returns length of the line\r\n */\r\n public static GetLineLength(data: Vector3[] | number[]): number {\r\n if (data.length === 0) {\r\n return 0;\r\n }\r\n\r\n let points: Vector3[];\r\n if (typeof data[0] === \"number\") {\r\n points = GreasedLineTools.ToVector3Array(<number[]>data) as Vector3[];\r\n } else {\r\n points = data as Vector3[];\r\n }\r\n\r\n const tmp = TmpVectors.Vector3[0];\r\n let length = 0;\r\n for (let index = 0; index < points.length - 1; index++) {\r\n const point1 = points[index];\r\n const point2 = points[index + 1];\r\n length += point2.subtractToRef(point1, tmp).length();\r\n }\r\n return length;\r\n }\r\n\r\n /**\r\n * Gets the the length from the beginning to each point of the line as array.\r\n * @param data array of line points\r\n * @returns length array of the line\r\n */\r\n public static GetLineLengthArray(data: number[]): Float32Array {\r\n const out = new Float32Array(data.length / 3);\r\n let length = 0;\r\n for (let index = 0, pointsLength = data.length / 3 - 1; index < pointsLength; index++) {\r\n let x = data[index * 3 + 0];\r\n let y = data[index * 3 + 1];\r\n let z = data[index * 3 + 2];\r\n x -= data[index * 3 + 3];\r\n y -= data[index * 3 + 4];\r\n z -= data[index * 3 + 5];\r\n const currentLength = Math.sqrt(x * x + y * y + z * z);\r\n length += currentLength;\r\n out[index + 1] = length;\r\n }\r\n return out;\r\n }\r\n\r\n /**\r\n * Divides a segment into smaller segments.\r\n * A segment is a part of the line between it's two points.\r\n * @param point1 first point of the line\r\n * @param point2 second point of the line\r\n * @param segmentCount number of segments we want to have in the divided line\r\n * @returns\r\n */\r\n public static SegmentizeSegmentByCount(point1: Vector3, point2: Vector3, segmentCount: number): Vector3[] {\r\n const dividedLinePoints: Vector3[] = [];\r\n const diff = point2.subtract(point1);\r\n const divisor = TmpVectors.Vector3[0];\r\n divisor.setAll(segmentCount);\r\n const segmentVector = TmpVectors.Vector3[1];\r\n diff.divideToRef(divisor, segmentVector);\r\n\r\n let nextPoint = point1.clone();\r\n dividedLinePoints.push(nextPoint);\r\n for (let index = 0; index < segmentCount; index++) {\r\n nextPoint = nextPoint.clone();\r\n dividedLinePoints.push(nextPoint.addInPlace(segmentVector));\r\n }\r\n\r\n return dividedLinePoints;\r\n }\r\n\r\n /**\r\n * Divides a line into segments.\r\n * A segment is a part of the line between it's two points.\r\n * @param what line points\r\n * @param segmentLength length of each segment of the resulting line (distance between two line points)\r\n * @returns line point\r\n */\r\n public static SegmentizeLineBySegmentLength(what: Vector3[] | number[] | { point1: Vector3; point2: Vector3; length: number }[], segmentLength: number): Vector3[] {\r\n const subLines =\r\n what[0] instanceof Vector3\r\n ? GreasedLineTools.GetLineSegments(what as Vector3[])\r\n : typeof what[0] === \"number\"\r\n ? GreasedLineTools.GetLineSegments(GreasedLineTools.ToVector3Array(what as number[]) as Vector3[])\r\n : (what as { point1: Vector3; point2: Vector3; length: number }[]);\r\n const points: Vector3[] = [];\r\n subLines.forEach((s) => {\r\n if (s.length > segmentLength) {\r\n const segments = GreasedLineTools.SegmentizeSegmentByCount(s.point1, s.point2, Math.ceil(s.length / segmentLength));\r\n segments.forEach((seg) => {\r\n points.push(seg);\r\n });\r\n } else {\r\n points.push(s.point1);\r\n points.push(s.point2);\r\n }\r\n });\r\n return points;\r\n }\r\n\r\n /**\r\n * Divides a line into segments.\r\n * A segment is a part of the line between it's two points.\r\n * @param what line points\r\n * @param segmentCount number of segments\r\n * @returns line point\r\n */\r\n public static SegmentizeLineBySegmentCount(what: Vector3[] | number[], segmentCount: number): Vector3[] {\r\n const points = <Vector3[]>(typeof what[0] === \"number\" ? GreasedLineTools.ToVector3Array(<number[]>what) : what);\r\n const segmentLength = GreasedLineTools.GetLineLength(points) / segmentCount;\r\n return GreasedLineTools.SegmentizeLineBySegmentLength(points, segmentLength);\r\n }\r\n /**\r\n * Gets line segments.\r\n * A segment is a part of the line between it's two points.\r\n * @param points line points\r\n * @returns segments information of the line segment including starting point, ending point and the distance between them\r\n */\r\n public static GetLineSegments(points: Vector3[]): { point1: Vector3; point2: Vector3; length: number }[] {\r\n const segments = [];\r\n for (let index = 0; index < points.length - 1; index++) {\r\n const point1 = points[index];\r\n const point2 = points[index + 1];\r\n const length = point2.subtract(point1).length();\r\n segments.push({ point1, point2, length });\r\n }\r\n\r\n return segments;\r\n }\r\n\r\n /**\r\n * Gets the minimum and the maximum length of a line segment in the line.\r\n * A segment is a part of the line between it's two points.\r\n * @param points line points\r\n * @returns\r\n */\r\n public static GetMinMaxSegmentLength(points: Vector3[]): { min: number; max: number } {\r\n const subLines = GreasedLineTools.GetLineSegments(points);\r\n const sorted = subLines.sort((s) => s.length);\r\n return {\r\n min: sorted[0].length,\r\n max: sorted[sorted.length - 1].length,\r\n };\r\n }\r\n\r\n /**\r\n * Finds the last visible position in world space of the line according to the visibility parameter\r\n * @param lineSegments segments of the line\r\n * @param lineLength total length of the line\r\n * @param visbility normalized value of visibility\r\n * @param localSpace if true the result will be in local space (default is false)\r\n * @returns world space coordinate of the last visible piece of the line\r\n */\r\n public static GetPositionOnLineByVisibility(lineSegments: { point1: Vector3; point2: Vector3; length: number }[], lineLength: number, visbility: number, localSpace = false) {\r\n const lengthVisibilityRatio = lineLength * visbility;\r\n let sumSegmentLengths = 0;\r\n let segmentIndex = 0;\r\n\r\n const lineSegmentsLength = lineSegments.length;\r\n for (let i = 0; i < lineSegmentsLength; i++) {\r\n if (lengthVisibilityRatio <= sumSegmentLengths + lineSegments[i].length) {\r\n segmentIndex = i;\r\n break;\r\n }\r\n sumSegmentLengths += lineSegments[i].length;\r\n }\r\n\r\n const s = (lengthVisibilityRatio - sumSegmentLengths) / lineSegments[segmentIndex].length;\r\n\r\n lineSegments[segmentIndex].point2.subtractToRef(lineSegments[segmentIndex].point1, TmpVectors.Vector3[0]);\r\n TmpVectors.Vector3[1] = TmpVectors.Vector3[0].multiplyByFloats(s, s, s);\r\n if (!localSpace) {\r\n TmpVectors.Vector3[1].addInPlace(lineSegments[segmentIndex].point1);\r\n }\r\n\r\n return TmpVectors.Vector3[1].clone();\r\n }\r\n\r\n /**\r\n * Creates lines in a shape of circle/arc.\r\n * A segment is a part of the line between it's two points.\r\n * @param radiusX radiusX of the circle\r\n * @param segments number of segments in the circle\r\n * @param z z coordinate of the points. Defaults to 0.\r\n * @param radiusY radiusY of the circle - you can draw an oval if using different values\r\n * @param segmentAngle angle offset of the segments. Defaults to Math.PI * 2 / segments. Change this value to draw a part of the circle.\r\n * @returns line points\r\n */\r\n public static GetCircleLinePoints(radiusX: number, segments: number, z = 0, radiusY = radiusX, segmentAngle = (Math.PI * 2) / segments) {\r\n const points: Vector3[] = [];\r\n for (let i = 0; i <= segments; i++) {\r\n points.push(new Vector3(Math.cos(i * segmentAngle) * radiusX, Math.sin(i * segmentAngle) * radiusY, z));\r\n }\r\n return points;\r\n }\r\n\r\n /**\r\n * Gets line points in a shape of a bezier curve\r\n * @param p0 bezier point0\r\n * @param p1 bezier point1\r\n * @param p2 bezier point2\r\n * @param segments number of segments in the curve\r\n * @returns\r\n */\r\n public static GetBezierLinePoints(p0: Vector3, p1: Vector3, p2: Vector3, segments: number) {\r\n return Curve3.CreateQuadraticBezier(p0, p1, p2, segments)\r\n .getPoints()\r\n .flatMap((v) => [v.x, v.y, v.z]);\r\n }\r\n\r\n /**\r\n *\r\n * @param position position of the arrow cap (mainly you want to create a triangle, set widthUp and widthDown to the same value and omit widthStartUp and widthStartDown)\r\n * @param direction direction which the arrow points to\r\n * @param length length (size) of the arrow cap itself\r\n * @param widthUp the arrow width above the line\r\n * @param widthDown the arrow width belove the line\r\n * @param widthStartUp the arrow width at the start of the arrow above the line. In most scenarios this is 0.\r\n * @param widthStartDown the arrow width at the start of the arrow below the line. In most scenarios this is 0.\r\n * @returns\r\n */\r\n public static GetArrowCap(position: Vector3, direction: Vector3, length: number, widthUp: number, widthDown: number, widthStartUp = 0, widthStartDown = 0) {\r\n const points = [position.clone(), position.add(direction.multiplyByFloats(length, length, length))];\r\n const widths = [widthUp, widthDown, widthStartUp, widthStartDown];\r\n\r\n return {\r\n points,\r\n widths,\r\n };\r\n }\r\n\r\n /**\r\n * Gets 3D positions of points from a text and font\r\n * @param text Text\r\n * @param size Size of the font\r\n * @param resolution Resolution of the font\r\n * @param fontData defines the font data (can be generated with http://gero3.github.io/facetype.js/)\r\n * @param z z coordinate\r\n * @param includeInner include the inner parts of the font in the result. Default true. If false, only the outlines will be returned.\r\n * @returns number[][] of 3D positions\r\n */\r\n public static GetPointsFromText(text: string, size: number, resolution: number, fontData: IFontData, z = 0, includeInner = true) {\r\n const allPoints = [];\r\n const shapePaths = CreateTextShapePaths(text, size, resolution, fontData);\r\n\r\n for (const sp of shapePaths) {\r\n for (const p of sp.paths) {\r\n const points = [];\r\n const points2d = p.getPoints();\r\n for (const p2d of points2d) {\r\n points.push(p2d.x, p2d.y, z);\r\n }\r\n allPoints.push(points);\r\n }\r\n\r\n if (includeInner) {\r\n for (const h of sp.holes) {\r\n const holes = [];\r\n const points2d = h.getPoints();\r\n for (const p2d of points2d) {\r\n holes.push(p2d.x, p2d.y, z);\r\n }\r\n allPoints.push(holes);\r\n }\r\n }\r\n }\r\n\r\n return allPoints;\r\n }\r\n\r\n /**\r\n * Converts an array of Color3 to Uint8Array\r\n * @param colors Arrray of Color3\r\n * @returns Uin8Array of colors [r, g, b, a, r, g, b, a, ...]\r\n */\r\n public static Color3toRGBAUint8(colors: Color3[]) {\r\n const colorTable: Uint8Array = new Uint8Array(colors.length * 4);\r\n for (let i = 0, j = 0; i < colors.length; i++) {\r\n colorTable[j++] = colors[i].r * 255;\r\n colorTable[j++] = colors[i].g * 255;\r\n colorTable[j++] = colors[i].b * 255;\r\n colorTable[j++] = 255;\r\n }\r\n\r\n return colorTable;\r\n }\r\n\r\n /**\r\n * Creates a RawTexture from an RGBA color array and sets it on the plugin material instance.\r\n * @param name name of the texture\r\n * @param colors Uint8Array of colors\r\n * @param colorsSampling sampling mode of the created texture\r\n * @param scene Scene\r\n * @returns the colors texture\r\n */\r\n public static CreateColorsTexture(name: string, colors: Color3[], colorsSampling: number, scene: Scene) {\r\n const maxTextureSize = scene.getEngine().getCaps().maxTextureSize ?? 1;\r\n const width = colors.length > maxTextureSize ? maxTextureSize : colors.length;\r\n const height = Math.ceil(colors.length / maxTextureSize);\r\n if (height > 1) {\r\n colors = [...colors, ...Array(width * height - colors.length).fill(colors[0])];\r\n }\r\n const colorsArray = GreasedLineTools.Color3toRGBAUint8(colors);\r\n const colorsTexture = new RawTexture(colorsArray, width, height, Engine.TEXTUREFORMAT_RGBA, scene, false, true, colorsSampling);\r\n colorsTexture.name = name;\r\n return colorsTexture;\r\n }\r\n\r\n /**\r\n * A minimum size texture for the colors sampler2D when there is no colors texture defined yet.\r\n * For fast switching using the useColors property without the need to use defines.\r\n * @param scene Scene\r\n * @returns empty colors texture\r\n */\r\n public static PrepareEmptyColorsTexture(scene: Scene) {\r\n if (!GreasedLineMaterialDefaults.EmptyColorsTexture) {\r\n const colorsArray = new Uint8Array(4);\r\n GreasedLineMaterialDefaults.EmptyColorsTexture = new RawTexture(colorsArray, 1, 1, Engine.TEXTUREFORMAT_RGBA, scene, false, false, RawTexture.NEAREST_NEAREST);\r\n GreasedLineMaterialDefaults.EmptyColorsTexture.name = \"grlEmptyColorsTexture\";\r\n }\r\n\r\n return GreasedLineMaterialDefaults.EmptyColorsTexture;\r\n }\r\n\r\n /**\r\n * Diposes the shared empty colors texture\r\n */\r\n public static DisposeEmptyColorsTexture() {\r\n GreasedLineMaterialDefaults.EmptyColorsTexture?.dispose();\r\n GreasedLineMaterialDefaults.EmptyColorsTexture = null;\r\n }\r\n\r\n /**\r\n * Converts boolean to number.\r\n * @param bool the bool value\r\n * @returns 1 if true, 0 if false.\r\n */\r\n public static BooleanToNumber(bool?: boolean) {\r\n return bool ? 1 : 0;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"greasedLineTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/greasedLineTools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAA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CAAC,kBAAkB,EAAE,OAAO,EAAE,CAAC;QAC1D,2BAA2B,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAC1D,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,eAAe,CAAC,IAAc;QACxC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC;CACJ","sourcesContent":["import { Curve3 } from \"../Maths/math.path\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { TmpVectors, Vector3 } from \"../Maths/math.vector\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { IFontData } from \"../Meshes/Builders/textBuilder\";\r\nimport { CreateTextShapePaths } from \"../Meshes/Builders/textBuilder\";\r\nimport type { FloatArray, IndicesArray } from \"../types\";\r\nimport type { GreasedLinePoints, GreasedLinePointsOptions } from \"../Meshes/GreasedLine/greasedLineBaseMesh\";\r\nimport type { Color3 } from \"../Maths/math.color\";\r\nimport { RawTexture } from \"../Materials/Textures/rawTexture\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Engine } from \"../Engines/engine\";\r\nimport { GreasedLineMaterialDefaults } from \"../Materials/GreasedLine/greasedLineMaterialDefaults\";\r\n\r\n/**\r\n * Tool functions for GreasedLine\r\n */\r\nexport class GreasedLineTools {\r\n /**\r\n * Converts GreasedLinePoints to number[][]\r\n * @param points GreasedLinePoints\r\n * @param options GreasedLineToolsConvertPointsOptions\r\n * @returns number[][] with x, y, z coordinates of the points, like [[x, y, z, x, y, z, ...], [x, y, z, ...]]\r\n */\r\n public static ConvertPoints(points: GreasedLinePoints, options?: GreasedLinePointsOptions): number[][] {\r\n if (points.length && Array.isArray(points) && typeof points[0] === \"number\") {\r\n return [<number[]>points];\r\n } else if (points.length && Array.isArray(points[0]) && typeof points[0][0] === \"number\") {\r\n return <number[][]>points;\r\n } else if (points.length && !Array.isArray(points[0]) && points[0] instanceof Vector3) {\r\n const positions: number[] = [];\r\n for (let j = 0; j < points.length; j++) {\r\n const p = points[j] as Vector3;\r\n positions.push(p.x, p.y, p.z);\r\n }\r\n return [positions];\r\n } else if (points.length > 0 && Array.isArray(points[0]) && points[0].length > 0 && points[0][0] instanceof Vector3) {\r\n const positions: number[][] = [];\r\n const vectorPoints = points as Vector3[][];\r\n vectorPoints.forEach((p) => {\r\n positions.push(p.flatMap((p2) => [p2.x, p2.y, p2.z]));\r\n });\r\n return positions;\r\n } else if (points instanceof Float32Array) {\r\n if (options?.floatArrayStride) {\r\n const positions: number[][] = [];\r\n const stride = options.floatArrayStride * 3;\r\n for (let i = 0; i < points.length; i += stride) {\r\n const linePoints = new Array(stride); // Pre-allocate memory for the line\r\n for (let j = 0; j < stride; j++) {\r\n linePoints[j] = points[i + j];\r\n }\r\n positions.push(linePoints);\r\n }\r\n return positions;\r\n } else {\r\n return [Array.from(points)];\r\n }\r\n } else if (points.length && points[0] instanceof Float32Array) {\r\n const positions: number[][] = [];\r\n points.forEach((p) => {\r\n positions.push(Array.from(p as Float32Array));\r\n });\r\n\r\n return positions;\r\n }\r\n\r\n return [];\r\n }\r\n\r\n /**\r\n * Omit zero length lines predicate for the MeshesToLines function\r\n * @param p1 point1 position of the face\r\n * @param p2 point2 position of the face\r\n * @param p3 point3 position of the face\r\n * @returns original points or null if any edge length is zero\r\n */\r\n public static OmitZeroLengthPredicate(p1: Vector3, p2: Vector3, p3: Vector3) {\r\n const fileredPoints = [];\r\n // edge1\r\n if (p2.subtract(p1).lengthSquared() > 0) {\r\n fileredPoints.push([p1, p2]);\r\n }\r\n // edge2\r\n if (p3.subtract(p2).lengthSquared() > 0) {\r\n fileredPoints.push([p2, p3]);\r\n }\r\n // edge3\r\n if (p1.subtract(p3).lengthSquared() > 0) {\r\n fileredPoints.push([p3, p1]);\r\n }\r\n return fileredPoints.length === 0 ? null : fileredPoints;\r\n }\r\n\r\n /**\r\n * Omit duplicate lines predicate for the MeshesToLines function\r\n * @param p1 point1 position of the face\r\n * @param p2 point2 position of the face\r\n * @param p3 point3 position of the face\r\n * @param points array of points to search in\r\n * @returns original points or null if any edge length is zero\r\n */\r\n public static OmitDuplicatesPredicate(p1: Vector3, p2: Vector3, p3: Vector3, points: Vector3[][]) {\r\n const fileredPoints = [];\r\n // edge1\r\n if (!GreasedLineTools._SearchInPoints(p1, p2, points)) {\r\n fileredPoints.push([p1, p2]);\r\n }\r\n // edge2\r\n if (!GreasedLineTools._SearchInPoints(p2, p3, points)) {\r\n fileredPoints.push([p2, p3]);\r\n }\r\n // edge3\r\n if (!GreasedLineTools._SearchInPoints(p3, p1, points)) {\r\n fileredPoints.push([p3, p1]);\r\n }\r\n return fileredPoints.length === 0 ? null : fileredPoints;\r\n }\r\n\r\n private static _SearchInPoints(p1: Vector3, p2: Vector3, points: Vector3[][]) {\r\n for (const ps of points) {\r\n for (let i = 0; i < ps.length; i++) {\r\n if (ps[i]?.equals(p1)) {\r\n // find the first point\r\n // if it has a sibling of p2 the line already exists\r\n if (ps[i + 1]?.equals(p2) || ps[i - 1]?.equals(p2)) {\r\n return true;\r\n }\r\n }\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Gets mesh triangles as line positions\r\n * @param meshes array of meshes\r\n * @param predicate predicate function which decides whether to include the mesh triangle/face in the ouput\r\n * @returns array of arrays of points\r\n */\r\n public static MeshesToLines(\r\n meshes: AbstractMesh[],\r\n predicate?: (\r\n p1: Vector3,\r\n p2: Vector3,\r\n p3: Vector3,\r\n points: Vector3[][],\r\n indiceIndex: number,\r\n vertexIndex: number,\r\n mesh: AbstractMesh,\r\n meshIndex: number,\r\n vertices: FloatArray,\r\n indices: IndicesArray\r\n ) => Vector3[][]\r\n ) {\r\n const points: Vector3[][] = [];\r\n\r\n meshes.forEach((m, meshIndex) => {\r\n const vertices = m.getVerticesData(VertexBuffer.PositionKind);\r\n const indices = m.getIndices();\r\n if (vertices && indices) {\r\n for (let i = 0, ii = 0; i < indices.length; i++) {\r\n const vi1 = indices[ii++] * 3;\r\n const vi2 = indices[ii++] * 3;\r\n const vi3 = indices[ii++] * 3;\r\n\r\n const p1 = new Vector3(vertices[vi1], vertices[vi1 + 1], vertices[vi1 + 2]);\r\n const p2 = new Vector3(vertices[vi2], vertices[vi2 + 1], vertices[vi2 + 2]);\r\n const p3 = new Vector3(vertices[vi3], vertices[vi3 + 1], vertices[vi3 + 2]);\r\n\r\n if (predicate) {\r\n const pointsFromPredicate = predicate(p1, p2, p3, points, i, vi1, m, meshIndex, vertices, indices);\r\n if (pointsFromPredicate) {\r\n for (const p of pointsFromPredicate) {\r\n points.push(p);\r\n }\r\n }\r\n } else {\r\n points.push([p1, p2], [p2, p3], [p3, p1]);\r\n }\r\n }\r\n }\r\n });\r\n\r\n return points;\r\n }\r\n\r\n /**\r\n * Converts number coordinates to Vector3s\r\n * @param points number array of x, y, z, x, y z, ... coordinates\r\n * @returns Vector3 array\r\n */\r\n public static ToVector3Array(points: number[] | number[][]) {\r\n if (Array.isArray(points[0])) {\r\n const array: Vector3[][] = [];\r\n const inputArray = points as number[][];\r\n for (const subInputArray of inputArray) {\r\n const subArray: Vector3[] = [];\r\n for (let i = 0; i < subInputArray.length; i += 3) {\r\n subArray.push(new Vector3(subInputArray[i], subInputArray[i + 1], subInputArray[i + 2]));\r\n }\r\n array.push(subArray);\r\n }\r\n return array;\r\n }\r\n\r\n const inputArray = points as number[];\r\n const array: Vector3[] = [];\r\n for (let i = 0; i < inputArray.length; i += 3) {\r\n array.push(new Vector3(inputArray[i], inputArray[i + 1], inputArray[i + 2]));\r\n }\r\n return array;\r\n }\r\n\r\n /**\r\n * Gets a number array from a Vector3 array.\r\n * You can you for example to convert your Vector3[] offsets to the required number[] for the offsets option.\r\n * @param points Vector3 array\r\n * @returns an array of x, y, z coordinates as numbers [x, y, z, x, y, z, x, y, z, ....]\r\n */\r\n public static ToNumberArray(points: Vector3[]) {\r\n return points.flatMap((v) => [v.x, v.y, v.z]);\r\n }\r\n\r\n /**\r\n * Calculates the sum of points of every line and the number of points in each line.\r\n * This function is useful when you are drawing multiple lines in one mesh and you want\r\n * to know the counts. For example for creating an offsets table.\r\n * @param points point array\r\n * @returns points count info\r\n */\r\n public static GetPointsCountInfo(points: number[][]): { total: number; counts: number[] } {\r\n const counts = new Array(points.length);\r\n let total = 0;\r\n for (let n = points.length; n--; ) {\r\n counts[n] = points[n].length / 3;\r\n total += counts[n];\r\n }\r\n return { total, counts };\r\n }\r\n\r\n /**\r\n * Gets the length of the line counting all it's segments length\r\n * @param data array of line points\r\n * @returns length of the line\r\n */\r\n public static GetLineLength(data: Vector3[] | number[]): number {\r\n if (data.length === 0) {\r\n return 0;\r\n }\r\n\r\n let points: Vector3[];\r\n if (typeof data[0] === \"number\") {\r\n points = GreasedLineTools.ToVector3Array(<number[]>data) as Vector3[];\r\n } else {\r\n points = data as Vector3[];\r\n }\r\n\r\n const tmp = TmpVectors.Vector3[0];\r\n let length = 0;\r\n for (let index = 0; index < points.length - 1; index++) {\r\n const point1 = points[index];\r\n const point2 = points[index + 1];\r\n length += point2.subtractToRef(point1, tmp).length();\r\n }\r\n return length;\r\n }\r\n\r\n /**\r\n * Gets the the length from the beginning to each point of the line as array.\r\n * @param data array of line points\r\n * @returns length array of the line\r\n */\r\n public static GetLineLengthArray(data: number[]): Float32Array {\r\n const out = new Float32Array(data.length / 3);\r\n let length = 0;\r\n for (let index = 0, pointsLength = data.length / 3 - 1; index < pointsLength; index++) {\r\n let x = data[index * 3 + 0];\r\n let y = data[index * 3 + 1];\r\n let z = data[index * 3 + 2];\r\n x -= data[index * 3 + 3];\r\n y -= data[index * 3 + 4];\r\n z -= data[index * 3 + 5];\r\n const currentLength = Math.sqrt(x * x + y * y + z * z);\r\n length += currentLength;\r\n out[index + 1] = length;\r\n }\r\n return out;\r\n }\r\n\r\n /**\r\n * Divides a segment into smaller segments.\r\n * A segment is a part of the line between it's two points.\r\n * @param point1 first point of the line\r\n * @param point2 second point of the line\r\n * @param segmentCount number of segments we want to have in the divided line\r\n * @returns\r\n */\r\n public static SegmentizeSegmentByCount(point1: Vector3, point2: Vector3, segmentCount: number): Vector3[] {\r\n const dividedLinePoints: Vector3[] = [];\r\n const diff = point2.subtract(point1);\r\n const divisor = TmpVectors.Vector3[0];\r\n divisor.setAll(segmentCount);\r\n const segmentVector = TmpVectors.Vector3[1];\r\n diff.divideToRef(divisor, segmentVector);\r\n\r\n let nextPoint = point1.clone();\r\n dividedLinePoints.push(nextPoint);\r\n for (let index = 0; index < segmentCount; index++) {\r\n nextPoint = nextPoint.clone();\r\n dividedLinePoints.push(nextPoint.addInPlace(segmentVector));\r\n }\r\n\r\n return dividedLinePoints;\r\n }\r\n\r\n /**\r\n * Divides a line into segments.\r\n * A segment is a part of the line between it's two points.\r\n * @param what line points\r\n * @param segmentLength length of each segment of the resulting line (distance between two line points)\r\n * @returns line point\r\n */\r\n public static SegmentizeLineBySegmentLength(what: Vector3[] | number[] | { point1: Vector3; point2: Vector3; length: number }[], segmentLength: number): Vector3[] {\r\n const subLines =\r\n what[0] instanceof Vector3\r\n ? GreasedLineTools.GetLineSegments(what as Vector3[])\r\n : typeof what[0] === \"number\"\r\n ? GreasedLineTools.GetLineSegments(GreasedLineTools.ToVector3Array(what as number[]) as Vector3[])\r\n : (what as { point1: Vector3; point2: Vector3; length: number }[]);\r\n const points: Vector3[] = [];\r\n subLines.forEach((s) => {\r\n if (s.length > segmentLength) {\r\n const segments = GreasedLineTools.SegmentizeSegmentByCount(s.point1, s.point2, Math.ceil(s.length / segmentLength));\r\n segments.forEach((seg) => {\r\n points.push(seg);\r\n });\r\n } else {\r\n points.push(s.point1);\r\n points.push(s.point2);\r\n }\r\n });\r\n return points;\r\n }\r\n\r\n /**\r\n * Divides a line into segments.\r\n * A segment is a part of the line between it's two points.\r\n * @param what line points\r\n * @param segmentCount number of segments\r\n * @returns line point\r\n */\r\n public static SegmentizeLineBySegmentCount(what: Vector3[] | number[], segmentCount: number): Vector3[] {\r\n const points = <Vector3[]>(typeof what[0] === \"number\" ? GreasedLineTools.ToVector3Array(<number[]>what) : what);\r\n const segmentLength = GreasedLineTools.GetLineLength(points) / segmentCount;\r\n return GreasedLineTools.SegmentizeLineBySegmentLength(points, segmentLength);\r\n }\r\n /**\r\n * Gets line segments.\r\n * A segment is a part of the line between it's two points.\r\n * @param points line points\r\n * @returns segments information of the line segment including starting point, ending point and the distance between them\r\n */\r\n public static GetLineSegments(points: Vector3[]): { point1: Vector3; point2: Vector3; length: number }[] {\r\n const segments = [];\r\n for (let index = 0; index < points.length - 1; index++) {\r\n const point1 = points[index];\r\n const point2 = points[index + 1];\r\n const length = point2.subtract(point1).length();\r\n segments.push({ point1, point2, length });\r\n }\r\n\r\n return segments;\r\n }\r\n\r\n /**\r\n * Gets the minimum and the maximum length of a line segment in the line.\r\n * A segment is a part of the line between it's two points.\r\n * @param points line points\r\n * @returns\r\n */\r\n public static GetMinMaxSegmentLength(points: Vector3[]): { min: number; max: number } {\r\n const subLines = GreasedLineTools.GetLineSegments(points);\r\n const sorted = subLines.sort((s) => s.length);\r\n return {\r\n min: sorted[0].length,\r\n max: sorted[sorted.length - 1].length,\r\n };\r\n }\r\n\r\n /**\r\n * Finds the last visible position in world space of the line according to the visibility parameter\r\n * @param lineSegments segments of the line\r\n * @param lineLength total length of the line\r\n * @param visbility normalized value of visibility\r\n * @param localSpace if true the result will be in local space (default is false)\r\n * @returns world space coordinate of the last visible piece of the line\r\n */\r\n public static GetPositionOnLineByVisibility(lineSegments: { point1: Vector3; point2: Vector3; length: number }[], lineLength: number, visbility: number, localSpace = false) {\r\n const lengthVisibilityRatio = lineLength * visbility;\r\n let sumSegmentLengths = 0;\r\n let segmentIndex = 0;\r\n\r\n const lineSegmentsLength = lineSegments.length;\r\n for (let i = 0; i < lineSegmentsLength; i++) {\r\n if (lengthVisibilityRatio <= sumSegmentLengths + lineSegments[i].length) {\r\n segmentIndex = i;\r\n break;\r\n }\r\n sumSegmentLengths += lineSegments[i].length;\r\n }\r\n\r\n const s = (lengthVisibilityRatio - sumSegmentLengths) / lineSegments[segmentIndex].length;\r\n\r\n lineSegments[segmentIndex].point2.subtractToRef(lineSegments[segmentIndex].point1, TmpVectors.Vector3[0]);\r\n TmpVectors.Vector3[1] = TmpVectors.Vector3[0].multiplyByFloats(s, s, s);\r\n if (!localSpace) {\r\n TmpVectors.Vector3[1].addInPlace(lineSegments[segmentIndex].point1);\r\n }\r\n\r\n return TmpVectors.Vector3[1].clone();\r\n }\r\n\r\n /**\r\n * Creates lines in a shape of circle/arc.\r\n * A segment is a part of the line between it's two points.\r\n * @param radiusX radiusX of the circle\r\n * @param segments number of segments in the circle\r\n * @param z z coordinate of the points. Defaults to 0.\r\n * @param radiusY radiusY of the circle - you can draw an oval if using different values\r\n * @param segmentAngle angle offset of the segments. Defaults to Math.PI * 2 / segments. Change this value to draw a part of the circle.\r\n * @returns line points\r\n */\r\n public static GetCircleLinePoints(radiusX: number, segments: number, z = 0, radiusY = radiusX, segmentAngle = (Math.PI * 2) / segments) {\r\n const points: Vector3[] = [];\r\n for (let i = 0; i <= segments; i++) {\r\n points.push(new Vector3(Math.cos(i * segmentAngle) * radiusX, Math.sin(i * segmentAngle) * radiusY, z));\r\n }\r\n return points;\r\n }\r\n\r\n /**\r\n * Gets line points in a shape of a bezier curve\r\n * @param p0 bezier point0\r\n * @param p1 bezier point1\r\n * @param p2 bezier point2\r\n * @param segments number of segments in the curve\r\n * @returns\r\n */\r\n public static GetBezierLinePoints(p0: Vector3, p1: Vector3, p2: Vector3, segments: number) {\r\n return Curve3.CreateQuadraticBezier(p0, p1, p2, segments)\r\n .getPoints()\r\n .flatMap((v) => [v.x, v.y, v.z]);\r\n }\r\n\r\n /**\r\n *\r\n * @param position position of the arrow cap (mainly you want to create a triangle, set widthUp and widthDown to the same value and omit widthStartUp and widthStartDown)\r\n * @param direction direction which the arrow points to\r\n * @param length length (size) of the arrow cap itself\r\n * @param widthUp the arrow width above the line\r\n * @param widthDown the arrow width belove the line\r\n * @param widthStartUp the arrow width at the start of the arrow above the line. In most scenarios this is 0.\r\n * @param widthStartDown the arrow width at the start of the arrow below the line. In most scenarios this is 0.\r\n * @returns\r\n */\r\n public static GetArrowCap(position: Vector3, direction: Vector3, length: number, widthUp: number, widthDown: number, widthStartUp = 0, widthStartDown = 0) {\r\n const points = [position.clone(), position.add(direction.multiplyByFloats(length, length, length))];\r\n const widths = [widthUp, widthDown, widthStartUp, widthStartDown];\r\n\r\n return {\r\n points,\r\n widths,\r\n };\r\n }\r\n\r\n /**\r\n * Gets 3D positions of points from a text and font\r\n * @param text Text\r\n * @param size Size of the font\r\n * @param resolution Resolution of the font\r\n * @param fontData defines the font data (can be generated with http://gero3.github.io/facetype.js/)\r\n * @param z z coordinate\r\n * @param includeInner include the inner parts of the font in the result. Default true. If false, only the outlines will be returned.\r\n * @returns number[][] of 3D positions\r\n */\r\n public static GetPointsFromText(text: string, size: number, resolution: number, fontData: IFontData, z = 0, includeInner = true) {\r\n const allPoints = [];\r\n const shapePaths = CreateTextShapePaths(text, size, resolution, fontData);\r\n\r\n for (const sp of shapePaths) {\r\n for (const p of sp.paths) {\r\n const points = [];\r\n const points2d = p.getPoints();\r\n for (const p2d of points2d) {\r\n points.push(p2d.x, p2d.y, z);\r\n }\r\n allPoints.push(points);\r\n }\r\n\r\n if (includeInner) {\r\n for (const h of sp.holes) {\r\n const holes = [];\r\n const points2d = h.getPoints();\r\n for (const p2d of points2d) {\r\n holes.push(p2d.x, p2d.y, z);\r\n }\r\n allPoints.push(holes);\r\n }\r\n }\r\n }\r\n\r\n return allPoints;\r\n }\r\n\r\n /**\r\n * Converts an array of Color3 to Uint8Array\r\n * @param colors Arrray of Color3\r\n * @returns Uin8Array of colors [r, g, b, a, r, g, b, a, ...]\r\n */\r\n public static Color3toRGBAUint8(colors: Color3[]): Uint8Array {\r\n const colorTable: Uint8Array = new Uint8Array(colors.length * 4);\r\n for (let i = 0, j = 0; i < colors.length; i++) {\r\n colorTable[j++] = colors[i].r * 255;\r\n colorTable[j++] = colors[i].g * 255;\r\n colorTable[j++] = colors[i].b * 255;\r\n colorTable[j++] = 255;\r\n }\r\n\r\n return colorTable;\r\n }\r\n\r\n /**\r\n * Creates a RawTexture from an RGBA color array and sets it on the plugin material instance.\r\n * @param name name of the texture\r\n * @param colors Uint8Array of colors\r\n * @param colorsSampling sampling mode of the created texture\r\n * @param scene Scene\r\n * @returns the colors texture\r\n */\r\n public static CreateColorsTexture(name: string, colors: Color3[], colorsSampling: number, scene: Scene) {\r\n const maxTextureSize = scene.getEngine().getCaps().maxTextureSize ?? 1;\r\n const width = colors.length > maxTextureSize ? maxTextureSize : colors.length;\r\n const height = Math.ceil(colors.length / maxTextureSize);\r\n if (height > 1) {\r\n colors = [...colors, ...Array(width * height - colors.length).fill(colors[0])];\r\n }\r\n const colorsArray = GreasedLineTools.Color3toRGBAUint8(colors);\r\n const colorsTexture = new RawTexture(colorsArray, width, height, Engine.TEXTUREFORMAT_RGBA, scene, false, true, colorsSampling);\r\n colorsTexture.name = name;\r\n return colorsTexture;\r\n }\r\n\r\n /**\r\n * A minimum size texture for the colors sampler2D when there is no colors texture defined yet.\r\n * For fast switching using the useColors property without the need to use defines.\r\n * @param scene Scene\r\n * @returns empty colors texture\r\n */\r\n public static PrepareEmptyColorsTexture(scene: Scene) {\r\n if (!GreasedLineMaterialDefaults.EmptyColorsTexture) {\r\n const colorsArray = new Uint8Array(4);\r\n GreasedLineMaterialDefaults.EmptyColorsTexture = new RawTexture(colorsArray, 1, 1, Engine.TEXTUREFORMAT_RGBA, scene, false, false, RawTexture.NEAREST_NEAREST);\r\n GreasedLineMaterialDefaults.EmptyColorsTexture.name = \"grlEmptyColorsTexture\";\r\n }\r\n\r\n return GreasedLineMaterialDefaults.EmptyColorsTexture;\r\n }\r\n\r\n /**\r\n * Diposes the shared empty colors texture\r\n */\r\n public static DisposeEmptyColorsTexture() {\r\n GreasedLineMaterialDefaults.EmptyColorsTexture?.dispose();\r\n GreasedLineMaterialDefaults.EmptyColorsTexture = null;\r\n }\r\n\r\n /**\r\n * Converts boolean to number.\r\n * @param bool the bool value\r\n * @returns 1 if true, 0 if false.\r\n */\r\n public static BooleanToNumber(bool?: boolean) {\r\n return bool ? 1 : 0;\r\n }\r\n}\r\n"]}
|
|
@@ -25,6 +25,13 @@ export declare class SnapshotRenderingHelper {
|
|
|
25
25
|
private _disableRenderingRefCount;
|
|
26
26
|
private _currentPerformancePriorityMode;
|
|
27
27
|
private _pendingCurrentPerformancePriorityMode?;
|
|
28
|
+
private _isEnabling;
|
|
29
|
+
private _enableCancelFunctions;
|
|
30
|
+
private _disableCancelFunctions;
|
|
31
|
+
/**
|
|
32
|
+
* Indicates if debug logs should be displayed
|
|
33
|
+
*/
|
|
34
|
+
showDebugLogs: boolean;
|
|
28
35
|
/**
|
|
29
36
|
* Creates a new snapshot rendering helper
|
|
30
37
|
* Note that creating an instance of the helper will set the snapshot rendering mode to SNAPSHOTRENDERING_FAST but will not enable snapshot rendering (engine.snapshotRendering is not updated).
|
|
@@ -33,6 +40,10 @@ export declare class SnapshotRenderingHelper {
|
|
|
33
40
|
* @param options The options for the helper
|
|
34
41
|
*/
|
|
35
42
|
constructor(scene: Scene, options?: SnapshotRenderingHelpersOptions);
|
|
43
|
+
/**
|
|
44
|
+
* Gets a value indicating if the helper is in a steady state (not in the process of enabling snapshot rendering).
|
|
45
|
+
*/
|
|
46
|
+
get isReady(): boolean;
|
|
36
47
|
/**
|
|
37
48
|
* Enable snapshot rendering
|
|
38
49
|
* Use this method instead of engine.snapshotRendering=true, to make sure everything is ready before enabling snapshot rendering.
|
|
@@ -68,4 +79,5 @@ export declare class SnapshotRenderingHelper {
|
|
|
68
79
|
private get _fastSnapshotRenderingEnabled();
|
|
69
80
|
private _updateMeshMatricesForRenderPassId;
|
|
70
81
|
private _executeAtFrame;
|
|
82
|
+
private _log;
|
|
71
83
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { BindMorphTargetParameters } from "../Materials/materialHelper.functions.js";
|
|
3
|
+
import { Logger } from "./logger.js";
|
|
3
4
|
/**
|
|
4
5
|
* A helper class to simplify work with FAST snapshot mode (WebGPU only - can be used in WebGL too, but won't do anything).
|
|
5
6
|
*/
|
|
@@ -14,6 +15,13 @@ export class SnapshotRenderingHelper {
|
|
|
14
15
|
constructor(scene, options) {
|
|
15
16
|
this._disableRenderingRefCount = 0;
|
|
16
17
|
this._currentPerformancePriorityMode = 0 /* ScenePerformancePriority.BackwardCompatible */;
|
|
18
|
+
this._isEnabling = false;
|
|
19
|
+
this._enableCancelFunctions = new Map(); // first function is the callback, second function is the cancel function
|
|
20
|
+
this._disableCancelFunctions = new Map(); // same as above
|
|
21
|
+
/**
|
|
22
|
+
* Indicates if debug logs should be displayed
|
|
23
|
+
*/
|
|
24
|
+
this.showDebugLogs = false;
|
|
17
25
|
this._scene = scene;
|
|
18
26
|
this._engine = scene.getEngine();
|
|
19
27
|
if (!this._engine.isWebGPU) {
|
|
@@ -26,9 +34,11 @@ export class SnapshotRenderingHelper {
|
|
|
26
34
|
this._engine.snapshotRenderingMode = 1;
|
|
27
35
|
this.fixMeshes();
|
|
28
36
|
this._onResizeObserver = this._engine.onResizeObservable.add(() => {
|
|
37
|
+
this._log("onResize", "start");
|
|
29
38
|
// enableSnapshotRendering() will delay the actual enabling of snapshot rendering by at least a frame, so these two lines are not redundant!
|
|
30
39
|
this.disableSnapshotRendering();
|
|
31
40
|
this.enableSnapshotRendering();
|
|
41
|
+
this._log("onResize", "end");
|
|
32
42
|
});
|
|
33
43
|
this._scene.onBeforeRenderObservable.add(() => {
|
|
34
44
|
if (!this._fastSnapshotRenderingEnabled) {
|
|
@@ -65,6 +75,12 @@ export class SnapshotRenderingHelper {
|
|
|
65
75
|
}
|
|
66
76
|
});
|
|
67
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Gets a value indicating if the helper is in a steady state (not in the process of enabling snapshot rendering).
|
|
80
|
+
*/
|
|
81
|
+
get isReady() {
|
|
82
|
+
return !this._isEnabling;
|
|
83
|
+
}
|
|
68
84
|
/**
|
|
69
85
|
* Enable snapshot rendering
|
|
70
86
|
* Use this method instead of engine.snapshotRendering=true, to make sure everything is ready before enabling snapshot rendering.
|
|
@@ -77,19 +93,34 @@ export class SnapshotRenderingHelper {
|
|
|
77
93
|
if (--this._disableRenderingRefCount > 0) {
|
|
78
94
|
return;
|
|
79
95
|
}
|
|
96
|
+
this._log("enableSnapshotRendering", "called");
|
|
97
|
+
if (this._disableCancelFunctions.size > 0) {
|
|
98
|
+
this._log("enableSnapshotRendering", `cancelling ${this._disableCancelFunctions.size} "disable" callbacks`);
|
|
99
|
+
}
|
|
100
|
+
this._disableCancelFunctions.forEach((cancel) => cancel());
|
|
101
|
+
this._disableCancelFunctions.clear();
|
|
102
|
+
this._isEnabling = true;
|
|
80
103
|
this._disableRenderingRefCount = 0;
|
|
81
104
|
this._currentPerformancePriorityMode = this._pendingCurrentPerformancePriorityMode ?? this._scene.performancePriority;
|
|
82
105
|
this._pendingCurrentPerformancePriorityMode = undefined;
|
|
83
106
|
this._scene.performancePriority = 0 /* ScenePerformancePriority.BackwardCompatible */;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
107
|
+
const callbackWhenSceneReady = () => {
|
|
108
|
+
this._enableCancelFunctions.delete(callbackWhenSceneReady);
|
|
88
109
|
// Make sure a full frame is rendered before enabling snapshot rendering, so use "+2" instead of "+1"
|
|
89
|
-
this.
|
|
110
|
+
const targetFrameId = this._engine.frameId + 2;
|
|
111
|
+
this._log("enableSnapshotRendering", `scene ready, add callbacks for frames ${targetFrameId} and ${targetFrameId + 1}`);
|
|
112
|
+
this._executeAtFrame(targetFrameId, () => {
|
|
113
|
+
this._log("enableSnapshotRendering", `callback #1, enable snapshot rendering at the engine level`);
|
|
90
114
|
this._engine.snapshotRendering = true;
|
|
91
115
|
});
|
|
92
|
-
|
|
116
|
+
// Render one frame with snapshot rendering enabled to make sure everything is ready
|
|
117
|
+
this._executeAtFrame(targetFrameId + 1, () => {
|
|
118
|
+
this._log("enableSnapshotRendering", `callback #2, signals that snapshot rendering helper is ready`);
|
|
119
|
+
this._isEnabling = false;
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
this._enableCancelFunctions.set(callbackWhenSceneReady, () => this._scene.onReadyObservable.removeCallback(callbackWhenSceneReady));
|
|
123
|
+
this._scene.executeWhenReady(callbackWhenSceneReady);
|
|
93
124
|
}
|
|
94
125
|
/**
|
|
95
126
|
* Disable snapshot rendering
|
|
@@ -99,22 +130,31 @@ export class SnapshotRenderingHelper {
|
|
|
99
130
|
if (!this._engine.isWebGPU) {
|
|
100
131
|
return;
|
|
101
132
|
}
|
|
133
|
+
this._log("disableSnapshotRendering", "called");
|
|
102
134
|
if (this._disableRenderingRefCount === 0) {
|
|
135
|
+
if (this._enableCancelFunctions.size > 0) {
|
|
136
|
+
this._log("disableSnapshotRendering", `cancelling ${this._enableCancelFunctions.size} "enable" callbacks`);
|
|
137
|
+
}
|
|
138
|
+
this._enableCancelFunctions.forEach((cancel) => cancel());
|
|
139
|
+
this._enableCancelFunctions.clear();
|
|
140
|
+
this._isEnabling = false;
|
|
103
141
|
// Snapshot rendering switches from enabled to disabled
|
|
104
142
|
// We reset the performance priority mode to that which it was before enabling snapshot rendering, but first set it to “BackwardCompatible” to allow the system to regenerate resources that may have been optimized for snapshot rendering.
|
|
105
143
|
// We'll then restore the original mode at the next frame.
|
|
106
144
|
this._scene.performancePriority = 0 /* ScenePerformancePriority.BackwardCompatible */;
|
|
107
145
|
if (this._currentPerformancePriorityMode !== 0 /* ScenePerformancePriority.BackwardCompatible */) {
|
|
146
|
+
this._log("disableSnapshotRendering", `makes sure that the scene is rendered once in BackwardCompatible mode (code: ${0 /* ScenePerformancePriority.BackwardCompatible */}) before switching to mode ${this._currentPerformancePriorityMode}`);
|
|
108
147
|
this._pendingCurrentPerformancePriorityMode = this._currentPerformancePriorityMode;
|
|
109
|
-
|
|
148
|
+
const callbackWhenSceneReady = () => {
|
|
149
|
+
this._log("disableSnapshotRendering", `scene ready, add callback for frame ${this._engine.frameId + 2}`);
|
|
110
150
|
this._executeAtFrame(this._engine.frameId + 2, () => {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
this._scene.performancePriority = this._pendingCurrentPerformancePriorityMode;
|
|
114
|
-
}
|
|
151
|
+
this._log("disableSnapshotRendering", `switching to performance priority mode ${this._pendingCurrentPerformancePriorityMode}`);
|
|
152
|
+
this._scene.performancePriority = this._pendingCurrentPerformancePriorityMode;
|
|
115
153
|
this._pendingCurrentPerformancePriorityMode = undefined;
|
|
116
|
-
},
|
|
117
|
-
}
|
|
154
|
+
}, "whenDisabled");
|
|
155
|
+
};
|
|
156
|
+
this._disableCancelFunctions.set(callbackWhenSceneReady, () => this._scene.onReadyObservable.removeCallback(callbackWhenSceneReady));
|
|
157
|
+
this._scene.executeWhenReady(callbackWhenSceneReady);
|
|
118
158
|
}
|
|
119
159
|
}
|
|
120
160
|
this._engine.snapshotRendering = false;
|
|
@@ -211,17 +251,31 @@ export class SnapshotRenderingHelper {
|
|
|
211
251
|
}
|
|
212
252
|
}
|
|
213
253
|
}
|
|
214
|
-
_executeAtFrame(frameId, func,
|
|
215
|
-
const
|
|
216
|
-
if ((this._disableRenderingRefCount > 0 && !executeWhenModeIsDisabled) || (this._disableRenderingRefCount === 0 && executeWhenModeIsDisabled)) {
|
|
217
|
-
this._engine.onEndFrameObservable.remove(obs);
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
254
|
+
_executeAtFrame(frameId, func, mode = "whenEnabled") {
|
|
255
|
+
const callback = () => {
|
|
220
256
|
if (this._engine.frameId >= frameId) {
|
|
221
257
|
this._engine.onEndFrameObservable.remove(obs);
|
|
258
|
+
if (mode === "whenEnabled") {
|
|
259
|
+
this._enableCancelFunctions.delete(callback);
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
this._disableCancelFunctions.delete(callback);
|
|
263
|
+
}
|
|
222
264
|
func();
|
|
223
265
|
}
|
|
224
|
-
}
|
|
266
|
+
};
|
|
267
|
+
const obs = this._engine.onEndFrameObservable.add(callback);
|
|
268
|
+
if (mode === "whenEnabled") {
|
|
269
|
+
this._enableCancelFunctions.set(callback, () => this._engine.onEndFrameObservable.remove(obs));
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
this._disableCancelFunctions.set(callback, () => this._engine.onEndFrameObservable.remove(obs));
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
_log(funcName, message) {
|
|
276
|
+
if (this.showDebugLogs) {
|
|
277
|
+
Logger.Log(`[Frame: ${this._engine.frameId}] SnapshotRenderingHelper:${funcName} - ${message}`);
|
|
278
|
+
}
|
|
225
279
|
}
|
|
226
280
|
}
|
|
227
281
|
//# sourceMappingURL=snapshotRenderingHelper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshotRenderingHelper.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/snapshotRenderingHelper.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,SAAS,EAAE,gCAA+B;AACnD,OAAO,EAAE,yBAAyB,EAAE,iDAAgD;AAiBpF;;GAEG;AACH,MAAM,OAAO,uBAAuB;IAWhC;;;;;;OAMG;IACH,YAAY,KAAY,EAAE,OAAyC;QAX3D,8BAAyB,GAAG,CAAC,CAAC;QAC9B,oCAA+B,uDAA+C;QAWlF,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAEjC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YACzB,OAAO;QACX,CAAC;QAED,IAAI,CAAC,QAAQ,GAAG;YACZ,4BAA4B,EAAE,EAAE;YAChC,GAAG,OAAO;SACb,CAAC;QAEF,IAAI,CAAC,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,sBAAsB,CAAC;QAEtE,IAAI,CAAC,SAAS,EAAE,CAAC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scene,\r\n WebGPUDrawContext,\r\n WebGPUShaderProcessor,\r\n WebGPUPipelineContext,\r\n GaussianSplattingMesh,\r\n // eslint-disable-next-line import/no-internal-modules\r\n} from \"core/index\";\r\n\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { BindMorphTargetParameters } from \"core/Materials/materialHelper.functions\";\r\nimport { ScenePerformancePriority } from \"core/scene\";\r\n\r\n/**\r\n * Options for the snapshot rendering helper\r\n */\r\nexport interface SnapshotRenderingHelpersOptions {\r\n /**\r\n * Maximum number of influences for morph target managers\r\n * In FAST snapshot mode, the number of influences must be fixed and cannot change from one frame to the next.\r\n * morphTargetsNumMaxInfluences is the maximum number of non-zero influences allowed in a morph target manager.\r\n * The final value defined for a morph target manager is: Math.min(morphTargetManager.numTargets, morphTargetsNumMaxInfluences)\r\n * Default: 20\r\n */\r\n morphTargetsNumMaxInfluences?: number;\r\n}\r\n\r\n/**\r\n * A helper class to simplify work with FAST snapshot mode (WebGPU only - can be used in WebGL too, but won't do anything).\r\n */\r\nexport class SnapshotRenderingHelper {\r\n private readonly _engine: AbstractEngine;\r\n private readonly _scene: Scene;\r\n private readonly _options: SnapshotRenderingHelpersOptions;\r\n private readonly _onBeforeRenderObserver: Nullable<Observer<Scene>>;\r\n private _onBeforeRenderObserverUpdateLayer: Nullable<Observer<Scene>>;\r\n private readonly _onResizeObserver: Nullable<Observer<AbstractEngine>>;\r\n private _disableRenderingRefCount = 0;\r\n private _currentPerformancePriorityMode = ScenePerformancePriority.BackwardCompatible;\r\n private _pendingCurrentPerformancePriorityMode?: ScenePerformancePriority;\r\n\r\n /**\r\n * Creates a new snapshot rendering helper\r\n * Note that creating an instance of the helper will set the snapshot rendering mode to SNAPSHOTRENDERING_FAST but will not enable snapshot rendering (engine.snapshotRendering is not updated).\r\n * Note also that fixMeshes() is called as part of the construction\r\n * @param scene The scene to use the helper in\r\n * @param options The options for the helper\r\n */\r\n constructor(scene: Scene, options?: SnapshotRenderingHelpersOptions) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n this._options = {\r\n morphTargetsNumMaxInfluences: 20,\r\n ...options,\r\n };\r\n\r\n this._engine.snapshotRenderingMode = Constants.SNAPSHOTRENDERING_FAST;\r\n\r\n this.fixMeshes();\r\n\r\n this._onResizeObserver = this._engine.onResizeObservable.add(() => {\r\n // enableSnapshotRendering() will delay the actual enabling of snapshot rendering by at least a frame, so these two lines are not redundant!\r\n this.disableSnapshotRendering();\r\n this.enableSnapshotRendering();\r\n });\r\n\r\n this._scene.onBeforeRenderObservable.add(() => {\r\n if (!this._fastSnapshotRenderingEnabled) {\r\n return;\r\n }\r\n\r\n // Animate skeletons\r\n scene.skeletons.forEach((skeleton) => skeleton.prepare(true));\r\n\r\n for (const mesh of scene.meshes) {\r\n if (mesh.infiniteDistance) {\r\n mesh.transferToEffect(mesh.computeWorldMatrix(true));\r\n }\r\n\r\n if (mesh.skeleton) {\r\n mesh.transferToEffect(mesh.computeWorldMatrix(true));\r\n }\r\n\r\n if (mesh.getClassName() === \"GaussianSplattingMesh\") {\r\n (mesh as GaussianSplattingMesh)._postToWorker();\r\n }\r\n\r\n if (mesh.morphTargetManager && mesh.subMeshes) {\r\n // Make sure morph target animations work\r\n for (const subMesh of mesh.subMeshes) {\r\n const dw = subMesh._drawWrapper;\r\n const effect = dw.effect;\r\n if (effect) {\r\n const dataBuffer = (dw.drawContext as WebGPUDrawContext).buffers[\"LeftOver\" satisfies (typeof WebGPUShaderProcessor)[\"LeftOvertUBOName\"]];\r\n const ubLeftOver = (effect._pipelineContext as WebGPUPipelineContext)?.uniformBuffer;\r\n if (dataBuffer && ubLeftOver && ubLeftOver.setDataBuffer(dataBuffer)) {\r\n mesh.morphTargetManager._bind(effect);\r\n BindMorphTargetParameters(mesh, effect);\r\n ubLeftOver.update();\r\n }\r\n }\r\n }\r\n }\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Enable snapshot rendering\r\n * Use this method instead of engine.snapshotRendering=true, to make sure everything is ready before enabling snapshot rendering.\r\n * Note that this method is ref-counted and works in pair with disableSnapshotRendering(): you should call enableSnapshotRendering() as many times as you call disableSnapshotRendering().\r\n */\r\n public enableSnapshotRendering() {\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n if (--this._disableRenderingRefCount > 0) {\r\n return;\r\n }\r\n\r\n this._disableRenderingRefCount = 0;\r\n\r\n this._currentPerformancePriorityMode = this._pendingCurrentPerformancePriorityMode ?? this._scene.performancePriority;\r\n this._pendingCurrentPerformancePriorityMode = undefined;\r\n this._scene.performancePriority = ScenePerformancePriority.BackwardCompatible;\r\n\r\n this._scene.executeWhenReady(() => {\r\n if (this._disableRenderingRefCount > 0) {\r\n return;\r\n }\r\n\r\n // Make sure a full frame is rendered before enabling snapshot rendering, so use \"+2\" instead of \"+1\"\r\n this._executeAtFrame(this._engine.frameId + 2, () => {\r\n this._engine.snapshotRendering = true;\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Disable snapshot rendering\r\n * Note that this method is ref-counted and works in pair with disableSnapshotRendering(): you should call enableSnapshotRendering() as many times as you call disableSnapshotRendering().\r\n */\r\n public disableSnapshotRendering() {\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n if (this._disableRenderingRefCount === 0) {\r\n // Snapshot rendering switches from enabled to disabled\r\n // We reset the performance priority mode to that which it was before enabling snapshot rendering, but first set it to “BackwardCompatible” to allow the system to regenerate resources that may have been optimized for snapshot rendering.\r\n // We'll then restore the original mode at the next frame.\r\n this._scene.performancePriority = ScenePerformancePriority.BackwardCompatible;\r\n if (this._currentPerformancePriorityMode !== ScenePerformancePriority.BackwardCompatible) {\r\n this._pendingCurrentPerformancePriorityMode = this._currentPerformancePriorityMode;\r\n this._scene.executeWhenReady(() => {\r\n this._executeAtFrame(\r\n this._engine.frameId + 2,\r\n () => {\r\n // if this._disableRenderingRefCount === 0, snapshot rendering has been enabled in the meantime, so do nothing\r\n if (this._disableRenderingRefCount > 0 && this._pendingCurrentPerformancePriorityMode !== undefined) {\r\n this._scene.performancePriority = this._pendingCurrentPerformancePriorityMode;\r\n }\r\n this._pendingCurrentPerformancePriorityMode = undefined;\r\n },\r\n true\r\n );\r\n });\r\n }\r\n }\r\n\r\n this._engine.snapshotRendering = false;\r\n this._disableRenderingRefCount++;\r\n }\r\n\r\n /**\r\n * Fix meshes for snapshot rendering.\r\n * This method will make sure that some features are disabled or fixed to make sure snapshot rendering works correctly.\r\n * @param meshes List of meshes to fix. If not provided, all meshes in the scene will be fixed.\r\n */\r\n public fixMeshes(meshes?: AbstractMesh[]) {\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n meshes = meshes || this._scene.meshes;\r\n\r\n for (const mesh of meshes) {\r\n (mesh as Mesh).ignoreCameraMaxZ = false;\r\n if (mesh.morphTargetManager) {\r\n mesh.morphTargetManager.numMaxInfluencers = Math.min(mesh.morphTargetManager.numTargets, this._options.morphTargetsNumMaxInfluences!);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Call this method to update a mesh on the GPU after some properties have changed (position, rotation, scaling, visibility).\r\n * @param mesh The mesh to update. Can be a single mesh or an array of meshes to update.\r\n */\r\n public updateMesh(mesh: AbstractMesh | AbstractMesh[]) {\r\n if (!this._fastSnapshotRenderingEnabled) {\r\n return;\r\n }\r\n\r\n if (Array.isArray(mesh)) {\r\n for (const m of mesh) {\r\n m.transferToEffect(m.computeWorldMatrix(true));\r\n }\r\n return;\r\n }\r\n\r\n mesh.transferToEffect(mesh.computeWorldMatrix(true));\r\n }\r\n\r\n /**\r\n * Update the meshes used in an effect layer to ensure that snapshot rendering works correctly for these meshes in this layer.\r\n * @param effectLayer The effect layer\r\n * @param autoUpdate If true, the helper will automatically update the effect layer meshes with each frame. If false, you'll need to call this method manually when the camera or layer meshes move or rotate.\r\n */\r\n public updateMeshesForEffectLayer(effectLayer: EffectLayer, autoUpdate = true) {\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n const renderPassId = effectLayer.mainTexture.renderPassId;\r\n\r\n if (autoUpdate) {\r\n this._onBeforeRenderObserverUpdateLayer = this._scene.onBeforeRenderObservable.add(() => {\r\n this._updateMeshMatricesForRenderPassId(renderPassId);\r\n });\r\n } else {\r\n this._updateMeshMatricesForRenderPassId(renderPassId);\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the helper\r\n */\r\n public dispose() {\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n this._scene.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);\r\n this._scene.onBeforeRenderObservable.remove(this._onBeforeRenderObserverUpdateLayer);\r\n this._engine.onResizeObservable.remove(this._onResizeObserver);\r\n }\r\n\r\n private get _fastSnapshotRenderingEnabled() {\r\n return this._engine.snapshotRendering && this._engine.snapshotRenderingMode === Constants.SNAPSHOTRENDERING_FAST;\r\n }\r\n\r\n private _updateMeshMatricesForRenderPassId(renderPassId: number) {\r\n if (!this._fastSnapshotRenderingEnabled) {\r\n return;\r\n }\r\n\r\n const sceneTransformationMatrix = this._scene.getTransformMatrix();\r\n\r\n for (let i = 0; i < this._scene.meshes.length; ++i) {\r\n const mesh = this._scene.meshes[i];\r\n if (!mesh.subMeshes) {\r\n continue;\r\n }\r\n\r\n for (let j = 0; j < mesh.subMeshes.length; ++j) {\r\n const dw = mesh.subMeshes[j]._getDrawWrapper(renderPassId);\r\n const effect = dw?.effect;\r\n if (effect) {\r\n const dataBuffer = (dw.drawContext as WebGPUDrawContext).buffers[\"LeftOver\" satisfies (typeof WebGPUShaderProcessor)[\"LeftOvertUBOName\"]];\r\n const ubLeftOver = (effect._pipelineContext as WebGPUPipelineContext)?.uniformBuffer;\r\n if (dataBuffer && ubLeftOver && ubLeftOver.setDataBuffer(dataBuffer)) {\r\n effect.setMatrix(\"viewProjection\", sceneTransformationMatrix);\r\n effect.setMatrix(\"world\", mesh.computeWorldMatrix());\r\n ubLeftOver.update();\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _executeAtFrame(frameId: number, func: () => void, executeWhenModeIsDisabled = false) {\r\n const obs = this._engine.onEndFrameObservable.add(() => {\r\n if ((this._disableRenderingRefCount > 0 && !executeWhenModeIsDisabled) || (this._disableRenderingRefCount === 0 && executeWhenModeIsDisabled)) {\r\n this._engine.onEndFrameObservable.remove(obs);\r\n return;\r\n }\r\n if (this._engine.frameId >= frameId) {\r\n this._engine.onEndFrameObservable.remove(obs);\r\n func();\r\n }\r\n });\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"snapshotRenderingHelper.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/snapshotRenderingHelper.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,SAAS,EAAE,gCAA+B;AACnD,OAAO,EAAE,yBAAyB,EAAE,iDAAgD;AAEpF,OAAO,EAAE,MAAM,EAAE,oBAAyB;AAgB1C;;GAEG;AACH,MAAM,OAAO,uBAAuB;IAmBhC;;;;;;OAMG;IACH,YAAY,KAAY,EAAE,OAAyC;QAnB3D,8BAAyB,GAAG,CAAC,CAAC;QAC9B,oCAA+B,uDAA+C;QAE9E,gBAAW,GAAG,KAAK,CAAC;QACpB,2BAAsB,GAAgC,IAAI,GAAG,EAAE,CAAC,CAAC,yEAAyE;QAC1I,4BAAuB,GAAgC,IAAI,GAAG,EAAE,CAAC,CAAC,gBAAgB;QAE1F;;WAEG;QACI,kBAAa,GAAG,KAAK,CAAC;QAUzB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAEjC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YACzB,OAAO;QACX,CAAC;QAED,IAAI,CAAC,QAAQ,GAAG;YACZ,4BAA4B,EAAE,EAAE;YAChC,GAAG,OAAO;SACb,CAAC;QAEF,IAAI,CAAC,OAAO,CAAC,qBAAqB,GAAG,SAA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IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACrB,MAAM,CAAC,GAAG,CAAC,WAAW,IAAI,CAAC,OAAO,CAAC,OAAO,6BAA6B,QAAQ,MAAM,OAAO,EAAE,CAAC,CAAC;QACpG,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type {\r\n AbstractEngine,\r\n AbstractMesh,\r\n EffectLayer,\r\n Mesh,\r\n Nullable,\r\n Observer,\r\n Scene,\r\n WebGPUDrawContext,\r\n WebGPUShaderProcessor,\r\n WebGPUPipelineContext,\r\n GaussianSplattingMesh,\r\n // eslint-disable-next-line import/no-internal-modules\r\n} from \"core/index\";\r\n\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { BindMorphTargetParameters } from \"core/Materials/materialHelper.functions\";\r\nimport { ScenePerformancePriority } from \"core/scene\";\r\nimport { Logger } from \"core/Misc/logger\";\r\n\r\n/**\r\n * Options for the snapshot rendering helper\r\n */\r\nexport interface SnapshotRenderingHelpersOptions {\r\n /**\r\n * Maximum number of influences for morph target managers\r\n * In FAST snapshot mode, the number of influences must be fixed and cannot change from one frame to the next.\r\n * morphTargetsNumMaxInfluences is the maximum number of non-zero influences allowed in a morph target manager.\r\n * The final value defined for a morph target manager is: Math.min(morphTargetManager.numTargets, morphTargetsNumMaxInfluences)\r\n * Default: 20\r\n */\r\n morphTargetsNumMaxInfluences?: number;\r\n}\r\n\r\n/**\r\n * A helper class to simplify work with FAST snapshot mode (WebGPU only - can be used in WebGL too, but won't do anything).\r\n */\r\nexport class SnapshotRenderingHelper {\r\n private readonly _engine: AbstractEngine;\r\n private readonly _scene: Scene;\r\n private readonly _options: SnapshotRenderingHelpersOptions;\r\n private readonly _onBeforeRenderObserver: Nullable<Observer<Scene>>;\r\n private _onBeforeRenderObserverUpdateLayer: Nullable<Observer<Scene>>;\r\n private readonly _onResizeObserver: Nullable<Observer<AbstractEngine>>;\r\n private _disableRenderingRefCount = 0;\r\n private _currentPerformancePriorityMode = ScenePerformancePriority.BackwardCompatible;\r\n private _pendingCurrentPerformancePriorityMode?: ScenePerformancePriority;\r\n private _isEnabling = false;\r\n private _enableCancelFunctions: Map<() => void, () => void> = new Map(); // first function is the callback, second function is the cancel function\r\n private _disableCancelFunctions: Map<() => void, () => void> = new Map(); // same as above\r\n\r\n /**\r\n * Indicates if debug logs should be displayed\r\n */\r\n public showDebugLogs = false;\r\n\r\n /**\r\n * Creates a new snapshot rendering helper\r\n * Note that creating an instance of the helper will set the snapshot rendering mode to SNAPSHOTRENDERING_FAST but will not enable snapshot rendering (engine.snapshotRendering is not updated).\r\n * Note also that fixMeshes() is called as part of the construction\r\n * @param scene The scene to use the helper in\r\n * @param options The options for the helper\r\n */\r\n constructor(scene: Scene, options?: SnapshotRenderingHelpersOptions) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n this._options = {\r\n morphTargetsNumMaxInfluences: 20,\r\n ...options,\r\n };\r\n\r\n this._engine.snapshotRenderingMode = Constants.SNAPSHOTRENDERING_FAST;\r\n\r\n this.fixMeshes();\r\n\r\n this._onResizeObserver = this._engine.onResizeObservable.add(() => {\r\n this._log(\"onResize\", \"start\");\r\n\r\n // enableSnapshotRendering() will delay the actual enabling of snapshot rendering by at least a frame, so these two lines are not redundant!\r\n this.disableSnapshotRendering();\r\n this.enableSnapshotRendering();\r\n\r\n this._log(\"onResize\", \"end\");\r\n });\r\n\r\n this._scene.onBeforeRenderObservable.add(() => {\r\n if (!this._fastSnapshotRenderingEnabled) {\r\n return;\r\n }\r\n\r\n // Animate skeletons\r\n scene.skeletons.forEach((skeleton) => skeleton.prepare(true));\r\n\r\n for (const mesh of scene.meshes) {\r\n if (mesh.infiniteDistance) {\r\n mesh.transferToEffect(mesh.computeWorldMatrix(true));\r\n }\r\n\r\n if (mesh.skeleton) {\r\n mesh.transferToEffect(mesh.computeWorldMatrix(true));\r\n }\r\n\r\n if (mesh.getClassName() === \"GaussianSplattingMesh\") {\r\n (mesh as GaussianSplattingMesh)._postToWorker();\r\n }\r\n\r\n if (mesh.morphTargetManager && mesh.subMeshes) {\r\n // Make sure morph target animations work\r\n for (const subMesh of mesh.subMeshes) {\r\n const dw = subMesh._drawWrapper;\r\n const effect = dw.effect;\r\n if (effect) {\r\n const dataBuffer = (dw.drawContext as WebGPUDrawContext).buffers[\"LeftOver\" satisfies (typeof WebGPUShaderProcessor)[\"LeftOvertUBOName\"]];\r\n const ubLeftOver = (effect._pipelineContext as WebGPUPipelineContext)?.uniformBuffer;\r\n if (dataBuffer && ubLeftOver && ubLeftOver.setDataBuffer(dataBuffer)) {\r\n mesh.morphTargetManager._bind(effect);\r\n BindMorphTargetParameters(mesh, effect);\r\n ubLeftOver.update();\r\n }\r\n }\r\n }\r\n }\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Gets a value indicating if the helper is in a steady state (not in the process of enabling snapshot rendering).\r\n */\r\n public get isReady() {\r\n return !this._isEnabling;\r\n }\r\n\r\n /**\r\n * Enable snapshot rendering\r\n * Use this method instead of engine.snapshotRendering=true, to make sure everything is ready before enabling snapshot rendering.\r\n * Note that this method is ref-counted and works in pair with disableSnapshotRendering(): you should call enableSnapshotRendering() as many times as you call disableSnapshotRendering().\r\n */\r\n public enableSnapshotRendering() {\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n if (--this._disableRenderingRefCount > 0) {\r\n return;\r\n }\r\n\r\n this._log(\"enableSnapshotRendering\", \"called\");\r\n if (this._disableCancelFunctions.size > 0) {\r\n this._log(\"enableSnapshotRendering\", `cancelling ${this._disableCancelFunctions.size} \"disable\" callbacks`);\r\n }\r\n\r\n this._disableCancelFunctions.forEach((cancel) => cancel());\r\n this._disableCancelFunctions.clear();\r\n\r\n this._isEnabling = true;\r\n this._disableRenderingRefCount = 0;\r\n\r\n this._currentPerformancePriorityMode = this._pendingCurrentPerformancePriorityMode ?? this._scene.performancePriority;\r\n this._pendingCurrentPerformancePriorityMode = undefined;\r\n this._scene.performancePriority = ScenePerformancePriority.BackwardCompatible;\r\n\r\n const callbackWhenSceneReady = () => {\r\n this._enableCancelFunctions.delete(callbackWhenSceneReady);\r\n\r\n // Make sure a full frame is rendered before enabling snapshot rendering, so use \"+2\" instead of \"+1\"\r\n const targetFrameId = this._engine.frameId + 2;\r\n\r\n this._log(\"enableSnapshotRendering\", `scene ready, add callbacks for frames ${targetFrameId} and ${targetFrameId + 1}`);\r\n\r\n this._executeAtFrame(targetFrameId, () => {\r\n this._log(\"enableSnapshotRendering\", `callback #1, enable snapshot rendering at the engine level`);\r\n this._engine.snapshotRendering = true;\r\n });\r\n\r\n // Render one frame with snapshot rendering enabled to make sure everything is ready\r\n this._executeAtFrame(targetFrameId + 1, () => {\r\n this._log(\"enableSnapshotRendering\", `callback #2, signals that snapshot rendering helper is ready`);\r\n this._isEnabling = false;\r\n });\r\n };\r\n\r\n this._enableCancelFunctions.set(callbackWhenSceneReady, () => this._scene.onReadyObservable.removeCallback(callbackWhenSceneReady));\r\n\r\n this._scene.executeWhenReady(callbackWhenSceneReady);\r\n }\r\n\r\n /**\r\n * Disable snapshot rendering\r\n * Note that this method is ref-counted and works in pair with disableSnapshotRendering(): you should call enableSnapshotRendering() as many times as you call disableSnapshotRendering().\r\n */\r\n public disableSnapshotRendering() {\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n this._log(\"disableSnapshotRendering\", \"called\");\r\n\r\n if (this._disableRenderingRefCount === 0) {\r\n if (this._enableCancelFunctions.size > 0) {\r\n this._log(\"disableSnapshotRendering\", `cancelling ${this._enableCancelFunctions.size} \"enable\" callbacks`);\r\n }\r\n\r\n this._enableCancelFunctions.forEach((cancel) => cancel());\r\n this._enableCancelFunctions.clear();\r\n\r\n this._isEnabling = false;\r\n\r\n // Snapshot rendering switches from enabled to disabled\r\n // We reset the performance priority mode to that which it was before enabling snapshot rendering, but first set it to “BackwardCompatible” to allow the system to regenerate resources that may have been optimized for snapshot rendering.\r\n // We'll then restore the original mode at the next frame.\r\n this._scene.performancePriority = ScenePerformancePriority.BackwardCompatible;\r\n if (this._currentPerformancePriorityMode !== ScenePerformancePriority.BackwardCompatible) {\r\n this._log(\r\n \"disableSnapshotRendering\",\r\n `makes sure that the scene is rendered once in BackwardCompatible mode (code: ${ScenePerformancePriority.BackwardCompatible}) before switching to mode ${this._currentPerformancePriorityMode}`\r\n );\r\n\r\n this._pendingCurrentPerformancePriorityMode = this._currentPerformancePriorityMode;\r\n\r\n const callbackWhenSceneReady = () => {\r\n this._log(\"disableSnapshotRendering\", `scene ready, add callback for frame ${this._engine.frameId + 2}`);\r\n\r\n this._executeAtFrame(\r\n this._engine.frameId + 2,\r\n () => {\r\n this._log(\"disableSnapshotRendering\", `switching to performance priority mode ${this._pendingCurrentPerformancePriorityMode}`);\r\n this._scene.performancePriority = this._pendingCurrentPerformancePriorityMode!;\r\n this._pendingCurrentPerformancePriorityMode = undefined;\r\n },\r\n \"whenDisabled\"\r\n );\r\n };\r\n\r\n this._disableCancelFunctions.set(callbackWhenSceneReady, () => this._scene.onReadyObservable.removeCallback(callbackWhenSceneReady));\r\n\r\n this._scene.executeWhenReady(callbackWhenSceneReady);\r\n }\r\n }\r\n\r\n this._engine.snapshotRendering = false;\r\n this._disableRenderingRefCount++;\r\n }\r\n\r\n /**\r\n * Fix meshes for snapshot rendering.\r\n * This method will make sure that some features are disabled or fixed to make sure snapshot rendering works correctly.\r\n * @param meshes List of meshes to fix. If not provided, all meshes in the scene will be fixed.\r\n */\r\n public fixMeshes(meshes?: AbstractMesh[]) {\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n meshes = meshes || this._scene.meshes;\r\n\r\n for (const mesh of meshes) {\r\n (mesh as Mesh).ignoreCameraMaxZ = false;\r\n if (mesh.morphTargetManager) {\r\n mesh.morphTargetManager.numMaxInfluencers = Math.min(mesh.morphTargetManager.numTargets, this._options.morphTargetsNumMaxInfluences!);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Call this method to update a mesh on the GPU after some properties have changed (position, rotation, scaling, visibility).\r\n * @param mesh The mesh to update. Can be a single mesh or an array of meshes to update.\r\n */\r\n public updateMesh(mesh: AbstractMesh | AbstractMesh[]) {\r\n if (!this._fastSnapshotRenderingEnabled) {\r\n return;\r\n }\r\n\r\n if (Array.isArray(mesh)) {\r\n for (const m of mesh) {\r\n m.transferToEffect(m.computeWorldMatrix(true));\r\n }\r\n return;\r\n }\r\n\r\n mesh.transferToEffect(mesh.computeWorldMatrix(true));\r\n }\r\n\r\n /**\r\n * Update the meshes used in an effect layer to ensure that snapshot rendering works correctly for these meshes in this layer.\r\n * @param effectLayer The effect layer\r\n * @param autoUpdate If true, the helper will automatically update the effect layer meshes with each frame. If false, you'll need to call this method manually when the camera or layer meshes move or rotate.\r\n */\r\n public updateMeshesForEffectLayer(effectLayer: EffectLayer, autoUpdate = true) {\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n const renderPassId = effectLayer.mainTexture.renderPassId;\r\n\r\n if (autoUpdate) {\r\n this._onBeforeRenderObserverUpdateLayer = this._scene.onBeforeRenderObservable.add(() => {\r\n this._updateMeshMatricesForRenderPassId(renderPassId);\r\n });\r\n } else {\r\n this._updateMeshMatricesForRenderPassId(renderPassId);\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the helper\r\n */\r\n public dispose() {\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n this._scene.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);\r\n this._scene.onBeforeRenderObservable.remove(this._onBeforeRenderObserverUpdateLayer);\r\n this._engine.onResizeObservable.remove(this._onResizeObserver);\r\n }\r\n\r\n private get _fastSnapshotRenderingEnabled() {\r\n return this._engine.snapshotRendering && this._engine.snapshotRenderingMode === Constants.SNAPSHOTRENDERING_FAST;\r\n }\r\n\r\n private _updateMeshMatricesForRenderPassId(renderPassId: number) {\r\n if (!this._fastSnapshotRenderingEnabled) {\r\n return;\r\n }\r\n\r\n const sceneTransformationMatrix = this._scene.getTransformMatrix();\r\n\r\n for (let i = 0; i < this._scene.meshes.length; ++i) {\r\n const mesh = this._scene.meshes[i];\r\n if (!mesh.subMeshes) {\r\n continue;\r\n }\r\n\r\n for (let j = 0; j < mesh.subMeshes.length; ++j) {\r\n const dw = mesh.subMeshes[j]._getDrawWrapper(renderPassId);\r\n const effect = dw?.effect;\r\n if (effect) {\r\n const dataBuffer = (dw.drawContext as WebGPUDrawContext).buffers[\"LeftOver\" satisfies (typeof WebGPUShaderProcessor)[\"LeftOvertUBOName\"]];\r\n const ubLeftOver = (effect._pipelineContext as WebGPUPipelineContext)?.uniformBuffer;\r\n if (dataBuffer && ubLeftOver && ubLeftOver.setDataBuffer(dataBuffer)) {\r\n effect.setMatrix(\"viewProjection\", sceneTransformationMatrix);\r\n effect.setMatrix(\"world\", mesh.computeWorldMatrix());\r\n ubLeftOver.update();\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _executeAtFrame(frameId: number, func: () => void, mode: \"whenEnabled\" | \"whenDisabled\" = \"whenEnabled\") {\r\n const callback = () => {\r\n if (this._engine.frameId >= frameId) {\r\n this._engine.onEndFrameObservable.remove(obs);\r\n if (mode === \"whenEnabled\") {\r\n this._enableCancelFunctions.delete(callback);\r\n } else {\r\n this._disableCancelFunctions.delete(callback);\r\n }\r\n func();\r\n }\r\n };\r\n\r\n const obs = this._engine.onEndFrameObservable.add(callback);\r\n if (mode === \"whenEnabled\") {\r\n this._enableCancelFunctions.set(callback, () => this._engine.onEndFrameObservable.remove(obs));\r\n } else {\r\n this._disableCancelFunctions.set(callback, () => this._engine.onEndFrameObservable.remove(obs));\r\n }\r\n }\r\n\r\n private _log(funcName: string, message: string) {\r\n if (this.showDebugLogs) {\r\n Logger.Log(`[Frame: ${this._engine.frameId}] SnapshotRenderingHelper:${funcName} - ${message}`);\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -78,15 +78,15 @@ export declare class PointsCloudSystem implements IDisposable {
|
|
|
78
78
|
/**
|
|
79
79
|
* Gets the particle positions computed by the Point Cloud System
|
|
80
80
|
*/
|
|
81
|
-
get positions(): Float32Array
|
|
81
|
+
get positions(): Float32Array;
|
|
82
82
|
/**
|
|
83
83
|
* Gets the particle colors computed by the Point Cloud System
|
|
84
84
|
*/
|
|
85
|
-
get colors(): Float32Array
|
|
85
|
+
get colors(): Float32Array;
|
|
86
86
|
/**
|
|
87
87
|
* Gets the particle uvs computed by the Point Cloud System
|
|
88
88
|
*/
|
|
89
|
-
get uvs(): Float32Array
|
|
89
|
+
get uvs(): Float32Array;
|
|
90
90
|
/**
|
|
91
91
|
* Creates a PCS (Points Cloud System) object
|
|
92
92
|
* @param name (String) is the PCS name, this will be the underlying mesh name
|