@babylonjs/core 7.28.0 → 7.30.0

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.
Files changed (120) hide show
  1. package/Culling/ray.core.d.ts +13 -0
  2. package/Culling/ray.core.js +14 -6
  3. package/Culling/ray.core.js.map +1 -1
  4. package/Engines/WebGPU/Extensions/engine.debugging.js +24 -0
  5. package/Engines/WebGPU/Extensions/engine.debugging.js.map +1 -1
  6. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +4 -1
  7. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
  8. package/Engines/abstractEngine.js +2 -2
  9. package/Engines/abstractEngine.js.map +1 -1
  10. package/Engines/engine.d.ts +2 -1
  11. package/Engines/index.d.ts +1 -0
  12. package/Engines/index.js +1 -0
  13. package/Engines/index.js.map +1 -1
  14. package/Engines/nullEngine.d.ts +1 -0
  15. package/Engines/nullEngine.js +1 -0
  16. package/Engines/nullEngine.js.map +1 -1
  17. package/Engines/webgpuEngine.d.ts +4 -0
  18. package/Engines/webgpuEngine.js +2 -4
  19. package/Engines/webgpuEngine.js.map +1 -1
  20. package/Lights/Shadows/shadowGenerator.js +1 -1
  21. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  22. package/Loading/Plugins/babylonFileLoader.js +34 -18
  23. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  24. package/Materials/Textures/rawTexture3D.d.ts +12 -0
  25. package/Materials/Textures/rawTexture3D.js +18 -0
  26. package/Materials/Textures/rawTexture3D.js.map +1 -1
  27. package/Materials/Textures/renderTargetTexture.js +1 -2
  28. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  29. package/Materials/effect.d.ts +11 -0
  30. package/Materials/effect.js +20 -0
  31. package/Materials/effect.js.map +1 -1
  32. package/Materials/materialPluginBase.d.ts +46 -46
  33. package/Materials/materialPluginBase.js +46 -60
  34. package/Materials/materialPluginBase.js.map +1 -1
  35. package/Meshes/Builders/greasedLineBuilder.d.ts +0 -16
  36. package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
  37. package/Meshes/GreasedLine/greasedLineBaseMesh.d.ts +17 -1
  38. package/Meshes/GreasedLine/greasedLineBaseMesh.js +3 -2
  39. package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
  40. package/Meshes/Node/Blocks/Set/latticeBlock.d.ts +91 -0
  41. package/Meshes/Node/Blocks/Set/latticeBlock.js +194 -0
  42. package/Meshes/Node/Blocks/Set/latticeBlock.js.map +1 -0
  43. package/Meshes/Node/Blocks/Set/setPositionsBlock.js +11 -4
  44. package/Meshes/Node/Blocks/Set/setPositionsBlock.js.map +1 -1
  45. package/Meshes/Node/Blocks/geometryClampBlock.d.ts +8 -0
  46. package/Meshes/Node/Blocks/geometryClampBlock.js +22 -6
  47. package/Meshes/Node/Blocks/geometryClampBlock.js.map +1 -1
  48. package/Meshes/Node/Blocks/geometryInputBlock.js +2 -0
  49. package/Meshes/Node/Blocks/geometryInputBlock.js.map +1 -1
  50. package/Meshes/Node/Blocks/geometryInterceptorBlock.d.ts +5 -0
  51. package/Meshes/Node/Blocks/geometryInterceptorBlock.js +5 -1
  52. package/Meshes/Node/Blocks/geometryInterceptorBlock.js.map +1 -1
  53. package/Meshes/Node/Enums/nodeGeometryContextualSources.d.ts +5 -1
  54. package/Meshes/Node/Enums/nodeGeometryContextualSources.js +4 -0
  55. package/Meshes/Node/Enums/nodeGeometryContextualSources.js.map +1 -1
  56. package/Meshes/Node/index.d.ts +1 -0
  57. package/Meshes/Node/index.js +1 -0
  58. package/Meshes/Node/index.js.map +1 -1
  59. package/Meshes/Node/nodeGeometryBuildState.js +12 -0
  60. package/Meshes/Node/nodeGeometryBuildState.js.map +1 -1
  61. package/Meshes/abstractMesh.d.ts +2 -0
  62. package/Meshes/abstractMesh.hotSpot.d.ts +30 -0
  63. package/Meshes/abstractMesh.hotSpot.js +84 -0
  64. package/Meshes/abstractMesh.hotSpot.js.map +1 -0
  65. package/Meshes/abstractMesh.js +2 -0
  66. package/Meshes/abstractMesh.js.map +1 -1
  67. package/Meshes/index.d.ts +3 -0
  68. package/Meshes/index.js +3 -0
  69. package/Meshes/index.js.map +1 -1
  70. package/Meshes/lattice.d.ts +110 -0
  71. package/Meshes/lattice.js +224 -0
  72. package/Meshes/lattice.js.map +1 -0
  73. package/Meshes/lattice.material.d.ts +82 -0
  74. package/Meshes/lattice.material.js +259 -0
  75. package/Meshes/lattice.material.js.map +1 -0
  76. package/Meshes/mesh.js +1 -1
  77. package/Meshes/mesh.js.map +1 -1
  78. package/Misc/greasedLineTools.d.ts +1 -2
  79. package/Misc/greasedLineTools.js.map +1 -1
  80. package/Misc/index.d.ts +1 -0
  81. package/Misc/index.js +1 -0
  82. package/Misc/index.js.map +1 -1
  83. package/Misc/screenshotTools.js +0 -3
  84. package/Misc/screenshotTools.js.map +1 -1
  85. package/Misc/snapshotRenderingHelper.d.ts +63 -0
  86. package/Misc/snapshotRenderingHelper.js +182 -0
  87. package/Misc/snapshotRenderingHelper.js.map +1 -0
  88. package/Morph/morphTargetManager.js +0 -1
  89. package/Morph/morphTargetManager.js.map +1 -1
  90. package/Shaders/spriteMap.fragment.d.ts +4 -0
  91. package/Shaders/spriteMap.fragment.js +16 -3
  92. package/Shaders/spriteMap.fragment.js.map +1 -1
  93. package/Shaders/spriteMap.vertex.d.ts +3 -0
  94. package/Shaders/spriteMap.vertex.js +14 -2
  95. package/Shaders/spriteMap.vertex.js.map +1 -1
  96. package/ShadersWGSL/bilateralBlurQuality.fragment.js +1 -1
  97. package/ShadersWGSL/bilateralBlurQuality.fragment.js.map +1 -1
  98. package/ShadersWGSL/default.fragment.js +1 -1
  99. package/ShadersWGSL/default.fragment.js.map +1 -1
  100. package/ShadersWGSL/geometry.fragment.js +2 -2
  101. package/ShadersWGSL/geometry.fragment.js.map +1 -1
  102. package/ShadersWGSL/geometry.vertex.js +2 -2
  103. package/ShadersWGSL/geometry.vertex.js.map +1 -1
  104. package/ShadersWGSL/pbr.fragment.js +1 -1
  105. package/ShadersWGSL/pbr.fragment.js.map +1 -1
  106. package/ShadersWGSL/rsmFullGlobalIllumination.fragment.js +1 -1
  107. package/ShadersWGSL/rsmFullGlobalIllumination.fragment.js.map +1 -1
  108. package/Sprites/spriteManager.d.ts +10 -1
  109. package/Sprites/spriteManager.js +3 -2
  110. package/Sprites/spriteManager.js.map +1 -1
  111. package/Sprites/spriteMap.d.ts +7 -0
  112. package/Sprites/spriteMap.js +29 -1
  113. package/Sprites/spriteMap.js.map +1 -1
  114. package/Sprites/spritePackedManager.d.ts +6 -1
  115. package/Sprites/spritePackedManager.js +6 -2
  116. package/Sprites/spritePackedManager.js.map +1 -1
  117. package/Sprites/spriteRenderer.d.ts +16 -3
  118. package/Sprites/spriteRenderer.js +5 -3
  119. package/Sprites/spriteRenderer.js.map +1 -1
  120. package/package.json +1 -1
