@babylonjs/core 6.19.0 → 6.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Actions/actionManager.js +2 -2
- package/Actions/actionManager.js.map +1 -1
- package/Animations/runtimeAnimation.js +2 -2
- package/Animations/runtimeAnimation.js.map +1 -1
- package/Cameras/Inputs/BaseCameraPointersInput.d.ts +4 -4
- package/Cameras/Inputs/BaseCameraPointersInput.js +4 -6
- package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/arcRotateCameraPointersInput.d.ts +3 -2
- package/Cameras/Inputs/arcRotateCameraPointersInput.js +3 -2
- package/Cameras/Inputs/arcRotateCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/flyCameraMouseInput.js +2 -7
- package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraKeyboardMoveInput.js +2 -7
- package/Cameras/Inputs/freeCameraKeyboardMoveInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraMouseInput.js +4 -14
- package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraTouchInput.js +2 -1
- package/Cameras/Inputs/freeCameraTouchInput.js.map +1 -1
- package/Cameras/arcRotateCamera.js +2 -7
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Cameras/camera.d.ts +2 -0
- package/Cameras/camera.js +8 -0
- package/Cameras/camera.js.map +1 -1
- package/Compute/computeShader.d.ts +15 -0
- package/Compute/computeShader.js +39 -0
- package/Compute/computeShader.js.map +1 -1
- package/Debug/physicsViewer.d.ts +33 -0
- package/Debug/physicsViewer.js +205 -0
- package/Debug/physicsViewer.js.map +1 -1
- package/Engines/Extensions/engine.computeShader.d.ts +2 -1
- package/Engines/Extensions/engine.computeShader.js +1 -0
- package/Engines/Extensions/engine.computeShader.js.map +1 -1
- package/Engines/WebGPU/webgpuComputeContext.js +15 -0
- package/Engines/WebGPU/webgpuComputeContext.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphAddBlock.d.ts +23 -0
- package/FlowGraph/Blocks/Data/flowGraphAddBlock.js +18 -0
- package/FlowGraph/Blocks/Data/flowGraphAddBlock.js.map +1 -0
- package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.d.ts +30 -0
- package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js +22 -0
- package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js.map +1 -0
- package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.d.ts +33 -0
- package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js +30 -0
- package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js.map +1 -0
- package/FlowGraph/Blocks/Data/index.d.ts +3 -1
- package/FlowGraph/Blocks/Data/index.js +3 -1
- package/FlowGraph/Blocks/Data/index.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.d.ts +12 -10
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js +25 -29
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.d.ts +25 -0
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js +31 -0
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -0
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.d.ts +3 -7
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js +11 -11
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/index.d.ts +1 -0
- package/FlowGraph/Blocks/Event/index.js +1 -0
- package/FlowGraph/Blocks/Event/index.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphConditionalBlock.d.ts +24 -0
- package/FlowGraph/Blocks/Execution/flowGraphConditionalBlock.js +23 -0
- package/FlowGraph/Blocks/Execution/flowGraphConditionalBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/flowGraphForLoopBlock.d.ts +10 -13
- package/FlowGraph/Blocks/Execution/flowGraphForLoopBlock.js +28 -22
- package/FlowGraph/Blocks/Execution/flowGraphForLoopBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphLogBlock.d.ts +5 -5
- package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js +8 -6
- package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphPlayAnimationBlock.d.ts +56 -0
- package/FlowGraph/Blocks/Execution/flowGraphPlayAnimationBlock.js +66 -0
- package/FlowGraph/Blocks/Execution/flowGraphPlayAnimationBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.d.ts +18 -0
- package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js +19 -0
- package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.d.ts +26 -0
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +36 -0
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.d.ts +23 -0
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js +25 -0
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/flowGraphStopAnimationBlock.d.ts +16 -0
- package/FlowGraph/Blocks/Execution/flowGraphStopAnimationBlock.js +18 -0
- package/FlowGraph/Blocks/Execution/flowGraphStopAnimationBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/flowGraphTimerBlock.d.ts +32 -0
- package/FlowGraph/Blocks/Execution/flowGraphTimerBlock.js +62 -0
- package/FlowGraph/Blocks/Execution/flowGraphTimerBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/index.d.ts +7 -0
- package/FlowGraph/Blocks/Execution/index.js +7 -0
- package/FlowGraph/Blocks/Execution/index.js.map +1 -1
- package/FlowGraph/flowGraph.d.ts +42 -12
- package/FlowGraph/flowGraph.js +37 -23
- package/FlowGraph/flowGraph.js.map +1 -1
- package/FlowGraph/flowGraphAsyncExecutionBlock.d.ts +29 -0
- package/FlowGraph/flowGraphAsyncExecutionBlock.js +21 -0
- package/FlowGraph/flowGraphAsyncExecutionBlock.js.map +1 -0
- package/FlowGraph/flowGraphBlock.d.ts +9 -11
- package/FlowGraph/flowGraphBlock.js +12 -8
- package/FlowGraph/flowGraphBlock.js.map +1 -1
- package/FlowGraph/flowGraphConnection.d.ts +17 -7
- package/FlowGraph/flowGraphConnection.js +26 -9
- package/FlowGraph/flowGraphConnection.js.map +1 -1
- package/FlowGraph/flowGraphContext.d.ts +102 -0
- package/FlowGraph/flowGraphContext.js +111 -0
- package/FlowGraph/flowGraphContext.js.map +1 -0
- package/FlowGraph/flowGraphCustomEvent.d.ts +5 -0
- package/FlowGraph/flowGraphCustomEvent.js +2 -0
- package/FlowGraph/flowGraphCustomEvent.js.map +1 -0
- package/FlowGraph/flowGraphDataConnection.d.ts +10 -2
- package/FlowGraph/flowGraphDataConnection.js +16 -8
- package/FlowGraph/flowGraphDataConnection.js.map +1 -1
- package/FlowGraph/flowGraphEventBlock.d.ts +5 -12
- package/FlowGraph/flowGraphEventBlock.js +5 -5
- package/FlowGraph/flowGraphEventBlock.js.map +1 -1
- package/FlowGraph/flowGraphEventCoordinator.d.ts +23 -0
- package/FlowGraph/flowGraphEventCoordinator.js +37 -0
- package/FlowGraph/flowGraphEventCoordinator.js.map +1 -0
- package/FlowGraph/flowGraphExecutionBlock.d.ts +5 -5
- package/FlowGraph/flowGraphExecutionBlock.js +3 -3
- package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
- package/FlowGraph/flowGraphRichTypes.d.ts +28 -0
- package/FlowGraph/flowGraphRichTypes.js +43 -0
- package/FlowGraph/flowGraphRichTypes.js.map +1 -0
- package/FlowGraph/flowGraphSignalConnection.d.ts +7 -1
- package/FlowGraph/flowGraphSignalConnection.js +11 -4
- package/FlowGraph/flowGraphSignalConnection.js.map +1 -1
- package/FlowGraph/flowGraphVariableDefinitions.d.ts +12 -0
- package/FlowGraph/flowGraphVariableDefinitions.js +22 -0
- package/FlowGraph/flowGraphVariableDefinitions.js.map +1 -0
- package/FlowGraph/flowGraphWithOnDoneExecutionBlock.d.ts +10 -2
- package/FlowGraph/flowGraphWithOnDoneExecutionBlock.js +8 -2
- package/FlowGraph/flowGraphWithOnDoneExecutionBlock.js.map +1 -1
- package/FlowGraph/index.d.ts +3 -0
- package/FlowGraph/index.js +3 -0
- package/FlowGraph/index.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +2 -1
- package/Materials/Node/nodeMaterial.js +26 -2
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.d.ts +1 -0
- package/Materials/PBR/pbrBaseMaterial.js +1 -0
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/videoTexture.d.ts +5 -0
- package/Materials/Textures/videoTexture.js +6 -0
- package/Materials/Textures/videoTexture.js.map +1 -1
- package/Materials/materialHelper.js +1 -0
- package/Materials/materialHelper.js.map +1 -1
- package/Materials/standardMaterial.d.ts +1 -0
- package/Materials/standardMaterial.js +1 -0
- package/Materials/standardMaterial.js.map +1 -1
- package/Materials/uniformBuffer.d.ts +7 -0
- package/Materials/uniformBuffer.js +8 -0
- package/Materials/uniformBuffer.js.map +1 -1
- package/Maths/math.vector.d.ts +5 -0
- package/Maths/math.vector.js +7 -0
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateBlock.d.ts +11 -5
- package/Meshes/Node/Blocks/Instances/instantiateBlock.js +20 -10
- package/Meshes/Node/Blocks/Instances/instantiateBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.d.ts +15 -9
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js +20 -11
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.d.ts +15 -9
- package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js +20 -11
- package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.d.ts +15 -9
- package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js +20 -11
- package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setColorsBlock.d.ts +12 -0
- package/Meshes/Node/Blocks/Set/setColorsBlock.js +62 -27
- package/Meshes/Node/Blocks/Set/setColorsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setMaterialIDBlock.d.ts +7 -0
- package/Meshes/Node/Blocks/Set/setMaterialIDBlock.js +19 -0
- package/Meshes/Node/Blocks/Set/setMaterialIDBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setNormalsBlock.d.ts +12 -0
- package/Meshes/Node/Blocks/Set/setNormalsBlock.js +62 -27
- package/Meshes/Node/Blocks/Set/setNormalsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setPositionsBlock.d.ts +12 -0
- package/Meshes/Node/Blocks/Set/setPositionsBlock.js +54 -19
- package/Meshes/Node/Blocks/Set/setPositionsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setTangentsBlock.d.ts +12 -0
- package/Meshes/Node/Blocks/Set/setTangentsBlock.js +62 -27
- package/Meshes/Node/Blocks/Set/setTangentsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setUVsBlock.d.ts +5 -0
- package/Meshes/Node/Blocks/Set/setUVsBlock.js +65 -46
- package/Meshes/Node/Blocks/Set/setUVsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/debugBlock.js +5 -1
- package/Meshes/Node/Blocks/debugBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryInputBlock.js +1 -0
- package/Meshes/Node/Blocks/geometryInputBlock.js.map +1 -1
- package/Meshes/Node/Blocks/intFloatConverterBlock.js +2 -2
- package/Meshes/Node/Blocks/intFloatConverterBlock.js.map +1 -1
- package/Meshes/Node/Blocks/mapRangeBlock.js +8 -1
- package/Meshes/Node/Blocks/mapRangeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/mathBlock.js +1 -0
- package/Meshes/Node/Blocks/mathBlock.js.map +1 -1
- package/Meshes/Node/Blocks/matrixComposeBlock.d.ts +30 -0
- package/Meshes/Node/Blocks/matrixComposeBlock.js +55 -0
- package/Meshes/Node/Blocks/matrixComposeBlock.js.map +1 -0
- package/Meshes/Node/Enums/nodeGeometryContextualSources.d.ts +3 -1
- package/Meshes/Node/Enums/nodeGeometryContextualSources.js +2 -0
- package/Meshes/Node/Enums/nodeGeometryContextualSources.js.map +1 -1
- package/Meshes/Node/Interfaces/nodeGeometryInstancingContext.d.ts +10 -0
- package/Meshes/Node/Interfaces/nodeGeometryInstancingContext.js +2 -0
- package/Meshes/Node/Interfaces/nodeGeometryInstancingContext.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/Node/nodeGeometry.js +2 -2
- package/Meshes/Node/nodeGeometry.js.map +1 -1
- package/Meshes/Node/nodeGeometryBuildState.d.ts +5 -0
- package/Meshes/Node/nodeGeometryBuildState.js +20 -0
- package/Meshes/Node/nodeGeometryBuildState.js.map +1 -1
- package/Meshes/abstractMesh.js +4 -1
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/geometry.js +10 -10
- package/Meshes/geometry.js.map +1 -1
- package/Meshes/mesh.js +7 -5
- package/Meshes/mesh.js.map +1 -1
- package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js +2 -1
- package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js.map +1 -1
- package/Misc/dumpTools.js +3 -2
- package/Misc/dumpTools.js.map +1 -1
- package/Misc/equirectangularCapture.d.ts +39 -0
- package/Misc/equirectangularCapture.js +56 -0
- package/Misc/equirectangularCapture.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/Particles/solidParticleSystem.d.ts +4 -0
- package/Particles/solidParticleSystem.js +16 -1
- package/Particles/solidParticleSystem.js.map +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.d.ts +10 -0
- package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.d.ts +8 -1
- package/Physics/v2/Plugins/havokPlugin.js +34 -0
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Physics/v2/physicsConstraint.d.ts +11 -1
- package/Physics/v2/physicsConstraint.js +7 -0
- package/Physics/v2/physicsConstraint.js.map +1 -1
- package/Rendering/prePassRenderer.d.ts +6 -0
- package/Rendering/prePassRenderer.js +14 -0
- package/Rendering/prePassRenderer.js.map +1 -1
- package/Shaders/default.fragment.js +4 -0
- package/Shaders/default.fragment.js.map +1 -1
- package/Shaders/equirectangularPanorama.fragment.d.ts +5 -0
- package/Shaders/equirectangularPanorama.fragment.js +17 -0
- package/Shaders/equirectangularPanorama.fragment.js.map +1 -0
- package/Shaders/pbr.fragment.js +4 -0
- package/Shaders/pbr.fragment.js.map +1 -1
- package/package.json +1 -1
- package/FlowGraph/Blocks/Data/flowGraphBinaryOpBlocks.d.ts +0 -34
- package/FlowGraph/Blocks/Data/flowGraphBinaryOpBlocks.js +0 -29
- package/FlowGraph/Blocks/Data/flowGraphBinaryOpBlocks.js.map +0 -1
|
@@ -52,8 +52,9 @@ export class PerfCollectionStrategy {
|
|
|
52
52
|
const wrapper = new PressureObserverWrapper();
|
|
53
53
|
wrapper.observe("cpu");
|
|
54
54
|
wrapper.onPressureChanged.add((update) => {
|
|
55
|
+
var _a, _b;
|
|
55
56
|
for (const record of update) {
|
|
56
|
-
if ((factor && record.factors.includes(factor)) || (!factor && record.factors.length === 0)) {
|
|
57
|
+
if ((factor && record.factors.includes(factor)) || (!factor && ((_b = (_a = record.factors) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) === 0)) {
|
|
57
58
|
// Let s consider each step being 25% of the total pressure.
|
|
58
59
|
switch (record.state) {
|
|
59
60
|
case "nominal":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"performanceViewerCollectionStrategies.js","sourceRoot":"","sources":["../../../../../dev/core/src/Misc/PerformanceViewer/performanceViewerCollectionStrategies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAEpF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAoBrE,8BAA8B;AAC9B,MAAM,kBAAkB,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAMpC;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAC/B;;;OAGG;IACI,MAAM,CAAC,WAAW;QACrB,OAAO,CAAC,KAAK,EAAE,EAAE;YACb,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;YACjC,OAAO;gBACH,EAAE,EAAE,KAAK;gBACT,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE;gBAC9B,OAAO,EAAE,kBAAkB;aAC9B,CAAC;QACN,CAAC,CAAC;IACN,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,eAAe;QACzB,OAAO,IAAI,CAAC,iBAAi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rumentation } from \"../../Instrumentation/engineInstrumentation\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { PrecisionDate } from \"../precisionDate\";\r\nimport { SceneInstrumentation } from \"../../Instrumentation/sceneInstrumentation\";\r\nimport { PressureObserverWrapper } from \"../pressureObserverWrapper\";\r\nimport type { Nullable } from \"../../types\";\r\n\r\n/**\r\n * Defines the general structure of what is necessary for a collection strategy.\r\n */\r\nexport interface IPerfViewerCollectionStrategy {\r\n /**\r\n * The id of the strategy.\r\n */\r\n id: string;\r\n /**\r\n * Function which gets the data for the strategy.\r\n */\r\n getData: () => number;\r\n /**\r\n * Function which does any necessary cleanup. Called when performanceViewerCollector.dispose() is called.\r\n */\r\n dispose: () => void;\r\n}\r\n// Dispose which does nothing.\r\nconst defaultDisposeImpl = () => {};\r\n\r\n/**\r\n * Initializer callback for a strategy\r\n */\r\nexport type PerfStrategyInitialization = (scene: Scene) => IPerfViewerCollectionStrategy;\r\n/**\r\n * Defines the predefined strategies used in the performance viewer.\r\n */\r\nexport class PerfCollectionStrategy {\r\n /**\r\n * Gets the initializer for the strategy used for collection of fps metrics\r\n * @returns the initializer for the fps strategy\r\n */\r\n public static FpsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n const engine = scene.getEngine();\r\n return {\r\n id: \"FPS\",\r\n getData: () => engine.getFps(),\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of thermal utilization metrics.\r\n * Needs the experimental pressure API.\r\n * @returns the initializer for the thermal utilization strategy\r\n */\r\n public static ThermalStrategy(): PerfStrategyInitialization {\r\n return this._PressureStrategy(\"Thermal utilization\", \"thermal\");\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of power supply utilization metrics.\r\n * Needs the experimental pressure API.\r\n * @returns the initializer for the power supply utilization strategy\r\n */\r\n public static PowerSupplyStrategy(): PerfStrategyInitialization {\r\n return this._PressureStrategy(\"Power supply utilization\", \"power-supply\");\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of pressure metrics.\r\n * Needs the experimental pressure API.\r\n * @returns the initializer for the pressure strategy\r\n */\r\n public static PressureStrategy(): PerfStrategyInitialization {\r\n return this._PressureStrategy(\"Pressure\");\r\n }\r\n\r\n private static _PressureStrategy(name: string, factor: Nullable<PressureFactor> = null): PerfStrategyInitialization {\r\n return () => {\r\n let value = 0;\r\n\r\n const wrapper = new PressureObserverWrapper();\r\n wrapper.observe(\"cpu\");\r\n\r\n wrapper.onPressureChanged.add((update) => {\r\n for (const record of update) {\r\n if ((factor && record.factors.includes(factor)) || (!factor && record.factors.length === 0)) {\r\n // Let s consider each step being 25% of the total pressure.\r\n switch (record.state) {\r\n case \"nominal\":\r\n value = 0;\r\n break;\r\n case \"fair\":\r\n value = 0.25;\r\n break;\r\n case \"serious\":\r\n value = 0.5;\r\n break;\r\n case \"critical\":\r\n value = 1;\r\n break;\r\n }\r\n }\r\n }\r\n });\r\n return {\r\n id: name,\r\n getData: () => value,\r\n dispose: () => wrapper.dispose(),\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of total meshes metrics.\r\n * @returns the initializer for the total meshes strategy\r\n */\r\n public static TotalMeshesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Total meshes\",\r\n getData: () => scene.meshes.length,\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of active meshes metrics.\r\n * @returns the initializer for the active meshes strategy\r\n */\r\n public static ActiveMeshesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Active meshes\",\r\n getData: () => scene.getActiveMeshes().length,\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of active indices metrics.\r\n * @returns the initializer for the active indices strategy\r\n */\r\n public static ActiveIndicesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Active indices\",\r\n getData: () => scene.getActiveIndices(),\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of active faces metrics.\r\n * @returns the initializer for the active faces strategy\r\n */\r\n public static ActiveFacesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Active faces\",\r\n getData: () => scene.getActiveIndices() / 3,\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of active bones metrics.\r\n * @returns the initializer for the active bones strategy\r\n */\r\n public static ActiveBonesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Active bones\",\r\n getData: () => scene.getActiveBones(),\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of active particles metrics.\r\n * @returns the initializer for the active particles strategy\r\n */\r\n public static ActiveParticlesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Active particles\",\r\n getData: () => scene.getActiveParticles(),\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of draw calls metrics.\r\n * @returns the initializer for the draw calls strategy\r\n */\r\n public static DrawCallsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let drawCalls = 0;\r\n const onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(() => {\r\n scene.getEngine()._drawCalls.fetchNewFrame();\r\n });\r\n\r\n const onAfterRenderObserver = scene.onAfterRenderObservable.add(() => {\r\n drawCalls = scene.getEngine()._drawCalls.current;\r\n });\r\n\r\n return {\r\n id: \"Draw calls\",\r\n getData: () => drawCalls,\r\n dispose: () => {\r\n scene.onBeforeAnimationsObservable.remove(onBeforeAnimationsObserver);\r\n scene.onAfterRenderObservable.remove(onAfterRenderObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of total lights metrics.\r\n * @returns the initializer for the total lights strategy\r\n */\r\n public static TotalLightsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Total lights\",\r\n getData: () => scene.lights.length,\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of total vertices metrics.\r\n * @returns the initializer for the total vertices strategy\r\n */\r\n public static TotalVerticesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Total vertices\",\r\n getData: () => scene.getTotalVertices(),\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of total materials metrics.\r\n * @returns the initializer for the total materials strategy\r\n */\r\n public static TotalMaterialsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Total materials\",\r\n getData: () => scene.materials.length,\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of total textures metrics.\r\n * @returns the initializer for the total textures strategy\r\n */\r\n public static TotalTexturesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Total textures\",\r\n getData: () => scene.textures.length,\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of absolute fps metrics.\r\n * @returns the initializer for the absolute fps strategy\r\n */\r\n public static AbsoluteFpsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n const sceneInstrumentation = new SceneInstrumentation(scene);\r\n sceneInstrumentation.captureFrameTime = true;\r\n\r\n return {\r\n id: \"Absolute FPS\",\r\n getData: () => {\r\n return 1000.0 / sceneInstrumentation.frameTimeCounter.lastSecAverage;\r\n },\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of meshes selection time metrics.\r\n * @returns the initializer for the meshes selection time strategy\r\n */\r\n public static MeshesSelectionStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeActiveMeshesObserver = scene.onBeforeActiveMeshesEvaluationObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterActiveMeshesObserver = scene.onAfterActiveMeshesEvaluationObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Meshes Selection\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeActiveMeshesEvaluationObservable.remove(onBeforeActiveMeshesObserver);\r\n scene.onAfterActiveMeshesEvaluationObservable.remove(onAfterActiveMeshesObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of render targets time metrics.\r\n * @returns the initializer for the render targets time strategy\r\n */\r\n public static RenderTargetsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeRenderTargetsObserver = scene.onBeforeRenderTargetsRenderObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterRenderTargetsObserver = scene.onAfterRenderTargetsRenderObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Render Targets\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeRenderTargetsRenderObservable.remove(onBeforeRenderTargetsObserver);\r\n scene.onAfterRenderTargetsRenderObservable.remove(onAfterRenderTargetsObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of particles time metrics.\r\n * @returns the initializer for the particles time strategy\r\n */\r\n public static ParticlesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeParticlesObserver = scene.onBeforeParticlesRenderingObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterParticlesObserver = scene.onAfterParticlesRenderingObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Particles\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeParticlesRenderingObservable.remove(onBeforeParticlesObserver);\r\n scene.onAfterParticlesRenderingObservable.remove(onAfterParticlesObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of sprites time metrics.\r\n * @returns the initializer for the sprites time strategy\r\n */\r\n public static SpritesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeSpritesObserver = scene.onBeforeSpritesRenderingObservable?.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterSpritesObserver = scene.onAfterSpritesRenderingObservable?.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Sprites\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeSpritesRenderingObservable?.remove(onBeforeSpritesObserver);\r\n scene.onAfterSpritesRenderingObservable?.remove(onAfterSpritesObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of animations time metrics.\r\n * @returns the initializer for the animations time strategy\r\n */\r\n public static AnimationsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterAnimationsObserver = scene.onAfterAnimationsObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Animations\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeAnimationsObservable.remove(onBeforeAnimationsObserver);\r\n scene.onAfterAnimationsObservable.remove(onAfterAnimationsObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of physics time metrics.\r\n * @returns the initializer for the physics time strategy\r\n */\r\n public static PhysicsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforePhysicsObserver = scene.onBeforePhysicsObservable?.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterPhysicsObserver = scene.onAfterPhysicsObservable?.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Physics\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforePhysicsObservable?.remove(onBeforePhysicsObserver);\r\n scene.onAfterPhysicsObservable?.remove(onAfterPhysicsObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of render time metrics.\r\n * @returns the initializer for the render time strategy\r\n */\r\n public static RenderStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeDrawPhaseObserver = scene.onBeforeDrawPhaseObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterDrawPhaseObserver = scene.onAfterDrawPhaseObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Render\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeDrawPhaseObservable.remove(onBeforeDrawPhaseObserver);\r\n scene.onAfterDrawPhaseObservable.remove(onAfterDrawPhaseObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of total frame time metrics.\r\n * @returns the initializer for the total frame time strategy\r\n */\r\n public static FrameTotalStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterRenderObserver = scene.onAfterRenderObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Frame Total\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeAnimationsObservable.remove(onBeforeAnimationsObserver);\r\n scene.onAfterRenderObservable.remove(onAfterRenderObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of inter-frame time metrics.\r\n * @returns the initializer for the inter-frame time strategy\r\n */\r\n public static InterFrameStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n\r\n const onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n const onAfterRenderObserver = scene.onAfterRenderObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n return {\r\n id: \"Inter-frame\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeAnimationsObservable.remove(onBeforeAnimationsObserver);\r\n scene.onAfterRenderObservable.remove(onAfterRenderObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of gpu frame time metrics.\r\n * @returns the initializer for the gpu frame time strategy\r\n */\r\n public static GpuFrameTimeStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n const engineInstrumentation = new EngineInstrumentation(scene.getEngine());\r\n engineInstrumentation.captureGPUFrameTime = true;\r\n return {\r\n id: \"GPU frame time\",\r\n getData: () => Math.max(engineInstrumentation.gpuFrameTimeCounter.current * 0.000001, 0),\r\n dispose: () => {\r\n engineInstrumentation.dispose();\r\n },\r\n };\r\n };\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"performanceViewerCollectionStrategies.js","sourceRoot":"","sources":["../../../../../dev/core/src/Misc/PerformanceViewer/performanceViewerCollectionStrategies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAEpF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAoBrE,8BAA8B;AAC9B,MAAM,kBAAkB,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAMpC;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAC/B;;;OAGG;IACI,MAAM,CAAC,WAAW;QACrB,OAAO,CAAC,KAAK,EAAE,EAAE;YACb,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;YACjC,OAAO;gBACH,EAAE,EAAE,KAAK;gBACT,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE;gBAC9B,OAAO,EAAE,kBAAkB;aAC9B,CAAC;QACN,CAAC,CAAC;IACN,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,eAAe;QACzB,OAAO,IAAI,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;IACpE,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,mBAAmB;QAC7B,OAAO,IAAI,CAAC,iBAAiB,CAAC,0BAA0B,EAAE,cAAc,CAAC,CAAC;IAC9E,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,gBAAgB;QAC1B,OAAO,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAC9C,CAAC;IAEO,MAAM,CAAC,iBAAiB,CAAC,I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AM,qBAAqB,GAAG,KAAK,CAAC,uBAAuB,CAAC,GAAG,CAAC,GAAG,EAAE;gBACjE,SAAS,GAAG,aAAa,CAAC,GAAG,CAAC;YAClC,CAAC,CAAC,CAAC;YAEH,OAAO;gBACH,EAAE,EAAE,aAAa;gBACjB,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS;gBACxB,OAAO,EAAE,GAAG,EAAE;oBACV,KAAK,CAAC,4BAA4B,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC;oBACtE,KAAK,CAAC,uBAAuB,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;gBAChE,CAAC;aACJ,CAAC;QACN,CAAC,CAAC;IACN,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,oBAAoB;QAC9B,OAAO,CAAC,KAAK,EAAE,EAAE;YACb,MAAM,qBAAqB,GAAG,IAAI,qBAAqB,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;YAC3E,qBAAqB,CAAC,mBAAmB,GAAG,IAAI,CAAC;YACjD,OAAO;gBACH,EAAE,EAAE,gBAAgB;gBACpB,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,qBAAqB,CAAC,mBAAmB,CAAC,OAAO,GAAG,QAAQ,EAAE,CAAC,CAAC;gBACxF,OAAO,EAAE,GAAG,EAAE;oBACV,qBAAqB,CAAC,OAAO,EAAE,CAAC;gBACpC,CAAC;aACJ,CAAC;QACN,CAAC,CAAC;IACN,CAAC;CACJ","sourcesContent":["import { EngineInstrumentation } from \"../../Instrumentation/engineInstrumentation\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { PrecisionDate } from \"../precisionDate\";\r\nimport { SceneInstrumentation } from \"../../Instrumentation/sceneInstrumentation\";\r\nimport { PressureObserverWrapper } from \"../pressureObserverWrapper\";\r\nimport type { Nullable } from \"../../types\";\r\n\r\n/**\r\n * Defines the general structure of what is necessary for a collection strategy.\r\n */\r\nexport interface IPerfViewerCollectionStrategy {\r\n /**\r\n * The id of the strategy.\r\n */\r\n id: string;\r\n /**\r\n * Function which gets the data for the strategy.\r\n */\r\n getData: () => number;\r\n /**\r\n * Function which does any necessary cleanup. Called when performanceViewerCollector.dispose() is called.\r\n */\r\n dispose: () => void;\r\n}\r\n// Dispose which does nothing.\r\nconst defaultDisposeImpl = () => {};\r\n\r\n/**\r\n * Initializer callback for a strategy\r\n */\r\nexport type PerfStrategyInitialization = (scene: Scene) => IPerfViewerCollectionStrategy;\r\n/**\r\n * Defines the predefined strategies used in the performance viewer.\r\n */\r\nexport class PerfCollectionStrategy {\r\n /**\r\n * Gets the initializer for the strategy used for collection of fps metrics\r\n * @returns the initializer for the fps strategy\r\n */\r\n public static FpsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n const engine = scene.getEngine();\r\n return {\r\n id: \"FPS\",\r\n getData: () => engine.getFps(),\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of thermal utilization metrics.\r\n * Needs the experimental pressure API.\r\n * @returns the initializer for the thermal utilization strategy\r\n */\r\n public static ThermalStrategy(): PerfStrategyInitialization {\r\n return this._PressureStrategy(\"Thermal utilization\", \"thermal\");\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of power supply utilization metrics.\r\n * Needs the experimental pressure API.\r\n * @returns the initializer for the power supply utilization strategy\r\n */\r\n public static PowerSupplyStrategy(): PerfStrategyInitialization {\r\n return this._PressureStrategy(\"Power supply utilization\", \"power-supply\");\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of pressure metrics.\r\n * Needs the experimental pressure API.\r\n * @returns the initializer for the pressure strategy\r\n */\r\n public static PressureStrategy(): PerfStrategyInitialization {\r\n return this._PressureStrategy(\"Pressure\");\r\n }\r\n\r\n private static _PressureStrategy(name: string, factor: Nullable<PressureFactor> = null): PerfStrategyInitialization {\r\n return () => {\r\n let value = 0;\r\n\r\n const wrapper = new PressureObserverWrapper();\r\n wrapper.observe(\"cpu\");\r\n\r\n wrapper.onPressureChanged.add((update) => {\r\n for (const record of update) {\r\n if ((factor && record.factors.includes(factor)) || (!factor && (record.factors?.length ?? 0) === 0)) {\r\n // Let s consider each step being 25% of the total pressure.\r\n switch (record.state) {\r\n case \"nominal\":\r\n value = 0;\r\n break;\r\n case \"fair\":\r\n value = 0.25;\r\n break;\r\n case \"serious\":\r\n value = 0.5;\r\n break;\r\n case \"critical\":\r\n value = 1;\r\n break;\r\n }\r\n }\r\n }\r\n });\r\n return {\r\n id: name,\r\n getData: () => value,\r\n dispose: () => wrapper.dispose(),\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of total meshes metrics.\r\n * @returns the initializer for the total meshes strategy\r\n */\r\n public static TotalMeshesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Total meshes\",\r\n getData: () => scene.meshes.length,\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of active meshes metrics.\r\n * @returns the initializer for the active meshes strategy\r\n */\r\n public static ActiveMeshesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Active meshes\",\r\n getData: () => scene.getActiveMeshes().length,\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of active indices metrics.\r\n * @returns the initializer for the active indices strategy\r\n */\r\n public static ActiveIndicesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Active indices\",\r\n getData: () => scene.getActiveIndices(),\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of active faces metrics.\r\n * @returns the initializer for the active faces strategy\r\n */\r\n public static ActiveFacesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Active faces\",\r\n getData: () => scene.getActiveIndices() / 3,\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of active bones metrics.\r\n * @returns the initializer for the active bones strategy\r\n */\r\n public static ActiveBonesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Active bones\",\r\n getData: () => scene.getActiveBones(),\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of active particles metrics.\r\n * @returns the initializer for the active particles strategy\r\n */\r\n public static ActiveParticlesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Active particles\",\r\n getData: () => scene.getActiveParticles(),\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of draw calls metrics.\r\n * @returns the initializer for the draw calls strategy\r\n */\r\n public static DrawCallsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let drawCalls = 0;\r\n const onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(() => {\r\n scene.getEngine()._drawCalls.fetchNewFrame();\r\n });\r\n\r\n const onAfterRenderObserver = scene.onAfterRenderObservable.add(() => {\r\n drawCalls = scene.getEngine()._drawCalls.current;\r\n });\r\n\r\n return {\r\n id: \"Draw calls\",\r\n getData: () => drawCalls,\r\n dispose: () => {\r\n scene.onBeforeAnimationsObservable.remove(onBeforeAnimationsObserver);\r\n scene.onAfterRenderObservable.remove(onAfterRenderObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of total lights metrics.\r\n * @returns the initializer for the total lights strategy\r\n */\r\n public static TotalLightsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Total lights\",\r\n getData: () => scene.lights.length,\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of total vertices metrics.\r\n * @returns the initializer for the total vertices strategy\r\n */\r\n public static TotalVerticesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Total vertices\",\r\n getData: () => scene.getTotalVertices(),\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of total materials metrics.\r\n * @returns the initializer for the total materials strategy\r\n */\r\n public static TotalMaterialsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Total materials\",\r\n getData: () => scene.materials.length,\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of total textures metrics.\r\n * @returns the initializer for the total textures strategy\r\n */\r\n public static TotalTexturesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Total textures\",\r\n getData: () => scene.textures.length,\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of absolute fps metrics.\r\n * @returns the initializer for the absolute fps strategy\r\n */\r\n public static AbsoluteFpsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n const sceneInstrumentation = new SceneInstrumentation(scene);\r\n sceneInstrumentation.captureFrameTime = true;\r\n\r\n return {\r\n id: \"Absolute FPS\",\r\n getData: () => {\r\n return 1000.0 / sceneInstrumentation.frameTimeCounter.lastSecAverage;\r\n },\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of meshes selection time metrics.\r\n * @returns the initializer for the meshes selection time strategy\r\n */\r\n public static MeshesSelectionStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeActiveMeshesObserver = scene.onBeforeActiveMeshesEvaluationObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterActiveMeshesObserver = scene.onAfterActiveMeshesEvaluationObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Meshes Selection\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeActiveMeshesEvaluationObservable.remove(onBeforeActiveMeshesObserver);\r\n scene.onAfterActiveMeshesEvaluationObservable.remove(onAfterActiveMeshesObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of render targets time metrics.\r\n * @returns the initializer for the render targets time strategy\r\n */\r\n public static RenderTargetsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeRenderTargetsObserver = scene.onBeforeRenderTargetsRenderObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterRenderTargetsObserver = scene.onAfterRenderTargetsRenderObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Render Targets\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeRenderTargetsRenderObservable.remove(onBeforeRenderTargetsObserver);\r\n scene.onAfterRenderTargetsRenderObservable.remove(onAfterRenderTargetsObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of particles time metrics.\r\n * @returns the initializer for the particles time strategy\r\n */\r\n public static ParticlesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeParticlesObserver = scene.onBeforeParticlesRenderingObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterParticlesObserver = scene.onAfterParticlesRenderingObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Particles\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeParticlesRenderingObservable.remove(onBeforeParticlesObserver);\r\n scene.onAfterParticlesRenderingObservable.remove(onAfterParticlesObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of sprites time metrics.\r\n * @returns the initializer for the sprites time strategy\r\n */\r\n public static SpritesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeSpritesObserver = scene.onBeforeSpritesRenderingObservable?.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterSpritesObserver = scene.onAfterSpritesRenderingObservable?.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Sprites\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeSpritesRenderingObservable?.remove(onBeforeSpritesObserver);\r\n scene.onAfterSpritesRenderingObservable?.remove(onAfterSpritesObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of animations time metrics.\r\n * @returns the initializer for the animations time strategy\r\n */\r\n public static AnimationsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterAnimationsObserver = scene.onAfterAnimationsObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Animations\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeAnimationsObservable.remove(onBeforeAnimationsObserver);\r\n scene.onAfterAnimationsObservable.remove(onAfterAnimationsObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of physics time metrics.\r\n * @returns the initializer for the physics time strategy\r\n */\r\n public static PhysicsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforePhysicsObserver = scene.onBeforePhysicsObservable?.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterPhysicsObserver = scene.onAfterPhysicsObservable?.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Physics\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforePhysicsObservable?.remove(onBeforePhysicsObserver);\r\n scene.onAfterPhysicsObservable?.remove(onAfterPhysicsObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of render time metrics.\r\n * @returns the initializer for the render time strategy\r\n */\r\n public static RenderStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeDrawPhaseObserver = scene.onBeforeDrawPhaseObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterDrawPhaseObserver = scene.onAfterDrawPhaseObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Render\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeDrawPhaseObservable.remove(onBeforeDrawPhaseObserver);\r\n scene.onAfterDrawPhaseObservable.remove(onAfterDrawPhaseObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of total frame time metrics.\r\n * @returns the initializer for the total frame time strategy\r\n */\r\n public static FrameTotalStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterRenderObserver = scene.onAfterRenderObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Frame Total\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeAnimationsObservable.remove(onBeforeAnimationsObserver);\r\n scene.onAfterRenderObservable.remove(onAfterRenderObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of inter-frame time metrics.\r\n * @returns the initializer for the inter-frame time strategy\r\n */\r\n public static InterFrameStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n\r\n const onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n const onAfterRenderObserver = scene.onAfterRenderObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n return {\r\n id: \"Inter-frame\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeAnimationsObservable.remove(onBeforeAnimationsObserver);\r\n scene.onAfterRenderObservable.remove(onAfterRenderObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of gpu frame time metrics.\r\n * @returns the initializer for the gpu frame time strategy\r\n */\r\n public static GpuFrameTimeStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n const engineInstrumentation = new EngineInstrumentation(scene.getEngine());\r\n engineInstrumentation.captureGPUFrameTime = true;\r\n return {\r\n id: \"GPU frame time\",\r\n getData: () => Math.max(engineInstrumentation.gpuFrameTimeCounter.current * 0.000001, 0),\r\n dispose: () => {\r\n engineInstrumentation.dispose();\r\n },\r\n };\r\n };\r\n }\r\n}\r\n"]}
|
package/Misc/dumpTools.js
CHANGED
|
@@ -10,7 +10,7 @@ import { Scalar } from "../Maths/math.scalar.js";
|
|
|
10
10
|
export class DumpTools {
|
|
11
11
|
static _CreateDumpRenderer() {
|
|
12
12
|
if (!DumpTools._DumpToolsEngine) {
|
|
13
|
-
let canvas
|
|
13
|
+
let canvas;
|
|
14
14
|
let engine = null;
|
|
15
15
|
const options = {
|
|
16
16
|
preserveDrawingBuffer: true,
|
|
@@ -22,10 +22,11 @@ export class DumpTools {
|
|
|
22
22
|
failIfMajorPerformanceCaveat: false,
|
|
23
23
|
};
|
|
24
24
|
try {
|
|
25
|
+
canvas = new OffscreenCanvas(100, 100); // will be resized later
|
|
25
26
|
engine = new ThinEngine(canvas, false, options);
|
|
26
27
|
}
|
|
27
28
|
catch (e) {
|
|
28
|
-
// The browser does not support WebGL context in OffscreenCanvas, fallback on a regular canvas
|
|
29
|
+
// The browser either does not support OffscreenCanvas or WebGL context in OffscreenCanvas, fallback on a regular canvas
|
|
29
30
|
canvas = document.createElement("canvas");
|
|
30
31
|
engine = new ThinEngine(canvas, false, options);
|
|
31
32
|
}
|
package/Misc/dumpTools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dumpTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/dumpTools.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAS9C;;GAEG;AACH,MAAM,OAAO,SAAS;IAGV,MAAM,CAAC,mBAAmB;QAC9B,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE;YAC7B,IAAI,MAAM,GAAwC,IAAI,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,wBAAwB;YACzG,IAAI,MAAM,GAAyB,IAAI,CAAC;YACxC,MAAM,OAAO,GAAG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AAE,QAAQ,EAAE,OAAO,CAAC,CAAC;SACnG;QAED,OAAO,CAAC,OAAO,EAAE,CAAC;IACtB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,OAAO;QACjB,IAAI,SAAS,CAAC,gBAAgB,EAAE;YAC5B,SAAS,CAAC,gBAAgB,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YAC7C,SAAS,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YAC9C,SAAS,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;SAC/C;QACD,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC;IACtC,CAAC;CACJ;AAED;;;;;GAKG;AACH,MAAM,eAAe,GAAG,GAAG,EAAE;IACzB,+BAA+B;IAC/B,KAAK,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;IACpC,KAAK,CAAC,aAAa,GAAG,SAAS,CAAC,aAAa,CAAC;IAC9C,KAAK,CAAC,eAAe,GAAG,SAAS,CAAC,eAAe,CAAC;AACtD,CAAC,CAAC;AAEF,eAAe,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport { _WarnImport } from \"./devTools\";\r\nimport type { Engine } from \"../Engines/engine\";\r\n\r\nimport { ThinEngine } from \"../Engines/thinEngine\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport { Tools } from \"./tools\";\r\nimport type { Nullable } from \"../types\";\r\n\r\nimport { passPixelShader } from \"../Shaders/pass.fragment\";\r\nimport { Scalar } from \"../Maths/math.scalar\";\r\n\r\ntype DumpToolsEngine = {\r\n canvas: HTMLCanvasElement | OffscreenCanvas;\r\n engine: ThinEngine;\r\n renderer: EffectRenderer;\r\n wrapper: EffectWrapper;\r\n};\r\n\r\n/**\r\n * Class containing a set of static utilities functions to dump data from a canvas\r\n */\r\nexport class DumpTools {\r\n private static _DumpToolsEngine: Nullable<DumpToolsEngine>;\r\n\r\n private static _CreateDumpRenderer(): DumpToolsEngine {\r\n if (!DumpTools._DumpToolsEngine) {\r\n let canvas: HTMLCanvasElement | OffscreenCanvas = new OffscreenCanvas(100, 100); // will be resized later\r\n let engine: Nullable<ThinEngine> = null;\r\n const options = {\r\n preserveDrawingBuffer: true,\r\n depth: false,\r\n stencil: false,\r\n alpha: true,\r\n premultipliedAlpha: false,\r\n antialias: false,\r\n failIfMajorPerformanceCaveat: false,\r\n };\r\n try {\r\n engine = new ThinEngine(canvas, false, options);\r\n } catch (e) {\r\n // The browser does not support WebGL context in OffscreenCanvas, fallback on a regular canvas\r\n canvas = document.createElement(\"canvas\");\r\n engine = new ThinEngine(canvas, false, options);\r\n }\r\n engine.getCaps().parallelShaderCompile = undefined;\r\n const renderer = new EffectRenderer(engine);\r\n const wrapper = new EffectWrapper({\r\n engine,\r\n name: passPixelShader.name,\r\n fragmentShader: passPixelShader.shader,\r\n samplerNames: [\"textureSampler\"],\r\n });\r\n DumpTools._DumpToolsEngine = {\r\n canvas,\r\n engine,\r\n renderer,\r\n wrapper,\r\n };\r\n }\r\n return DumpTools._DumpToolsEngine!;\r\n }\r\n\r\n /**\r\n * Dumps the current bound framebuffer\r\n * @param width defines the rendering width\r\n * @param height defines the rendering height\r\n * @param engine defines the hosting engine\r\n * @param successCallback defines the callback triggered once the data are available\r\n * @param mimeType defines the mime type of the result\r\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\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 a void promise\r\n */\r\n public static async DumpFramebuffer(\r\n width: number,\r\n height: number,\r\n engine: Engine,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n fileName?: string,\r\n quality?: number\r\n ) {\r\n // Read the contents of the framebuffer\r\n const bufferView = await engine.readPixels(0, 0, width, height);\r\n\r\n const data = new Uint8Array(bufferView.buffer);\r\n\r\n DumpTools.DumpData(width, height, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true, undefined, quality);\r\n }\r\n\r\n /**\r\n * Dumps an array buffer\r\n * @param width defines the rendering width\r\n * @param height defines the rendering height\r\n * @param data the data array\r\n * @param mimeType defines the mime type of the result\r\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\r\n * @param invertY true to invert the picture in the Y dimension\r\n * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string\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 a promise that resolve to the final data\r\n */\r\n public static DumpDataAsync(\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n mimeType = \"image/png\",\r\n fileName?: string,\r\n invertY = false,\r\n toArrayBuffer = false,\r\n quality?: number\r\n ): Promise<string | ArrayBuffer> {\r\n return new Promise((resolve) => {\r\n DumpTools.DumpData(width, height, data, (result) => resolve(result), mimeType, fileName, invertY, toArrayBuffer, quality);\r\n });\r\n }\r\n\r\n /**\r\n * Dumps an array buffer\r\n * @param width defines the rendering width\r\n * @param height defines the rendering height\r\n * @param data the data array\r\n * @param successCallback defines the callback triggered once the data are available\r\n * @param mimeType defines the mime type of the result\r\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\r\n * @param invertY true to invert the picture in the Y dimension\r\n * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string\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 public static DumpData(\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n successCallback?: (data: string | ArrayBuffer) => void,\r\n mimeType = \"image/png\",\r\n fileName?: string,\r\n invertY = false,\r\n toArrayBuffer = false,\r\n quality?: number\r\n ) {\r\n const renderer = DumpTools._CreateDumpRenderer();\r\n renderer.engine.setSize(width, height, true);\r\n\r\n // Convert if data are float32\r\n if (data instanceof Float32Array) {\r\n const data2 = new Uint8Array(data.length);\r\n let n = data.length;\r\n while (n--) {\r\n const v = data[n];\r\n data2[n] = Math.round(Scalar.Clamp(v) * 255);\r\n }\r\n data = data2;\r\n }\r\n\r\n // Create the image\r\n const texture = renderer.engine.createRawTexture(data, width, height, Constants.TEXTUREFORMAT_RGBA, false, !invertY, Constants.TEXTURE_NEAREST_NEAREST);\r\n\r\n renderer.renderer.setViewport();\r\n renderer.renderer.applyEffectWrapper(renderer.wrapper);\r\n renderer.wrapper.effect._bindTexture(\"textureSampler\", texture);\r\n renderer.renderer.draw();\r\n\r\n if (toArrayBuffer) {\r\n Tools.ToBlob(\r\n renderer.canvas,\r\n (blob) => {\r\n const fileReader = new FileReader();\r\n fileReader.onload = (event: any) => {\r\n const arrayBuffer = event.target!.result as ArrayBuffer;\r\n if (successCallback) {\r\n successCallback(arrayBuffer);\r\n }\r\n };\r\n fileReader.readAsArrayBuffer(blob!);\r\n },\r\n mimeType,\r\n quality\r\n );\r\n } else {\r\n Tools.EncodeScreenshotCanvasData(renderer.canvas, successCallback, mimeType, fileName, quality);\r\n }\r\n\r\n texture.dispose();\r\n }\r\n\r\n /**\r\n * Dispose the dump tools associated resources\r\n */\r\n public static Dispose() {\r\n if (DumpTools._DumpToolsEngine) {\r\n DumpTools._DumpToolsEngine.wrapper.dispose();\r\n DumpTools._DumpToolsEngine.renderer.dispose();\r\n DumpTools._DumpToolsEngine.engine.dispose();\r\n }\r\n DumpTools._DumpToolsEngine = null;\r\n }\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.DumpData = DumpTools.DumpData;\r\n Tools.DumpDataAsync = DumpTools.DumpDataAsync;\r\n Tools.DumpFramebuffer = DumpTools.DumpFramebuffer;\r\n};\r\n\r\ninitSideEffects();\r\n"]}
|
|
1
|
+
{"version":3,"file":"dumpTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/dumpTools.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAS9C;;GAEG;AACH,MAAM,OAAO,SAAS;IAGV,MAAM,CAAC,mBAAmB;QAC9B,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE;YAC7B,IAAI,MAA2C,CAAC;YAChD,IAAI,MAAM,GAAyB,IAAI,CAAC;YACxC,MAAM,OAAO,GAAG;gBACZ,qBAAqB,EAAE,IAAI;gBAC3B,KAAK,EAAE,KAAK;gBACZ,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,IAAI;gBACX,kBAAkB,EAAE,KAAK;gBACzB,SAAS,EAAE,KAAK;gBAChB,4BAA4B,EAAE,KAAK;aACtC,CAAC;YACF,IAAI;gBACA,MAAM,GAAG,IAAI,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,wBAAwB;gBAChE,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;aACnD;YAAC,OAAO,CAAC,EAAE;gBACR,wHAAwH;gBACxH,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AAO,EAAE,CAAC;SAC/C;QACD,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC;IACtC,CAAC;CACJ;AAED;;;;;GAKG;AACH,MAAM,eAAe,GAAG,GAAG,EAAE;IACzB,+BAA+B;IAC/B,KAAK,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;IACpC,KAAK,CAAC,aAAa,GAAG,SAAS,CAAC,aAAa,CAAC;IAC9C,KAAK,CAAC,eAAe,GAAG,SAAS,CAAC,eAAe,CAAC;AACtD,CAAC,CAAC;AAEF,eAAe,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport { _WarnImport } from \"./devTools\";\r\nimport type { Engine } from \"../Engines/engine\";\r\n\r\nimport { ThinEngine } from \"../Engines/thinEngine\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport { Tools } from \"./tools\";\r\nimport type { Nullable } from \"../types\";\r\n\r\nimport { passPixelShader } from \"../Shaders/pass.fragment\";\r\nimport { Scalar } from \"../Maths/math.scalar\";\r\n\r\ntype DumpToolsEngine = {\r\n canvas: HTMLCanvasElement | OffscreenCanvas;\r\n engine: ThinEngine;\r\n renderer: EffectRenderer;\r\n wrapper: EffectWrapper;\r\n};\r\n\r\n/**\r\n * Class containing a set of static utilities functions to dump data from a canvas\r\n */\r\nexport class DumpTools {\r\n private static _DumpToolsEngine: Nullable<DumpToolsEngine>;\r\n\r\n private static _CreateDumpRenderer(): DumpToolsEngine {\r\n if (!DumpTools._DumpToolsEngine) {\r\n let canvas: HTMLCanvasElement | OffscreenCanvas;\r\n let engine: Nullable<ThinEngine> = null;\r\n const options = {\r\n preserveDrawingBuffer: true,\r\n depth: false,\r\n stencil: false,\r\n alpha: true,\r\n premultipliedAlpha: false,\r\n antialias: false,\r\n failIfMajorPerformanceCaveat: false,\r\n };\r\n try {\r\n canvas = new OffscreenCanvas(100, 100); // will be resized later\r\n engine = new ThinEngine(canvas, false, options);\r\n } catch (e) {\r\n // The browser either does not support OffscreenCanvas or WebGL context in OffscreenCanvas, fallback on a regular canvas\r\n canvas = document.createElement(\"canvas\");\r\n engine = new ThinEngine(canvas, false, options);\r\n }\r\n engine.getCaps().parallelShaderCompile = undefined;\r\n const renderer = new EffectRenderer(engine);\r\n const wrapper = new EffectWrapper({\r\n engine,\r\n name: passPixelShader.name,\r\n fragmentShader: passPixelShader.shader,\r\n samplerNames: [\"textureSampler\"],\r\n });\r\n DumpTools._DumpToolsEngine = {\r\n canvas,\r\n engine,\r\n renderer,\r\n wrapper,\r\n };\r\n }\r\n return DumpTools._DumpToolsEngine!;\r\n }\r\n\r\n /**\r\n * Dumps the current bound framebuffer\r\n * @param width defines the rendering width\r\n * @param height defines the rendering height\r\n * @param engine defines the hosting engine\r\n * @param successCallback defines the callback triggered once the data are available\r\n * @param mimeType defines the mime type of the result\r\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\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 a void promise\r\n */\r\n public static async DumpFramebuffer(\r\n width: number,\r\n height: number,\r\n engine: Engine,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n fileName?: string,\r\n quality?: number\r\n ) {\r\n // Read the contents of the framebuffer\r\n const bufferView = await engine.readPixels(0, 0, width, height);\r\n\r\n const data = new Uint8Array(bufferView.buffer);\r\n\r\n DumpTools.DumpData(width, height, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true, undefined, quality);\r\n }\r\n\r\n /**\r\n * Dumps an array buffer\r\n * @param width defines the rendering width\r\n * @param height defines the rendering height\r\n * @param data the data array\r\n * @param mimeType defines the mime type of the result\r\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\r\n * @param invertY true to invert the picture in the Y dimension\r\n * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string\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 a promise that resolve to the final data\r\n */\r\n public static DumpDataAsync(\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n mimeType = \"image/png\",\r\n fileName?: string,\r\n invertY = false,\r\n toArrayBuffer = false,\r\n quality?: number\r\n ): Promise<string | ArrayBuffer> {\r\n return new Promise((resolve) => {\r\n DumpTools.DumpData(width, height, data, (result) => resolve(result), mimeType, fileName, invertY, toArrayBuffer, quality);\r\n });\r\n }\r\n\r\n /**\r\n * Dumps an array buffer\r\n * @param width defines the rendering width\r\n * @param height defines the rendering height\r\n * @param data the data array\r\n * @param successCallback defines the callback triggered once the data are available\r\n * @param mimeType defines the mime type of the result\r\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\r\n * @param invertY true to invert the picture in the Y dimension\r\n * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string\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 public static DumpData(\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n successCallback?: (data: string | ArrayBuffer) => void,\r\n mimeType = \"image/png\",\r\n fileName?: string,\r\n invertY = false,\r\n toArrayBuffer = false,\r\n quality?: number\r\n ) {\r\n const renderer = DumpTools._CreateDumpRenderer();\r\n renderer.engine.setSize(width, height, true);\r\n\r\n // Convert if data are float32\r\n if (data instanceof Float32Array) {\r\n const data2 = new Uint8Array(data.length);\r\n let n = data.length;\r\n while (n--) {\r\n const v = data[n];\r\n data2[n] = Math.round(Scalar.Clamp(v) * 255);\r\n }\r\n data = data2;\r\n }\r\n\r\n // Create the image\r\n const texture = renderer.engine.createRawTexture(data, width, height, Constants.TEXTUREFORMAT_RGBA, false, !invertY, Constants.TEXTURE_NEAREST_NEAREST);\r\n\r\n renderer.renderer.setViewport();\r\n renderer.renderer.applyEffectWrapper(renderer.wrapper);\r\n renderer.wrapper.effect._bindTexture(\"textureSampler\", texture);\r\n renderer.renderer.draw();\r\n\r\n if (toArrayBuffer) {\r\n Tools.ToBlob(\r\n renderer.canvas,\r\n (blob) => {\r\n const fileReader = new FileReader();\r\n fileReader.onload = (event: any) => {\r\n const arrayBuffer = event.target!.result as ArrayBuffer;\r\n if (successCallback) {\r\n successCallback(arrayBuffer);\r\n }\r\n };\r\n fileReader.readAsArrayBuffer(blob!);\r\n },\r\n mimeType,\r\n quality\r\n );\r\n } else {\r\n Tools.EncodeScreenshotCanvasData(renderer.canvas, successCallback, mimeType, fileName, quality);\r\n }\r\n\r\n texture.dispose();\r\n }\r\n\r\n /**\r\n * Dispose the dump tools associated resources\r\n */\r\n public static Dispose() {\r\n if (DumpTools._DumpToolsEngine) {\r\n DumpTools._DumpToolsEngine.wrapper.dispose();\r\n DumpTools._DumpToolsEngine.renderer.dispose();\r\n DumpTools._DumpToolsEngine.engine.dispose();\r\n }\r\n DumpTools._DumpToolsEngine = null;\r\n }\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.DumpData = DumpTools.DumpData;\r\n Tools.DumpDataAsync = DumpTools.DumpDataAsync;\r\n Tools.DumpFramebuffer = DumpTools.DumpFramebuffer;\r\n};\r\n\r\ninitSideEffects();\r\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Scene } from "../scene";
|
|
2
|
+
import { ReflectionProbe } from "../Probes/reflectionProbe";
|
|
3
|
+
import type { AbstractMesh } from "../Meshes/abstractMesh";
|
|
4
|
+
import type { Vector3 } from "../Maths/math.vector";
|
|
5
|
+
import "../Shaders/equirectangularPanorama.fragment";
|
|
6
|
+
/**
|
|
7
|
+
* Interface containing options related to equirectangular capture of the current scene
|
|
8
|
+
*/
|
|
9
|
+
export interface EquiRectangularCaptureOptions {
|
|
10
|
+
/**
|
|
11
|
+
* This option relates to smallest dimension of the given equirectangular capture
|
|
12
|
+
* Giving a 512px size would result in an image that 512 x 1024px
|
|
13
|
+
*/
|
|
14
|
+
size: number;
|
|
15
|
+
/**
|
|
16
|
+
* Optional function to map which meshes should get rendered on the equirectangular map
|
|
17
|
+
* This is specifically helpful when you have certain meshes that you want to skip, especially ground
|
|
18
|
+
*/
|
|
19
|
+
meshesFilter?: (mesh: AbstractMesh) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Optional argument to specify filename, passing this would auto download the given file
|
|
22
|
+
*/
|
|
23
|
+
filename?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Optional argument to specify position in 3D Space from where the equirectangular capture should be taken, if not specified, it would take the position of the scene's active camera or else origin
|
|
26
|
+
*/
|
|
27
|
+
position?: Vector3;
|
|
28
|
+
/**
|
|
29
|
+
* Optional argument to specify probe with which the equirectangular image is generated
|
|
30
|
+
* When passing this, size and position arguments are ignored
|
|
31
|
+
*/
|
|
32
|
+
probe?: ReflectionProbe;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @param scene This refers to the scene which would be rendered in the given equirectangular capture
|
|
36
|
+
* @param options This refers to the options for a given equirectangular capture
|
|
37
|
+
* @returns the requested capture's pixel-data or auto downloads the file if options.filename is specified
|
|
38
|
+
*/
|
|
39
|
+
export declare function captureEquirectangularFromScene(scene: Scene, options: EquiRectangularCaptureOptions): Promise<ArrayBufferView | null>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ReflectionProbe } from "../Probes/reflectionProbe.js";
|
|
2
|
+
import { RenderTargetTexture } from "../Materials/Textures/renderTargetTexture.js";
|
|
3
|
+
import { CustomProceduralTexture } from "../Materials/Textures/Procedurals/customProceduralTexture.js";
|
|
4
|
+
import { DumpTools } from "./dumpTools.js";
|
|
5
|
+
import "../Shaders/equirectangularPanorama.fragment.js";
|
|
6
|
+
/**
|
|
7
|
+
* @param scene This refers to the scene which would be rendered in the given equirectangular capture
|
|
8
|
+
* @param options This refers to the options for a given equirectangular capture
|
|
9
|
+
* @returns the requested capture's pixel-data or auto downloads the file if options.filename is specified
|
|
10
|
+
*/
|
|
11
|
+
export async function captureEquirectangularFromScene(scene, options) {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
const probe = (_a = options.probe) !== null && _a !== void 0 ? _a : new ReflectionProbe("tempProbe", options.size, scene);
|
|
14
|
+
const wasProbeProvided = !!options.probe;
|
|
15
|
+
if (!wasProbeProvided) {
|
|
16
|
+
if (options.position) {
|
|
17
|
+
probe.position = options.position.clone();
|
|
18
|
+
}
|
|
19
|
+
else if (scene.activeCamera) {
|
|
20
|
+
probe.position = scene.activeCamera.position.clone();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const meshesToConsider = options.meshesFilter ? scene.meshes.filter(options.meshesFilter) : scene.meshes;
|
|
24
|
+
(_b = probe.renderList) === null || _b === void 0 ? void 0 : _b.push(...meshesToConsider);
|
|
25
|
+
probe.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;
|
|
26
|
+
probe.cubeTexture.render();
|
|
27
|
+
const dumpTexture = new CustomProceduralTexture("tempProceduralTexture", "equirectangularPanorama", { width: options.size * 2, height: options.size }, scene);
|
|
28
|
+
dumpTexture.setTexture("cubeMap", probe.cubeTexture);
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
dumpTexture.onGeneratedObservable.addOnce(() => {
|
|
31
|
+
const pixelDataPromise = dumpTexture.readPixels();
|
|
32
|
+
if (!pixelDataPromise) {
|
|
33
|
+
reject(new Error("No Pixel Data found on procedural texture"));
|
|
34
|
+
dumpTexture.dispose();
|
|
35
|
+
if (!wasProbeProvided) {
|
|
36
|
+
probe.dispose();
|
|
37
|
+
}
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
pixelDataPromise.then((pixelData) => {
|
|
41
|
+
dumpTexture.dispose();
|
|
42
|
+
if (!wasProbeProvided) {
|
|
43
|
+
probe.dispose();
|
|
44
|
+
}
|
|
45
|
+
if (options.filename) {
|
|
46
|
+
DumpTools.DumpData(options.size * 2, options.size, pixelData, undefined, "image/png", options.filename);
|
|
47
|
+
resolve(null);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
resolve(pixelData);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=equirectangularCapture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"equirectangularCapture.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/equirectangularCapture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,uBAAuB,EAAE,MAAM,2DAA2D,CAAC;AACpG,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,6CAA6C,CAAC;AAiCrD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,+BAA+B,CAAC,KAAY,EAAE,OAAsC;;IACtG,MAAM,KAAK,GAAoB,MAAA,OAAO,CAAC,KAAK,mCAAI,IAAI,eAAe,CAAC,WAAW,EAAE,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACtG,MAAM,gBAAgB,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IACzC,IAAI,CAAC,gBAAgB,EAAE;QACnB,IAAI,OAAO,CAAC,QAAQ,EAAE;YAClB,KAAK,CA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AgB,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE;gBAChC,WAAW,CAAC,OAAO,EAAE,CAAC;gBACtB,IAAI,CAAC,gBAAgB,EAAE;oBACnB,KAAK,CAAC,OAAO,EAAE,CAAC;iBACnB;gBACD,IAAI,OAAO,CAAC,QAAQ,EAAE;oBAClB,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,EAAE,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;oBACxG,OAAO,CAAC,IAAI,CAAC,CAAC;iBACjB;qBAAM;oBACH,OAAO,CAAC,SAAS,CAAC,CAAC;iBACtB;YACL,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import type { Scene } from \"../scene\";\r\nimport { ReflectionProbe } from \"../Probes/reflectionProbe\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { CustomProceduralTexture } from \"../Materials/Textures/Procedurals/customProceduralTexture\";\r\nimport { DumpTools } from \"./dumpTools\";\r\nimport type { Vector3 } from \"../Maths/math.vector\";\r\nimport \"../Shaders/equirectangularPanorama.fragment\";\r\n\r\n/**\r\n * Interface containing options related to equirectangular capture of the current scene\r\n */\r\nexport interface EquiRectangularCaptureOptions {\r\n /**\r\n * This option relates to smallest dimension of the given equirectangular capture\r\n * Giving a 512px size would result in an image that 512 x 1024px\r\n */\r\n size: number;\r\n /**\r\n * Optional function to map which meshes should get rendered on the equirectangular map\r\n * This is specifically helpful when you have certain meshes that you want to skip, especially ground\r\n */\r\n meshesFilter?: (mesh: AbstractMesh) => boolean;\r\n /**\r\n * Optional argument to specify filename, passing this would auto download the given file\r\n */\r\n filename?: string;\r\n\r\n /**\r\n * Optional argument to specify position in 3D Space from where the equirectangular capture should be taken, if not specified, it would take the position of the scene's active camera or else origin\r\n */\r\n position?: Vector3;\r\n\r\n /**\r\n * Optional argument to specify probe with which the equirectangular image is generated\r\n * When passing this, size and position arguments are ignored\r\n */\r\n probe?: ReflectionProbe;\r\n}\r\n\r\n/**\r\n * @param scene This refers to the scene which would be rendered in the given equirectangular capture\r\n * @param options This refers to the options for a given equirectangular capture\r\n * @returns the requested capture's pixel-data or auto downloads the file if options.filename is specified\r\n */\r\nexport async function captureEquirectangularFromScene(scene: Scene, options: EquiRectangularCaptureOptions): Promise<ArrayBufferView | null> {\r\n const probe: ReflectionProbe = options.probe ?? new ReflectionProbe(\"tempProbe\", options.size, scene);\r\n const wasProbeProvided = !!options.probe;\r\n if (!wasProbeProvided) {\r\n if (options.position) {\r\n probe.position = options.position.clone();\r\n } else if (scene.activeCamera) {\r\n probe.position = scene.activeCamera.position.clone();\r\n }\r\n }\r\n const meshesToConsider = options.meshesFilter ? scene.meshes.filter(options.meshesFilter) : scene.meshes;\r\n probe.renderList?.push(...meshesToConsider);\r\n probe.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;\r\n probe.cubeTexture.render();\r\n const dumpTexture = new CustomProceduralTexture(\"tempProceduralTexture\", \"equirectangularPanorama\", { width: options.size * 2, height: options.size }, scene);\r\n dumpTexture.setTexture(\"cubeMap\", probe.cubeTexture);\r\n return new Promise((resolve, reject) => {\r\n dumpTexture.onGeneratedObservable.addOnce(() => {\r\n const pixelDataPromise = dumpTexture.readPixels();\r\n if (!pixelDataPromise) {\r\n reject(new Error(\"No Pixel Data found on procedural texture\"));\r\n dumpTexture.dispose();\r\n if (!wasProbeProvided) {\r\n probe.dispose();\r\n }\r\n return;\r\n }\r\n pixelDataPromise.then((pixelData) => {\r\n dumpTexture.dispose();\r\n if (!wasProbeProvided) {\r\n probe.dispose();\r\n }\r\n if (options.filename) {\r\n DumpTools.DumpData(options.size * 2, options.size, pixelData, undefined, \"image/png\", options.filename);\r\n resolve(null);\r\n } else {\r\n resolve(pixelData);\r\n }\r\n });\r\n });\r\n });\r\n}\r\n"]}
|
package/Misc/index.d.ts
CHANGED
package/Misc/index.js
CHANGED
package/Misc/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,iCAAiC,CAAC;AAChD,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,yCAAyC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./andOrNotEvaluator\";\r\nexport * from \"./assetsManager\";\r\nexport * from \"./basis\";\r\nexport * from \"./dds\";\r\nexport * from \"./decorators\";\r\nexport * from \"./deferred\";\r\nexport * from \"./environmentTextureTools\";\r\nexport * from \"./meshExploder\";\r\nexport * from \"./filesInput\";\r\nexport * from \"./HighDynamicRange/index\";\r\nexport * from \"./khronosTextureContainer\";\r\nexport * from \"./observable\";\r\nexport * from \"./observable.extensions\";\r\nexport * from \"./performanceMonitor\";\r\nexport * from \"./sceneOptimizer\";\r\nexport * from \"./sceneSerializer\";\r\nexport * from \"./smartArray\";\r\nexport * from \"./stringDictionary\";\r\nexport * from \"./tags\";\r\nexport * from \"./textureTools\";\r\nexport * from \"./tga\";\r\nexport * from \"./tools\";\r\nexport * from \"./videoRecorder\";\r\nexport * from \"./virtualJoystick\";\r\nexport * from \"./workerPool\";\r\nexport * from \"./logger\";\r\nexport * from \"./typeStore\";\r\nexport * from \"./filesInputStore\";\r\nexport * from \"./deepCopier\";\r\nexport * from \"./pivotTools\";\r\nexport * from \"./precisionDate\";\r\nexport * from \"./screenshotTools\";\r\nexport * from \"./webRequest\";\r\nexport * from \"./iInspectable\";\r\nexport * from \"./brdfTextureTools\";\r\nexport * from \"./rgbdTextureTools\";\r\nexport * from \"./gradients\";\r\nexport * from \"./perfCounter\";\r\nexport * from \"./fileRequest\";\r\nexport * from \"./customAnimationFrameRequester\";\r\nexport * from \"./retryStrategy\";\r\nexport * from \"./interfaces/screenshotSize\";\r\nexport * from \"./interfaces/iPerfViewer\";\r\nexport * from \"./fileTools\";\r\nexport * from \"./stringTools\";\r\nexport * from \"./dataReader\";\r\nexport * from \"./minMaxReducer\";\r\nexport * from \"./depthReducer\";\r\nexport * from \"./dataStorage\";\r\nexport * from \"./sceneRecorder\";\r\nexport * from \"./khronosTextureContainer2\";\r\nexport * from \"./trajectoryClassifier\";\r\nexport * from \"./timer\";\r\nexport * from \"./copyTools\";\r\nexport * from \"./reflector\";\r\nexport * from \"./domManagement\";\r\nexport * from \"./pressureObserverWrapper\";\r\nexport * from \"./PerformanceViewer/index\";\r\nexport * from \"./coroutine\";\r\nexport * from \"./guid\";\r\nexport * from \"./error\";\r\n// eslint-disable-next-line import/export\r\nexport * from \"./observableCoroutine\";\r\nexport * from \"./copyTextureToTexture\";\r\nexport * from \"./dumpTools\";\r\nexport * from \"./greasedLineTools\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY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;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,yCAAyC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./andOrNotEvaluator\";\r\nexport * from \"./assetsManager\";\r\nexport * from \"./basis\";\r\nexport * from \"./dds\";\r\nexport * from \"./decorators\";\r\nexport * from \"./deferred\";\r\nexport * from \"./environmentTextureTools\";\r\nexport * from \"./meshExploder\";\r\nexport * from \"./filesInput\";\r\nexport * from \"./HighDynamicRange/index\";\r\nexport * from \"./khronosTextureContainer\";\r\nexport * from \"./observable\";\r\nexport * from \"./observable.extensions\";\r\nexport * from \"./performanceMonitor\";\r\nexport * from \"./sceneOptimizer\";\r\nexport * from \"./sceneSerializer\";\r\nexport * from \"./smartArray\";\r\nexport * from \"./stringDictionary\";\r\nexport * from \"./tags\";\r\nexport * from \"./textureTools\";\r\nexport * from \"./tga\";\r\nexport * from \"./tools\";\r\nexport * from \"./videoRecorder\";\r\nexport * from \"./virtualJoystick\";\r\nexport * from \"./workerPool\";\r\nexport * from \"./logger\";\r\nexport * from \"./typeStore\";\r\nexport * from \"./filesInputStore\";\r\nexport * from \"./deepCopier\";\r\nexport * from \"./pivotTools\";\r\nexport * from \"./precisionDate\";\r\nexport * from \"./screenshotTools\";\r\nexport * from \"./webRequest\";\r\nexport * from \"./iInspectable\";\r\nexport * from \"./brdfTextureTools\";\r\nexport * from \"./rgbdTextureTools\";\r\nexport * from \"./gradients\";\r\nexport * from \"./perfCounter\";\r\nexport * from \"./fileRequest\";\r\nexport * from \"./customAnimationFrameRequester\";\r\nexport * from \"./retryStrategy\";\r\nexport * from \"./interfaces/screenshotSize\";\r\nexport * from \"./interfaces/iPerfViewer\";\r\nexport * from \"./fileTools\";\r\nexport * from \"./stringTools\";\r\nexport * from \"./dataReader\";\r\nexport * from \"./minMaxReducer\";\r\nexport * from \"./depthReducer\";\r\nexport * from \"./dataStorage\";\r\nexport * from \"./sceneRecorder\";\r\nexport * from \"./khronosTextureContainer2\";\r\nexport * from \"./trajectoryClassifier\";\r\nexport * from \"./timer\";\r\nexport * from \"./copyTools\";\r\nexport * from \"./reflector\";\r\nexport * from \"./domManagement\";\r\nexport * from \"./pressureObserverWrapper\";\r\nexport * from \"./PerformanceViewer/index\";\r\nexport * from \"./coroutine\";\r\nexport * from \"./guid\";\r\nexport * from \"./error\";\r\n// eslint-disable-next-line import/export\r\nexport * from \"./observableCoroutine\";\r\nexport * from \"./copyTextureToTexture\";\r\nexport * from \"./dumpTools\";\r\nexport * from \"./greasedLineTools\";\r\nexport * from \"./equirectangularCapture\";\r\n"]}
|
|
@@ -195,6 +195,7 @@ export declare class SolidParticleSystem implements IDisposable {
|
|
|
195
195
|
* @returns the created mesh
|
|
196
196
|
*/
|
|
197
197
|
buildMesh(): Mesh;
|
|
198
|
+
private _getUVKind;
|
|
198
199
|
/**
|
|
199
200
|
* Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
|
|
200
201
|
* These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
|
|
@@ -204,10 +205,12 @@ export declare class SolidParticleSystem implements IDisposable {
|
|
|
204
205
|
* {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
|
|
205
206
|
* {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
|
|
206
207
|
* {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
|
|
208
|
+
* {uvKind} (optional positive integer, default 0) is the kind of UV to read from. Use -1 to deduce it from the diffuse/albedo texture (if any) of the mesh material
|
|
207
209
|
* @param options.facetNb
|
|
208
210
|
* @param options.number
|
|
209
211
|
* @param options.delta
|
|
210
212
|
* @param options.storage
|
|
213
|
+
* @param options.uvKind
|
|
211
214
|
* @returns the current SPS
|
|
212
215
|
*/
|
|
213
216
|
digest(mesh: Mesh, options?: {
|
|
@@ -215,6 +218,7 @@ export declare class SolidParticleSystem implements IDisposable {
|
|
|
215
218
|
number?: number;
|
|
216
219
|
delta?: number;
|
|
217
220
|
storage?: [];
|
|
221
|
+
uvKind?: number;
|
|
218
222
|
}): SolidParticleSystem;
|
|
219
223
|
/**
|
|
220
224
|
* Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
|
|
@@ -238,6 +238,18 @@ export class SolidParticleSystem {
|
|
|
238
238
|
this._recomputeInvisibles = true;
|
|
239
239
|
return this.mesh;
|
|
240
240
|
}
|
|
241
|
+
_getUVKind(mesh, uvKind) {
|
|
242
|
+
var _a, _b;
|
|
243
|
+
if (uvKind === -1) {
|
|
244
|
+
if ((_a = mesh.material) === null || _a === void 0 ? void 0 : _a.diffuseTexture) {
|
|
245
|
+
uvKind = mesh.material.diffuseTexture.coordinatesIndex;
|
|
246
|
+
}
|
|
247
|
+
else if ((_b = mesh.material) === null || _b === void 0 ? void 0 : _b.albedoTexture) {
|
|
248
|
+
uvKind = mesh.material.albedoTexture.coordinatesIndex;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return "uv" + (uvKind ? uvKind + 1 : "");
|
|
252
|
+
}
|
|
241
253
|
/**
|
|
242
254
|
* Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
|
|
243
255
|
* These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
|
|
@@ -247,19 +259,22 @@ export class SolidParticleSystem {
|
|
|
247
259
|
* {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
|
|
248
260
|
* {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
|
|
249
261
|
* {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
|
|
262
|
+
* {uvKind} (optional positive integer, default 0) is the kind of UV to read from. Use -1 to deduce it from the diffuse/albedo texture (if any) of the mesh material
|
|
250
263
|
* @param options.facetNb
|
|
251
264
|
* @param options.number
|
|
252
265
|
* @param options.delta
|
|
253
266
|
* @param options.storage
|
|
267
|
+
* @param options.uvKind
|
|
254
268
|
* @returns the current SPS
|
|
255
269
|
*/
|
|
256
270
|
digest(mesh, options) {
|
|
271
|
+
var _a;
|
|
257
272
|
let size = (options && options.facetNb) || 1;
|
|
258
273
|
let number = (options && options.number) || 0;
|
|
259
274
|
let delta = (options && options.delta) || 0;
|
|
260
275
|
const meshPos = mesh.getVerticesData(VertexBuffer.PositionKind);
|
|
261
276
|
const meshInd = mesh.getIndices();
|
|
262
|
-
const meshUV = mesh.getVerticesData(
|
|
277
|
+
const meshUV = mesh.getVerticesData(this._getUVKind(mesh, (_a = options === null || options === void 0 ? void 0 : options.uvKind) !== null && _a !== void 0 ? _a : 0));
|
|
263
278
|
const meshCol = mesh.getVerticesData(VertexBuffer.ColorKind);
|
|
264
279
|
const meshNor = mesh.getVerticesData(VertexBuffer.NormalKind);
|
|
265
280
|
const storage = options && options.storage ? options.storage : null;
|