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

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

Open
dataexcess opened this issue Nov 24, 2022 · 1 comment
Open

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

dataexcess opened this issue Nov 24, 2022 · 1 comment

Comments

@dataexcess
Copy link

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
Copy link
Author

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

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