@@ -2,11 +2,10 @@ import { Vector3 } from "../Maths/math.vector";
2
2
  import type { AbstractMesh } from "../Meshes/abstractMesh";
3
3
  import type { IFontData } from "../Meshes/Builders/textBuilder";
4
4
  import type { FloatArray, IndicesArray } from "../types";
5
- import type { GreasedLinePoints } from "../Meshes/GreasedLine/greasedLineBaseMesh";
5
+ import type { GreasedLinePoints, GreasedLinePointsOptions } from "../Meshes/GreasedLine/greasedLineBaseMesh";
6
6
  import type { Color3 } from "../Maths/math.color";
7
7
  import { RawTexture } from "../Materials/Textures/rawTexture";
8
8
  import type { Scene } from "../scene";
9
- import type { GreasedLinePointsOptions } from "../Meshes/Builders/greasedLineBuilder";
10
9
  /**
11
10
  * Tool functions for GreasedLine
12
11
  */
@@ -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,E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AAI,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;YACjD,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;SACjF;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 } 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\nimport type { GreasedLinePointsOptions } from \"../Meshes/Builders/greasedLineBuilder\";\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,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,MA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G,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;SACjF;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"]}
package/Misc/index.d.ts CHANGED
@@ -63,6 +63,7 @@ export * from "./PerformanceViewer/index";
63
63
  export * from "./coroutine";
64
64
  export * from "./guid";
65
65
  export * from "./error";
66
+ export * from "./snapshotRenderingHelper";
66
67
  export * from "./observableCoroutine";
67
68
  export * from "./copyTextureToTexture";
68
69
  /** @deprecated Use individual exports */
package/Misc/index.js CHANGED
@@ -65,6 +65,7 @@ export * from "./PerformanceViewer/index.js";
65
65
  export * from "./coroutine.js";
66
66
  export * from "./guid.js";
67
67
  export * from "./error.js";
68
+ export * from "./snapshotRenderingHelper.js";
68
69
  // eslint-disable-next-line import/export
69
70
  export * from "./observableCoroutine.js";
70
71
  export * from "./copyTextureToTexture.js";
package/Misc/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC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e,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,yCAAyC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,yCAAyC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,aAAa,CAAC;AAE5B,mBAAmB;AACnB,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AAEnD,uBAAuB;AACvB,cAAc,0CAA0C,CAAC;AACzD,cAAc,8CAA8C,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./andOrNotEvaluator\";\r\nexport * from \"./assetsManager\";\r\nexport * from \"./basis\";\r\nexport * from \"./dds\";\r\nexport * from \"./decorators\";\r\nexport * from \"./deferred\";\r\nexport * from \"./environmentTextureTools\";\r\nexport * from \"./meshExploder\";\r\nexport * from \"./filesInput\";\r\nexport * from \"./HighDynamicRange/index\";\r\nexport * from \"./khronosTextureContainer\";\r\nexport * from \"./observable\";\r\nexport * from \"./observable.extensions\";\r\nexport * from \"./performanceMonitor\";\r\nexport * from \"./sceneOptimizer\";\r\nexport * from \"./sceneSerializer\";\r\nexport * from \"./smartArray\";\r\nexport * from \"./stringDictionary\";\r\nexport * from \"./tags\";\r\nexport * from \"./textureTools\";\r\n// loaded from texture tools\r\nexport * from \"../Shaders/lodCube.fragment\";\r\nexport * from \"../Shaders/lod.fragment\";\r\nexport * from \"../ShadersWGSL/lodCube.fragment\";\r\nexport * from \"../ShadersWGSL/lod.fragment\";\r\nexport * from \"./tga\";\r\nexport * from \"./tools\";\r\nexport * from \"./videoRecorder\";\r\nexport * from \"./virtualJoystick\";\r\nexport * from \"./workerPool\";\r\nexport * from \"./logger\";\r\nexport * from \"./typeStore\";\r\nexport * from \"./filesInputStore\";\r\nexport * from \"./deepCopier\";\r\nexport * from \"./pivotTools\";\r\nexport * from \"./precisionDate\";\r\nexport * from \"./screenshotTools\";\r\nexport * from \"./webRequest\";\r\nexport * from \"./iInspectable\";\r\nexport * from \"./brdfTextureTools\";\r\nexport * from \"./rgbdTextureTools\";\r\nexport * from \"./gradients\";\r\nexport * from \"./perfCounter\";\r\nexport * from \"./fileRequest\";\r\nexport * from \"./customAnimationFrameRequester\";\r\nexport * from \"./retryStrategy\";\r\nexport * from \"./interfaces/screenshotSize\";\r\nexport * from \"./interfaces/iPerfViewer\";\r\nexport * from \"./fileTools\";\r\nexport * from \"./stringTools\";\r\nexport * from \"./dataReader\";\r\nexport * from \"./minMaxReducer\";\r\nexport * from \"./depthReducer\";\r\nexport * from \"./dataStorage\";\r\nexport * from \"./sceneRecorder\";\r\nexport * from \"./khronosTextureContainer2\";\r\nexport * from \"./trajectoryClassifier\";\r\nexport * from \"./timer\";\r\nexport * from \"./copyTools\";\r\nexport * from \"./reflector\";\r\nexport * from \"./domManagement\";\r\nexport * from \"./pressureObserverWrapper\";\r\nexport * from \"./PerformanceViewer/index\";\r\nexport * from \"./coroutine\";\r\nexport * from \"./guid\";\r\nexport * from \"./error\";\r\n// eslint-disable-next-line import/export\r\nexport * from \"./observableCoroutine\";\r\nexport * from \"./copyTextureToTexture\";\r\n/** @deprecated Use individual exports */\r\nexport { DumpTools } from \"./dumpTools\";\r\nexport * from \"./greasedLineTools\";\r\nexport * from \"./equirectangularCapture\";\r\nexport * from \"./decorators.serialization\";\r\nexport * from \"./asyncLock\";\r\n\r\n// RGBDTextureTools\r\nexport * from \"../Shaders/rgbdDecode.fragment\";\r\nexport * from \"../Shaders/rgbdEncode.fragment\";\r\nexport * from \"../ShadersWGSL/rgbdDecode.fragment\";\r\nexport * from \"../ShadersWGSL/rgbdEncode.fragment\";\r\n\r\n// CopyTextureToTexture\r\nexport * from \"../Shaders/copyTextureToTexture.fragment\";\r\nexport * from \"../ShadersWGSL/copyTextureToTexture.fragment\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,4BAA4B;AAC5B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;A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CAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AAEnD,uBAAuB;AACvB,cAAc,0CAA0C,CAAC;AACzD,cAAc,8CAA8C,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./andOrNotEvaluator\";\r\nexport * from \"./assetsManager\";\r\nexport * from \"./basis\";\r\nexport * from \"./dds\";\r\nexport * from \"./decorators\";\r\nexport * from \"./deferred\";\r\nexport * from \"./environmentTextureTools\";\r\nexport * from \"./meshExploder\";\r\nexport * from \"./filesInput\";\r\nexport * from \"./HighDynamicRange/index\";\r\nexport * from \"./khronosTextureContainer\";\r\nexport * from \"./observable\";\r\nexport * from \"./observable.extensions\";\r\nexport * from \"./performanceMonitor\";\r\nexport * from \"./sceneOptimizer\";\r\nexport * from \"./sceneSerializer\";\r\nexport * from \"./smartArray\";\r\nexport * from \"./stringDictionary\";\r\nexport * from \"./tags\";\r\nexport * from \"./textureTools\";\r\n// loaded from texture tools\r\nexport * from \"../Shaders/lodCube.fragment\";\r\nexport * from \"../Shaders/lod.fragment\";\r\nexport * from \"../ShadersWGSL/lodCube.fragment\";\r\nexport * from \"../ShadersWGSL/lod.fragment\";\r\nexport * from \"./tga\";\r\nexport * from \"./tools\";\r\nexport * from \"./videoRecorder\";\r\nexport * from \"./virtualJoystick\";\r\nexport * from \"./workerPool\";\r\nexport * from \"./logger\";\r\nexport * from \"./typeStore\";\r\nexport * from \"./filesInputStore\";\r\nexport * from \"./deepCopier\";\r\nexport * from \"./pivotTools\";\r\nexport * from \"./precisionDate\";\r\nexport * from \"./screenshotTools\";\r\nexport * from \"./webRequest\";\r\nexport * from \"./iInspectable\";\r\nexport * from \"./brdfTextureTools\";\r\nexport * from \"./rgbdTextureTools\";\r\nexport * from \"./gradients\";\r\nexport * from \"./perfCounter\";\r\nexport * from \"./fileRequest\";\r\nexport * from \"./customAnimationFrameRequester\";\r\nexport * from \"./retryStrategy\";\r\nexport * from \"./interfaces/screenshotSize\";\r\nexport * from \"./interfaces/iPerfViewer\";\r\nexport * from \"./fileTools\";\r\nexport * from \"./stringTools\";\r\nexport * from \"./dataReader\";\r\nexport * from \"./minMaxReducer\";\r\nexport * from \"./depthReducer\";\r\nexport * from \"./dataStorage\";\r\nexport * from \"./sceneRecorder\";\r\nexport * from \"./khronosTextureContainer2\";\r\nexport * from \"./trajectoryClassifier\";\r\nexport * from \"./timer\";\r\nexport * from \"./copyTools\";\r\nexport * from \"./reflector\";\r\nexport * from \"./domManagement\";\r\nexport * from \"./pressureObserverWrapper\";\r\nexport * from \"./PerformanceViewer/index\";\r\nexport * from \"./coroutine\";\r\nexport * from \"./guid\";\r\nexport * from \"./error\";\r\nexport * from \"./snapshotRenderingHelper\";\r\n// eslint-disable-next-line import/export\r\nexport * from \"./observableCoroutine\";\r\nexport * from \"./copyTextureToTexture\";\r\n/** @deprecated Use individual exports */\r\nexport { DumpTools } from \"./dumpTools\";\r\nexport * from \"./greasedLineTools\";\r\nexport * from \"./equirectangularCapture\";\r\nexport * from \"./decorators.serialization\";\r\nexport * from \"./asyncLock\";\r\n\r\n// RGBDTextureTools\r\nexport * from \"../Shaders/rgbdDecode.fragment\";\r\nexport * from \"../Shaders/rgbdEncode.fragment\";\r\nexport * from \"../ShadersWGSL/rgbdDecode.fragment\";\r\nexport * from \"../ShadersWGSL/rgbdEncode.fragment\";\r\n\r\n// CopyTextureToTexture\r\nexport * from \"../Shaders/copyTextureToTexture.fragment\";\r\nexport * from \"../ShadersWGSL/copyTextureToTexture.fragment\";\r\n"]}
@@ -190,14 +190,11 @@ export function CreateScreenshotUsingRenderTarget(engine, camera, size, successC
190
190
  }));
191
191
  }
192
192
  });
