#Grid Highliting
2 messages · Page 1 of 1 (latest)
I think i've figured it out!
This post helped, but I didn't quite understand it at first: https://discourse.threejs.org/t/where-can-i-see-the-number-of-draw-calls-per-frame/4311/3
The solution in short is to disable autoReset and manually reset info at the beginning/end of each frame respectively - like so:
<>
<Canvas>
<BeginFrame />
<YourScene />
<EndFrame />
</Canvas>
<t.Out />
</>
BeginFrame:
export const BeginFrame = () => {
useFrame(({ gl: { info } }) => {
info.autoReset = false;
});
return null;
};
End Frame:
export const EndFrame = () => {
const [geometries, setGeometries] = useState(0);
const [textures, setTextures] = useState(0);
const [calls, setCalls] = useState(0);
useFrame(({ gl: { info } }) => {
info.memory.geometries !== geometries ? setGeometries(info.memory.geometries) : null;
info.memory.textures !== textures ? setTextures(info.memory.textures) : null;
info.render.calls !== calls ? setCalls(info.render.calls) : null;
info.reset();
}, 999);
return (
<t.In>
<ul className="absolute top-4 right-4 bg-gray-800 text-white">
<li>Geometries: {geometries}</li>
<li>Textures: {textures}</li>
<li>Calls: {calls}</li>
</ul>
</t.In>
);
};
three.js forum
It should be renderer.info.render.calls. It reports the amount of draw calls for a single render call. If you have multiple calls of WebGLRenderer.render() in order to produce a single frame, you need to set renderer.info.autoReset to false and call renderer.info.reset() manually at the end of your frame.