Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 50 additions & 34 deletions examples/jsm/renderers/common/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,27 @@ class Renderer {

if ( this._initialized === false ) await this.init();

const renderContext = this._renderContext( scene, camera );

await this.backend.resolveTimestampAsync( renderContext, 'render' );

}

render( scene, camera ) {

if ( this._initialized === false ) {

console.error( 'THREE.Renderer: .render() called before the backend is initialized. Try using .renderAsync() instead.' );
return;

}

this._renderContext( scene, camera );

}

_renderContext( scene, camera ) {

// preserve render tree

const nodeFrame = this._nodes.nodeFrame;
Expand Down Expand Up @@ -486,8 +507,9 @@ class Renderer {

sceneRef.onAfterRender( this, scene, camera, renderTarget );

//

await this.backend.resolveTimestampAsync( renderContext, 'render' );
return renderContext;

}

Expand Down Expand Up @@ -737,9 +759,7 @@ class Renderer {

}

async clearAsync( color = true, depth = true, stencil = true ) {

if ( this._initialized === false ) await this.init();
clear( color = true, depth = true, stencil = true ) {

let renderTargetData = null;
const renderTarget = this._renderTarget;
Expand All @@ -756,6 +776,32 @@ class Renderer {

}

clearColor() {

return this.clear( true, false, false );

}

clearDepth() {

return this.clear( false, true, false );

}

clearStencil() {

return this.clear( false, false, true );

}

async clearAsync( color = true, depth = true, stencil = true ) {

if ( this._initialized === false ) await this.init();

this.clear( color, depth, stencil );

}

clearColorAsync() {

return this.clearAsync( true, false, false );
Expand Down Expand Up @@ -1253,36 +1299,6 @@ class Renderer {

}

get render() {

return this.renderAsync;

}

get clear() {

return this.clearAsync;

}

get clearColor() {

return this.clearColorAsync;

}

get clearDepth() {

return this.clearDepthAsync;

}

get clearStencil() {

return this.clearStencilAsync;

}

}

export default Renderer;
2 changes: 1 addition & 1 deletion examples/webgpu_compute_texture.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@

function render() {

renderer.render( scene, camera );
renderer.renderAsync( scene, camera );

}

Expand Down
2 changes: 1 addition & 1 deletion examples/webgpu_loader_gltf.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@

function render() {

renderer.render( scene, camera );
renderer.renderAsync( scene, camera );

}

Expand Down
1 change: 0 additions & 1 deletion examples/webgpu_mirror.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
let sphereGroup, smallSphere;

init();
animate();

function init() {

Expand Down