Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

render.calls is always 0 #42

Open
davcri opened this issue Apr 13, 2023 · 0 comments
Open

render.calls is always 0 #42

davcri opened this issue Apr 13, 2023 · 0 comments

Comments

@davcri
Copy link

davcri commented Apr 13, 2023

Issue

https://codesandbox.io/s/r3f-perf-issue-with-gl-0do0bm

const perf = getPerf()
console.log(perf.gl?.info.render.calls) // 0
console.log(perf.gl?.info.render.triangles) // 0

I think this is because of the gl.info.reset() in https://github.com/utsuboco/r3f-perf/blob/main/src/components/PerfHeadless.tsx#L262

Possible fix

Could we save render.calls and render.triangles in the store? In this way we don't break code which relies on that number.

Possible workaround

const info = usePerf((state) => state.gl?.info)
    
useFrame((state) => {
    const { camera, gl, scene } = state
    gl.render(scene, camera)
    console.log(info.render.frames) 
}, 1)

I'm not sure though if this can cause some issue. Do gl.render() gets called twice in this way? Once for useFrame(...,1) and then for useFrame(..., Infinity)?

const Renderer = () =>{
useFrame(function updateR3FPerf({ gl, scene, camera }) {
camera.updateMatrix()
matriceCount.value -= 1
camera.matrixWorld.copy(camera.matrix)
camera.matrixWorldInverse.copy(camera.matrixWorld).invert();
gl.render(scene,camera)
matriceWorldCount.value = 0
matriceCount.value = 0
}, Infinity)
return null
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant