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

WebGPURenderer: Move .init() to private and added .setAnimationLoop() #24755

Merged
merged 4 commits into from
Oct 13, 2022

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Oct 6, 2022

Description

This is one of the part to maintain backward compatibility between WebGLRenderer and WebGPURenderer.

After initializing the WebGPU Device it will call the setAnimationLoop() callback, but as there are legacy projects that don't use .setAnimationLoop(), the .render() and .compute() function makes a test to verify if the device is available.

const renderer = new WebGPURenderer();

// recommended approach
renderer.setAnimationLoop( animate );

// legacy approach
requestAnimationFrame( animate )

This contribution is funded by Google

@sunag sunag marked this pull request as ready for review October 6, 2022 22:09
@mrdoob
Copy link
Owner

mrdoob commented Oct 7, 2022

Love this!

Would it be possible to initialise webgpu in renderer.render() instead?

That way if someone needed to make sure webgpu was initialised the could call await renderer.init() themselves, but renderer.render() would do it for them automatically.

🤔

@sunag
Copy link
Collaborator Author

sunag commented Oct 9, 2022

Ways to initialize a WebGPU Device.

// 1. Adding an animation loop callback
renderer.setAnimationLoop( animate );

// 2. Async init
renderer.render( scene, camera );
// or
renderer.compute( computeNode );
// or
renderer.init();

// 3. Sync init
await renderer.render( scene, camera );
// or
await renderer.compute( computeNode );
// or
await renderer.init();

@Mugen87 Mugen87 added this to the r146 milestone Oct 10, 2022
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.

None yet

3 participants