import React, { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import SsidChartIcon from '@mui/icons-material/SsidChart' import { SceneState } from '../../../functions/sceneRenderFunctions' import { InfoTooltip } from '../../layout/Tooltip' import styles from '../styles.module.scss' /** * Stats used to show stats of memory and render. * * @constructor */ const StatsTool = () => { const [info, setInfo] = useState({}) const [isVisible, setVisible] = useState(false) const { t } = useTranslation() useEffect(() => { SceneState.onUpdateStats = (info) => { setInfo({ geometries: info.memory.geometries, textures: info.memory.textures, fps: (info.render as any).fps, frameTime: (info.render as any).frameTime, calls: info.render.calls, triangles: info.render.triangles, points: info.render.points, lines: info.render.lines }) } return () => { SceneState.onUpdateStats = undefined } }, []) const toggleStats = () => { setVisible(!isVisible) } /** * Rendering stats view in ViewportToolbar and shows when click on toggleStats */ return ( <>
{isVisible && (

{t('editor:viewport.state.header')}

{info && ( )}
)} ) } export default StatsTool