trois
trois copied to clipboard
How can we access and use delta of the renderer component?
Hi There!
I am using custom controls for my camera and I need to pass the delta argument to its update method... how can I find this inside the renderer's onBeforeRender() method?
renderer.value.onBeforeRender(() => {
update( delta ???)
box.value.mesh.rotation.x += 0.01
box.value.mesh.rotation.y += 0.01
})
Thank you
Ok I found it. For anyone wondering this is how you can do it...
let time = 0
onMounted(async () => {
await nextTick()
if (renderer.value !== null) {
renderer.value.onBeforeRender((e:any) => {
const delta = e.time - time
time = e.time
box.value.mesh.rotation.x += 0.01
box.value.mesh.rotation.y += 0.01
update(delta)
})
}
})