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

fix: not change subscribed reference #21

Merged
merged 2 commits into from
May 16, 2022

Conversation

eXponenta
Copy link
Contributor

@eXponenta eXponenta commented May 16, 2022

State MUST store actual reference to subscribed, but unsubscribe produce new Array which will unmatch with same field in state.

I use custom render loop and for me this is critical bug.
I can't use boxed loop because it use requestAnimationFrame from window, that not working in XR mode (XRSession has own requestAnimationFrame that needs to use instead of window.requestAnimationFrame)

	const animate = (time?: number) => {
		state.animation = renderer.requestAnimationFrame(animate);

		// update OGL useFrame
		subscribed.forEach((ref: any) => ref.current?.(state, time));

		// Render to screen
		renderer.render({ scene, camera, frustumCull: false } as any);
	};

	state.animation = renderer.requestAnimationFrame(animate);

State MUST store actual reference to subscribed, but `unsubscribe` produce new Array which will unmatch with same field in state.
@CodyJasonBennett CodyJasonBennett merged commit 8555b0c into pmndrs:main May 16, 2022
@CodyJasonBennett
Copy link
Member

Published this to 0.1.5. Can look into playing nicer with WebXR.

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

Successfully merging this pull request may close these issues.

2 participants