useFrame losing context. updates stop working. #2290
Unanswered
alazyartist
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am running into issues where the useFrame effects I have running are not updating if I navigate to a different page and back again. Once it loses the Three.WebGLRender context it instantiates a new scene with new Cameras but for some reason the useFrame is no longer updating those.
in debugging i found that when you navigate back to the page it will not update the render to screen but will update the gizmo to use the controls.
my useFrame looks like this. I had all of the variable declarations pulled out but was running into no updates painting to screen.
useFrame(({}) => {
let pos;
pos = hipsRef.current.position;
if (isFollowCam && hipsRef.current && camera) {
let { x, y, z } = pos;
let quat = hipsRef.current.quaternion;
let posArr = [x, y, z];
posArr = posArr.map((p) => p * 0.01);
let vec = new Vector3(posArr[0], 0.5, posArr[1]);
camera.quaternion.set(quat, 0.1);
camera.lookAt(vec, 1);
camera.updateProjectionMatrix();
}
});
Project structure related to this issue is basically
<Sandbox>
<CanvasComponent>
<TorqueScene>
<Frank/>
// <- Source of issue found here.</TorqueScene>
</CanvasComponent
</Sandbox>
Within the model is where I define the useFrame which works great on first load. but any navigation to other parts of the website crash it.
code can be found here -> https://github.com/alazyartist/tricking-3d/tree/tricklist
Specifically these files.
Holds CanvasComponent and styling
https://github.com/alazyartist/tricking-3d/blob/tricklist/frontend/src/pages/Sandbox.js
Defines Canvas and Calls TorqueScene
https://github.com/alazyartist/tricking-3d/blob/tricklist/frontend/src/components/panels/CanvasComponent.js
Fragment returning scene graph. defines Perspective Camera, Orbit Controls, Gizmo Helper and Some lights. Calls Frank
https://github.com/alazyartist/tricking-3d/blob/tricklist/frontend/src/scenes/TorqueScene.js
Source of the problem. Line 48-61
https://github.com/alazyartist/tricking-3d/blob/tricklist/frontend/src/animations/Frank.js
live bug available at https://torquetricking.com/3d/sandbox
bottom left button toggles the followCam
ANY HELP IS APPRECIATED!!! I've read and tried everything I could get my eyes on and cannot find anything that solves this bug. Thanks if you read this!
Beta Was this translation helpful? Give feedback.
All reactions