Report the backend that is actually in use

The viewer's readout took `navigator.gpu ? 'WebGPU' : 'WebGL2 (fallback)'`,
which is the browser's CAPABILITY and not the backend the renderer settled on.
The two agree in every ordinary case, which is exactly why it would have gone
on being wrong indefinitely.

It came up while checking what a visitor without WebGPU actually gets from the
page, since that page is meant to be published and Safari and Firefox only got
WebGPU recently. Forcing the WebGL2 path, the readout went on saying WebGPU
throughout. It now asks the renderer, and forcing the path again proves it:
with `navigator.gpu` still present it correctly reads WebGL2 (fallback). One
line, and it is the only signal anyone has about which path they are on — a
readout that can be wrong is worse than none.

The check itself was worth more than the fix. The whole viewer works on the
WebGL2 backend, `@scifi-kit`'s TSL node materials included: the gauge renders
with its emissive dial and its brass intact, and the console is clean. So the
README's warning was wrong in the direction that costs you readers — it told
people they needed WebGPU to run the viewer, when only the separate demo app
insists on it.

Also: the comment above the showcase buttons still did its arithmetic for 27
models. Same class of thing as the stale README numbers, in a place
`check-docs` cannot see, so it now names all three durations and says why 90 s
exists.
This commit is contained in:
CRTkafa 2026-08-27 01:43:57 +07:00
parent 5e390bcc85
commit d6c76dae32
2 changed files with 22 additions and 8 deletions

View file

@ -20,8 +20,10 @@ and edit, not an asset you load.
## Run the viewer ## Run the viewer
Requires [Bun](https://bun.sh) and a browser with WebGPU (the `@scifi-kit` model Requires [Bun](https://bun.sh). The viewer runs on WebGPU where the browser has
in the demo uses TSL node materials; the medieval kit itself does not). it and falls back to three's own WebGL2 backend where it does not — including
for `@scifi-kit`'s TSL node materials, which compile on both paths. Only the
separate demo app at `/` insists on WebGPU.
```sh ```sh
bun install bun install

View file

@ -118,11 +118,12 @@ app.innerHTML = `
60 s is the default, not 30. 60 s is the default, not 30.
The tour gives every model an equal share of the running time, so The tour gives every model an equal share of the running time, so
with 27 of them 30 s is 1.1 s each. A beat spends that time sweeping across 35 of them 30 s is 0.86 s each, 60 s is 1.7 and 90 s is 2.6.
its parameters and stepping its counts, and none of it reads in a A beat spends its time sweeping the parameters and stepping the
second: the 30 s run is a flyby of the kit, while 60 s is the one counts, and none of that reads in under a second: the 30 s run is a
that actually shows what each model can do. The order and the flyby of the kit, 60 s is the one that shows what each model can do,
emphasis say so. and 90 s is there because that share shrinks every time a model is
added. The order and the emphasis say so.
--> -->
<button class="action action-primary" type="button" data-showcase="60"> <button class="action action-primary" type="button" data-showcase="60">
<span>Play 60 s tour</span><span class="state">&#9654;</span> <span>Play 60 s tour</span><span class="state">&#9654;</span>
@ -191,7 +192,18 @@ renderer.setPixelRatio(Math.min(globalThis.devicePixelRatio, 2))
renderer.shadowMap.enabled = true renderer.shadowMap.enabled = true
renderer.shadowMap.type = PCFSoftShadowMap renderer.shadowMap.type = PCFSoftShadowMap
const backend = navigator.gpu ? 'WebGPU' : 'WebGL2 (fallback)' // Asked of the renderer, not of the browser.
//
// This read `navigator.gpu ? 'WebGPU' : 'WebGL2 (fallback)'`, which is the
// browser's CAPABILITY and not the backend that ended up being used. Forcing
// the WebGL2 path to see what a visitor without WebGPU gets, the readout went
// on saying WebGPU throughout. The two agree in every ordinary case, which is
// exactly why it would have gone on lying: this line is the only signal anyone
// has about which path they are on, and a readout that can be wrong is worse
// than none.
const backend = (renderer.backend as { isWebGPUBackend?: boolean }).isWebGPUBackend
? 'WebGPU'
: 'WebGL2 (fallback)'
readout('backend').textContent = backend readout('backend').textContent = backend
const scene = new Scene() const scene = new Scene()