@babylonjs/core 6.8.1 → 6.9.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 (233) hide show
  1. package/Actions/action.d.ts +4 -5
  2. package/Actions/action.js.map +1 -1
  3. package/Actions/condition.d.ts +1 -2
  4. package/Actions/condition.js.map +1 -1
  5. package/Actions/directActions.d.ts +1 -2
  6. package/Actions/directActions.js.map +1 -1
  7. package/Animations/animatable.interface.d.ts +1 -2
  8. package/Animations/animatable.interface.js.map +1 -1
  9. package/Animations/animation.d.ts +3 -4
  10. package/Animations/animation.js.map +1 -1
  11. package/Animations/runtimeAnimation.d.ts +1 -2
  12. package/Animations/runtimeAnimation.js.map +1 -1
  13. package/Bones/bone.d.ts +3 -3
  14. package/Bones/bone.js.map +1 -1
  15. package/Cameras/arcRotateCamera.d.ts +1 -2
  16. package/Cameras/arcRotateCamera.js.map +1 -1
  17. package/Cameras/camera.d.ts +6 -7
  18. package/Cameras/camera.js.map +1 -1
  19. package/Cameras/flyCamera.js.map +1 -1
  20. package/Cameras/freeCamera.js.map +1 -1
  21. package/Collisions/meshCollisionData.d.ts +1 -2
  22. package/Collisions/meshCollisionData.js.map +1 -1
  23. package/Collisions/pickingInfo.d.ts +1 -2
  24. package/Collisions/pickingInfo.js.map +1 -1
  25. package/Compute/computeEffect.d.ts +1 -2
  26. package/Compute/computeEffect.js.map +1 -1
  27. package/Culling/Octrees/octreeSceneComponent.d.ts +1 -2
  28. package/Culling/Octrees/octreeSceneComponent.js.map +1 -1
  29. package/Culling/boundingBox.d.ts +1 -2
  30. package/Culling/boundingBox.js.map +1 -1
  31. package/Culling/boundingInfo.d.ts +1 -2
  32. package/Culling/boundingInfo.js.map +1 -1
  33. package/Culling/ray.js.map +1 -1
  34. package/Engines/Extensions/engine.storageBuffer.d.ts +1 -2
  35. package/Engines/Extensions/engine.storageBuffer.js.map +1 -1
  36. package/Engines/Extensions/engine.textureSampler.d.ts +1 -2
  37. package/Engines/Extensions/engine.textureSampler.js.map +1 -1
  38. package/Engines/Processors/iShaderProcessor.d.ts +1 -2
  39. package/Engines/Processors/iShaderProcessor.js.map +1 -1
  40. package/Engines/Processors/shaderProcessor.d.ts +5 -6
  41. package/Engines/Processors/shaderProcessor.js.map +1 -1
  42. package/Engines/WebGL/webGLShaderProcessors.d.ts +1 -2
  43. package/Engines/WebGL/webGLShaderProcessors.js.map +1 -1
  44. package/Engines/WebGPU/Extensions/engine.cubeTexture.js.map +1 -1
  45. package/Engines/WebGPU/Extensions/engine.query.js.map +1 -1
  46. package/Engines/WebGPU/Extensions/engine.rawTexture.js.map +1 -1
  47. package/Engines/WebGPU/Extensions/engine.storageBuffer.d.ts +1 -2
  48. package/Engines/WebGPU/Extensions/engine.storageBuffer.js.map +1 -1
  49. package/Engines/WebGPU/Extensions/engine.textureSampler.d.ts +1 -2
  50. package/Engines/WebGPU/Extensions/engine.textureSampler.js.map +1 -1
  51. package/Engines/WebGPU/webgpuHardwareTexture.d.ts +1 -2
  52. package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
  53. package/Engines/engine.d.ts +3 -3
  54. package/Engines/engine.js.map +1 -1
  55. package/Engines/engineStore.d.ts +4 -5
  56. package/Engines/engineStore.js.map +1 -1
  57. package/Engines/thinEngine.js +2 -2
  58. package/Engines/thinEngine.js.map +1 -1
  59. package/Engines/webgpuEngine.d.ts +1 -2
  60. package/Engines/webgpuEngine.js.map +1 -1
  61. package/Events/pointerEvents.d.ts +1 -2
  62. package/Events/pointerEvents.js.map +1 -1
  63. package/Helpers/textureDome.js.map +1 -1
  64. package/Inputs/scene.inputManager.d.ts +1 -2
  65. package/Inputs/scene.inputManager.js.map +1 -1
  66. package/Materials/Node/Blocks/Dual/currentScreenBlock.d.ts +1 -2
  67. package/Materials/Node/Blocks/Dual/currentScreenBlock.js.map +1 -1
  68. package/Materials/Node/Blocks/Dual/sceneDepthBlock.d.ts +1 -2
  69. package/Materials/Node/Blocks/Dual/sceneDepthBlock.js.map +1 -1
  70. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.d.ts +3 -4
  71. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
  72. package/Materials/Node/Blocks/Particle/particleTextureBlock.d.ts +1 -2
  73. package/Materials/Node/Blocks/Particle/particleTextureBlock.js.map +1 -1
  74. package/Materials/Node/Blocks/Vertex/vertexOutputBlock.js.map +1 -1
  75. package/Materials/Node/nodeMaterialDecorator.d.ts +2 -3
  76. package/Materials/Node/nodeMaterialDecorator.js.map +1 -1
  77. package/Materials/PBR/pbrAnisotropicConfiguration.d.ts +3 -4
  78. package/Materials/PBR/pbrAnisotropicConfiguration.js.map +1 -1
  79. package/Materials/PBR/pbrClearCoatConfiguration.d.ts +3 -4
  80. package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
  81. package/Materials/PBR/pbrIridescenceConfiguration.d.ts +3 -4
  82. package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
  83. package/Materials/PBR/pbrSheenConfiguration.d.ts +3 -4
  84. package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
  85. package/Materials/PBR/pbrSubSurfaceConfiguration.d.ts +3 -4
  86. package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
  87. package/Materials/Textures/baseTexture.d.ts +2 -1
  88. package/Materials/Textures/baseTexture.js.map +1 -1
  89. package/Materials/Textures/htmlElementTexture.d.ts +2 -3
  90. package/Materials/Textures/htmlElementTexture.js.map +1 -1
  91. package/Materials/Textures/internalTexture.d.ts +3 -4
  92. package/Materials/Textures/internalTexture.js.map +1 -1
  93. package/Materials/Textures/rawTexture.d.ts +1 -2
  94. package/Materials/Textures/rawTexture.js.map +1 -1
  95. package/Materials/Textures/rawTexture2DArray.d.ts +1 -2
  96. package/Materials/Textures/rawTexture2DArray.js.map +1 -1
  97. package/Materials/Textures/renderTargetTexture.d.ts +1 -2
  98. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  99. package/Materials/Textures/texture.d.ts +4 -5
  100. package/Materials/Textures/texture.js.map +1 -1
  101. package/Materials/drawWrapper.d.ts +3 -4
  102. package/Materials/drawWrapper.js.map +1 -1
  103. package/Materials/effect.d.ts +5 -6
  104. package/Materials/effect.js.map +1 -1
  105. package/Materials/effectFallbacks.d.ts +2 -3
  106. package/Materials/effectFallbacks.js.map +1 -1
  107. package/Materials/iEffectFallbacks.d.ts +1 -2
  108. package/Materials/iEffectFallbacks.js.map +1 -1
  109. package/Materials/imageProcessingConfiguration.d.ts +2 -3
  110. package/Materials/imageProcessingConfiguration.js.map +1 -1
  111. package/Materials/material.d.ts +3 -4
  112. package/Materials/material.detailMapConfiguration.d.ts +4 -5
  113. package/Materials/material.detailMapConfiguration.js.map +1 -1
  114. package/Materials/material.js.map +1 -1
  115. package/Materials/materialPluginBase.d.ts +11 -12
  116. package/Materials/materialPluginBase.js.map +1 -1
  117. package/Materials/materialPluginEvent.d.ts +8 -9
  118. package/Materials/materialPluginEvent.js.map +1 -1
  119. package/Materials/materialPluginFactoryExport.d.ts +1 -2
  120. package/Materials/materialPluginFactoryExport.js.map +1 -1
  121. package/Materials/materialPluginManager.d.ts +3 -4
  122. package/Materials/materialPluginManager.js.map +1 -1
  123. package/Materials/materialStencilState.d.ts +1 -2
  124. package/Materials/materialStencilState.js.map +1 -1
  125. package/Materials/shaderMaterial.d.ts +1 -2
  126. package/Materials/shaderMaterial.js.map +1 -1
  127. package/Meshes/Builders/linesBuilder.d.ts +1 -2
  128. package/Meshes/Builders/linesBuilder.js.map +1 -1
  129. package/Meshes/Builders/textBuilder.d.ts +34 -0
  130. package/Meshes/Builders/textBuilder.js +10 -2
  131. package/Meshes/Builders/textBuilder.js.map +1 -1
  132. package/Meshes/abstractMesh.d.ts +5 -5
  133. package/Meshes/abstractMesh.js.map +1 -1
  134. package/Meshes/geometry.d.ts +1 -2
  135. package/Meshes/geometry.js.map +1 -1
  136. package/Meshes/mesh.d.ts +6 -6
  137. package/Meshes/mesh.js.map +1 -1
  138. package/Meshes/mesh.vertexData.d.ts +2 -3
  139. package/Meshes/mesh.vertexData.js.map +1 -1
  140. package/Meshes/subMesh.d.ts +7 -8
  141. package/Meshes/subMesh.js.map +1 -1
  142. package/Misc/copyTools.d.ts +1 -2
  143. package/Misc/copyTools.js.map +1 -1
  144. package/Misc/decorators.d.ts +5 -6
  145. package/Misc/decorators.js.map +1 -1
  146. package/Misc/greasedLineTools.d.ts +12 -0
  147. package/Misc/greasedLineTools.js +36 -0
  148. package/Misc/greasedLineTools.js.map +1 -1
  149. package/Misc/rgbdTextureTools.d.ts +3 -4
  150. package/Misc/rgbdTextureTools.js.map +1 -1
  151. package/Misc/screenshotTools.d.ts +1 -2
  152. package/Misc/screenshotTools.js.map +1 -1
  153. package/Morph/morphTarget.d.ts +2 -1
  154. package/Morph/morphTarget.js.map +1 -1
  155. package/Particles/EmitterTypes/IParticleEmitterType.d.ts +1 -2
  156. package/Particles/EmitterTypes/IParticleEmitterType.js.map +1 -1
  157. package/Particles/IParticleSystem.d.ts +2 -3
  158. package/Particles/IParticleSystem.js.map +1 -1
  159. package/Particles/gpuParticleSystem.d.ts +1 -2
  160. package/Particles/gpuParticleSystem.js.map +1 -1
  161. package/Particles/particle.js.map +1 -1
  162. package/Particles/particleSystem.d.ts +1 -2
  163. package/Particles/particleSystem.js.map +1 -1
  164. package/Particles/subEmitter.d.ts +2 -3
  165. package/Particles/subEmitter.js.map +1 -1
  166. package/Particles/webgl2ParticleSystem.js.map +1 -1
  167. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.d.ts +1 -2
  168. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js.map +1 -1
  169. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.d.ts +1 -2
  170. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js.map +1 -1
  171. package/PostProcesses/RenderPipeline/postProcessRenderPipeline.d.ts +1 -2
  172. package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js.map +1 -1
  173. package/PostProcesses/blackAndWhitePostProcess.d.ts +1 -2
  174. package/PostProcesses/blackAndWhitePostProcess.js.map +1 -1
  175. package/PostProcesses/blurPostProcess.d.ts +1 -2
  176. package/PostProcesses/blurPostProcess.js.map +1 -1
  177. package/PostProcesses/chromaticAberrationPostProcess.d.ts +1 -2
  178. package/PostProcesses/chromaticAberrationPostProcess.js.map +1 -1
  179. package/PostProcesses/colorCorrectionPostProcess.d.ts +1 -2
  180. package/PostProcesses/colorCorrectionPostProcess.js.map +1 -1
  181. package/PostProcesses/convolutionPostProcess.d.ts +1 -2
  182. package/PostProcesses/convolutionPostProcess.js.map +1 -1
  183. package/PostProcesses/displayPassPostProcess.d.ts +1 -2
  184. package/PostProcesses/displayPassPostProcess.js.map +1 -1
  185. package/PostProcesses/filterPostProcess.d.ts +1 -2
  186. package/PostProcesses/filterPostProcess.js.map +1 -1
  187. package/PostProcesses/fxaaPostProcess.d.ts +1 -2
  188. package/PostProcesses/fxaaPostProcess.js.map +1 -1
  189. package/PostProcesses/grainPostProcess.d.ts +1 -2
  190. package/PostProcesses/grainPostProcess.js.map +1 -1
  191. package/PostProcesses/motionBlurPostProcess.d.ts +2 -3
  192. package/PostProcesses/motionBlurPostProcess.js.map +1 -1
  193. package/PostProcesses/passPostProcess.d.ts +1 -2
  194. package/PostProcesses/passPostProcess.js.map +1 -1
  195. package/PostProcesses/postProcess.d.ts +6 -6
  196. package/PostProcesses/postProcess.js.map +1 -1
  197. package/PostProcesses/postProcessManager.d.ts +1 -2
  198. package/PostProcesses/postProcessManager.js.map +1 -1
  199. package/PostProcesses/refractionPostProcess.d.ts +1 -2
  200. package/PostProcesses/refractionPostProcess.js.map +1 -1
  201. package/PostProcesses/screenSpaceCurvaturePostProcess.d.ts +2 -3
  202. package/PostProcesses/screenSpaceCurvaturePostProcess.js.map +1 -1
  203. package/PostProcesses/screenSpaceReflectionPostProcess.d.ts +2 -3
  204. package/PostProcesses/screenSpaceReflectionPostProcess.js.map +1 -1
  205. package/PostProcesses/sharpenPostProcess.d.ts +2 -3
  206. package/PostProcesses/sharpenPostProcess.js.map +1 -1
  207. package/PostProcesses/tonemapPostProcess.d.ts +1 -2
  208. package/PostProcesses/tonemapPostProcess.js.map +1 -1
  209. package/PostProcesses/volumetricLightScatteringPostProcess.d.ts +1 -2
  210. package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
  211. package/Rendering/depthRenderer.d.ts +2 -3
  212. package/Rendering/depthRenderer.js.map +1 -1
  213. package/Rendering/geometryBufferRenderer.js +2 -2
  214. package/Rendering/geometryBufferRenderer.js.map +1 -1
  215. package/Rendering/renderingManager.d.ts +5 -6
  216. package/Rendering/renderingManager.js.map +1 -1
  217. package/Sprites/sprite.d.ts +1 -2
  218. package/Sprites/sprite.js.map +1 -1
  219. package/Sprites/spriteManager.d.ts +1 -2
  220. package/Sprites/spriteManager.js.map +1 -1
  221. package/Sprites/spriteRenderer.d.ts +2 -3
  222. package/Sprites/spriteRenderer.js.map +1 -1
  223. package/XR/webXRExperienceHelper.js +1 -0
  224. package/XR/webXRExperienceHelper.js.map +1 -1
  225. package/abstractScene.d.ts +3 -3
  226. package/abstractScene.js.map +1 -1
  227. package/node.d.ts +6 -7
  228. package/node.js.map +1 -1
  229. package/package.json +1 -1
  230. package/scene.d.ts +49 -50
  231. package/scene.js.map +1 -1
  232. package/sceneComponent.d.ts +6 -7
  233. package/sceneComponent.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"greasedLineTools.js","sourceRoot":"","sources":["../../../../lts/core/generated/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;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACzB;;;;;OAKG;IACI,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ACpG,MAAM,MAAM,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;QAElE,OAAO;YACH,MAAM;YACN,MAAM;SACT,CAAC;IACN,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\n\r\n/**\r\n * Tool functions for GreasedLine\r\n */\r\nexport class GreasedLineTools {\r\n /**\r\n * Gets mesh triangles as line positions\r\n * @param meshes array of meshes\r\n * @param omitZeroLengthLines do not generate a line when the distance if the vertices in the triangle equals to zero\r\n * @returns array of arrays of points\r\n */\r\n public static MeshesToLines(meshes: AbstractMesh[], omitZeroLengthLines = true) {\r\n const points: Vector3[][] = [];\r\n\r\n meshes.forEach((m) => {\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 (omitZeroLengthLines && p1.lengthSquared() + p2.lengthSquared() + p3.lengthSquared() === 0) {\r\n continue;\r\n }\r\n points.push([p1, p2, p3, p1]);\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[]) {\r\n const array: Vector3[] = [];\r\n for (let i = 0; i < points.length; i += 3) {\r\n array.push(new Vector3(points[i], points[i + 1], points[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);\r\n } else {\r\n points = <Vector3[]>data;\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 * 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 = what[0] instanceof Vector3 ? GreasedLineTools.GetLineSegments(what as Vector3[]) : (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[], segmentCount: number): Vector3[] {\r\n const segmentLength = GreasedLineTools.GetLineLength(what) / segmentCount;\r\n return GreasedLineTools.SegmentizeLineBySegmentLength(what, 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 * @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}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AAE,CAAC,KAAK,EAAE;oBACtB,MAAM,KAAK,GAAG,EAAE,CAAC;oBACjB,MAAM,QAAQ,GAAG,CAAC,CAAC,SAAS,EAAE,CAAC;oBAC/B,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE;wBACxB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;qBAC/B;oBACD,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;iBACzB;aACJ;SACJ;QAED,OAAO,SAAS,CAAC;IACrB,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 \"core/Meshes/Builders/textBuilder\";\r\nimport { CreateTextShapePaths } from \"core/Meshes/Builders/textBuilder\";\r\n\r\n/**\r\n * Tool functions for GreasedLine\r\n */\r\nexport class GreasedLineTools {\r\n /**\r\n * Gets mesh triangles as line positions\r\n * @param meshes array of meshes\r\n * @param omitZeroLengthLines do not generate a line when the distance if the vertices in the triangle equals to zero\r\n * @returns array of arrays of points\r\n */\r\n public static MeshesToLines(meshes: AbstractMesh[], omitZeroLengthLines = true) {\r\n const points: Vector3[][] = [];\r\n\r\n meshes.forEach((m) => {\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 (omitZeroLengthLines && p1.lengthSquared() + p2.lengthSquared() + p3.lengthSquared() === 0) {\r\n continue;\r\n }\r\n points.push([p1, p2, p3, p1]);\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[]) {\r\n const array: Vector3[] = [];\r\n for (let i = 0; i < points.length; i += 3) {\r\n array.push(new Vector3(points[i], points[i + 1], points[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);\r\n } else {\r\n points = <Vector3[]>data;\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 * 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 = what[0] instanceof Vector3 ? GreasedLineTools.GetLineSegments(what as Vector3[]) : (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[], segmentCount: number): Vector3[] {\r\n const segmentLength = GreasedLineTools.GetLineLength(what) / segmentCount;\r\n return GreasedLineTools.SegmentizeLineBySegmentLength(what, 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 * @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"]}
