scene.deltaTime initially undefined?

Not sure what’s going on here as the issue is only evident in my local code and no problem in the PG I created (hover over the viewport center for sphere to appear by Lerping sphere.visibility)

Basically in my local, if I use a fixed value for lerpAmount then no problem, but as soon as I switch to scene.deltaTime then initial values for deltaTime are undefined and the Lerp returns NaN.

On further testing it looks like, on my local only, scene.deltaTime is initially undefined. I wouldn’t have expected this inside either a scene.registerBeforeRender or scene.registerAfterRender callback?

I just realised that, in my local code, I’m setting up this Lerp after scene instantiation but before first render, so it makes sense that scene.deltaTime may be undefined.

Yes, and also note that deltaTime is defined only if you have enabled animations (scene.animationsEnabled, which is true by default).

1 Like