@babylonjs/core 7.50.0 → 7.51.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Behaviors/Meshes/pointerDragBehavior.js +4 -1
- package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
- package/Engines/AbstractEngine/abstractEngine.cubeTexture.js +2 -3
- package/Engines/AbstractEngine/abstractEngine.cubeTexture.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/thinEngine.functions.js +5 -3
- package/Engines/thinEngine.functions.js.map +1 -1
- package/Loading/loadingScreen.js +4 -1
- package/Loading/loadingScreen.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/boxBlock.js +4 -4
- package/Meshes/Node/Blocks/Sources/boxBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/gridBlock.js +3 -3
- package/Meshes/Node/Blocks/Sources/gridBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/planeBlock.js +3 -3
- package/Meshes/Node/Blocks/Sources/planeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/subdivideBlock.d.ts +45 -0
- package/Meshes/Node/Blocks/subdivideBlock.js +98 -0
- package/Meshes/Node/Blocks/subdivideBlock.js.map +1 -0
- package/Meshes/Node/index.d.ts +1 -0
- package/Meshes/Node/index.js +1 -0
- package/Meshes/Node/index.js.map +1 -1
- package/Meshes/csg2.js +4 -0
- package/Meshes/csg2.js.map +1 -1
- package/Meshes/geometry.js +1 -1
- package/Meshes/geometry.js.map +1 -1
- package/Meshes/index.d.ts +1 -0
- package/Meshes/index.js +1 -0
- package/Meshes/index.js.map +1 -1
- package/Meshes/mesh.vertexData.js +1 -1
- package/Meshes/mesh.vertexData.js.map +1 -1
- package/Meshes/mesh.vertexData.subdivide.d.ts +28 -0
- package/Meshes/mesh.vertexData.subdivide.js +400 -0
- package/Meshes/mesh.vertexData.subdivide.js.map +1 -0
- package/Misc/index.d.ts +1 -0
- package/Misc/index.js +1 -0
- package/Misc/index.js.map +1 -1
- package/Misc/sceneOptimizer.js +1 -0
- package/Misc/sceneOptimizer.js.map +1 -1
- package/Misc/screenshotTools.d.ts +4 -2
- package/Misc/screenshotTools.js +8 -5
- package/Misc/screenshotTools.js.map +1 -1
- package/Misc/urlTools.d.ts +6 -0
- package/Misc/urlTools.js +12 -0
- package/Misc/urlTools.js.map +1 -0
- package/Physics/v2/characterController.d.ts +8 -0
- package/Physics/v2/characterController.js +12 -5
- package/Physics/v2/characterController.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +5 -3
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/lightFragment.js +1 -1
- package/Shaders/ShadersInclude/lightFragment.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents.js +5 -1
- package/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js +1 -1
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
- package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js +2 -1
- package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js +1 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalUnlitComponents.js +5 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalUnlitComponents.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockSubSurface.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +2 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/ShadersWGSL/pbr.fragment.js +1 -1
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/XR/features/WebXRAnchorSystem.d.ts +4 -0
- package/XR/features/WebXRAnchorSystem.js +8 -5
- package/XR/features/WebXRAnchorSystem.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sceneOptimizer.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/sceneOptimizer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAGtC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IAC1B;;;OAGG;IACI,cAAc;QACjB,OAAO,EAAE,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,KAAY,EAAE,SAAyB;QAChD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;OAGG;IACH;IACI;;OAEG;IACI,WAAmB,CAAC;QAApB,aAAQ,GAAR,QAAQ,CAAY;IAC5B,CAAC;CACP;AAED;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,iBAAiB;IACtD;;;OAGG;IACa,cAAc;QAC1B,OAAO,yCAAyC,GAAG,IAAI,CAAC,WAAW,CAAC;IACxE,CAAC;IAED;;;;;OAKG;IACH;IACI;;OAEG;IACa,WAAmB,CAAC;IACpC;;OAEG;IACI,cAAsB,IAAI;IACjC;;OAEG;IACI,OAAO,GAAG;QAEjB,KAAK,CAAC,QAAQ,CAAC,CAAC;QAVA,aAAQ,GAAR,QAAQ,CAAY;QAI7B,gBAAW,GAAX,WAAW,CAAe;QAI1B,SAAI,GAAJ,IAAI,CAAM;IAGrB,CAAC;IAED;;;;;OAKG;IACa,KAAK,CAAC,KAAY,EAAE,SAAyB;QACzD,IAAI,OAAO,GAAG,IAAI,CAAC;QACnB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KA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AK,EAAE,OAAO,IAAI,qBAAqB,CAAC,0BAA0B,EAAE,EAAE,KAAK,CAAC,CAAC;QAElH,IAAI,SAAS,EAAE,CAAC;YACZ,SAAS,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,EAAE;gBACnC,SAAS,EAAE,CAAC;YAChB,CAAC,CAAC,CAAC;QACP,CAAC;QAED,IAAI,SAAS,EAAE,CAAC;YACZ,SAAS,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,EAAE;gBACnC,SAAS,EAAE,CAAC;YAChB,CAAC,CAAC,CAAC;QACP,CAAC;QAED,SAAS,CAAC,KAAK,EAAE,CAAC;QAElB,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport type { Scene, IDisposable } from \"../scene\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Observer } from \"./observable\";\r\nimport { Observable } from \"./observable\";\r\n\r\n/**\r\n * Defines the root class used to create scene optimization to use with SceneOptimizer\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public getDescription(): string {\r\n return \"\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n return true;\r\n }\r\n\r\n /**\r\n * Creates the SceneOptimization object\r\n * @param priority defines the priority of this optimization (0 by default which means first in the list)\r\n */\r\n constructor(\r\n /**\r\n * [0] Defines the priority of this optimization (0 by default which means first in the list)\r\n */\r\n public priority: number = 0\r\n ) {}\r\n}\r\n\r\n/**\r\n * Defines an optimization used to reduce the size of render target textures\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class TextureOptimization extends SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Reducing render target texture size to \" + this.maximumSize;\r\n }\r\n\r\n /**\r\n * Creates the TextureOptimization object\r\n * @param priority defines the priority of this optimization (0 by default which means first in the list)\r\n * @param maximumSize defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter\r\n * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.\r\n */\r\n constructor(\r\n /**\r\n * [0] Defines the priority of this optimization (0 by default which means first in the list)\r\n */\r\n public override priority: number = 0,\r\n /**\r\n * [1024] Defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter\r\n */\r\n public maximumSize: number = 1024,\r\n /**\r\n * [0.5] Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.\r\n */\r\n public step = 0.5\r\n ) {\r\n super(priority);\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n let allDone = true;\r\n for (let index = 0; index < scene.textures.length; index++) {\r\n const texture = scene.textures[index];\r\n\r\n if (!texture.canRescale || (<any>texture).getContext) {\r\n continue;\r\n }\r\n\r\n const currentSize = texture.getSize();\r\n const maxDimension = Math.max(currentSize.width, currentSize.height);\r\n\r\n if (maxDimension > this.maximumSize) {\r\n texture.scale(this.step);\r\n allDone = false;\r\n }\r\n }\r\n\r\n return allDone;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to increase or decrease the rendering resolution\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class HardwareScalingOptimization extends SceneOptimization {\r\n private _currentScale = -1;\r\n private _directionOffset = 1;\r\n\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Setting hardware scaling level to \" + this._currentScale;\r\n }\r\n\r\n /**\r\n * Creates the HardwareScalingOptimization object\r\n * @param priority defines the priority of this optimization (0 by default which means first in the list)\r\n * @param maximumScale defines the maximum scale to use (2 by default)\r\n * @param step defines the step to use between two passes (0.5 by default)\r\n */\r\n constructor(\r\n /**\r\n * [0] Defines the priority of this optimization (0 by default which means first in the list)\r\n */\r\n public override priority: number = 0,\r\n /**\r\n * [2] Defines the maximum scale to use (2 by default)\r\n */\r\n public maximumScale: number = 2,\r\n /**\r\n * [0.25] Defines the step to use between two passes (0.5 by default)\r\n */\r\n public step: number = 0.25\r\n ) {\r\n super(priority);\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n if (this._currentScale === -1) {\r\n this._currentScale = scene.getEngine().getHardwareScalingLevel();\r\n if (this._currentScale > this.maximumScale) {\r\n this._directionOffset = -1;\r\n }\r\n }\r\n\r\n this._currentScale += this._directionOffset * this.step;\r\n\r\n scene.getEngine().setHardwareScalingLevel(this._currentScale);\r\n\r\n return this._directionOffset === 1 ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to remove shadows\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class ShadowsOptimization extends SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Turning shadows on/off\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n scene.shadowsEnabled = optimizer.isInImprovementMode;\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to turn post-processes off\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class PostProcessesOptimization extends SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Turning post-processes on/off\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n scene.postProcessesEnabled = optimizer.isInImprovementMode;\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to turn lens flares off\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class LensFlaresOptimization extends SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Turning lens flares on/off\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n scene.lensFlaresEnabled = optimizer.isInImprovementMode;\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization based on user defined callback.\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class CustomOptimization extends SceneOptimization {\r\n /**\r\n * Callback called to apply the custom optimization.\r\n */\r\n public onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;\r\n\r\n /**\r\n * Callback called to get custom description\r\n */\r\n public onGetDescription: () => string;\r\n\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n if (this.onGetDescription) {\r\n return this.onGetDescription();\r\n }\r\n\r\n return \"Running user defined callback\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n if (this.onApply) {\r\n return this.onApply(scene, optimizer);\r\n }\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to turn particles off\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class ParticlesOptimization extends SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Turning particles on/off\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n scene.particlesEnabled = optimizer.isInImprovementMode;\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to turn render targets off\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class RenderTargetsOptimization extends SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Turning render targets off\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n scene.renderTargetsEnabled = optimizer.isInImprovementMode;\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to merge meshes with compatible materials\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class MergeMeshesOptimization extends SceneOptimization {\r\n private static _UpdateSelectionTree = false;\r\n\r\n /**\r\n * Gets or sets a boolean which defines if optimization octree has to be updated\r\n */\r\n public static get UpdateSelectionTree(): boolean {\r\n return MergeMeshesOptimization._UpdateSelectionTree;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean which defines if optimization octree has to be updated\r\n */\r\n public static set UpdateSelectionTree(value: boolean) {\r\n MergeMeshesOptimization._UpdateSelectionTree = value;\r\n }\r\n\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Merging similar meshes together\";\r\n }\r\n\r\n private _canBeMerged = (abstractMesh: AbstractMesh): boolean => {\r\n if (!(abstractMesh instanceof Mesh)) {\r\n return false;\r\n }\r\n\r\n const mesh = <Mesh>abstractMesh;\r\n\r\n if (mesh.isDisposed()) {\r\n return false;\r\n }\r\n\r\n if (!mesh.isVisible || !mesh.isEnabled()) {\r\n return false;\r\n }\r\n\r\n if (mesh.instances.length > 0) {\r\n return false;\r\n }\r\n\r\n if (mesh.skeleton || mesh.hasLODLevels) {\r\n return false;\r\n }\r\n\r\n if (mesh.getTotalVertices() === 0) {\r\n return false;\r\n }\r\n\r\n return true;\r\n };\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @param updateSelectionTree defines that the selection octree has to be updated (false by default)\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean {\r\n const globalPool = scene.meshes.slice(0);\r\n let globalLength = globalPool.length;\r\n\r\n for (let index = 0; index < globalLength; index++) {\r\n const currentPool: Mesh[] = [];\r\n const current = globalPool[index];\r\n\r\n // Checks\r\n if (!this._canBeMerged(current)) {\r\n continue;\r\n }\r\n\r\n currentPool.push(<Mesh>current);\r\n\r\n // Find compatible meshes\r\n for (let subIndex = index + 1; subIndex < globalLength; subIndex++) {\r\n const otherMesh = globalPool[subIndex];\r\n\r\n if (!this._canBeMerged(otherMesh)) {\r\n continue;\r\n }\r\n\r\n if (otherMesh.material !== current.material) {\r\n continue;\r\n }\r\n\r\n if (otherMesh.checkCollisions !== current.checkCollisions) {\r\n continue;\r\n }\r\n\r\n currentPool.push(<Mesh>otherMesh);\r\n globalLength--;\r\n\r\n globalPool.splice(subIndex, 1);\r\n\r\n subIndex--;\r\n }\r\n\r\n if (currentPool.length < 2) {\r\n continue;\r\n }\r\n\r\n // Merge meshes\r\n Mesh.MergeMeshes(currentPool, undefined, true);\r\n }\r\n\r\n // Call the octree system optimization if it is defined.\r\n const sceneAsAny = scene as any;\r\n if (sceneAsAny.createOrUpdateSelectionOctree) {\r\n if (updateSelectionTree != undefined) {\r\n if (updateSelectionTree) {\r\n sceneAsAny.createOrUpdateSelectionOctree();\r\n }\r\n } else if (MergeMeshesOptimization.UpdateSelectionTree) {\r\n sceneAsAny.createOrUpdateSelectionOctree();\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines a list of options used by SceneOptimizer\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class SceneOptimizerOptions {\r\n /**\r\n * Gets the list of optimizations to apply\r\n */\r\n public optimizations: SceneOptimization[] = [];\r\n\r\n /**\r\n * Creates a new list of options used by SceneOptimizer\r\n * @param targetFrameRate defines the target frame rate to reach (60 by default)\r\n * @param trackerDuration defines the interval between two checks (2000ms by default)\r\n */\r\n constructor(\r\n /**\r\n * [60] Defines the target frame rate to reach (60 by default)\r\n */\r\n public targetFrameRate: number = 60,\r\n /**\r\n * [2000] Defines the interval between two checks (2000ms by default)\r\n */\r\n public trackerDuration: number = 2000\r\n ) {}\r\n\r\n /**\r\n * Add a new optimization\r\n * @param optimization defines the SceneOptimization to add to the list of active optimizations\r\n * @returns the current SceneOptimizerOptions\r\n */\r\n public addOptimization(optimization: SceneOptimization): SceneOptimizerOptions {\r\n this.optimizations.push(optimization);\r\n return this;\r\n }\r\n\r\n /**\r\n * Add a new custom optimization\r\n * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)\r\n * @param onGetDescription defines the callback called to get the description attached with the optimization.\r\n * @param priority defines the priority of this optimization (0 by default which means first in the list)\r\n * @returns the current SceneOptimizerOptions\r\n */\r\n public addCustomOptimization(onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean, onGetDescription: () => string, priority: number = 0): SceneOptimizerOptions {\r\n const optimization = new CustomOptimization(priority);\r\n optimization.onApply = onApply;\r\n optimization.onGetDescription = onGetDescription;\r\n\r\n this.optimizations.push(optimization);\r\n return this;\r\n }\r\n\r\n /**\r\n * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene\r\n * @param targetFrameRate defines the target frame rate (60 by default)\r\n * @returns a SceneOptimizerOptions object\r\n */\r\n public static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions {\r\n const result = new SceneOptimizerOptions(targetFrameRate);\r\n\r\n let priority = 0;\r\n result.addOptimization(new MergeMeshesOptimization(priority));\r\n result.addOptimization(new ShadowsOptimization(priority));\r\n result.addOptimization(new LensFlaresOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new PostProcessesOptimization(priority));\r\n result.addOptimization(new ParticlesOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new TextureOptimization(priority, 1024));\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual\r\n * @param targetFrameRate defines the target frame rate (60 by default)\r\n * @returns a SceneOptimizerOptions object\r\n */\r\n public static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions {\r\n const result = new SceneOptimizerOptions(targetFrameRate);\r\n\r\n let priority = 0;\r\n result.addOptimization(new MergeMeshesOptimization(priority));\r\n result.addOptimization(new ShadowsOptimization(priority));\r\n result.addOptimization(new LensFlaresOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new PostProcessesOptimization(priority));\r\n result.addOptimization(new ParticlesOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new TextureOptimization(priority, 512));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new RenderTargetsOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new HardwareScalingOptimization(priority, 2));\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual\r\n * @param targetFrameRate defines the target frame rate (60 by default)\r\n * @returns a SceneOptimizerOptions object\r\n */\r\n public static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions {\r\n const result = new SceneOptimizerOptions(targetFrameRate);\r\n\r\n let priority = 0;\r\n result.addOptimization(new MergeMeshesOptimization(priority));\r\n result.addOptimization(new ShadowsOptimization(priority));\r\n result.addOptimization(new LensFlaresOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new PostProcessesOptimization(priority));\r\n result.addOptimization(new ParticlesOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new TextureOptimization(priority, 256));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new RenderTargetsOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new HardwareScalingOptimization(priority, 4));\r\n\r\n return result;\r\n }\r\n}\r\n\r\n/**\r\n * Class used to run optimizations in order to reach a target frame rate\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class SceneOptimizer implements IDisposable {\r\n private _isRunning = false;\r\n private _options: SceneOptimizerOptions;\r\n private _scene: Scene;\r\n private _currentPriorityLevel = 0;\r\n private _targetFrameRate = 60;\r\n private _trackerDuration = 2000;\r\n private _currentFrameRate = 0;\r\n private _sceneDisposeObserver: Nullable<Observer<Scene>>;\r\n private _improvementMode = false;\r\n\r\n /**\r\n * Defines an observable called when the optimizer reaches the target frame rate\r\n */\r\n public onSuccessObservable = new Observable<SceneOptimizer>();\r\n /**\r\n * Defines an observable called when the optimizer enables an optimization\r\n */\r\n public onNewOptimizationAppliedObservable = new Observable<SceneOptimization>();\r\n /**\r\n * Defines an observable called when the optimizer is not able to reach the target frame rate\r\n */\r\n public onFailureObservable = new Observable<SceneOptimizer>();\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the optimizer is in improvement mode\r\n */\r\n public get isInImprovementMode(): boolean {\r\n return this._improvementMode;\r\n }\r\n\r\n public set isInImprovementMode(value: boolean) {\r\n this._improvementMode = value;\r\n }\r\n\r\n /**\r\n * Gets the current priority level (0 at start)\r\n */\r\n public get currentPriorityLevel(): number {\r\n return this._currentPriorityLevel;\r\n }\r\n\r\n /**\r\n * Gets the current frame rate checked by the SceneOptimizer\r\n */\r\n public get currentFrameRate(): number {\r\n return this._currentFrameRate;\r\n }\r\n\r\n /**\r\n * Gets or sets the current target frame rate (60 by default)\r\n */\r\n public get targetFrameRate(): number {\r\n return this._targetFrameRate;\r\n }\r\n\r\n /**\r\n * Gets or sets the current target frame rate (60 by default)\r\n */\r\n public set targetFrameRate(value: number) {\r\n this._targetFrameRate = value;\r\n }\r\n\r\n /**\r\n * Gets or sets the current interval between two checks (every 2000ms by default)\r\n */\r\n public get trackerDuration(): number {\r\n return this._trackerDuration;\r\n }\r\n\r\n /**\r\n * Gets or sets the current interval between two checks (every 2000ms by default)\r\n */\r\n public set trackerDuration(value: number) {\r\n this._trackerDuration = value;\r\n }\r\n\r\n /**\r\n * Gets the list of active optimizations\r\n */\r\n public get optimizations(): SceneOptimization[] {\r\n return this._options.optimizations;\r\n }\r\n\r\n /**\r\n * Creates a new SceneOptimizer\r\n * @param scene defines the scene to work on\r\n * @param options defines the options to use with the SceneOptimizer\r\n * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)\r\n * @param improvementMode defines if the scene optimizer must run the maximum optimization while staying over a target frame instead of trying to reach the target framerate (false by default)\r\n */\r\n public constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities = true, improvementMode = false) {\r\n if (!options) {\r\n this._options = new SceneOptimizerOptions();\r\n } else {\r\n this._options = options;\r\n }\r\n\r\n if (this._options.targetFrameRate) {\r\n this._targetFrameRate = this._options.targetFrameRate;\r\n }\r\n\r\n if (this._options.trackerDuration) {\r\n this._trackerDuration = this._options.trackerDuration;\r\n }\r\n\r\n if (autoGeneratePriorities) {\r\n let priority = 0;\r\n for (const optim of this._options.optimizations) {\r\n optim.priority = priority++;\r\n }\r\n }\r\n\r\n this._improvementMode = improvementMode;\r\n this._scene = scene || EngineStore.LastCreatedScene;\r\n this._sceneDisposeObserver = this._scene.onDisposeObservable.add(() => {\r\n this._sceneDisposeObserver = null;\r\n this.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * Stops the current optimizer\r\n */\r\n public stop() {\r\n this._isRunning = false;\r\n }\r\n\r\n /**\r\n * Reset the optimizer to initial step (current priority level = 0)\r\n */\r\n public reset() {\r\n this._currentPriorityLevel = 0;\r\n }\r\n\r\n /**\r\n * Start the optimizer. By default it will try to reach a specific framerate\r\n * but if the optimizer is set with improvementMode === true then it will run all optimization while frame rate is above the target frame rate\r\n */\r\n public start() {\r\n if (this._isRunning) {\r\n return;\r\n }\r\n\r\n this._isRunning = true;\r\n\r\n // Let's wait for the scene to be ready before running our check\r\n this._scene.executeWhenReady(() => {\r\n setTimeout(() => {\r\n this._checkCurrentState();\r\n }, this._trackerDuration);\r\n });\r\n }\r\n\r\n private _checkCurrentState() {\r\n if (!this._isRunning) {\r\n return;\r\n }\r\n\r\n const scene = this._scene;\r\n const options = this._options;\r\n\r\n this._currentFrameRate = Math.round(scene.getEngine().getFps());\r\n\r\n if ((this._improvementMode && this._currentFrameRate <= this._targetFrameRate) || (!this._improvementMode && this._currentFrameRate >= this._targetFrameRate)) {\r\n this._isRunning = false;\r\n this.onSuccessObservable.notifyObservers(this);\r\n return;\r\n }\r\n\r\n // Apply current level of optimizations\r\n let allDone = true;\r\n let noOptimizationApplied = true;\r\n for (let index = 0; index < options.optimizations.length; index++) {\r\n const optimization = options.optimizations[index];\r\n\r\n if (optimization.priority === this._currentPriorityLevel) {\r\n noOptimizationApplied = false;\r\n allDone = allDone && optimization.apply(scene, this);\r\n this.onNewOptimizationAppliedObservable.notifyObservers(optimization);\r\n }\r\n }\r\n\r\n // If no optimization was applied, this is a failure :(\r\n if (noOptimizationApplied) {\r\n this._isRunning = false;\r\n this.onFailureObservable.notifyObservers(this);\r\n\r\n return;\r\n }\r\n\r\n // If all optimizations were done, move to next level\r\n if (allDone) {\r\n this._currentPriorityLevel++;\r\n }\r\n\r\n // Let's the system running for a specific amount of time before checking FPS\r\n scene.executeWhenReady(() => {\r\n setTimeout(() => {\r\n this._checkCurrentState();\r\n }, this._trackerDuration);\r\n });\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public dispose(): void {\r\n this.stop();\r\n this.onSuccessObservable.clear();\r\n this.onFailureObservable.clear();\r\n this.onNewOptimizationAppliedObservable.clear();\r\n if (this._sceneDisposeObserver) {\r\n this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);\r\n }\r\n }\r\n\r\n /**\r\n * Helper function to create a SceneOptimizer with one single line of code\r\n * @param scene defines the scene to work on\r\n * @param options defines the options to use with the SceneOptimizer\r\n * @param onSuccess defines a callback to call on success\r\n * @param onFailure defines a callback to call on failure\r\n * @returns the new SceneOptimizer object\r\n */\r\n public static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer {\r\n const optimizer = new SceneOptimizer(scene, options || SceneOptimizerOptions.ModerateDegradationAllowed(), false);\r\n\r\n if (onSuccess) {\r\n optimizer.onSuccessObservable.add(() => {\r\n onSuccess();\r\n });\r\n }\r\n\r\n if (onFailure) {\r\n optimizer.onFailureObservable.add(() => {\r\n onFailure();\r\n });\r\n }\r\n\r\n optimizer.start();\r\n\r\n return optimizer;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"sceneOptimizer.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/sceneOptimizer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAGtC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IAC1B;;;OAGG;IACI,cAAc;QACjB,OAAO,EAAE,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,KAAY,EAAE,SAAyB;QAChD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;OAGG;IACH;IACI;;OAEG;IACI,WAAmB,CAAC;QAApB,aAAQ,GAAR,QAAQ,CAAY;IAC5B,CAAC;CACP;AAED;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,iBAAiB;IACtD;;;OAGG;IACa,cAAc;QAC1B,OAAO,yCAAyC,GAAG,IAAI,CAAC,WAAW,CAAC;IACxE,CAAC;IAED;;;;;OA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ED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;QACjC,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;QACjC,IAAI,CAAC,kCAAkC,CAAC,KAAK,EAAE,CAAC;QAChD,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QACvE,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,aAAa,CAAC,KAAY,EAAE,OAA+B,EAAE,SAAsB,EAAE,SAAsB;QACrH,MAAM,SAAS,GAAG,IAAI,cAAc,CAAC,KAAK,EAAE,OAAO,IAAI,qBAAqB,CAAC,0BAA0B,EAAE,EAAE,KAAK,CAAC,CAAC;QAElH,IAAI,SAAS,EAAE,CAAC;YACZ,SAAS,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,EAAE;gBACnC,SAAS,EAAE,CAAC;YAChB,CAAC,CAAC,CAAC;QACP,CAAC;QAED,IAAI,SAAS,EAAE,CAAC;YACZ,SAAS,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,EAAE;gBACnC,SAAS,EAAE,CAAC;YAChB,CAAC,CAAC,CAAC;QACP,CAAC;QAED,SAAS,CAAC,KAAK,EAAE,CAAC;QAElB,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport type { Scene, IDisposable } from \"../scene\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Observer } from \"./observable\";\r\nimport { Observable } from \"./observable\";\r\n\r\n/**\r\n * Defines the root class used to create scene optimization to use with SceneOptimizer\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public getDescription(): string {\r\n return \"\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n return true;\r\n }\r\n\r\n /**\r\n * Creates the SceneOptimization object\r\n * @param priority defines the priority of this optimization (0 by default which means first in the list)\r\n */\r\n constructor(\r\n /**\r\n * [0] Defines the priority of this optimization (0 by default which means first in the list)\r\n */\r\n public priority: number = 0\r\n ) {}\r\n}\r\n\r\n/**\r\n * Defines an optimization used to reduce the size of render target textures\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class TextureOptimization extends SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Reducing render target texture size to \" + this.maximumSize;\r\n }\r\n\r\n /**\r\n * Creates the TextureOptimization object\r\n * @param priority defines the priority of this optimization (0 by default which means first in the list)\r\n * @param maximumSize defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter\r\n * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.\r\n */\r\n constructor(\r\n /**\r\n * [0] Defines the priority of this optimization (0 by default which means first in the list)\r\n */\r\n public override priority: number = 0,\r\n /**\r\n * [1024] Defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter\r\n */\r\n public maximumSize: number = 1024,\r\n /**\r\n * [0.5] Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.\r\n */\r\n public step = 0.5\r\n ) {\r\n super(priority);\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n let allDone = true;\r\n for (let index = 0; index < scene.textures.length; index++) {\r\n const texture = scene.textures[index];\r\n\r\n if (!texture.canRescale || (<any>texture).getContext) {\r\n continue;\r\n }\r\n\r\n const currentSize = texture.getSize();\r\n const maxDimension = Math.max(currentSize.width, currentSize.height);\r\n\r\n if (maxDimension > this.maximumSize) {\r\n texture.scale(this.step);\r\n allDone = false;\r\n }\r\n }\r\n\r\n return allDone;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to increase or decrease the rendering resolution\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class HardwareScalingOptimization extends SceneOptimization {\r\n private _currentScale = -1;\r\n private _directionOffset = 1;\r\n\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Setting hardware scaling level to \" + this._currentScale;\r\n }\r\n\r\n /**\r\n * Creates the HardwareScalingOptimization object\r\n * @param priority defines the priority of this optimization (0 by default which means first in the list)\r\n * @param maximumScale defines the maximum scale to use (2 by default)\r\n * @param step defines the step to use between two passes (0.5 by default)\r\n */\r\n constructor(\r\n /**\r\n * [0] Defines the priority of this optimization (0 by default which means first in the list)\r\n */\r\n public override priority: number = 0,\r\n /**\r\n * [2] Defines the maximum scale to use (2 by default)\r\n */\r\n public maximumScale: number = 2,\r\n /**\r\n * [0.25] Defines the step to use between two passes (0.5 by default)\r\n */\r\n public step: number = 0.25\r\n ) {\r\n super(priority);\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n if (this._currentScale === -1) {\r\n this._currentScale = scene.getEngine().getHardwareScalingLevel();\r\n if (this._currentScale > this.maximumScale) {\r\n this._directionOffset = -1;\r\n }\r\n }\r\n\r\n this._currentScale += this._directionOffset * this.step;\r\n this._currentScale = Math.min(this.maximumScale, this._currentScale);\r\n\r\n scene.getEngine().setHardwareScalingLevel(this._currentScale);\r\n\r\n return this._directionOffset === 1 ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to remove shadows\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class ShadowsOptimization extends SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Turning shadows on/off\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n scene.shadowsEnabled = optimizer.isInImprovementMode;\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to turn post-processes off\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class PostProcessesOptimization extends SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Turning post-processes on/off\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n scene.postProcessesEnabled = optimizer.isInImprovementMode;\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to turn lens flares off\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class LensFlaresOptimization extends SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Turning lens flares on/off\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n scene.lensFlaresEnabled = optimizer.isInImprovementMode;\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization based on user defined callback.\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class CustomOptimization extends SceneOptimization {\r\n /**\r\n * Callback called to apply the custom optimization.\r\n */\r\n public onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;\r\n\r\n /**\r\n * Callback called to get custom description\r\n */\r\n public onGetDescription: () => string;\r\n\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n if (this.onGetDescription) {\r\n return this.onGetDescription();\r\n }\r\n\r\n return \"Running user defined callback\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n if (this.onApply) {\r\n return this.onApply(scene, optimizer);\r\n }\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to turn particles off\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class ParticlesOptimization extends SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Turning particles on/off\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n scene.particlesEnabled = optimizer.isInImprovementMode;\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to turn render targets off\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class RenderTargetsOptimization extends SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Turning render targets off\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n scene.renderTargetsEnabled = optimizer.isInImprovementMode;\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to merge meshes with compatible materials\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class MergeMeshesOptimization extends SceneOptimization {\r\n private static _UpdateSelectionTree = false;\r\n\r\n /**\r\n * Gets or sets a boolean which defines if optimization octree has to be updated\r\n */\r\n public static get UpdateSelectionTree(): boolean {\r\n return MergeMeshesOptimization._UpdateSelectionTree;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean which defines if optimization octree has to be updated\r\n */\r\n public static set UpdateSelectionTree(value: boolean) {\r\n MergeMeshesOptimization._UpdateSelectionTree = value;\r\n }\r\n\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Merging similar meshes together\";\r\n }\r\n\r\n private _canBeMerged = (abstractMesh: AbstractMesh): boolean => {\r\n if (!(abstractMesh instanceof Mesh)) {\r\n return false;\r\n }\r\n\r\n const mesh = <Mesh>abstractMesh;\r\n\r\n if (mesh.isDisposed()) {\r\n return false;\r\n }\r\n\r\n if (!mesh.isVisible || !mesh.isEnabled()) {\r\n return false;\r\n }\r\n\r\n if (mesh.instances.length > 0) {\r\n return false;\r\n }\r\n\r\n if (mesh.skeleton || mesh.hasLODLevels) {\r\n return false;\r\n }\r\n\r\n if (mesh.getTotalVertices() === 0) {\r\n return false;\r\n }\r\n\r\n return true;\r\n };\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @param updateSelectionTree defines that the selection octree has to be updated (false by default)\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean {\r\n const globalPool = scene.meshes.slice(0);\r\n let globalLength = globalPool.length;\r\n\r\n for (let index = 0; index < globalLength; index++) {\r\n const currentPool: Mesh[] = [];\r\n const current = globalPool[index];\r\n\r\n // Checks\r\n if (!this._canBeMerged(current)) {\r\n continue;\r\n }\r\n\r\n currentPool.push(<Mesh>current);\r\n\r\n // Find compatible meshes\r\n for (let subIndex = index + 1; subIndex < globalLength; subIndex++) {\r\n const otherMesh = globalPool[subIndex];\r\n\r\n if (!this._canBeMerged(otherMesh)) {\r\n continue;\r\n }\r\n\r\n if (otherMesh.material !== current.material) {\r\n continue;\r\n }\r\n\r\n if (otherMesh.checkCollisions !== current.checkCollisions) {\r\n continue;\r\n }\r\n\r\n currentPool.push(<Mesh>otherMesh);\r\n globalLength--;\r\n\r\n globalPool.splice(subIndex, 1);\r\n\r\n subIndex--;\r\n }\r\n\r\n if (currentPool.length < 2) {\r\n continue;\r\n }\r\n\r\n // Merge meshes\r\n Mesh.MergeMeshes(currentPool, undefined, true);\r\n }\r\n\r\n // Call the octree system optimization if it is defined.\r\n const sceneAsAny = scene as any;\r\n if (sceneAsAny.createOrUpdateSelectionOctree) {\r\n if (updateSelectionTree != undefined) {\r\n if (updateSelectionTree) {\r\n sceneAsAny.createOrUpdateSelectionOctree();\r\n }\r\n } else if (MergeMeshesOptimization.UpdateSelectionTree) {\r\n sceneAsAny.createOrUpdateSelectionOctree();\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines a list of options used by SceneOptimizer\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class SceneOptimizerOptions {\r\n /**\r\n * Gets the list of optimizations to apply\r\n */\r\n public optimizations: SceneOptimization[] = [];\r\n\r\n /**\r\n * Creates a new list of options used by SceneOptimizer\r\n * @param targetFrameRate defines the target frame rate to reach (60 by default)\r\n * @param trackerDuration defines the interval between two checks (2000ms by default)\r\n */\r\n constructor(\r\n /**\r\n * [60] Defines the target frame rate to reach (60 by default)\r\n */\r\n public targetFrameRate: number = 60,\r\n /**\r\n * [2000] Defines the interval between two checks (2000ms by default)\r\n */\r\n public trackerDuration: number = 2000\r\n ) {}\r\n\r\n /**\r\n * Add a new optimization\r\n * @param optimization defines the SceneOptimization to add to the list of active optimizations\r\n * @returns the current SceneOptimizerOptions\r\n */\r\n public addOptimization(optimization: SceneOptimization): SceneOptimizerOptions {\r\n this.optimizations.push(optimization);\r\n return this;\r\n }\r\n\r\n /**\r\n * Add a new custom optimization\r\n * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)\r\n * @param onGetDescription defines the callback called to get the description attached with the optimization.\r\n * @param priority defines the priority of this optimization (0 by default which means first in the list)\r\n * @returns the current SceneOptimizerOptions\r\n */\r\n public addCustomOptimization(onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean, onGetDescription: () => string, priority: number = 0): SceneOptimizerOptions {\r\n const optimization = new CustomOptimization(priority);\r\n optimization.onApply = onApply;\r\n optimization.onGetDescription = onGetDescription;\r\n\r\n this.optimizations.push(optimization);\r\n return this;\r\n }\r\n\r\n /**\r\n * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene\r\n * @param targetFrameRate defines the target frame rate (60 by default)\r\n * @returns a SceneOptimizerOptions object\r\n */\r\n public static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions {\r\n const result = new SceneOptimizerOptions(targetFrameRate);\r\n\r\n let priority = 0;\r\n result.addOptimization(new MergeMeshesOptimization(priority));\r\n result.addOptimization(new ShadowsOptimization(priority));\r\n result.addOptimization(new LensFlaresOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new PostProcessesOptimization(priority));\r\n result.addOptimization(new ParticlesOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new TextureOptimization(priority, 1024));\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual\r\n * @param targetFrameRate defines the target frame rate (60 by default)\r\n * @returns a SceneOptimizerOptions object\r\n */\r\n public static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions {\r\n const result = new SceneOptimizerOptions(targetFrameRate);\r\n\r\n let priority = 0;\r\n result.addOptimization(new MergeMeshesOptimization(priority));\r\n result.addOptimization(new ShadowsOptimization(priority));\r\n result.addOptimization(new LensFlaresOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new PostProcessesOptimization(priority));\r\n result.addOptimization(new ParticlesOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new TextureOptimization(priority, 512));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new RenderTargetsOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new HardwareScalingOptimization(priority, 2));\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual\r\n * @param targetFrameRate defines the target frame rate (60 by default)\r\n * @returns a SceneOptimizerOptions object\r\n */\r\n public static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions {\r\n const result = new SceneOptimizerOptions(targetFrameRate);\r\n\r\n let priority = 0;\r\n result.addOptimization(new MergeMeshesOptimization(priority));\r\n result.addOptimization(new ShadowsOptimization(priority));\r\n result.addOptimization(new LensFlaresOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new PostProcessesOptimization(priority));\r\n result.addOptimization(new ParticlesOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new TextureOptimization(priority, 256));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new RenderTargetsOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new HardwareScalingOptimization(priority, 4));\r\n\r\n return result;\r\n }\r\n}\r\n\r\n/**\r\n * Class used to run optimizations in order to reach a target frame rate\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class SceneOptimizer implements IDisposable {\r\n private _isRunning = false;\r\n private _options: SceneOptimizerOptions;\r\n private _scene: Scene;\r\n private _currentPriorityLevel = 0;\r\n private _targetFrameRate = 60;\r\n private _trackerDuration = 2000;\r\n private _currentFrameRate = 0;\r\n private _sceneDisposeObserver: Nullable<Observer<Scene>>;\r\n private _improvementMode = false;\r\n\r\n /**\r\n * Defines an observable called when the optimizer reaches the target frame rate\r\n */\r\n public onSuccessObservable = new Observable<SceneOptimizer>();\r\n /**\r\n * Defines an observable called when the optimizer enables an optimization\r\n */\r\n public onNewOptimizationAppliedObservable = new Observable<SceneOptimization>();\r\n /**\r\n * Defines an observable called when the optimizer is not able to reach the target frame rate\r\n */\r\n public onFailureObservable = new Observable<SceneOptimizer>();\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the optimizer is in improvement mode\r\n */\r\n public get isInImprovementMode(): boolean {\r\n return this._improvementMode;\r\n }\r\n\r\n public set isInImprovementMode(value: boolean) {\r\n this._improvementMode = value;\r\n }\r\n\r\n /**\r\n * Gets the current priority level (0 at start)\r\n */\r\n public get currentPriorityLevel(): number {\r\n return this._currentPriorityLevel;\r\n }\r\n\r\n /**\r\n * Gets the current frame rate checked by the SceneOptimizer\r\n */\r\n public get currentFrameRate(): number {\r\n return this._currentFrameRate;\r\n }\r\n\r\n /**\r\n * Gets or sets the current target frame rate (60 by default)\r\n */\r\n public get targetFrameRate(): number {\r\n return this._targetFrameRate;\r\n }\r\n\r\n /**\r\n * Gets or sets the current target frame rate (60 by default)\r\n */\r\n public set targetFrameRate(value: number) {\r\n this._targetFrameRate = value;\r\n }\r\n\r\n /**\r\n * Gets or sets the current interval between two checks (every 2000ms by default)\r\n */\r\n public get trackerDuration(): number {\r\n return this._trackerDuration;\r\n }\r\n\r\n /**\r\n * Gets or sets the current interval between two checks (every 2000ms by default)\r\n */\r\n public set trackerDuration(value: number) {\r\n this._trackerDuration = value;\r\n }\r\n\r\n /**\r\n * Gets the list of active optimizations\r\n */\r\n public get optimizations(): SceneOptimization[] {\r\n return this._options.optimizations;\r\n }\r\n\r\n /**\r\n * Creates a new SceneOptimizer\r\n * @param scene defines the scene to work on\r\n * @param options defines the options to use with the SceneOptimizer\r\n * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)\r\n * @param improvementMode defines if the scene optimizer must run the maximum optimization while staying over a target frame instead of trying to reach the target framerate (false by default)\r\n */\r\n public constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities = true, improvementMode = false) {\r\n if (!options) {\r\n this._options = new SceneOptimizerOptions();\r\n } else {\r\n this._options = options;\r\n }\r\n\r\n if (this._options.targetFrameRate) {\r\n this._targetFrameRate = this._options.targetFrameRate;\r\n }\r\n\r\n if (this._options.trackerDuration) {\r\n this._trackerDuration = this._options.trackerDuration;\r\n }\r\n\r\n if (autoGeneratePriorities) {\r\n let priority = 0;\r\n for (const optim of this._options.optimizations) {\r\n optim.priority = priority++;\r\n }\r\n }\r\n\r\n this._improvementMode = improvementMode;\r\n this._scene = scene || EngineStore.LastCreatedScene;\r\n this._sceneDisposeObserver = this._scene.onDisposeObservable.add(() => {\r\n this._sceneDisposeObserver = null;\r\n this.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * Stops the current optimizer\r\n */\r\n public stop() {\r\n this._isRunning = false;\r\n }\r\n\r\n /**\r\n * Reset the optimizer to initial step (current priority level = 0)\r\n */\r\n public reset() {\r\n this._currentPriorityLevel = 0;\r\n }\r\n\r\n /**\r\n * Start the optimizer. By default it will try to reach a specific framerate\r\n * but if the optimizer is set with improvementMode === true then it will run all optimization while frame rate is above the target frame rate\r\n */\r\n public start() {\r\n if (this._isRunning) {\r\n return;\r\n }\r\n\r\n this._isRunning = true;\r\n\r\n // Let's wait for the scene to be ready before running our check\r\n this._scene.executeWhenReady(() => {\r\n setTimeout(() => {\r\n this._checkCurrentState();\r\n }, this._trackerDuration);\r\n });\r\n }\r\n\r\n private _checkCurrentState() {\r\n if (!this._isRunning) {\r\n return;\r\n }\r\n\r\n const scene = this._scene;\r\n const options = this._options;\r\n\r\n this._currentFrameRate = Math.round(scene.getEngine().getFps());\r\n\r\n if ((this._improvementMode && this._currentFrameRate <= this._targetFrameRate) || (!this._improvementMode && this._currentFrameRate >= this._targetFrameRate)) {\r\n this._isRunning = false;\r\n this.onSuccessObservable.notifyObservers(this);\r\n return;\r\n }\r\n\r\n // Apply current level of optimizations\r\n let allDone = true;\r\n let noOptimizationApplied = true;\r\n for (let index = 0; index < options.optimizations.length; index++) {\r\n const optimization = options.optimizations[index];\r\n\r\n if (optimization.priority === this._currentPriorityLevel) {\r\n noOptimizationApplied = false;\r\n allDone = allDone && optimization.apply(scene, this);\r\n this.onNewOptimizationAppliedObservable.notifyObservers(optimization);\r\n }\r\n }\r\n\r\n // If no optimization was applied, this is a failure :(\r\n if (noOptimizationApplied) {\r\n this._isRunning = false;\r\n this.onFailureObservable.notifyObservers(this);\r\n\r\n return;\r\n }\r\n\r\n // If all optimizations were done, move to next level\r\n if (allDone) {\r\n this._currentPriorityLevel++;\r\n }\r\n\r\n // Let's the system running for a specific amount of time before checking FPS\r\n scene.executeWhenReady(() => {\r\n setTimeout(() => {\r\n this._checkCurrentState();\r\n }, this._trackerDuration);\r\n });\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public dispose(): void {\r\n this.stop();\r\n this.onSuccessObservable.clear();\r\n this.onFailureObservable.clear();\r\n this.onNewOptimizationAppliedObservable.clear();\r\n if (this._sceneDisposeObserver) {\r\n this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);\r\n }\r\n }\r\n\r\n /**\r\n * Helper function to create a SceneOptimizer with one single line of code\r\n * @param scene defines the scene to work on\r\n * @param options defines the options to use with the SceneOptimizer\r\n * @param onSuccess defines a callback to call on success\r\n * @param onFailure defines a callback to call on failure\r\n * @returns the new SceneOptimizer object\r\n */\r\n public static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer {\r\n const optimizer = new SceneOptimizer(scene, options || SceneOptimizerOptions.ModerateDegradationAllowed(), false);\r\n\r\n if (onSuccess) {\r\n optimizer.onSuccessObservable.add(() => {\r\n onSuccess();\r\n });\r\n }\r\n\r\n if (onFailure) {\r\n optimizer.onFailureObservable.add(() => {\r\n onFailure();\r\n });\r\n }\r\n\r\n optimizer.start();\r\n\r\n return optimizer;\r\n }\r\n}\r\n"]}
|
|
@@ -78,8 +78,9 @@ export declare function CreateScreenshotWithResizeAsync(engine: AbstractEngine,
|
|
|
78
78
|
* @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)
|
|
79
79
|
* @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.
|
|
80
80
|
* @param customizeTexture An optional callback that can be used to modify the render target texture before taking the screenshot. This can be used, for instance, to enable camera post-processes before taking the screenshot.
|
|
81
|
+
* @param customDumpData The function to use to dump the data. If not provided, the default DumpData function will be used.
|
|
81
82
|
*/
|
|
82
|
-
export declare function CreateScreenshotUsingRenderTarget(engine: AbstractEngine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean, useLayerMask?: boolean, quality?: number, customizeTexture?: (texture: RenderTargetTexture) => void): void;
|
|
83
|
+
export declare function CreateScreenshotUsingRenderTarget(engine: AbstractEngine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean, useLayerMask?: boolean, quality?: number, customizeTexture?: (texture: RenderTargetTexture) => void, customDumpData?: (width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean, quality?: number) => void): void;
|
|
83
84
|
/**
|
|
84
85
|
* Generates an image screenshot from the specified camera.
|
|
85
86
|
* @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG
|
|
@@ -100,10 +101,11 @@ export declare function CreateScreenshotUsingRenderTarget(engine: AbstractEngine
|
|
|
100
101
|
* @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)
|
|
101
102
|
* @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.
|
|
102
103
|
* @param customizeTexture An optional callback that can be used to modify the render target texture before taking the screenshot. This can be used, for instance, to enable camera post-processes before taking the screenshot.
|
|
104
|
+
* @param customDumpData The function to use to dump the data. If not provided, the default DumpData function will be used.
|
|
103
105
|
* @returns screenshot as a string of base64-encoded characters. This string can be assigned
|
|
104
106
|
* to the src parameter of an <img> to display it
|
|
105
107
|
*/
|
|
106
|
-
export declare function CreateScreenshotUsingRenderTargetAsync(engine: AbstractEngine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean, useLayerMask?: boolean, quality?: number, customizeTexture?: (texture: RenderTargetTexture) => void): Promise<string>;
|
|
108
|
+
export declare function CreateScreenshotUsingRenderTargetAsync(engine: AbstractEngine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean, useLayerMask?: boolean, quality?: number, customizeTexture?: (texture: RenderTargetTexture) => void, customDumpData?: (width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean, quality?: number) => void): Promise<string>;
|
|
107
109
|
/**
|
|
108
110
|
* Class containing a set of static utilities functions for screenshots
|
|
109
111
|
*/
|
package/Misc/screenshotTools.js
CHANGED
|
@@ -160,8 +160,9 @@ export function CreateScreenshotWithResizeAsync(engine, camera, width, height, m
|
|
|
160
160
|
* @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)
|
|
161
161
|
* @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.
|
|
162
162
|
* @param customizeTexture An optional callback that can be used to modify the render target texture before taking the screenshot. This can be used, for instance, to enable camera post-processes before taking the screenshot.
|
|
163
|
+
* @param customDumpData The function to use to dump the data. If not provided, the default DumpData function will be used.
|
|
163
164
|
*/
|
|
164
|
-
export function CreateScreenshotUsingRenderTarget(engine, camera, size, successCallback, mimeType = "image/png", samples = 1, antialiasing = false, fileName, renderSprites = false, enableStencilBuffer = false, useLayerMask = true, quality, customizeTexture) {
|
|
165
|
+
export function CreateScreenshotUsingRenderTarget(engine, camera, size, successCallback, mimeType = "image/png", samples = 1, antialiasing = false, fileName, renderSprites = false, enableStencilBuffer = false, useLayerMask = true, quality, customizeTexture, customDumpData) {
|
|
165
166
|
const { height, width, finalWidth, finalHeight } = _GetScreenshotSize(engine, camera, size);
|
|
166
167
|
const targetTextureSize = { width, height };
|
|
167
168
|
if (!(height && width)) {
|
|
@@ -201,12 +202,13 @@ export function CreateScreenshotUsingRenderTarget(engine, camera, size, successC
|
|
|
201
202
|
texture.activeCamera = camera;
|
|
202
203
|
texture.forceLayerMaskCheck = useLayerMask;
|
|
203
204
|
customizeTexture?.(texture);
|
|
205
|
+
const dumpDataFunc = customDumpData || DumpData;
|
|
204
206
|
const renderWhenReady = () => {
|
|
205
207
|
_retryWithInterval(() => texture.isReadyForRendering() && camera.isReady(true), () => {
|
|
206
208
|
engine.onEndFrameObservable.addOnce(() => {
|
|
207
209
|
if (finalWidth === width && finalHeight === height) {
|
|
208
210
|
texture.readPixels(undefined, undefined, undefined, false).then((data) => {
|
|
209
|
-
|
|
211
|
+
dumpDataFunc(width, height, data, successCallback, mimeType, fileName, true, undefined, quality);
|
|
210
212
|
texture.dispose();
|
|
211
213
|
});
|
|
212
214
|
}
|
|
@@ -214,7 +216,7 @@ export function CreateScreenshotUsingRenderTarget(engine, camera, size, successC
|
|
|
214
216
|
const importPromise = engine.isWebGPU ? import("../ShadersWGSL/pass.fragment.js") : import("../Shaders/pass.fragment.js");
|
|
215
217
|
importPromise.then(() => ApplyPostProcess("pass", texture.getInternalTexture(), scene, undefined, undefined, undefined, finalWidth, finalHeight).then((texture) => {
|
|
216
218
|
engine._readTexturePixels(texture, finalWidth, finalHeight, -1, 0, null, true, false, 0, 0).then((data) => {
|
|
217
|
-
|
|
219
|
+
dumpDataFunc(finalWidth, finalHeight, data, successCallback, mimeType, fileName, true, undefined, quality);
|
|
218
220
|
texture.dispose();
|
|
219
221
|
});
|
|
220
222
|
}));
|
|
@@ -308,10 +310,11 @@ export function CreateScreenshotUsingRenderTarget(engine, camera, size, successC
|
|
|
308
310
|
* @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)
|
|
309
311
|
* @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.
|
|
310
312
|
* @param customizeTexture An optional callback that can be used to modify the render target texture before taking the screenshot. This can be used, for instance, to enable camera post-processes before taking the screenshot.
|
|
313
|
+
* @param customDumpData The function to use to dump the data. If not provided, the default DumpData function will be used.
|
|
311
314
|
* @returns screenshot as a string of base64-encoded characters. This string can be assigned
|
|
312
315
|
* to the src parameter of an <img> to display it
|
|
313
316
|
*/
|
|
314
|
-
export function CreateScreenshotUsingRenderTargetAsync(engine, camera, size, mimeType = "image/png", samples = 1, antialiasing = false, fileName, renderSprites = false, enableStencilBuffer = false, useLayerMask = true, quality, customizeTexture) {
|
|
317
|
+
export function CreateScreenshotUsingRenderTargetAsync(engine, camera, size, mimeType = "image/png", samples = 1, antialiasing = false, fileName, renderSprites = false, enableStencilBuffer = false, useLayerMask = true, quality, customizeTexture, customDumpData) {
|
|
315
318
|
return new Promise((resolve, reject) => {
|
|
316
319
|
CreateScreenshotUsingRenderTarget(engine, camera, size, (data) => {
|
|
317
320
|
if (typeof data !== "undefined") {
|
|
@@ -320,7 +323,7 @@ export function CreateScreenshotUsingRenderTargetAsync(engine, camera, size, mim
|
|
|
320
323
|
else {
|
|
321
324
|
reject(new Error("Data is undefined"));
|
|
322
325
|
}
|
|
323
|
-
}, mimeType, samples, antialiasing, fileName, renderSprites, enableStencilBuffer, useLayerMask, quality, customizeTexture);
|
|
326
|
+
}, mimeType, samples, antialiasing, fileName, renderSprites, enableStencilBuffer, useLayerMask, quality, customizeTexture, customDumpData);
|
|
324
327
|
});
|
|
325
328
|
}
|
|
326
329
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenshotTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/screenshotTools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,IAAI,gBAAgB,GAAgC,IAAI,CAAC;AAEzD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,gBAAgB,CAC5B,MAAsB,EACtB,MAAc,EACd,IAA8B,EAC9B,eAAwC,EACxC,QAAQ,GAAG,WAAW,EACtB,aAAa,GAAG,KAAK,EACrB,OAAgB,EAChB,OAAO,GAAG,KAAK;IAEf,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAEnE,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC;QACrB,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAC3C,OAAO;IACX,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE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CAAiC,GAAG,iCAAiC,CAAC;IAC5E,KAAK,CAAC,sCAAsC,GAAG,sCAAsC,CAAC;AAC1F,CAAC,CAAC;AAEF,eAAe,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { FxaaPostProcess } from \"../PostProcesses/fxaaPostProcess\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { Logger } from \"./logger\";\r\nimport { Tools } from \"./tools\";\r\nimport type { IScreenshotSize } from \"./interfaces/screenshotSize\";\r\nimport { DumpData } from \"./dumpTools\";\r\nimport type { Nullable } from \"../types\";\r\nimport { ApplyPostProcess } from \"./textureTools\";\r\n\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport { _retryWithInterval } from \"./timingTools\";\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. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\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 * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n */\r\nexport function CreateScreenshot(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n forceDownload = false,\r\n quality?: number,\r\n useFill = false\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 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 return;\r\n }\r\n\r\n engine.onEndFrameObservable.addOnce(() => {\r\n if (!screenshotCanvas) {\r\n screenshotCanvas = document.createElement(\"canvas\");\r\n }\r\n screenshotCanvas.width = width;\r\n screenshotCanvas.height = height;\r\n\r\n const renderContext = screenshotCanvas.getContext(\"2d\");\r\n const renderingCanvas = engine.getRenderingCanvas();\r\n if (!renderContext || !renderingCanvas) {\r\n Logger.Error(\"Failed to create screenshot. Rendering context or rendering canvas is not available.\");\r\n return;\r\n }\r\n\r\n const srcWidth = renderingCanvas.width;\r\n const srcHeight = renderingCanvas.height;\r\n const destWidth = screenshotCanvas.width;\r\n const destHeight = screenshotCanvas.height;\r\n\r\n // Calculate scale factors for width and height.\r\n const scaleX = destWidth / srcWidth;\r\n const scaleY = destHeight / srcHeight;\r\n // Use the larger of the two scales to fill the screenshot dimensions, else use the smaller to fit.\r\n const scale = useFill ? Math.max(scaleX, scaleY) : Math.min(scaleX, scaleY);\r\n const newWidth = srcWidth * scale;\r\n const newHeight = srcHeight * scale;\r\n\r\n // Center the image in the screenshot canvas\r\n const offsetX = (destWidth - newWidth) / 2;\r\n const offsetY = (destHeight - newHeight) / 2;\r\n\r\n renderContext.drawImage(renderingCanvas, 0, 0, srcWidth, srcHeight, offsetX, offsetY, newWidth, newHeight);\r\n\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 * 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. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\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 * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\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(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n mimeType = \"image/png\",\r\n quality?: number,\r\n useFill = false\r\n): 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 useFill\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Captures and automatically downloads 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 * If screenshot image data is needed, use {@link CreateScreenshotAsync} instead.\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. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\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 * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n * @returns promise that resolves once the screenshot is taken\r\n */\r\nexport function CreateScreenshotWithResizeAsync(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n width: number,\r\n height: number,\r\n mimeType = \"image/png\",\r\n quality?: number,\r\n useFill = false\r\n): 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 useFill\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height, finalWidth, finalHeight. If a single number is passed,\r\n * it will be used for both width and height, as well as finalWidth, finalHeight. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param customizeTexture An optional callback that can be used to modify the render target texture before taking the screenshot. This can be used, for instance, to enable camera post-processes before taking the screenshot.\r\n */\r\nexport function CreateScreenshotUsingRenderTarget(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n samples = 1,\r\n antialiasing = false,\r\n fileName?: string,\r\n renderSprites = false,\r\n enableStencilBuffer = false,\r\n useLayerMask = true,\r\n quality?: number,\r\n customizeTexture?: (texture: RenderTargetTexture) => void\r\n): void {\r\n const { height, width, finalWidth, finalHeight } = _GetScreenshotSize(engine, camera, size);\r\n const targetTextureSize = { width, height };\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n // Prevent engine to render on screen while we do the screenshot\r\n engine.skipFrameRender = true;\r\n\r\n const originalGetRenderWidth = engine.getRenderWidth;\r\n const originalGetRenderHeight = engine.getRenderHeight;\r\n\r\n // Override getRenderWidth and getRenderHeight to return the desired size of the render\r\n // A few internal methods are relying on the canvas size to compute the render size\r\n // so we need to override these methods to ensure the correct size is used during the preparation of the render\r\n // as well as the screenshot\r\n engine.getRenderWidth = (useScreen = false) => {\r\n if (!useScreen && engine._currentRenderTarget) {\r\n return engine._currentRenderTarget.width;\r\n }\r\n\r\n return width;\r\n };\r\n engine.getRenderHeight = (useScreen = false) => {\r\n if (!useScreen && engine._currentRenderTarget) {\r\n return engine._currentRenderTarget.height;\r\n }\r\n\r\n return height;\r\n };\r\n\r\n // Trigger a resize event to ensure the intermediate renders have the correct size\r\n if (engine.onResizeObservable.hasObservers()) {\r\n engine.onResizeObservable.notifyObservers(engine);\r\n }\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_BYTE,\r\n false,\r\n Texture.BILINEAR_SAMPLINGMODE,\r\n undefined,\r\n enableStencilBuffer,\r\n undefined,\r\n undefined,\r\n undefined,\r\n samples\r\n );\r\n texture.renderList = scene.meshes.slice();\r\n texture.samples = samples;\r\n texture.renderSprites = renderSprites;\r\n texture.activeCamera = camera;\r\n texture.forceLayerMaskCheck = useLayerMask;\r\n customizeTexture?.(texture);\r\n\r\n const renderWhenReady = () => {\r\n _retryWithInterval(\r\n () => texture.isReadyForRendering() && camera.isReady(true),\r\n () => {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n if (finalWidth === width && finalHeight === height) {\r\n texture.readPixels(undefined, undefined, undefined, false)!.then((data) => {\r\n DumpData(width, height, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true, undefined, quality);\r\n texture.dispose();\r\n });\r\n } else {\r\n const importPromise = engine.isWebGPU ? import(\"../ShadersWGSL/pass.fragment\") : import(\"../Shaders/pass.fragment\");\r\n importPromise.then(() =>\r\n ApplyPostProcess(\"pass\", texture.getInternalTexture()!, scene, undefined, undefined, undefined, finalWidth, finalHeight).then((texture) => {\r\n engine._readTexturePixels(texture, finalWidth, finalHeight, -1, 0, null, true, false, 0, 0).then((data) => {\r\n DumpData(finalWidth, finalHeight, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true, undefined, quality);\r\n texture.dispose();\r\n });\r\n })\r\n );\r\n }\r\n });\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n\r\n // Record the original scene setup\r\n const originalCamera = scene.activeCamera;\r\n const originalCameras = scene.activeCameras;\r\n const originalOutputRenderTarget = camera.outputRenderTarget;\r\n const originalSpritesEnabled = scene.spritesEnabled;\r\n\r\n // Swap with the requested one\r\n scene.activeCamera = camera;\r\n scene.activeCameras = null;\r\n camera.outputRenderTarget = texture;\r\n scene.spritesEnabled = renderSprites;\r\n\r\n const currentMeshList = scene.meshes;\r\n scene.meshes = texture.renderList || scene.meshes;\r\n\r\n // render the scene on the RTT\r\n try {\r\n scene.render();\r\n } finally {\r\n // Restore the original scene camera setup\r\n scene.activeCamera = originalCamera;\r\n scene.activeCameras = originalCameras;\r\n camera.outputRenderTarget = originalOutputRenderTarget;\r\n scene.spritesEnabled = originalSpritesEnabled;\r\n scene.meshes = currentMeshList;\r\n\r\n engine.getRenderWidth = originalGetRenderWidth;\r\n engine.getRenderHeight = originalGetRenderHeight;\r\n\r\n // Trigger a resize event to ensure the intermediate renders have the correct size\r\n if (engine.onResizeObservable.hasObservers()) {\r\n engine.onResizeObservable.notifyObservers(engine);\r\n }\r\n\r\n camera.getProjectionMatrix(true); // Force cache refresh;\r\n\r\n engine.skipFrameRender = false;\r\n }\r\n },\r\n () => {\r\n // Restore engine frame rendering on error\r\n engine.skipFrameRender = false;\r\n engine.getRenderWidth = originalGetRenderWidth;\r\n engine.getRenderHeight = originalGetRenderHeight;\r\n }\r\n );\r\n };\r\n\r\n const renderToTexture = () => {\r\n // render the RTT\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n\r\n renderWhenReady();\r\n };\r\n\r\n if (antialiasing) {\r\n const fxaaPostProcess = new FxaaPostProcess(\"antialiasing\", 1.0, scene.activeCamera);\r\n texture.addPostProcess(fxaaPostProcess);\r\n // Async Shader Compilation can lead to none ready effects in synchronous code\r\n fxaaPostProcess.onEffectCreatedObservable.addOnce((e) => {\r\n if (!e.isReady()) {\r\n e.onCompiled = () => {\r\n renderToTexture();\r\n };\r\n }\r\n // The effect is ready we can render\r\n else {\r\n renderToTexture();\r\n }\r\n });\r\n } else {\r\n // No need to wait for extra resources to be ready\r\n renderToTexture();\r\n }\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param customizeTexture An optional callback that can be used to modify the render target texture before taking the screenshot. This can be used, for instance, to enable camera post-processes before taking the screenshot.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotUsingRenderTargetAsync(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n mimeType = \"image/png\",\r\n samples = 1,\r\n antialiasing = false,\r\n fileName?: string,\r\n renderSprites = false,\r\n enableStencilBuffer = false,\r\n useLayerMask = true,\r\n quality?: number,\r\n customizeTexture?: (texture: RenderTargetTexture) => void\r\n): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType,\r\n samples,\r\n antialiasing,\r\n fileName,\r\n renderSprites,\r\n enableStencilBuffer,\r\n useLayerMask,\r\n quality,\r\n customizeTexture\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Gets height and width for screenshot size\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This size of the screenshot. can be a number or an object implementing IScreenshotSize\r\n * @returns height and width for screenshot size\r\n */\r\nfunction _GetScreenshotSize(engine: AbstractEngine, camera: Camera, size: IScreenshotSize | number): { height: number; width: number; finalWidth: number; finalHeight: number } {\r\n let height = 0;\r\n let width = 0;\r\n let finalWidth = 0;\r\n let finalHeight = 0;\r\n\r\n //If a size value defined as object\r\n if (typeof size === \"object\") {\r\n const precision = size.precision\r\n ? Math.abs(size.precision) // prevent GL_INVALID_VALUE : glViewport: negative width/height\r\n : 1;\r\n\r\n //If a width and height values is specified\r\n if (size.width && size.height) {\r\n height = size.height * precision;\r\n width = size.width * precision;\r\n }\r\n //If passing only width, computing height to keep display canvas ratio.\r\n else if (size.width && !size.height) {\r\n width = size.width * precision;\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n //If passing only height, computing width to keep display canvas ratio.\r\n else if (size.height && !size.width) {\r\n height = size.height * precision;\r\n width = Math.round(height * engine.getAspectRatio(camera));\r\n } else {\r\n width = Math.round(engine.getRenderWidth() * precision);\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n\r\n //If a finalWidth and finalHeight values is specified\r\n if (size.finalWidth && size.finalHeight) {\r\n finalHeight = size.finalHeight;\r\n finalWidth = size.finalWidth;\r\n }\r\n //If passing only finalWidth, computing finalHeight to keep display canvas ratio.\r\n else if (size.finalWidth && !size.finalHeight) {\r\n finalWidth = size.finalWidth;\r\n finalHeight = Math.round(finalWidth / engine.getAspectRatio(camera));\r\n }\r\n //If passing only finalHeight, computing finalWidth to keep display canvas ratio.\r\n else if (size.finalHeight && !size.finalWidth) {\r\n finalHeight = size.finalHeight;\r\n finalWidth = Math.round(finalHeight * engine.getAspectRatio(camera));\r\n } else {\r\n finalWidth = width;\r\n finalHeight = height;\r\n }\r\n }\r\n //Assuming here that \"size\" parameter is a number\r\n else if (!isNaN(size)) {\r\n height = size;\r\n width = size;\r\n finalWidth = size;\r\n finalHeight = size;\r\n }\r\n\r\n // When creating the image data from the CanvasRenderingContext2D, the width and height is clamped to the size of the _gl context\r\n // On certain GPUs, it seems as if the _gl context truncates to an integer automatically. Therefore, if a user tries to pass the width of their canvas element\r\n // and it happens to be a float (1000.5 x 600.5 px), the engine.readPixels will return a different size array than context.createImageData\r\n // to resolve this, we truncate the floats here to ensure the same size\r\n if (width) {\r\n width = Math.floor(width);\r\n }\r\n if (height) {\r\n height = Math.floor(height);\r\n }\r\n if (finalWidth) {\r\n finalWidth = Math.floor(finalWidth);\r\n }\r\n if (finalHeight) {\r\n finalHeight = Math.floor(finalHeight);\r\n }\r\n\r\n return { height: height | 0, width: width | 0, finalWidth: finalWidth | 0, finalHeight: finalHeight | 0 };\r\n}\r\n\r\n/**\r\n * Class containing a set of static utilities functions for screenshots\r\n */\r\nexport const ScreenshotTools = {\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\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 * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\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. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\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 * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\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 and automatically downloads 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 * If screenshot image data is needed, use {@link CreateScreenshotAsync} instead.\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. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\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 * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n * @returns promise that resolves once the screenshot is taken\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":["../../../../dev/core/src/Misc/screenshotTools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,IAAI,gBAAgB,GAAgC,IAAI,CAAC;AAEzD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,gBAAgB,CAC5B,MAAsB,EACtB,MAAc,EACd,IAA8B,EAC9B,eAAwC,EACxC,QAAQ,GAAG,WAAW,EACtB,aAAa,GAAG,KAAK,EACrB,OAAgB,EAChB,OAAO,GAAG,KAAK;IAEf,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAEnE,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC;QACrB,MAAM,CAAC,KAAK,CAAC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ACH,MAAM,eAAe,GAAG,GAAG,EAAE;IACzB,+BAA+B;IAC/B,KAAK,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC1C,KAAK,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;IACpD,KAAK,CAAC,iCAAiC,GAAG,iCAAiC,CAAC;IAC5E,KAAK,CAAC,sCAAsC,GAAG,sCAAsC,CAAC;AAC1F,CAAC,CAAC;AAEF,eAAe,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { FxaaPostProcess } from \"../PostProcesses/fxaaPostProcess\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { Logger } from \"./logger\";\r\nimport { Tools } from \"./tools\";\r\nimport type { IScreenshotSize } from \"./interfaces/screenshotSize\";\r\nimport { DumpData } from \"./dumpTools\";\r\nimport type { Nullable } from \"../types\";\r\nimport { ApplyPostProcess } from \"./textureTools\";\r\n\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport { _retryWithInterval } from \"./timingTools\";\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. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\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 * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n */\r\nexport function CreateScreenshot(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n forceDownload = false,\r\n quality?: number,\r\n useFill = false\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 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 return;\r\n }\r\n\r\n engine.onEndFrameObservable.addOnce(() => {\r\n if (!screenshotCanvas) {\r\n screenshotCanvas = document.createElement(\"canvas\");\r\n }\r\n screenshotCanvas.width = width;\r\n screenshotCanvas.height = height;\r\n\r\n const renderContext = screenshotCanvas.getContext(\"2d\");\r\n const renderingCanvas = engine.getRenderingCanvas();\r\n if (!renderContext || !renderingCanvas) {\r\n Logger.Error(\"Failed to create screenshot. Rendering context or rendering canvas is not available.\");\r\n return;\r\n }\r\n\r\n const srcWidth = renderingCanvas.width;\r\n const srcHeight = renderingCanvas.height;\r\n const destWidth = screenshotCanvas.width;\r\n const destHeight = screenshotCanvas.height;\r\n\r\n // Calculate scale factors for width and height.\r\n const scaleX = destWidth / srcWidth;\r\n const scaleY = destHeight / srcHeight;\r\n // Use the larger of the two scales to fill the screenshot dimensions, else use the smaller to fit.\r\n const scale = useFill ? Math.max(scaleX, scaleY) : Math.min(scaleX, scaleY);\r\n const newWidth = srcWidth * scale;\r\n const newHeight = srcHeight * scale;\r\n\r\n // Center the image in the screenshot canvas\r\n const offsetX = (destWidth - newWidth) / 2;\r\n const offsetY = (destHeight - newHeight) / 2;\r\n\r\n renderContext.drawImage(renderingCanvas, 0, 0, srcWidth, srcHeight, offsetX, offsetY, newWidth, newHeight);\r\n\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 * 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. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\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 * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\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(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n mimeType = \"image/png\",\r\n quality?: number,\r\n useFill = false\r\n): 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 useFill\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Captures and automatically downloads 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 * If screenshot image data is needed, use {@link CreateScreenshotAsync} instead.\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. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\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 * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n * @returns promise that resolves once the screenshot is taken\r\n */\r\nexport function CreateScreenshotWithResizeAsync(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n width: number,\r\n height: number,\r\n mimeType = \"image/png\",\r\n quality?: number,\r\n useFill = false\r\n): 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 useFill\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height, finalWidth, finalHeight. If a single number is passed,\r\n * it will be used for both width and height, as well as finalWidth, finalHeight. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param customizeTexture An optional callback that can be used to modify the render target texture before taking the screenshot. This can be used, for instance, to enable camera post-processes before taking the screenshot.\r\n * @param customDumpData The function to use to dump the data. If not provided, the default DumpData function will be used.\r\n */\r\nexport function CreateScreenshotUsingRenderTarget(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n samples = 1,\r\n antialiasing = false,\r\n fileName?: string,\r\n renderSprites = false,\r\n enableStencilBuffer = false,\r\n useLayerMask = true,\r\n quality?: number,\r\n customizeTexture?: (texture: RenderTargetTexture) => void,\r\n customDumpData?: (\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n successCallback?: (data: string | ArrayBuffer) => void,\r\n mimeType?: string,\r\n fileName?: string,\r\n invertY?: boolean,\r\n toArrayBuffer?: boolean,\r\n quality?: number\r\n ) => void\r\n): void {\r\n const { height, width, finalWidth, finalHeight } = _GetScreenshotSize(engine, camera, size);\r\n const targetTextureSize = { width, height };\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n // Prevent engine to render on screen while we do the screenshot\r\n engine.skipFrameRender = true;\r\n\r\n const originalGetRenderWidth = engine.getRenderWidth;\r\n const originalGetRenderHeight = engine.getRenderHeight;\r\n\r\n // Override getRenderWidth and getRenderHeight to return the desired size of the render\r\n // A few internal methods are relying on the canvas size to compute the render size\r\n // so we need to override these methods to ensure the correct size is used during the preparation of the render\r\n // as well as the screenshot\r\n engine.getRenderWidth = (useScreen = false) => {\r\n if (!useScreen && engine._currentRenderTarget) {\r\n return engine._currentRenderTarget.width;\r\n }\r\n\r\n return width;\r\n };\r\n engine.getRenderHeight = (useScreen = false) => {\r\n if (!useScreen && engine._currentRenderTarget) {\r\n return engine._currentRenderTarget.height;\r\n }\r\n\r\n return height;\r\n };\r\n\r\n // Trigger a resize event to ensure the intermediate renders have the correct size\r\n if (engine.onResizeObservable.hasObservers()) {\r\n engine.onResizeObservable.notifyObservers(engine);\r\n }\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_BYTE,\r\n false,\r\n Texture.BILINEAR_SAMPLINGMODE,\r\n undefined,\r\n enableStencilBuffer,\r\n undefined,\r\n undefined,\r\n undefined,\r\n samples\r\n );\r\n texture.renderList = scene.meshes.slice();\r\n texture.samples = samples;\r\n texture.renderSprites = renderSprites;\r\n texture.activeCamera = camera;\r\n texture.forceLayerMaskCheck = useLayerMask;\r\n customizeTexture?.(texture);\r\n\r\n const dumpDataFunc = customDumpData || DumpData;\r\n\r\n const renderWhenReady = () => {\r\n _retryWithInterval(\r\n () => texture.isReadyForRendering() && camera.isReady(true),\r\n () => {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n if (finalWidth === width && finalHeight === height) {\r\n texture.readPixels(undefined, undefined, undefined, false)!.then((data) => {\r\n dumpDataFunc(width, height, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true, undefined, quality);\r\n texture.dispose();\r\n });\r\n } else {\r\n const importPromise = engine.isWebGPU ? import(\"../ShadersWGSL/pass.fragment\") : import(\"../Shaders/pass.fragment\");\r\n importPromise.then(() =>\r\n ApplyPostProcess(\"pass\", texture.getInternalTexture()!, scene, undefined, undefined, undefined, finalWidth, finalHeight).then((texture) => {\r\n engine._readTexturePixels(texture, finalWidth, finalHeight, -1, 0, null, true, false, 0, 0).then((data) => {\r\n dumpDataFunc(\r\n finalWidth,\r\n finalHeight,\r\n data,\r\n successCallback as (data: string | ArrayBuffer) => void,\r\n mimeType,\r\n fileName,\r\n true,\r\n undefined,\r\n quality\r\n );\r\n texture.dispose();\r\n });\r\n })\r\n );\r\n }\r\n });\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n\r\n // Record the original scene setup\r\n const originalCamera = scene.activeCamera;\r\n const originalCameras = scene.activeCameras;\r\n const originalOutputRenderTarget = camera.outputRenderTarget;\r\n const originalSpritesEnabled = scene.spritesEnabled;\r\n\r\n // Swap with the requested one\r\n scene.activeCamera = camera;\r\n scene.activeCameras = null;\r\n camera.outputRenderTarget = texture;\r\n scene.spritesEnabled = renderSprites;\r\n\r\n const currentMeshList = scene.meshes;\r\n scene.meshes = texture.renderList || scene.meshes;\r\n\r\n // render the scene on the RTT\r\n try {\r\n scene.render();\r\n } finally {\r\n // Restore the original scene camera setup\r\n scene.activeCamera = originalCamera;\r\n scene.activeCameras = originalCameras;\r\n camera.outputRenderTarget = originalOutputRenderTarget;\r\n scene.spritesEnabled = originalSpritesEnabled;\r\n scene.meshes = currentMeshList;\r\n\r\n engine.getRenderWidth = originalGetRenderWidth;\r\n engine.getRenderHeight = originalGetRenderHeight;\r\n\r\n // Trigger a resize event to ensure the intermediate renders have the correct size\r\n if (engine.onResizeObservable.hasObservers()) {\r\n engine.onResizeObservable.notifyObservers(engine);\r\n }\r\n\r\n camera.getProjectionMatrix(true); // Force cache refresh;\r\n\r\n engine.skipFrameRender = false;\r\n }\r\n },\r\n () => {\r\n // Restore engine frame rendering on error\r\n engine.skipFrameRender = false;\r\n engine.getRenderWidth = originalGetRenderWidth;\r\n engine.getRenderHeight = originalGetRenderHeight;\r\n }\r\n );\r\n };\r\n\r\n const renderToTexture = () => {\r\n // render the RTT\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n\r\n renderWhenReady();\r\n };\r\n\r\n if (antialiasing) {\r\n const fxaaPostProcess = new FxaaPostProcess(\"antialiasing\", 1.0, scene.activeCamera);\r\n texture.addPostProcess(fxaaPostProcess);\r\n // Async Shader Compilation can lead to none ready effects in synchronous code\r\n fxaaPostProcess.onEffectCreatedObservable.addOnce((e) => {\r\n if (!e.isReady()) {\r\n e.onCompiled = () => {\r\n renderToTexture();\r\n };\r\n }\r\n // The effect is ready we can render\r\n else {\r\n renderToTexture();\r\n }\r\n });\r\n } else {\r\n // No need to wait for extra resources to be ready\r\n renderToTexture();\r\n }\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param customizeTexture An optional callback that can be used to modify the render target texture before taking the screenshot. This can be used, for instance, to enable camera post-processes before taking the screenshot.\r\n * @param customDumpData The function to use to dump the data. If not provided, the default DumpData function will be used.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotUsingRenderTargetAsync(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n mimeType = \"image/png\",\r\n samples = 1,\r\n antialiasing = false,\r\n fileName?: string,\r\n renderSprites = false,\r\n enableStencilBuffer = false,\r\n useLayerMask = true,\r\n quality?: number,\r\n customizeTexture?: (texture: RenderTargetTexture) => void,\r\n customDumpData?: (\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n successCallback?: (data: string | ArrayBuffer) => void,\r\n mimeType?: string,\r\n fileName?: string,\r\n invertY?: boolean,\r\n toArrayBuffer?: boolean,\r\n quality?: number\r\n ) => void\r\n): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType,\r\n samples,\r\n antialiasing,\r\n fileName,\r\n renderSprites,\r\n enableStencilBuffer,\r\n useLayerMask,\r\n quality,\r\n customizeTexture,\r\n customDumpData\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Gets height and width for screenshot size\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 size of the screenshot. can be a number or an object implementing IScreenshotSize\r\n * @returns height and width for screenshot size\r\n */\r\nfunction _GetScreenshotSize(engine: AbstractEngine, camera: Camera, size: IScreenshotSize | number): { height: number; width: number; finalWidth: number; finalHeight: number } {\r\n let height = 0;\r\n let width = 0;\r\n let finalWidth = 0;\r\n let finalHeight = 0;\r\n\r\n //If a size value defined as object\r\n if (typeof size === \"object\") {\r\n const precision = size.precision\r\n ? Math.abs(size.precision) // prevent GL_INVALID_VALUE : glViewport: negative width/height\r\n : 1;\r\n\r\n //If a width and height values is specified\r\n if (size.width && size.height) {\r\n height = size.height * precision;\r\n width = size.width * precision;\r\n }\r\n //If passing only width, computing height to keep display canvas ratio.\r\n else if (size.width && !size.height) {\r\n width = size.width * precision;\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n //If passing only height, computing width to keep display canvas ratio.\r\n else if (size.height && !size.width) {\r\n height = size.height * precision;\r\n width = Math.round(height * engine.getAspectRatio(camera));\r\n } else {\r\n width = Math.round(engine.getRenderWidth() * precision);\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n\r\n //If a finalWidth and finalHeight values is specified\r\n if (size.finalWidth && size.finalHeight) {\r\n finalHeight = size.finalHeight;\r\n finalWidth = size.finalWidth;\r\n }\r\n //If passing only finalWidth, computing finalHeight to keep display canvas ratio.\r\n else if (size.finalWidth && !size.finalHeight) {\r\n finalWidth = size.finalWidth;\r\n finalHeight = Math.round(finalWidth / engine.getAspectRatio(camera));\r\n }\r\n //If passing only finalHeight, computing finalWidth to keep display canvas ratio.\r\n else if (size.finalHeight && !size.finalWidth) {\r\n finalHeight = size.finalHeight;\r\n finalWidth = Math.round(finalHeight * engine.getAspectRatio(camera));\r\n } else {\r\n finalWidth = width;\r\n finalHeight = height;\r\n }\r\n }\r\n //Assuming here that \"size\" parameter is a number\r\n else if (!isNaN(size)) {\r\n height = size;\r\n width = size;\r\n finalWidth = size;\r\n finalHeight = size;\r\n }\r\n\r\n // When creating the image data from the CanvasRenderingContext2D, the width and height is clamped to the size of the _gl context\r\n // On certain GPUs, it seems as if the _gl context truncates to an integer automatically. Therefore, if a user tries to pass the width of their canvas element\r\n // and it happens to be a float (1000.5 x 600.5 px), the engine.readPixels will return a different size array than context.createImageData\r\n // to resolve this, we truncate the floats here to ensure the same size\r\n if (width) {\r\n width = Math.floor(width);\r\n }\r\n if (height) {\r\n height = Math.floor(height);\r\n }\r\n if (finalWidth) {\r\n finalWidth = Math.floor(finalWidth);\r\n }\r\n if (finalHeight) {\r\n finalHeight = Math.floor(finalHeight);\r\n }\r\n\r\n return { height: height | 0, width: width | 0, finalWidth: finalWidth | 0, finalHeight: finalHeight | 0 };\r\n}\r\n\r\n/**\r\n * Class containing a set of static utilities functions for screenshots\r\n */\r\nexport const ScreenshotTools = {\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\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 * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\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. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\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 * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\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 and automatically downloads 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 * If screenshot image data is needed, use {@link CreateScreenshotAsync} instead.\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. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\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 * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n * @returns promise that resolves once the screenshot is taken\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"]}
|
package/Misc/urlTools.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets the file extension from a URL.
|
|
3
|
+
* @param url The URL to get the file extension from.
|
|
4
|
+
* @returns The file extension, or an empty string if no extension is found.
|
|
5
|
+
*/
|
|
6
|
+
export function GetExtensionFromUrl(url) {
|
|
7
|
+
const urlWithoutUriParams = url.split("?")[0];
|
|
8
|
+
const lastDot = urlWithoutUriParams.lastIndexOf(".");
|
|
9
|
+
const extension = lastDot > -1 ? urlWithoutUriParams.substring(lastDot).toLowerCase() : "";
|
|
10
|
+
return extension;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=urlTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urlTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/urlTools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAW;IAC3C,MAAM,mBAAmB,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,mBAAmB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACrD,MAAM,SAAS,GAAG,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3F,OAAO,SAAS,CAAC;AACrB,CAAC","sourcesContent":["/**\r\n * Gets the file extension from a URL.\r\n * @param url The URL to get the file extension from.\r\n * @returns The file extension, or an empty string if no extension is found.\r\n */\r\nexport function GetExtensionFromUrl(url: string) {\r\n const urlWithoutUriParams = url.split(\"?\")[0];\r\n const lastDot = urlWithoutUriParams.lastIndexOf(\".\");\r\n const extension = lastDot > -1 ? urlWithoutUriParams.substring(lastDot).toLowerCase() : \"\";\r\n return extension;\r\n}\r\n"]}
|
|
@@ -218,6 +218,14 @@ export declare class PhysicsCharacterController {
|
|
|
218
218
|
* default 1e38
|
|
219
219
|
*/
|
|
220
220
|
characterStrength: number;
|
|
221
|
+
/**
|
|
222
|
+
* Acceleration factor. A value of 1 means reaching max velocity immediately
|
|
223
|
+
*/
|
|
224
|
+
acceleration: number;
|
|
225
|
+
/**
|
|
226
|
+
* maximum acceleration in world space coordinate
|
|
227
|
+
*/
|
|
228
|
+
maxAcceleration: number;
|
|
221
229
|
/**
|
|
222
230
|
* character mass
|
|
223
231
|
* default 0
|