From b3e571ac66bdee7e1f5dac640c40983a7f3d935a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Beaufort?= Date: Tue, 1 Oct 2024 13:04:27 +0200 Subject: [PATCH] Use more specific condition --- sample/particles/main.ts | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/sample/particles/main.ts b/sample/particles/main.ts index 3b84b955..1ac2726a 100644 --- a/sample/particles/main.ts +++ b/sample/particles/main.ts @@ -35,7 +35,7 @@ function configureContext() { toneMapping: { mode: simulationParams.toneMappingMode }, alphaMode: 'premultiplied', }); - updateHdrFolderName(); + hdrFolder.name = getHdrFolderName(); } const particlesBuffer = device.createBuffer({ @@ -347,23 +347,24 @@ hdrFolder hdrFolder.add(simulationParams, 'brightnessFactor', 0, 4, 0.1); hdrFolder.open(); const hdrMediaQuery = window.matchMedia('(dynamic-range: high)'); -function updateHdrFolderName() { +function getHdrFolderName() { if (!hdrMediaQuery.matches) { - hdrFolder.name = 'HDR settings ⚠️ Your display is not compatible'; - return; + return "HDR settings ⚠️ Display isn't compatible"; } if (!('getConfiguration' in GPUCanvasContext.prototype)) { - hdrFolder.name = 'HDR settings'; - return; + return 'HDR settings'; } - const configuration = context.getConfiguration(); - const toneMappingModeMatches = - configuration.toneMapping.mode === simulationParams.toneMappingMode; - hdrFolder.name = `HDR settings ${ - toneMappingModeMatches ? '' : "⚠️ Your browser doesn't support HDR canvas" - }`; + if ( + simulationParams.toneMappingMode === 'extended' && + context.getConfiguration().toneMapping.mode !== 'extended' + ) { + return "HDR settings ⚠️ Browser doesn't support HDR canvas"; + } + return 'HDR settings'; } -hdrMediaQuery.onchange = updateHdrFolderName; +hdrMediaQuery.onchange = () => { + hdrFolder.name = getHdrFolderName(); +}; const computePipeline = device.createComputePipeline({ layout: 'auto',