@@ -1,8 +1,8 @@
1
1
  import "../Shaders/rgbdDecode.fragment";
2
2
  import "../Engines/Extensions/engine.renderTarget";
3
- declare type Texture = import("../Materials/Textures/texture").Texture;
4
- declare type InternalTexture = import("../Materials/Textures/internalTexture").InternalTexture;
5
- declare type Scene = import("../scene").Scene;
3
+ import type { Texture } from "../Materials/Textures/texture";
4
+ import type { InternalTexture } from "../Materials/Textures/internalTexture";
5
+ import type { Scene } from "../scene";
6
6
  /**
7
7
  * Class used to host RGBD texture specific utilities
8
8
  */
@@ -21,4 +21,3 @@ export declare class RGBDTextureTools {
21
21
  */
22
22
  static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
23
23
  }
24
- export {};
@@ -1 +1 @@
1
- {"version":3,"file":"rgbdTextureTools.js","sourceRoot":"","sources":["../../../../lts/core/generated/Misc/rgbdTextureTools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,gCAAgC,CAAC;AAGxC,OAAO,2CAA2C,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAMlD;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACzB;;;OAGG;IACI,MAAM,CAAC,iBAAiB,CAAC,OAAgB;QAC5C,MAAM,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;QACzC,IAAI,CAAC,eAAe,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACrC,OAAO;SACV;QAED,yBAAyB;QACzB,MAAM,MAAM,GAAG,eAAe,CAAC,SAAS,EAAY,CAAC;QACrD,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC;QACxC,IAAI,aAAa,GAAG,KAAK,CAAC;QAE1B,wDAAwD;QACxD,IAAI,IAAI,CAAC,sBAAsB,IAAI,IAAI,CAAC,+BAA+B,EAAE;YACrE,aAAa,GAAG,IAAI,CAAC;YACrB,eAAe,CAAC,IAAI,GAAG,SAAS,CAAC,sBAAsB,CAAC;SAC3D;QACD,wDAAwD;aACnD,IAAI,IAAI,CAAC,kBAAkB,IAAI,IAAI,CAAC,2BAA2B,EAAE;YAClE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;oBACF,OAAO,CAAC,QAAQ,EAAG,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC,eAAgB,CAAC,EAAE,eAAe,EAAE,IAAI,CAAC,CAAC;oBAE/F,UAAU;oBACV,MAAM,CAAC,yBAAyB,EAAE,CAAC;oBACnC,MAAM,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;oBACxC,IAAI,eAAe,EAAE;wBACjB,eAAe,CAAC,OAAO,EAAE,CAAC;qBAC7B;oBAED,gBAAgB;oBAChB,eAAe,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;oBAE7C,8BAA8B;oBAC9B,eAAe,CAAC,OAAO,GAAG,IAAI,CAAC;gBACnC,CAAC,CAAC,CAAC;aACN;QACL,CAAC,CAAC;QAEF,IAAI,OAAO,EAAE;YACT,iBAAiB,EAAE,CAAC;SACvB;aAAM;YACH,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;SACvD;IACL,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,mBAAmB,CAAC,eAAgC,EAAE,KAAY,EAAE,iBAAiB,GAAG,SAAS,CAAC,yBAAyB;QACrI,OAAO,gBAAgB,CAAC,YAAY,EAAE,eAAe,EAAE,KAAK,EAAE,iBAAiB,EAAE,SAAS,CAAC,4BAA4B,EAAE,SAAS,CAAC,kBAAkB,CAAC,CAAC;IAC3J,CAAC;CACJ","sourcesContent":["import { Constants } from \"../Engines/constants\";\r\nimport { PostProcess } from \"../PostProcesses/postProcess\";\r\nimport \"../Shaders/rgbdDecode.fragment\";\r\nimport type { Engine } from \"../Engines/engine\";\r\n\r\nimport \"../Engines/Extensions/engine.renderTarget\";\r\nimport { ApplyPostProcess } from \"./textureTools\";\r\n\r\ndeclare type Texture = import(\"../Materials/Textures/texture\").Texture;\r\ndeclare type InternalTexture = import(\"../Materials/Textures/internalTexture\").InternalTexture;\r\ndeclare type Scene = import(\"../scene\").Scene;\r\n\r\n/**\r\n * Class used to host RGBD texture specific utilities\r\n */\r\nexport class RGBDTextureTools {\r\n /**\r\n * Expand the RGBD Texture from RGBD to Half Float if possible.\r\n * @param texture the texture to expand.\r\n */\r\n public static ExpandRGBDTexture(texture: Texture) {\r\n const internalTexture = texture._texture;\r\n if (!internalTexture || !texture.isRGBD) {\r\n return;\r\n }\r\n\r\n // Gets everything ready.\r\n const engine = internalTexture.getEngine() as Engine;\r\n const caps = engine.getCaps();\r\n const isReady = internalTexture.isReady;\r\n let expandTexture = false;\r\n\r\n // If half float available we can uncompress the texture\r\n if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {\r\n expandTexture = true;\r\n internalTexture.type = Constants.TEXTURETYPE_HALF_FLOAT;\r\n }\r\n // If full float available we can uncompress the texture\r\n else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {\r\n expandTexture = true;\r\n internalTexture.type = Constants.TEXTURETYPE_FLOAT;\r\n }\r\n\r\n if (expandTexture) {\r\n // Do not use during decode.\r\n internalTexture.isReady = false;\r\n internalTexture._isRGBD = false;\r\n internalTexture.invertY = false;\r\n }\r\n\r\n const expandRGBDTexture = () => {\r\n // Expand the texture if possible\r\n if (expandTexture) {\r\n // Simply run through the decode PP.\r\n const rgbdPostProcess = new PostProcess(\r\n \"rgbdDecode\",\r\n \"rgbdDecode\",\r\n null,\r\n null,\r\n 1,\r\n null,\r\n Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n engine,\r\n false,\r\n undefined,\r\n internalTexture.type,\r\n undefined,\r\n null,\r\n false\r\n );\r\n rgbdPostProcess.externalTextureSamplerBinding = true;\r\n\r\n // Hold the output of the decoding.\r\n const expandedTexture = engine.createRenderTargetTexture(internalTexture.width, {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n generateStencilBuffer: false,\r\n samplingMode: internalTexture.samplingMode,\r\n type: internalTexture.type,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n });\r\n\r\n rgbdPostProcess.getEffect().executeWhenCompiled(() => {\r\n // PP Render Pass\r\n rgbdPostProcess.onApply = (effect) => {\r\n effect._bindTexture(\"textureSampler\", internalTexture);\r\n effect.setFloat2(\"scale\", 1, 1);\r\n };\r\n texture.getScene()!.postProcessManager.directRender([rgbdPostProcess!], expandedTexture, true);\r\n\r\n // Cleanup\r\n engine.restoreDefaultFramebuffer();\r\n engine._releaseTexture(internalTexture);\r\n if (rgbdPostProcess) {\r\n rgbdPostProcess.dispose();\r\n }\r\n\r\n // Internal Swap\r\n expandedTexture._swapAndDie(internalTexture);\r\n\r\n // Ready to get rolling again.\r\n internalTexture.isReady = true;\r\n });\r\n }\r\n };\r\n\r\n if (isReady) {\r\n expandRGBDTexture();\r\n } else {\r\n texture.onLoadObservable.addOnce(expandRGBDTexture);\r\n }\r\n }\r\n\r\n /**\r\n * Encode the texture to RGBD if possible.\r\n * @param internalTexture the texture to encode\r\n * @param scene the scene hosting the texture\r\n * @param outputTextureType type of the texture in which the encoding is performed\r\n * @returns a promise with the internalTexture having its texture replaced by the result of the processing\r\n */\r\n public static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType = Constants.TEXTURETYPE_UNSIGNED_BYTE): Promise<InternalTexture> {\r\n return ApplyPostProcess(\"rgbdEncode\", internalTexture, scene, outputTextureType, Constants.TEXTURE_NEAREST_SAMPLINGMODE, Constants.TEXTUREFORMAT_RGBA);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"rgbdTextureTools.js","sourceRoot":"","sources":["../../../../lts/core/generated/Misc/rgbdTextureTools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,gCAAgC,CAAC;AAGxC,OAAO,2CAA2C,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAMlD;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACzB;;;OAGG;IACI,MAAM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;;;;;;OAMG;IACI,MAAM,CAAC,mBAAmB,CAAC,eAAgC,EAAE,KAAY,EAAE,iBAAiB,GAAG,SAAS,CAAC,yBAAyB;QACrI,OAAO,gBAAgB,CAAC,YAAY,EAAE,eAAe,EAAE,KAAK,EAAE,iBAAiB,EAAE,SAAS,CAAC,4BAA4B,EAAE,SAAS,CAAC,kBAAkB,CAAC,CAAC;IAC3J,CAAC;CACJ","sourcesContent":["import { Constants } from \"../Engines/constants\";\r\nimport { PostProcess } from \"../PostProcesses/postProcess\";\r\nimport \"../Shaders/rgbdDecode.fragment\";\r\nimport type { Engine } from \"../Engines/engine\";\r\n\r\nimport \"../Engines/Extensions/engine.renderTarget\";\r\nimport { ApplyPostProcess } from \"./textureTools\";\r\n\r\nimport type { Texture } from \"../Materials/Textures/texture\";\r\nimport type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport type { Scene } from \"../scene\";\r\n\r\n/**\r\n * Class used to host RGBD texture specific utilities\r\n */\r\nexport class RGBDTextureTools {\r\n /**\r\n * Expand the RGBD Texture from RGBD to Half Float if possible.\r\n * @param texture the texture to expand.\r\n */\r\n public static ExpandRGBDTexture(texture: Texture) {\r\n const internalTexture = texture._texture;\r\n if (!internalTexture || !texture.isRGBD) {\r\n return;\r\n }\r\n\r\n // Gets everything ready.\r\n const engine = internalTexture.getEngine() as Engine;\r\n const caps = engine.getCaps();\r\n const isReady = internalTexture.isReady;\r\n let expandTexture = false;\r\n\r\n // If half float available we can uncompress the texture\r\n if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {\r\n expandTexture = true;\r\n internalTexture.type = Constants.TEXTURETYPE_HALF_FLOAT;\r\n }\r\n // If full float available we can uncompress the texture\r\n else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {\r\n expandTexture = true;\r\n internalTexture.type = Constants.TEXTURETYPE_FLOAT;\r\n }\r\n\r\n if (expandTexture) {\r\n // Do not use during decode.\r\n internalTexture.isReady = false;\r\n internalTexture._isRGBD = false;\r\n internalTexture.invertY = false;\r\n }\r\n\r\n const expandRGBDTexture = () => {\r\n // Expand the texture if possible\r\n if (expandTexture) {\r\n // Simply run through the decode PP.\r\n const rgbdPostProcess = new PostProcess(\r\n \"rgbdDecode\",\r\n \"rgbdDecode\",\r\n null,\r\n null,\r\n 1,\r\n null,\r\n Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n engine,\r\n false,\r\n undefined,\r\n internalTexture.type,\r\n undefined,\r\n null,\r\n false\r\n );\r\n rgbdPostProcess.externalTextureSamplerBinding = true;\r\n\r\n // Hold the output of the decoding.\r\n const expandedTexture = engine.createRenderTargetTexture(internalTexture.width, {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n generateStencilBuffer: false,\r\n samplingMode: internalTexture.samplingMode,\r\n type: internalTexture.type,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n });\r\n\r\n rgbdPostProcess.getEffect().executeWhenCompiled(() => {\r\n // PP Render Pass\r\n rgbdPostProcess.onApply = (effect) => {\r\n effect._bindTexture(\"textureSampler\", internalTexture);\r\n effect.setFloat2(\"scale\", 1, 1);\r\n };\r\n texture.getScene()!.postProcessManager.directRender([rgbdPostProcess!], expandedTexture, true);\r\n\r\n // Cleanup\r\n engine.restoreDefaultFramebuffer();\r\n engine._releaseTexture(internalTexture);\r\n if (rgbdPostProcess) {\r\n rgbdPostProcess.dispose();\r\n }\r\n\r\n // Internal Swap\r\n expandedTexture._swapAndDie(internalTexture);\r\n\r\n // Ready to get rolling again.\r\n internalTexture.isReady = true;\r\n });\r\n }\r\n };\r\n\r\n if (isReady) {\r\n expandRGBDTexture();\r\n } else {\r\n texture.onLoadObservable.addOnce(expandRGBDTexture);\r\n }\r\n }\r\n\r\n /**\r\n * Encode the texture to RGBD if possible.\r\n * @param internalTexture the texture to encode\r\n * @param scene the scene hosting the texture\r\n * @param outputTextureType type of the texture in which the encoding is performed\r\n * @returns a promise with the internalTexture having its texture replaced by the result of the processing\r\n */\r\n public static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType = Constants.TEXTURETYPE_UNSIGNED_BYTE): Promise<InternalTexture> {\r\n return ApplyPostProcess(\"rgbdEncode\", internalTexture, scene, outputTextureType, Constants.TEXTURE_NEAREST_SAMPLINGMODE, Constants.TEXTUREFORMAT_RGBA);\r\n }\r\n}\r\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { Camera } from "../Cameras/camera";
2
2
  import type { IScreenshotSize } from "./interfaces/screenshotSize";
3
- declare type Engine = import("../Engines/engine").Engine;
3
+ import type { Engine } from "../Engines/engine";
4
4
  /**
5
5
  * Captures a screenshot of the current rendering
6
6
  * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG
@@ -197,4 +197,3 @@ export declare const ScreenshotTools: {
197
197
  */
198
198
  CreateScreenshotUsingRenderTargetAsync: typeof CreateScreenshotUsingRenderTargetAsync;
199
199
  };
200
- export {};
@@ -1 +1 @@
1
- {"version":3,"file":"screenshotTools.js","sourceRoot":"","sources":["../../../../lts/core/generated/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,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIlD,IAAI,gBAAgB,GAAgC,IAAI,CAAC;AAEzD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,gBAAgB,CAC5B,MAAc,EACd,MAAc,EACd,IAA8B,EAC9B,eAA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C,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 { DumpTools } from \"./dumpTools\";\r\nimport type { Nullable } from \"../types\";\r\nimport { ApplyPostProcess } from \"./textureTools\";\r\n\r\ndeclare type Engine = import(\"../Engines/engine\").Engine;\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: Engine,\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: Engine, 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: Engine, 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 */\r\nexport function CreateScreenshotUsingRenderTarget(\r\n engine: Engine,\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): 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\r\n const renderToTexture = () => {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n if (finalWidth === width && finalHeight === height) {\r\n texture.readPixels(undefined, undefined, undefined, false)!.then((data) => {\r\n DumpTools.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 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 DumpTools.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 // render the RTT\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n texture.render(true);\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 engine.setSize(originalSize.width, originalSize.height);\r\n camera.getProjectionMatrix(true); // Force cache refresh;\r\n scene.render();\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 if (!fxaaPostProcess.getEffect().isReady()) {\r\n fxaaPostProcess.getEffect().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 } 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 * @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: Engine,\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): 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 );\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: Engine, 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":"","sources":["../../../../lts/core/generated/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,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIlD,IAAI,gBAAgB,GAAgC,IAAI,CAAC;AAEzD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,gBAAgB,CAC5B,M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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 { DumpTools } from \"./dumpTools\";\r\nimport type { Nullable } from \"../types\";\r\nimport { ApplyPostProcess } from \"./textureTools\";\r\n\r\nimport type { Engine } from \"../Engines/engine\";\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: Engine,\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: Engine, 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: Engine, 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 */\r\nexport function CreateScreenshotUsingRenderTarget(\r\n engine: Engine,\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): 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\r\n const renderToTexture = () => {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n if (finalWidth === width && finalHeight === height) {\r\n texture.readPixels(undefined, undefined, undefined, false)!.then((data) => {\r\n DumpTools.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 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 DumpTools.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 // render the RTT\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n texture.render(true);\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 engine.setSize(originalSize.width, originalSize.height);\r\n camera.getProjectionMatrix(true); // Force cache refresh;\r\n scene.render();\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 if (!fxaaPostProcess.getEffect().isReady()) {\r\n fxaaPostProcess.getEffect().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 } 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 * @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: Engine,\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): 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 );\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: Engine, 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"]}
@@ -4,6 +4,7 @@ import type { Nullable, FloatArray } from "../types";
4
4
  import type { Scene } from "../scene";
5
5
  import type { AbstractMesh } from "../Meshes/abstractMesh";
6
6
  import type { AnimationPropertiesOverride } from "../Animations/animationPropertiesOverride";
7
+ import type { Animation } from "../Animations/animation";
7
8
  /**
8
9
  * Defines a target to use with MorphTargetManager
9
10
  * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/morphTargets
@@ -14,7 +15,7 @@ export declare class MorphTarget implements IAnimatable {
14
15
  /**
15
16
  * Gets or sets the list of animations
16
17
  */
17
- animations: import("../Animations/animation").Animation[];
18
+ animations: Animation[];
18
19
  private _scene;
19
20
  private _positions;
20
21
  private _normals;
@@ -1 +1 @@
1
- {"version":3,"file":"morphTarget.js","sourceRoot":"","sources":["../../../../lts/core/generated/Morph/morphTarget.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oB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AE;gBAC1C,KAAK,CAAC,cAAc,CAChB,MAAM,EACN,mBAAmB,CAAC,eAAe,EACnC,mBAAmB,CAAC,aAAa,EACjC,mBAAmB,CAAC,eAAe,EACnC,mBAAmB,CAAC,gBAAgB,IAAI,GAAG,CAC9C,CAAC;aACL;SACJ;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,QAAQ,CAAC,IAAkB,EAAE,IAAa,EAAE,SAAkB;QACxE,IAAI,CAAC,IAAI,EAAE;YACP,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;SACpB;QAED,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEjE,MAAM,CAAC,YAAY,CAAa,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;QAEjF,IAAI,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE;YACrD,MAAM,CAAC,UAAU,CAAa,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;SAChF;QACD,IAAI,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE;YACtD,MAAM,CAAC,WAAW,CAAa,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC;SAClF;QACD,IAAI,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE;YACjD,MAAM,CAAC,MAAM,CAAa,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;SACxE;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AApSU;IADN,SAAS,EAAE;uCACM","sourcesContent":["import type { IAnimatable } from \"../Animations/animatable.interface\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { Nullable, FloatArray } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport type { AnimationPropertiesOverride } from \"../Animations/animationPropertiesOverride\";\r\nimport { serialize, SerializationHelper } from \"../Misc/decorators\";\r\nimport { GetClass } from \"../Misc/typeStore\";\r\n\r\ndeclare type Animation = import(\"../Animations/animation\").Animation;\r\n\r\n/**\r\n * Defines a target to use with MorphTargetManager\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/morphTargets\r\n */\r\nexport class MorphTarget implements IAnimatable {\r\n /**\r\n * Gets or sets the list of animations\r\n */\r\n public animations = new Array<Animation>();\r\n\r\n private _scene: Nullable<Scene>;\r\n private _positions: Nullable<FloatArray> = null;\r\n private _normals: Nullable<FloatArray> = null;\r\n private _tangents: Nullable<FloatArray> = null;\r\n private _uvs: Nullable<FloatArray> = null;\r\n private _influence: number;\r\n private _uniqueId = 0;\r\n\r\n /**\r\n * Observable raised when the influence changes\r\n */\r\n public onInfluenceChanged = new Observable<boolean>();\r\n\r\n /** @internal */\r\n public _onDataLayoutChanged = new Observable<void>();\r\n\r\n /**\r\n * Gets or sets the influence of this target (ie. its weight in the overall morphing)\r\n */\r\n public get influence(): number {\r\n return this._influence;\r\n }\r\n\r\n public set influence(influence: number) {\r\n if (this._influence === influence) {\r\n return;\r\n }\r\n\r\n const previous = this._influence;\r\n this._influence = influence;\r\n\r\n if (this.onInfluenceChanged.hasObservers()) {\r\n this.onInfluenceChanged.notifyObservers(previous === 0 || influence === 0);\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the id of the morph Target\r\n */\r\n @serialize()\r\n public id: string;\r\n\r\n private _animationPropertiesOverride: Nullable<AnimationPropertiesOverride> = null;\r\n\r\n /**\r\n * Gets or sets the animation properties override\r\n */\r\n public get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride> {\r\n if (!this._animationPropertiesOverride && this._scene) {\r\n return this._scene.animationPropertiesOverride;\r\n }\r\n return this._animationPropertiesOverride;\r\n }\r\n\r\n public set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>) {\r\n this._animationPropertiesOverride = value;\r\n }\r\n\r\n /**\r\n * Creates a new MorphTarget\r\n * @param name defines the name of the target\r\n * @param influence defines the influence to use\r\n * @param scene defines the scene the morphtarget belongs to\r\n */\r\n public constructor(\r\n /** defines the name of the target */\r\n public name: string,\r\n influence = 0,\r\n scene: Nullable<Scene> = null\r\n ) {\r\n this._scene = scene || EngineStore.LastCreatedScene;\r\n this.influence = influence;\r\n\r\n if (this._scene) {\r\n this._uniqueId = this._scene.getUniqueId();\r\n }\r\n }\r\n\r\n /**\r\n * Gets the unique ID of this manager\r\n */\r\n public get uniqueId(): number {\r\n return this._uniqueId;\r\n }\r\n\r\n /**\r\n * Gets a boolean defining if the target contains position data\r\n */\r\n public get hasPositions(): boolean {\r\n return !!this._positions;\r\n }\r\n\r\n /**\r\n * Gets a boolean defining if the target contains normal data\r\n */\r\n public get hasNormals(): boolean {\r\n return !!this._normals;\r\n }\r\n\r\n /**\r\n * Gets a boolean defining if the target contains tangent data\r\n */\r\n public get hasTangents(): boolean {\r\n return !!this._tangents;\r\n }\r\n\r\n /**\r\n * Gets a boolean defining if the target contains texture coordinates data\r\n */\r\n public get hasUVs(): boolean {\r\n return !!this._uvs;\r\n }\r\n\r\n /**\r\n * Affects position data to this target\r\n * @param data defines the position data to use\r\n */\r\n public setPositions(data: Nullable<FloatArray>) {\r\n const hadPositions = this.hasPositions;\r\n\r\n this._positions = data;\r\n\r\n if (hadPositions !== this.hasPositions) {\r\n this._onDataLayoutChanged.notifyObservers(undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the position data stored in this target\r\n * @returns a FloatArray containing the position data (or null if not present)\r\n */\r\n public getPositions(): Nullable<FloatArray> {\r\n return this._positions;\r\n }\r\n\r\n /**\r\n * Affects normal data to this target\r\n * @param data defines the normal data to use\r\n */\r\n public setNormals(data: Nullable<FloatArray>) {\r\n const hadNormals = this.hasNormals;\r\n\r\n this._normals = data;\r\n\r\n if (hadNormals !== this.hasNormals) {\r\n this._onDataLayoutChanged.notifyObservers(undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the normal data stored in this target\r\n * @returns a FloatArray containing the normal data (or null if not present)\r\n */\r\n public getNormals(): Nullable<FloatArray> {\r\n return this._normals;\r\n }\r\n\r\n /**\r\n * Affects tangent data to this target\r\n * @param data defines the tangent data to use\r\n */\r\n public setTangents(data: Nullable<FloatArray>) {\r\n const hadTangents = this.hasTangents;\r\n\r\n this._tangents = data;\r\n\r\n if (hadTangents !== this.hasTangents) {\r\n this._onDataLayoutChanged.notifyObservers(undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the tangent data stored in this target\r\n * @returns a FloatArray containing the tangent data (or null if not present)\r\n */\r\n public getTangents(): Nullable<FloatArray> {\r\n return this._tangents;\r\n }\r\n\r\n /**\r\n * Affects texture coordinates data to this target\r\n * @param data defines the texture coordinates data to use\r\n */\r\n public setUVs(data: Nullable<FloatArray>) {\r\n const hadUVs = this.hasUVs;\r\n\r\n this._uvs = data;\r\n\r\n if (hadUVs !== this.hasUVs) {\r\n this._onDataLayoutChanged.notifyObservers(undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the texture coordinates data stored in this target\r\n * @returns a FloatArray containing the texture coordinates data (or null if not present)\r\n */\r\n public getUVs(): Nullable<FloatArray> {\r\n return this._uvs;\r\n }\r\n\r\n /**\r\n * Clone the current target\r\n * @returns a new MorphTarget\r\n */\r\n public clone(): MorphTarget {\r\n const newOne = SerializationHelper.Clone(() => new MorphTarget(this.name, this.influence, this._scene), this);\r\n\r\n newOne._positions = this._positions;\r\n newOne._normals = this._normals;\r\n newOne._tangents = this._tangents;\r\n newOne._uvs = this._uvs;\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Serializes the current target into a Serialization object\r\n * @returns the serialized object\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {};\r\n\r\n serializationObject.name = this.name;\r\n serializationObject.influence = this.influence;\r\n\r\n serializationObject.positions = Array.prototype.slice.call(this.getPositions());\r\n if (this.id != null) {\r\n serializationObject.id = this.id;\r\n }\r\n if (this.hasNormals) {\r\n serializationObject.normals = Array.prototype.slice.call(this.getNormals());\r\n }\r\n if (this.hasTangents) {\r\n serializationObject.tangents = Array.prototype.slice.call(this.getTangents());\r\n }\r\n if (this.hasUVs) {\r\n serializationObject.uvs = Array.prototype.slice.call(this.getUVs());\r\n }\r\n\r\n // Animations\r\n SerializationHelper.AppendSerializedAnimations(this, serializationObject);\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Returns the string \"MorphTarget\"\r\n * @returns \"MorphTarget\"\r\n */\r\n public getClassName(): string {\r\n return \"MorphTarget\";\r\n }\r\n\r\n // Statics\r\n\r\n /**\r\n * Creates a new target from serialized data\r\n * @param serializationObject defines the serialized data to use\r\n * @param scene defines the hosting scene\r\n * @returns a new MorphTarget\r\n */\r\n public static Parse(serializationObject: any, scene?: Scene): MorphTarget {\r\n const result = new MorphTarget(serializationObject.name, serializationObject.influence);\r\n\r\n result.setPositions(serializationObject.positions);\r\n\r\n if (serializationObject.id != null) {\r\n result.id = serializationObject.id;\r\n }\r\n if (serializationObject.normals) {\r\n result.setNormals(serializationObject.normals);\r\n }\r\n if (serializationObject.tangents) {\r\n result.setTangents(serializationObject.tangents);\r\n }\r\n if (serializationObject.uvs) {\r\n result.setUVs(serializationObject.uvs);\r\n }\r\n\r\n // Animations\r\n if (serializationObject.animations) {\r\n for (let animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {\r\n const parsedAnimation = serializationObject.animations[animationIndex];\r\n const internalClass = GetClass(\"BABYLON.Animation\");\r\n if (internalClass) {\r\n result.animations.push(internalClass.Parse(parsedAnimation));\r\n }\r\n }\r\n\r\n if (serializationObject.autoAnimate && scene) {\r\n scene.beginAnimation(\r\n result,\r\n serializationObject.autoAnimateFrom,\r\n serializationObject.autoAnimateTo,\r\n serializationObject.autoAnimateLoop,\r\n serializationObject.autoAnimateSpeed || 1.0\r\n );\r\n }\r\n }\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Creates a MorphTarget from mesh data\r\n * @param mesh defines the source mesh\r\n * @param name defines the name to use for the new target\r\n * @param influence defines the influence to attach to the target\r\n * @returns a new MorphTarget\r\n */\r\n public static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget {\r\n if (!name) {\r\n name = mesh.name;\r\n }\r\n\r\n const result = new MorphTarget(name, influence, mesh.getScene());\r\n\r\n result.setPositions(<FloatArray>mesh.getVerticesData(VertexBuffer.PositionKind));\r\n\r\n if (mesh.isVerticesDataPresent(VertexBuffer.NormalKind)) {\r\n result.setNormals(<FloatArray>mesh.getVerticesData(VertexBuffer.NormalKind));\r\n }\r\n if (mesh.isVerticesDataPresent(VertexBuffer.TangentKind)) {\r\n result.setTangents(<FloatArray>mesh.getVerticesData(VertexBuffer.TangentKind));\r\n }\r\n if (mesh.isVerticesDataPresent(VertexBuffer.UVKind)) {\r\n result.setUVs(<FloatArray>mesh.getVerticesData(VertexBuffer.UVKind));\r\n }\r\n\r\n return result;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"morphTarget.js","sourceRoot":"","sources":["../../../../lts/core/generated/Morph/morphTarget.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI7C;;;GAGG;AACH,MAAM,OAAO,WAAW;IAsBpB;;OAEG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC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AE;YACP,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;SACpB;QAED,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEjE,MAAM,CAAC,YAAY,CAAa,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;QAEjF,IAAI,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE;YACrD,MAAM,CAAC,UAAU,CAAa,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;SAChF;QACD,IAAI,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE;YACtD,MAAM,CAAC,WAAW,CAAa,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC;SAClF;QACD,IAAI,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE;YACjD,MAAM,CAAC,MAAM,CAAa,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;SACxE;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AApSU;IADN,SAAS,EAAE;uCACM","sourcesContent":["import type { IAnimatable } from \"../Animations/animatable.interface\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { Nullable, FloatArray } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport type { AnimationPropertiesOverride } from \"../Animations/animationPropertiesOverride\";\r\nimport { serialize, SerializationHelper } from \"../Misc/decorators\";\r\nimport { GetClass } from \"../Misc/typeStore\";\r\n\r\nimport type { Animation } from \"../Animations/animation\";\r\n\r\n/**\r\n * Defines a target to use with MorphTargetManager\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/morphTargets\r\n */\r\nexport class MorphTarget implements IAnimatable {\r\n /**\r\n * Gets or sets the list of animations\r\n */\r\n public animations = new Array<Animation>();\r\n\r\n private _scene: Nullable<Scene>;\r\n private _positions: Nullable<FloatArray> = null;\r\n private _normals: Nullable<FloatArray> = null;\r\n private _tangents: Nullable<FloatArray> = null;\r\n private _uvs: Nullable<FloatArray> = null;\r\n private _influence: number;\r\n private _uniqueId = 0;\r\n\r\n /**\r\n * Observable raised when the influence changes\r\n */\r\n public onInfluenceChanged = new Observable<boolean>();\r\n\r\n /** @internal */\r\n public _onDataLayoutChanged = new Observable<void>();\r\n\r\n /**\r\n * Gets or sets the influence of this target (ie. its weight in the overall morphing)\r\n */\r\n public get influence(): number {\r\n return this._influence;\r\n }\r\n\r\n public set influence(influence: number) {\r\n if (this._influence === influence) {\r\n return;\r\n }\r\n\r\n const previous = this._influence;\r\n this._influence = influence;\r\n\r\n if (this.onInfluenceChanged.hasObservers()) {\r\n this.onInfluenceChanged.notifyObservers(previous === 0 || influence === 0);\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the id of the morph Target\r\n */\r\n @serialize()\r\n public id: string;\r\n\r\n private _animationPropertiesOverride: Nullable<AnimationPropertiesOverride> = null;\r\n\r\n /**\r\n * Gets or sets the animation properties override\r\n */\r\n public get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride> {\r\n if (!this._animationPropertiesOverride && this._scene) {\r\n return this._scene.animationPropertiesOverride;\r\n }\r\n return this._animationPropertiesOverride;\r\n }\r\n\r\n public set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>) {\r\n this._animationPropertiesOverride = value;\r\n }\r\n\r\n /**\r\n * Creates a new MorphTarget\r\n * @param name defines the name of the target\r\n * @param influence defines the influence to use\r\n * @param scene defines the scene the morphtarget belongs to\r\n */\r\n public constructor(\r\n /** defines the name of the target */\r\n public name: string,\r\n influence = 0,\r\n scene: Nullable<Scene> = null\r\n ) {\r\n this._scene = scene || EngineStore.LastCreatedScene;\r\n this.influence = influence;\r\n\r\n if (this._scene) {\r\n this._uniqueId = this._scene.getUniqueId();\r\n }\r\n }\r\n\r\n /**\r\n * Gets the unique ID of this manager\r\n */\r\n public get uniqueId(): number {\r\n return this._uniqueId;\r\n }\r\n\r\n /**\r\n * Gets a boolean defining if the target contains position data\r\n */\r\n public get hasPositions(): boolean {\r\n return !!this._positions;\r\n }\r\n\r\n /**\r\n * Gets a boolean defining if the target contains normal data\r\n */\r\n public get hasNormals(): boolean {\r\n return !!this._normals;\r\n }\r\n\r\n /**\r\n * Gets a boolean defining if the target contains tangent data\r\n */\r\n public get hasTangents(): boolean {\r\n return !!this._tangents;\r\n }\r\n\r\n /**\r\n * Gets a boolean defining if the target contains texture coordinates data\r\n */\r\n public get hasUVs(): boolean {\r\n return !!this._uvs;\r\n }\r\n\r\n /**\r\n * Affects position data to this target\r\n * @param data defines the position data to use\r\n */\r\n public setPositions(data: Nullable<FloatArray>) {\r\n const hadPositions = this.hasPositions;\r\n\r\n this._positions = data;\r\n\r\n if (hadPositions !== this.hasPositions) {\r\n this._onDataLayoutChanged.notifyObservers(undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the position data stored in this target\r\n * @returns a FloatArray containing the position data (or null if not present)\r\n */\r\n public getPositions(): Nullable<FloatArray> {\r\n return this._positions;\r\n }\r\n\r\n /**\r\n * Affects normal data to this target\r\n * @param data defines the normal data to use\r\n */\r\n public setNormals(data: Nullable<FloatArray>) {\r\n const hadNormals = this.hasNormals;\r\n\r\n this._normals = data;\r\n\r\n if (hadNormals !== this.hasNormals) {\r\n this._onDataLayoutChanged.notifyObservers(undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the normal data stored in this target\r\n * @returns a FloatArray containing the normal data (or null if not present)\r\n */\r\n public getNormals(): Nullable<FloatArray> {\r\n return this._normals;\r\n }\r\n\r\n /**\r\n * Affects tangent data to this target\r\n * @param data defines the tangent data to use\r\n */\r\n public setTangents(data: Nullable<FloatArray>) {\r\n const hadTangents = this.hasTangents;\r\n\r\n this._tangents = data;\r\n\r\n if (hadTangents !== this.hasTangents) {\r\n this._onDataLayoutChanged.notifyObservers(undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the tangent data stored in this target\r\n * @returns a FloatArray containing the tangent data (or null if not present)\r\n */\r\n public getTangents(): Nullable<FloatArray> {\r\n return this._tangents;\r\n }\r\n\r\n /**\r\n * Affects texture coordinates data to this target\r\n * @param data defines the texture coordinates data to use\r\n */\r\n public setUVs(data: Nullable<FloatArray>) {\r\n const hadUVs = this.hasUVs;\r\n\r\n this._uvs = data;\r\n\r\n if (hadUVs !== this.hasUVs) {\r\n this._onDataLayoutChanged.notifyObservers(undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the texture coordinates data stored in this target\r\n * @returns a FloatArray containing the texture coordinates data (or null if not present)\r\n */\r\n public getUVs(): Nullable<FloatArray> {\r\n return this._uvs;\r\n }\r\n\r\n /**\r\n * Clone the current target\r\n * @returns a new MorphTarget\r\n */\r\n public clone(): MorphTarget {\r\n const newOne = SerializationHelper.Clone(() => new MorphTarget(this.name, this.influence, this._scene), this);\r\n\r\n newOne._positions = this._positions;\r\n newOne._normals = this._normals;\r\n newOne._tangents = this._tangents;\r\n newOne._uvs = this._uvs;\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Serializes the current target into a Serialization object\r\n * @returns the serialized object\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {};\r\n\r\n serializationObject.name = this.name;\r\n serializationObject.influence = this.influence;\r\n\r\n serializationObject.positions = Array.prototype.slice.call(this.getPositions());\r\n if (this.id != null) {\r\n serializationObject.id = this.id;\r\n }\r\n if (this.hasNormals) {\r\n serializationObject.normals = Array.prototype.slice.call(this.getNormals());\r\n }\r\n if (this.hasTangents) {\r\n serializationObject.tangents = Array.prototype.slice.call(this.getTangents());\r\n }\r\n if (this.hasUVs) {\r\n serializationObject.uvs = Array.prototype.slice.call(this.getUVs());\r\n }\r\n\r\n // Animations\r\n SerializationHelper.AppendSerializedAnimations(this, serializationObject);\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Returns the string \"MorphTarget\"\r\n * @returns \"MorphTarget\"\r\n */\r\n public getClassName(): string {\r\n return \"MorphTarget\";\r\n }\r\n\r\n // Statics\r\n\r\n /**\r\n * Creates a new target from serialized data\r\n * @param serializationObject defines the serialized data to use\r\n * @param scene defines the hosting scene\r\n * @returns a new MorphTarget\r\n */\r\n public static Parse(serializationObject: any, scene?: Scene): MorphTarget {\r\n const result = new MorphTarget(serializationObject.name, serializationObject.influence);\r\n\r\n result.setPositions(serializationObject.positions);\r\n\r\n if (serializationObject.id != null) {\r\n result.id = serializationObject.id;\r\n }\r\n if (serializationObject.normals) {\r\n result.setNormals(serializationObject.normals);\r\n }\r\n if (serializationObject.tangents) {\r\n result.setTangents(serializationObject.tangents);\r\n }\r\n if (serializationObject.uvs) {\r\n result.setUVs(serializationObject.uvs);\r\n }\r\n\r\n // Animations\r\n if (serializationObject.animations) {\r\n for (let animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {\r\n const parsedAnimation = serializationObject.animations[animationIndex];\r\n const internalClass = GetClass(\"BABYLON.Animation\");\r\n if (internalClass) {\r\n result.animations.push(internalClass.Parse(parsedAnimation));\r\n }\r\n }\r\n\r\n if (serializationObject.autoAnimate && scene) {\r\n scene.beginAnimation(\r\n result,\r\n serializationObject.autoAnimateFrom,\r\n serializationObject.autoAnimateTo,\r\n serializationObject.autoAnimateLoop,\r\n serializationObject.autoAnimateSpeed || 1.0\r\n );\r\n }\r\n }\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Creates a MorphTarget from mesh data\r\n * @param mesh defines the source mesh\r\n * @param name defines the name to use for the new target\r\n * @param influence defines the influence to attach to the target\r\n * @returns a new MorphTarget\r\n */\r\n public static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget {\r\n if (!name) {\r\n name = mesh.name;\r\n }\r\n\r\n const result = new MorphTarget(name, influence, mesh.getScene());\r\n\r\n result.setPositions(<FloatArray>mesh.getVerticesData(VertexBuffer.PositionKind));\r\n\r\n if (mesh.isVerticesDataPresent(VertexBuffer.NormalKind)) {\r\n result.setNormals(<FloatArray>mesh.getVerticesData(VertexBuffer.NormalKind));\r\n }\r\n if (mesh.isVerticesDataPresent(VertexBuffer.TangentKind)) {\r\n result.setTangents(<FloatArray>mesh.getVerticesData(VertexBuffer.TangentKind));\r\n }\r\n if (mesh.isVerticesDataPresent(VertexBuffer.UVKind)) {\r\n result.setUVs(<FloatArray>mesh.getVerticesData(VertexBuffer.UVKind));\r\n }\r\n\r\n return result;\r\n }\r\n}\r\n"]}
@@ -3,7 +3,7 @@ import type { Particle } from "../../Particles/particle";
3
3
  import type { Nullable } from "../../types";
4
4
  import type { UniformBufferEffectCommonAccessor } from "../../Materials/uniformBufferEffectCommonAccessor";
5
5
  import type { UniformBuffer } from "../../Materials/uniformBuffer";
6
- declare type Scene = import("../../scene").Scene;
6
+ import type { Scene } from "../../scene";
7
7
  /**
8
8
  * Particle emitter represents a volume emitting particles.
9
9
  * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
@@ -63,4 +63,3 @@ export interface IParticleEmitterType {
63
63
  */
64
64
  parse(serializationObject: any, scene: Nullable<Scene>): void;
65
65
  }
66
- export {};
@@ -1 +1 @@
1
- {"version":3,"file":"IParticleEmitterType.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Particles/EmitterTypes/IParticleEmitterType.ts"],"names":[],"mappings":"","sourcesContent":["import type { Vector3, Matrix } from \"../../Maths/math.vector\";\r\nimport type { Particle } from \"../../Particles/particle\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { UniformBufferEffectCommonAccessor } from \"../../Materials/uniformBufferEffectCommonAccessor\";\r\nimport type { UniformBuffer } from \"../../Materials/uniformBuffer\";\r\n\r\ndeclare type Scene = import(\"../../scene\").Scene;\r\n\r\n/**\r\n * Particle emitter represents a volume emitting particles.\r\n * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.\r\n */\r\nexport interface IParticleEmitterType {\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param particle is the particle we are computed the direction for\r\n * @param isLocal defines if the direction should be set in local space\r\n * @param inverseWorldMatrix defines the inverted world matrix to use if isLocal is false\r\n */\r\n startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean, inverseWorldMatrix: Matrix): void;\r\n\r\n /**\r\n * Called by the particle System when the position is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param positionToUpdate is the position vector to update with the result\r\n * @param particle is the particle we are computed the position for\r\n * @param isLocal defines if the position should be set in local space\r\n */\r\n startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n clone(): IParticleEmitterType;\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void;\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n buildUniformLayout(ubo: UniformBuffer): void;\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns the effect defines string\r\n */\r\n getEffectDefines(): string;\r\n\r\n /**\r\n * Returns a string representing the class name\r\n * @returns a string containing the class name\r\n */\r\n getClassName(): string;\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n serialize(): any;\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n * @param scene defines the hosting scene\r\n */\r\n parse(serializationObject: any, scene: Nullable<Scene>): void;\r\n}\r\n"]}
1
+ {"version":3,"file":"IParticleEmitterType.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Particles/EmitterTypes/IParticleEmitterType.ts"],"names":[],"mappings":"","sourcesContent":["import type { Vector3, Matrix } from \"../../Maths/math.vector\";\r\nimport type { Particle } from \"../../Particles/particle\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { UniformBufferEffectCommonAccessor } from \"../../Materials/uniformBufferEffectCommonAccessor\";\r\nimport type { UniformBuffer } from \"../../Materials/uniformBuffer\";\r\n\r\nimport type { Scene } from \"../../scene\";\r\n\r\n/**\r\n * Particle emitter represents a volume emitting particles.\r\n * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.\r\n */\r\nexport interface IParticleEmitterType {\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param particle is the particle we are computed the direction for\r\n * @param isLocal defines if the direction should be set in local space\r\n * @param inverseWorldMatrix defines the inverted world matrix to use if isLocal is false\r\n */\r\n startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean, inverseWorldMatrix: Matrix): void;\r\n\r\n /**\r\n * Called by the particle System when the position is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param positionToUpdate is the position vector to update with the result\r\n * @param particle is the particle we are computed the position for\r\n * @param isLocal defines if the position should be set in local space\r\n */\r\n startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n clone(): IParticleEmitterType;\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void;\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n buildUniformLayout(ubo: UniformBuffer): void;\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns the effect defines string\r\n */\r\n getEffectDefines(): string;\r\n\r\n /**\r\n * Returns a string representing the class name\r\n * @returns a string containing the class name\r\n */\r\n getClassName(): string;\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n serialize(): any;\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n * @param scene defines the hosting scene\r\n */\r\n parse(serializationObject: any, scene: Nullable<Scene>): void;\r\n}\r\n"]}
@@ -9,8 +9,8 @@ import type { Effect } from "../Materials/effect";
9
9
  import type { Observable } from "../Misc/observable";
10
10
  import type { VertexBuffer } from "../Buffers/buffer";
11
11
  import type { DataBuffer } from "../Buffers/dataBuffer";
12
- declare type Animation = import("../Animations/animation").Animation;
13
- declare type AbstractMesh = import("../Meshes/abstractMesh").AbstractMesh;
12
+ import type { Animation } from "../Animations/animation";
13
+ import type { AbstractMesh } from "../Meshes/abstractMesh";
14
14
  /**
15
15
  * Interface representing a particle system in Babylon.js.
16
16
  * This groups the common functionalities that needs to be implemented in order to create a particle system.
@@ -669,4 +669,3 @@ export interface IParticleSystem {
669
669
  */
670
670
  getScene(): Nullable<Scene>;
671
671
  }
672
- export {};