193
- // re-render the scene after the camera has been reset to the original camera to avoid a flicker that could occur
194
- // if the camera used for the RTT rendering stays in effect for the next frame (and if that camera was different from the original camera)
195
193
  scene.incrementRenderId();
196
194
  scene.resetCachedMaterial();
197
195
  texture.render(true);
198
196
  engine.setSize(originalSize.width, originalSize.height);
199
197
  camera.getProjectionMatrix(true); // Force cache refresh;
200
- scene.render();
201
198
  }
202
199
  else {
203
200
  setTimeout(renderWhenReady, 16);
@@ -1 +1 @@
1
- {"version":3,"file":"screenshotTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/screenshotTools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIlD,IAAI,gBAAgB,GAAgC,IAAI,CAAC;AAEzD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,gBAAgB,CAC5B,MAAsB,EACtB,MAAc,EACd,IAA8B,EAC9B,eAAwC,EACxC,QAAQ,GAAG,WAAW,EACtB,aAAa,GAAG,KAAK,EACrB,OAAgB;IAEhB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAEnE,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,EAAE;QACpB,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAC3C,OAAO;KACV;IAED,IAAI,CAAC,gBAAgB,EAAE;QACnB,gBAAgB,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;KACvD;IAED,gBAAgB,CAAC,KAAK,GAAG,KAAK,CAAC;IAC/B,gBAAgB,CAAC,MAAM,GAAG,MAAM,CAAC;IAEjC,MAAM,aAAa,G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EAAE;QACR,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;KAC/B;IACD,IAAI,UAAU,EAAE;QACZ,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;KACvC;IACD,IAAI,WAAW,EAAE;QACb,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;KACzC;IAED,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,UAAU,EAAE,UAAU,GAAG,CAAC,EAAE,WAAW,EAAE,WAAW,GAAG,CAAC,EAAE,CAAC;AAC9G,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B;;;;;;;;;;;;;;;;;OAiBG;IACH,gBAAgB;IAEhB;;;;;;;;;;;;;;;OAeG;IACH,qBAAqB;IAErB;;;;;;;;;;;;OAYG;IACH,+BAA+B;IAE/B;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,iCAAiC;IAEjC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,sCAAsC;CACzC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,eAAe,GAAG,GAAG,EAAE;IACzB,+BAA+B;IAC/B,KAAK,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC1C,KAAK,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;IACpD,KAAK,CAAC,iCAAiC,GAAG,iCAAiC,CAAC;IAC5E,KAAK,CAAC,sCAAsC,GAAG,sCAAsC,CAAC;AAC1F,CAAC,CAAC;AAEF,eAAe,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { FxaaPostProcess } from \"../PostProcesses/fxaaPostProcess\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { Logger } from \"./logger\";\r\nimport { Tools } from \"./tools\";\r\nimport type { IScreenshotSize } from \"./interfaces/screenshotSize\";\r\nimport { DumpData } from \"./dumpTools\";\r\nimport type { Nullable } from \"../types\";\r\nimport { ApplyPostProcess } from \"./textureTools\";\r\n\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\n\r\nlet screenshotCanvas: Nullable<HTMLCanvasElement> = null;\r\n\r\n/**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback defines the callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param forceDownload force the system to download the image even if a successCallback is provided\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n */\r\nexport function CreateScreenshot(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n forceDownload = false,\r\n quality?: number\r\n): void {\r\n const { height, width } = _GetScreenshotSize(engine, camera, size);\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n if (!screenshotCanvas) {\r\n screenshotCanvas = document.createElement(\"canvas\");\r\n }\r\n\r\n screenshotCanvas.width = width;\r\n screenshotCanvas.height = height;\r\n\r\n const renderContext = screenshotCanvas.getContext(\"2d\");\r\n\r\n const ratio = engine.getRenderWidth() / engine.getRenderHeight();\r\n let newWidth = width;\r\n let newHeight = newWidth / ratio;\r\n if (newHeight > height) {\r\n newHeight = height;\r\n newWidth = newHeight * ratio;\r\n }\r\n\r\n const offsetX = Math.max(0, width - newWidth) / 2;\r\n const offsetY = Math.max(0, height - newHeight) / 2;\r\n\r\n const scene = camera.getScene();\r\n if (scene.activeCamera !== camera) {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (forceDownload) {\r\n const blob = new Blob([data]);\r\n Tools.DownloadBlob(blob);\r\n if (successCallback) {\r\n successCallback(\"\");\r\n }\r\n } else if (successCallback) {\r\n successCallback(data);\r\n }\r\n },\r\n mimeType,\r\n 1.0,\r\n engine.getCreationOptions().antialias,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n quality\r\n );\r\n } else {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n const renderingCanvas = engine.getRenderingCanvas();\r\n if (renderContext && renderingCanvas) {\r\n renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);\r\n }\r\n\r\n if (screenshotCanvas) {\r\n if (forceDownload) {\r\n Tools.EncodeScreenshotCanvasData(screenshotCanvas, undefined, mimeType, undefined, quality);\r\n if (successCallback) {\r\n successCallback(\"\");\r\n }\r\n } else {\r\n Tools.EncodeScreenshotCanvasData(screenshotCanvas, successCallback, mimeType, undefined, quality);\r\n }\r\n }\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotAsync(engine: AbstractEngine, camera: Camera, size: IScreenshotSize | number, mimeType = \"image/png\", quality?: number): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n CreateScreenshot(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType,\r\n undefined,\r\n quality\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotWithResizeAsync(engine: AbstractEngine, camera: Camera, width: number, height: number, mimeType = \"image/png\", quality?: number): Promise<void> {\r\n return new Promise((resolve) => {\r\n CreateScreenshot(\r\n engine,\r\n camera,\r\n { width: width, height: height },\r\n () => {\r\n resolve();\r\n },\r\n mimeType,\r\n true,\r\n quality\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height, finalWidth, finalHeight. If a single number is passed,\r\n * it will be used for both width and height, as well as finalWidth, finalHeight. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param customizeTexture An optional callback that can be used to modify the render target texture before taking the screenshot. This can be used, for instance, to enable camera post-processes before taking the screenshot.\r\n */\r\nexport function CreateScreenshotUsingRenderTarget(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n samples = 1,\r\n antialiasing = false,\r\n fileName?: string,\r\n renderSprites = false,\r\n enableStencilBuffer = false,\r\n useLayerMask = true,\r\n quality?: number,\r\n customizeTexture?: (texture: RenderTargetTexture) => void\r\n): void {\r\n const { height, width, finalWidth, finalHeight } = _GetScreenshotSize(engine, camera, size);\r\n const targetTextureSize = { width, height };\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n const originalSize = { width: engine.getRenderWidth(), height: engine.getRenderHeight() };\r\n engine.setSize(width, height); // we need this call to trigger onResizeObservable with the screenshot width/height on all the subsystems that are observing this event and that needs to (re)create some resources with the right dimensions\r\n\r\n const scene = camera.getScene();\r\n\r\n // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)\r\n const texture = new RenderTargetTexture(\r\n \"screenShot\",\r\n targetTextureSize,\r\n scene,\r\n false,\r\n false,\r\n Constants.TEXTURETYPE_UNSIGNED_INT,\r\n false,\r\n Texture.BILINEAR_SAMPLINGMODE,\r\n undefined,\r\n enableStencilBuffer,\r\n undefined,\r\n undefined,\r\n undefined,\r\n samples\r\n );\r\n texture.renderList = scene.meshes.slice();\r\n texture.samples = samples;\r\n texture.renderSprites = renderSprites;\r\n texture.activeCamera = camera;\r\n texture.forceLayerMaskCheck = useLayerMask;\r\n customizeTexture?.(texture);\r\n\r\n const renderWhenReady = () => {\r\n if (texture.isReadyForRendering() && camera.isReady(true)) {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n if (finalWidth === width && finalHeight === height) {\r\n texture.readPixels(undefined, undefined, undefined, false)!.then((data) => {\r\n DumpData(width, height, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true, undefined, quality);\r\n texture.dispose();\r\n });\r\n } else {\r\n const importPromise = engine.isWebGPU ? import(\"../ShadersWGSL/pass.fragment\") : import(\"../Shaders/pass.fragment\");\r\n\r\n importPromise.then(() =>\r\n ApplyPostProcess(\"pass\", texture.getInternalTexture()!, scene, undefined, undefined, undefined, finalWidth, finalHeight).then((texture) => {\r\n engine._readTexturePixels(texture, finalWidth, finalHeight, -1, 0, null, true, false, 0, 0).then((data) => {\r\n DumpData(finalWidth, finalHeight, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true, undefined, quality);\r\n texture.dispose();\r\n });\r\n })\r\n );\r\n }\r\n });\r\n\r\n // re-render the scene after the camera has been reset to the original camera to avoid a flicker that could occur\r\n // if the camera used for the RTT rendering stays in effect for the next frame (and if that camera was different from the original camera)\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n texture.render(true);\r\n engine.setSize(originalSize.width, originalSize.height);\r\n camera.getProjectionMatrix(true); // Force cache refresh;\r\n scene.render();\r\n } else {\r\n setTimeout(renderWhenReady, 16);\r\n }\r\n };\r\n\r\n const renderToTexture = () => {\r\n // render the RTT\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n\r\n renderWhenReady();\r\n };\r\n\r\n if (antialiasing) {\r\n const fxaaPostProcess = new FxaaPostProcess(\"antialiasing\", 1.0, scene.activeCamera);\r\n texture.addPostProcess(fxaaPostProcess);\r\n // Async Shader Compilation can lead to none ready effects in synchronous code\r\n fxaaPostProcess.onEffectCreatedObservable.addOnce((e) => {\r\n if (!e.isReady()) {\r\n e.onCompiled = () => {\r\n renderToTexture();\r\n };\r\n }\r\n // The effect is ready we can render\r\n else {\r\n renderToTexture();\r\n }\r\n });\r\n } else {\r\n // No need to wait for extra resources to be ready\r\n renderToTexture();\r\n }\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param customizeTexture An optional callback that can be used to modify the render target texture before taking the screenshot. This can be used, for instance, to enable camera post-processes before taking the screenshot.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotUsingRenderTargetAsync(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n mimeType = \"image/png\",\r\n samples = 1,\r\n antialiasing = false,\r\n fileName?: string,\r\n renderSprites = false,\r\n enableStencilBuffer = false,\r\n useLayerMask = true,\r\n quality?: number,\r\n customizeTexture?: (texture: RenderTargetTexture) => void\r\n): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType,\r\n samples,\r\n antialiasing,\r\n fileName,\r\n renderSprites,\r\n enableStencilBuffer,\r\n useLayerMask,\r\n quality,\r\n customizeTexture\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Gets height and width for screenshot size\r\n * @param engine\r\n * @param camera\r\n * @param size\r\n * @private\r\n */\r\nfunction _GetScreenshotSize(engine: AbstractEngine, camera: Camera, size: IScreenshotSize | number): { height: number; width: number; finalWidth: number; finalHeight: number } {\r\n let height = 0;\r\n let width = 0;\r\n let finalWidth = 0;\r\n let finalHeight = 0;\r\n\r\n //If a size value defined as object\r\n if (typeof size === \"object\") {\r\n const precision = size.precision\r\n ? Math.abs(size.precision) // prevent GL_INVALID_VALUE : glViewport: negative width/height\r\n : 1;\r\n\r\n //If a width and height values is specified\r\n if (size.width && size.height) {\r\n height = size.height * precision;\r\n width = size.width * precision;\r\n }\r\n //If passing only width, computing height to keep display canvas ratio.\r\n else if (size.width && !size.height) {\r\n width = size.width * precision;\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n //If passing only height, computing width to keep display canvas ratio.\r\n else if (size.height && !size.width) {\r\n height = size.height * precision;\r\n width = Math.round(height * engine.getAspectRatio(camera));\r\n } else {\r\n width = Math.round(engine.getRenderWidth() * precision);\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n\r\n //If a finalWidth and finalHeight values is specified\r\n if (size.finalWidth && size.finalHeight) {\r\n finalHeight = size.finalHeight;\r\n finalWidth = size.finalWidth;\r\n }\r\n //If passing only finalWidth, computing finalHeight to keep display canvas ratio.\r\n else if (size.finalWidth && !size.finalHeight) {\r\n finalWidth = size.finalWidth;\r\n finalHeight = Math.round(finalWidth / engine.getAspectRatio(camera));\r\n }\r\n //If passing only finalHeight, computing finalWidth to keep display canvas ratio.\r\n else if (size.finalHeight && !size.finalWidth) {\r\n finalHeight = size.finalHeight;\r\n finalWidth = Math.round(finalHeight * engine.getAspectRatio(camera));\r\n } else {\r\n finalWidth = width;\r\n finalHeight = height;\r\n }\r\n }\r\n //Assuming here that \"size\" parameter is a number\r\n else if (!isNaN(size)) {\r\n height = size;\r\n width = size;\r\n finalWidth = size;\r\n finalHeight = size;\r\n }\r\n\r\n // When creating the image data from the CanvasRenderingContext2D, the width and height is clamped to the size of the _gl context\r\n // On certain GPUs, it seems as if the _gl context truncates to an integer automatically. Therefore, if a user tries to pass the width of their canvas element\r\n // and it happens to be a float (1000.5 x 600.5 px), the engine.readPixels will return a different size array than context.createImageData\r\n // to resolve this, we truncate the floats here to ensure the same size\r\n if (width) {\r\n width = Math.floor(width);\r\n }\r\n if (height) {\r\n height = Math.floor(height);\r\n }\r\n if (finalWidth) {\r\n finalWidth = Math.floor(finalWidth);\r\n }\r\n if (finalHeight) {\r\n finalHeight = Math.floor(finalHeight);\r\n }\r\n\r\n return { height: height | 0, width: width | 0, finalWidth: finalWidth | 0, finalHeight: finalHeight | 0 };\r\n}\r\n\r\n/**\r\n * Class containing a set of static utilities functions for screenshots\r\n */\r\nexport const ScreenshotTools = {\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback defines the callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param forceDownload force the system to download the image even if a successCallback is provided\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n */\r\n CreateScreenshot,\r\n\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotAsync,\r\n\r\n /**\r\n * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotWithResizeAsync,\r\n\r\n /**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n */\r\n CreateScreenshotUsingRenderTarget,\r\n\r\n /**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotUsingRenderTargetAsync,\r\n};\r\n\r\n/**\r\n * This will be executed automatically for UMD and es5.\r\n * If esm dev wants the side effects to execute they will have to run it manually\r\n * Once we build native modules those need to be exported.\r\n * @internal\r\n */\r\nconst initSideEffects = () => {\r\n // References the dependencies.\r\n Tools.CreateScreenshot = CreateScreenshot;\r\n Tools.CreateScreenshotAsync = CreateScreenshotAsync;\r\n Tools.CreateScreenshotUsingRenderTarget = CreateScreenshotUsingRenderTarget;\r\n Tools.CreateScreenshotUsingRenderTargetAsync = CreateScreenshotUsingRenderTargetAsync;\r\n};\r\n\r\ninitSideEffects();\r\n"]}
1
+ {"version":3,"file":"screenshotTools.js","sourceRoot":"","s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WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;KACzC;IAED,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,UAAU,EAAE,UAAU,GAAG,CAAC,EAAE,WAAW,EAAE,WAAW,GAAG,CAAC,EAAE,CAAC;AAC9G,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B;;;;;;;;;;;;;;;;;OAiBG;IACH,gBAAgB;IAEhB;;;;;;;;;;;;;;;OAeG;IACH,qBAAqB;IAErB;;;;;;;;;;;;OAYG;IACH,+BAA+B;IAE/B;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,iCAAiC;IAEjC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,sCAAsC;CACzC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,eAAe,GAAG,GAAG,EAAE;IACzB,+BAA+B;IAC/B,KAAK,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC1C,KAAK,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;IACpD,KAAK,CAAC,iCAAiC,GAAG,iCAAiC,CAAC;IAC5E,KAAK,CAAC,sCAAsC,GAAG,sCAAsC,CAAC;AAC1F,CAAC,CAAC;AAEF,eAAe,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { FxaaPostProcess } from \"../PostProcesses/fxaaPostProcess\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { Logger } from \"./logger\";\r\nimport { Tools } from \"./tools\";\r\nimport type { IScreenshotSize } from \"./interfaces/screenshotSize\";\r\nimport { DumpData } from \"./dumpTools\";\r\nimport type { Nullable } from \"../types\";\r\nimport { ApplyPostProcess } from \"./textureTools\";\r\n\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\n\r\nlet screenshotCanvas: Nullable<HTMLCanvasElement> = null;\r\n\r\n/**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback defines the callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param forceDownload force the system to download the image even if a successCallback is provided\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n */\r\nexport function CreateScreenshot(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n forceDownload = false,\r\n quality?: number\r\n): void {\r\n const { height, width } = _GetScreenshotSize(engine, camera, size);\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n if (!screenshotCanvas) {\r\n screenshotCanvas = document.createElement(\"canvas\");\r\n }\r\n\r\n screenshotCanvas.width = width;\r\n screenshotCanvas.height = height;\r\n\r\n const renderContext = screenshotCanvas.getContext(\"2d\");\r\n\r\n const ratio = engine.getRenderWidth() / engine.getRenderHeight();\r\n let newWidth = width;\r\n let newHeight = newWidth / ratio;\r\n if (newHeight > height) {\r\n newHeight = height;\r\n newWidth = newHeight * ratio;\r\n }\r\n\r\n const offsetX = Math.max(0, width - newWidth) / 2;\r\n const offsetY = Math.max(0, height - newHeight) / 2;\r\n\r\n const scene = camera.getScene();\r\n if (scene.activeCamera !== camera) {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (forceDownload) {\r\n const blob = new Blob([data]);\r\n Tools.DownloadBlob(blob);\r\n if (successCallback) {\r\n successCallback(\"\");\r\n }\r\n } else if (successCallback) {\r\n successCallback(data);\r\n }\r\n },\r\n mimeType,\r\n 1.0,\r\n engine.getCreationOptions().antialias,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n quality\r\n );\r\n } else {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n const renderingCanvas = engine.getRenderingCanvas();\r\n if (renderContext && renderingCanvas) {\r\n renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);\r\n }\r\n\r\n if (screenshotCanvas) {\r\n if (forceDownload) {\r\n Tools.EncodeScreenshotCanvasData(screenshotCanvas, undefined, mimeType, undefined, quality);\r\n if (successCallback) {\r\n successCallback(\"\");\r\n }\r\n } else {\r\n Tools.EncodeScreenshotCanvasData(screenshotCanvas, successCallback, mimeType, undefined, quality);\r\n }\r\n }\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotAsync(engine: AbstractEngine, camera: Camera, size: IScreenshotSize | number, mimeType = \"image/png\", quality?: number): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n CreateScreenshot(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType,\r\n undefined,\r\n quality\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotWithResizeAsync(engine: AbstractEngine, camera: Camera, width: number, height: number, mimeType = \"image/png\", quality?: number): Promise<void> {\r\n return new Promise((resolve) => {\r\n CreateScreenshot(\r\n engine,\r\n camera,\r\n { width: width, height: height },\r\n () => {\r\n resolve();\r\n },\r\n mimeType,\r\n true,\r\n quality\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height, finalWidth, finalHeight. If a single number is passed,\r\n * it will be used for both width and height, as well as finalWidth, finalHeight. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param customizeTexture An optional callback that can be used to modify the render target texture before taking the screenshot. This can be used, for instance, to enable camera post-processes before taking the screenshot.\r\n */\r\nexport function CreateScreenshotUsingRenderTarget(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n samples = 1,\r\n antialiasing = false,\r\n fileName?: string,\r\n renderSprites = false,\r\n enableStencilBuffer = false,\r\n useLayerMask = true,\r\n quality?: number,\r\n customizeTexture?: (texture: RenderTargetTexture) => void\r\n): void {\r\n const { height, width, finalWidth, finalHeight } = _GetScreenshotSize(engine, camera, size);\r\n const targetTextureSize = { width, height };\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n const originalSize = { width: engine.getRenderWidth(), height: engine.getRenderHeight() };\r\n engine.setSize(width, height); // we need this call to trigger onResizeObservable with the screenshot width/height on all the subsystems that are observing this event and that needs to (re)create some resources with the right dimensions\r\n\r\n const scene = camera.getScene();\r\n\r\n // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)\r\n const texture = new RenderTargetTexture(\r\n \"screenShot\",\r\n targetTextureSize,\r\n scene,\r\n false,\r\n false,\r\n Constants.TEXTURETYPE_UNSIGNED_INT,\r\n false,\r\n Texture.BILINEAR_SAMPLINGMODE,\r\n undefined,\r\n enableStencilBuffer,\r\n undefined,\r\n undefined,\r\n undefined,\r\n samples\r\n );\r\n texture.renderList = scene.meshes.slice();\r\n texture.samples = samples;\r\n texture.renderSprites = renderSprites;\r\n texture.activeCamera = camera;\r\n texture.forceLayerMaskCheck = useLayerMask;\r\n customizeTexture?.(texture);\r\n\r\n const renderWhenReady = () => {\r\n if (texture.isReadyForRendering() && camera.isReady(true)) {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n if (finalWidth === width && finalHeight === height) {\r\n texture.readPixels(undefined, undefined, undefined, false)!.then((data) => {\r\n DumpData(width, height, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true, undefined, quality);\r\n texture.dispose();\r\n });\r\n } else {\r\n const importPromise = engine.isWebGPU ? import(\"../ShadersWGSL/pass.fragment\") : import(\"../Shaders/pass.fragment\");\r\n importPromise.then(() =>\r\n ApplyPostProcess(\"pass\", texture.getInternalTexture()!, scene, undefined, undefined, undefined, finalWidth, finalHeight).then((texture) => {\r\n engine._readTexturePixels(texture, finalWidth, finalHeight, -1, 0, null, true, false, 0, 0).then((data) => {\r\n DumpData(finalWidth, finalHeight, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true, undefined, quality);\r\n texture.dispose();\r\n });\r\n })\r\n );\r\n }\r\n });\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n texture.render(true);\r\n engine.setSize(originalSize.width, originalSize.height);\r\n camera.getProjectionMatrix(true); // Force cache refresh;\r\n } else {\r\n setTimeout(renderWhenReady, 16);\r\n }\r\n };\r\n\r\n const renderToTexture = () => {\r\n // render the RTT\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n\r\n renderWhenReady();\r\n };\r\n\r\n if (antialiasing) {\r\n const fxaaPostProcess = new FxaaPostProcess(\"antialiasing\", 1.0, scene.activeCamera);\r\n texture.addPostProcess(fxaaPostProcess);\r\n // Async Shader Compilation can lead to none ready effects in synchronous code\r\n fxaaPostProcess.onEffectCreatedObservable.addOnce((e) => {\r\n if (!e.isReady()) {\r\n e.onCompiled = () => {\r\n renderToTexture();\r\n };\r\n }\r\n // The effect is ready we can render\r\n else {\r\n renderToTexture();\r\n }\r\n });\r\n } else {\r\n // No need to wait for extra resources to be ready\r\n renderToTexture();\r\n }\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param customizeTexture An optional callback that can be used to modify the render target texture before taking the screenshot. This can be used, for instance, to enable camera post-processes before taking the screenshot.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotUsingRenderTargetAsync(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n mimeType = \"image/png\",\r\n samples = 1,\r\n antialiasing = false,\r\n fileName?: string,\r\n renderSprites = false,\r\n enableStencilBuffer = false,\r\n useLayerMask = true,\r\n quality?: number,\r\n customizeTexture?: (texture: RenderTargetTexture) => void\r\n): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType,\r\n samples,\r\n antialiasing,\r\n fileName,\r\n renderSprites,\r\n enableStencilBuffer,\r\n useLayerMask,\r\n quality,\r\n customizeTexture\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Gets height and width for screenshot size\r\n * @param engine\r\n * @param camera\r\n * @param size\r\n * @private\r\n */\r\nfunction _GetScreenshotSize(engine: AbstractEngine, camera: Camera, size: IScreenshotSize | number): { height: number; width: number; finalWidth: number; finalHeight: number } {\r\n let height = 0;\r\n let width = 0;\r\n let finalWidth = 0;\r\n let finalHeight = 0;\r\n\r\n //If a size value defined as object\r\n if (typeof size === \"object\") {\r\n const precision = size.precision\r\n ? Math.abs(size.precision) // prevent GL_INVALID_VALUE : glViewport: negative width/height\r\n : 1;\r\n\r\n //If a width and height values is specified\r\n if (size.width && size.height) {\r\n height = size.height * precision;\r\n width = size.width * precision;\r\n }\r\n //If passing only width, computing height to keep display canvas ratio.\r\n else if (size.width && !size.height) {\r\n width = size.width * precision;\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n //If passing only height, computing width to keep display canvas ratio.\r\n else if (size.height && !size.width) {\r\n height = size.height * precision;\r\n width = Math.round(height * engine.getAspectRatio(camera));\r\n } else {\r\n width = Math.round(engine.getRenderWidth() * precision);\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n\r\n //If a finalWidth and finalHeight values is specified\r\n if (size.finalWidth && size.finalHeight) {\r\n finalHeight = size.finalHeight;\r\n finalWidth = size.finalWidth;\r\n }\r\n //If passing only finalWidth, computing finalHeight to keep display canvas ratio.\r\n else if (size.finalWidth && !size.finalHeight) {\r\n finalWidth = size.finalWidth;\r\n finalHeight = Math.round(finalWidth / engine.getAspectRatio(camera));\r\n }\r\n //If passing only finalHeight, computing finalWidth to keep display canvas ratio.\r\n else if (size.finalHeight && !size.finalWidth) {\r\n finalHeight = size.finalHeight;\r\n finalWidth = Math.round(finalHeight * engine.getAspectRatio(camera));\r\n } else {\r\n finalWidth = width;\r\n finalHeight = height;\r\n }\r\n }\r\n //Assuming here that \"size\" parameter is a number\r\n else if (!isNaN(size)) {\r\n height = size;\r\n width = size;\r\n finalWidth = size;\r\n finalHeight = size;\r\n }\r\n\r\n // When creating the image data from the CanvasRenderingContext2D, the width and height is clamped to the size of the _gl context\r\n // On certain GPUs, it seems as if the _gl context truncates to an integer automatically. Therefore, if a user tries to pass the width of their canvas element\r\n // and it happens to be a float (1000.5 x 600.5 px), the engine.readPixels will return a different size array than context.createImageData\r\n // to resolve this, we truncate the floats here to ensure the same size\r\n if (width) {\r\n width = Math.floor(width);\r\n }\r\n if (height) {\r\n height = Math.floor(height);\r\n }\r\n if (finalWidth) {\r\n finalWidth = Math.floor(finalWidth);\r\n }\r\n if (finalHeight) {\r\n finalHeight = Math.floor(finalHeight);\r\n }\r\n\r\n return { height: height | 0, width: width | 0, finalWidth: finalWidth | 0, finalHeight: finalHeight | 0 };\r\n}\r\n\r\n/**\r\n * Class containing a set of static utilities functions for screenshots\r\n */\r\nexport const ScreenshotTools = {\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback defines the callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param forceDownload force the system to download the image even if a successCallback is provided\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n */\r\n CreateScreenshot,\r\n\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotAsync,\r\n\r\n /**\r\n * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotWithResizeAsync,\r\n\r\n /**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n */\r\n CreateScreenshotUsingRenderTarget,\r\n\r\n /**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotUsingRenderTargetAsync,\r\n};\r\n\r\n/**\r\n * This will be executed automatically for UMD and es5.\r\n * If esm dev wants the side effects to execute they will have to run it manually\r\n * Once we build native modules those need to be exported.\r\n * @internal\r\n */\r\nconst initSideEffects = () => {\r\n // References the dependencies.\r\n Tools.CreateScreenshot = CreateScreenshot;\r\n Tools.CreateScreenshotAsync = CreateScreenshotAsync;\r\n Tools.CreateScreenshotUsingRenderTarget = CreateScreenshotUsingRenderTarget;\r\n Tools.CreateScreenshotUsingRenderTargetAsync = CreateScreenshotUsingRenderTargetAsync;\r\n};\r\n\r\ninitSideEffects();\r\n"]}
@@ -0,0 +1,63 @@
1
+ import type { AbstractMesh, EffectLayer, Scene } from "../index.js";
2
+ /**
3
+ * Options for the snapshot rendering helper
4
+ */
5
+ export interface SnapshotRenderingHelpersOptions {
6
+ /**
7
+ * Maximum number of influences for morph target managers
8
+ * In FAST snapshot mode, the number of influences must be fixed and cannot change from one frame to the next.
9
+ * morphTargetsNumMaxInfluences is the maximum number of non-zero influences allowed in a morph target manager.
10
+ * The final value defined for a morph target manager is: Math.min(morphTargetManager.numTargets, morphTargetsNumMaxInfluences)
11
+ * Default: 20
12
+ */
13
+ morphTargetsNumMaxInfluences?: number;
14
+ }
15
+ /**
16
+ * A helper class to simplify work with FAST snapshot mode (WebGPU only - can be used in WebGL too, but won't do anything).
17
+ */
18
+ export declare class SnapshotRenderingHelper {
19
+ private readonly _engine;
20
+ private readonly _scene;
21
+ private readonly _options;
22
+ private readonly _onBeforeRenderObserver;
23
+ private _onBeforeRenderObserverUpdateLayer;
24
+ private readonly _onResizeObserver;
25
+ private _disableRenderingRefCount;
26
+ /**
27
+ * Creates a new snapshot rendering helper
28
+ * 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).
29
+ * Note also that fixMeshes() is called as part of the construction
30
+ * @param scene The scene to use the helper in
31
+ * @param options The options for the helper
32
+ */
33
+ constructor(scene: Scene, options?: SnapshotRenderingHelpersOptions);
34
+ /**
35
+ * Enable snapshot rendering
36
+ * Use this method instead of engine.snapshotRendering=true, to make sure everything is ready before enabling snapshot rendering.
37
+ * Note that this method is ref-counted and works in pair with disableSnapshotRendering(): you should call enableSnapshotRendering() as many times as you call disableSnapshotRendering().
38
+ */
39
+ enableSnapshotRendering(): void;
40
+ /**
41
+ * Disable snapshot rendering
42
+ * Note that this method is ref-counted and works in pair with disableSnapshotRendering(): you should call enableSnapshotRendering() as many times as you call disableSnapshotRendering().
43
+ */
44
+ disableSnapshotRendering(): void;
45
+ /**
46
+ * Fix meshes for snapshot rendering.
47
+ * This method will make sure that some features are disabled or fixed to make sure snapshot rendering works correctly.
48
+ * @param meshes List of meshes to fix. If not provided, all meshes in the scene will be fixed.
49
+ */
50
+ fixMeshes(meshes?: AbstractMesh[]): void;
51
+ /**
52
+ * Update the meshes used in an effect layer to ensure that snapshot rendering works correctly for these meshes in this layer.
53
+ * @param effectLayer The effect layer
54
+ * @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.
55
+ */
56
+ updateMeshesForEffectLayer(effectLayer: EffectLayer, autoUpdate?: boolean): void;
57
+ /**
58
+ * Dispose the helper
59
+ */
60
+ dispose(): void;
61
+ private _updateMeshMatricesForRenderPassId;
62
+ private _executeAtFrame;
63
+ }