trois icon indicating copy to clipboard operation
trois copied to clipboard

How can we access and use delta of the renderer component?

Open dataexcess opened this issue 3 years ago • 1 comments

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

dataexcess avatar Nov 24 '22 21:11 dataexcess

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)
        })
    }
})

dataexcess avatar Nov 24 '22 22:11 dataexcess