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

Backend: Add this.isWeb*Backend #26877

Merged
merged 1 commit into from
Oct 1, 2023
Merged

Backend: Add this.isWeb*Backend #26877

merged 1 commit into from
Oct 1, 2023

Conversation

WestLangley
Copy link
Collaborator

I want to know which Backend is running. Maybe there is a better way...

console.log( 'renderer.backend: ', renderer.backend.isWebGLBackend ? 'WebGLBackend' : 'WebGPUBackend' );
@sunag sunag added this to the r158 milestone Sep 30, 2023
@sunag sunag merged commit 8581f79 into mrdoob:dev Oct 1, 2023
18 checks passed
@sunag
Copy link
Collaborator

sunag commented Oct 1, 2023

Another alternative could be using renderer.coordinateSystem.

@WestLangley WestLangley deleted the dev-backend branch October 1, 2023 00:12
@WestLangley
Copy link
Collaborator Author

How would you describe what camera.coordinateSystem represents?

renderer.backend:  WebGPUBackend
renderer.coordinateSystem:  2001
camera.coordinateSystem:  2000
@sunag
Copy link
Collaborator

sunag commented Oct 1, 2023

This happens because the default value of camera.coordinateSystem is WebGLCoordinateSystem, after the first rendering this value is updated for the chosen backend.

const coordinateSystem = this.coordinateSystem;
if ( camera.coordinateSystem !== coordinateSystem ) {
camera.coordinateSystem = coordinateSystem;
camera.updateProjectionMatrix();
}

@WestLangley
Copy link
Collaborator Author

I'm just trying to determine if the design may be too fragile... thanks for bearing with me. :-)

Are there any situations in which the renderer must be instantiated prior to the camera -- or the camera prior to the renderer?

@sunag
Copy link
Collaborator

sunag commented Oct 1, 2023

It would not have priority in terms of instantiation, both can be declared before or after, renderer.coordinateSystem will always be the predominant value while camera.coordinateSystem must adapt to the renderer's backend. camera.coordinateSystem should not be recommended as a strong value for backend comparison unlike renderer.coordinateSystem.

It will always be a pleasure for me to refine any stage with you. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants