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

Examples: Fix WebGPU logarithmic depth buffer demo. #28249

Merged
merged 1 commit into from
May 1, 2024
Merged
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
25 changes: 13 additions & 12 deletions examples/webgpu_camera_logarithmicdepthbuffer.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@
{ size: 1e19, scale: 1.0, label: 'mind boggling (1000 light years)' }
];

init();
init().then( animate );

function init() {
async function init() {

if ( WebGPU.isAvailable() === false && WebGL.isWebGL2Available() === false ) {

Expand All @@ -133,15 +133,13 @@
container = document.getElementById( 'container' );

const loader = new FontLoader();
loader.load( 'fonts/helvetiker_regular.typeface.json', function ( font ) {
const font = await loader.loadAsync( 'fonts/helvetiker_regular.typeface.json' );

const scene = initScene( font );
const scene = initScene( font );

// Initialize two copies of the same scene, one with normal z-buffer and one with logarithmic z-buffer
objects.normal = initView( scene, 'normal', false );
objects.logzbuf = initView( scene, 'logzbuf', true );

} );
// Initialize two copies of the same scene, one with normal z-buffer and one with logarithmic z-buffer
objects.normal = await initView( scene, 'normal', false );
objects.logzbuf = await initView( scene, 'logzbuf', true );

stats = new Stats();
container.appendChild( stats.dom );
Expand All @@ -156,7 +154,7 @@

}

function initView( scene, name, logDepthBuf ) {
async function initView( scene, name, logDepthBuf ) {

const framecontainer = document.getElementById( 'container_' + name );

Expand All @@ -166,11 +164,12 @@
const renderer = new WebGPURenderer( { antialias: true, logarithmicDepthBuffer: logDepthBuf } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( SCREEN_WIDTH / 2, SCREEN_HEIGHT );
renderer.setAnimationLoop( render );
renderer.domElement.style.position = 'relative';
renderer.domElement.id = 'renderer_' + name;
framecontainer.appendChild( renderer.domElement );

await renderer.init();

return { container: framecontainer, renderer: renderer, scene: scene, camera: camera };

}
Expand Down Expand Up @@ -259,7 +258,9 @@

}

function render() {
function animate() {

requestAnimationFrame( animate );

// Put some limits on zooming
const minzoom = labeldata[ 0 ].size * labeldata[ 0 ].scale * 1;
Expand Down
Loading