import * as React from "react"; import { PaneComponent, IPaneComponentProps } from "../paneComponent"; import { TextLineComponent } from "../lines/textLineComponent"; import { LineContainerComponent } from "../lineContainerComponent"; import { SceneInstrumentation, EngineInstrumentation, Nullable } from "babylonjs"; import { ValueLineComponent } from "../lines/valueLineComponent"; import { BooleanLineComponent } from "../lines/booleanLineComponent"; export class StatisticsTabComponent extends PaneComponent { private _sceneInstrumentation: Nullable; private _engineInstrumentation: Nullable; private _timerIntervalId: number; constructor(props: IPaneComponentProps) { super(props); } componentWillMount() { const scene = this.props.scene; if (!scene) { return; } this._sceneInstrumentation = new BABYLON.SceneInstrumentation(scene); this._sceneInstrumentation.captureActiveMeshesEvaluationTime = true; this._sceneInstrumentation.captureRenderTargetsRenderTime = true; this._sceneInstrumentation.captureFrameTime = true; this._sceneInstrumentation.captureRenderTime = true; this._sceneInstrumentation.captureInterFrameTime = true; this._sceneInstrumentation.captureParticlesRenderTime = true; this._sceneInstrumentation.captureSpritesRenderTime = true; this._sceneInstrumentation.capturePhysicsTime = true; this._sceneInstrumentation.captureAnimationsTime = true; this._engineInstrumentation = new BABYLON.EngineInstrumentation(scene.getEngine()); this._engineInstrumentation.captureGPUFrameTime = true; this._timerIntervalId = window.setInterval(() => this.forceUpdate(), 500); } componentWillUnmount() { if (this._sceneInstrumentation) { this._sceneInstrumentation.dispose(); this._sceneInstrumentation = null; } if (this._engineInstrumentation) { this._engineInstrumentation.dispose(); this._engineInstrumentation = null; } window.clearInterval(this._timerIntervalId); } render() { const scene = this.props.scene; if (!scene || !this._sceneInstrumentation || !this._engineInstrumentation) { return null; } const engine = scene.getEngine(); const sceneInstrumentation = this._sceneInstrumentation; const engineInstrumentation = this._engineInstrumentation; const caps = engine.getCaps(); return (
); } }