@null3d/engine 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +109 -0
- package/THIRD-PARTY-NOTICES.txt +0 -1
- package/dist/wasm/single/null3d.js +19 -6
- package/dist/wasm/single/null3d_bg.wasm +0 -0
- package/dist/wasm/threaded/null3d.js +19 -6
- package/dist/wasm/threaded/null3d_bg.wasm +0 -0
- package/docs/api/animation.md +23 -67
- package/docs/api/assets.md +42 -26
- package/docs/api/cameras.md +8 -6
- package/docs/api/controls.md +46 -44
- package/docs/api/debug.md +13 -8
- package/docs/api/engine.md +17 -11
- package/docs/api/feature-draws.md +3 -3
- package/docs/api/feature-effects.md +3 -3
- package/docs/api/feature-instances.md +2 -2
- package/docs/api/features.md +14 -15
- package/docs/api/geometry.md +56 -75
- package/docs/api/grass.md +1 -1
- package/docs/api/impostors.md +120 -9
- package/docs/api/input.md +4 -11
- package/docs/api/lights.md +14 -38
- package/docs/api/lines.md +8 -25
- package/docs/api/materials.md +69 -70
- package/docs/api/math.md +6 -7
- package/docs/api/objects.md +13 -13
- package/docs/api/particles.md +2 -14
- package/docs/api/points.md +3 -25
- package/docs/api/post.md +22 -23
- package/docs/api/quality.md +11 -6
- package/docs/api/raycast.md +13 -32
- package/docs/api/reference/animation.md +9 -9
- package/docs/api/reference/assets.md +18 -18
- package/docs/api/reference/cameras.md +5 -2
- package/docs/api/reference/controls.md +75 -23
- package/docs/api/reference/debug.md +23 -8
- package/docs/api/reference/engine.md +22 -10
- package/docs/api/reference/geometry.md +161 -82
- package/docs/api/reference/grass.md +1 -1
- package/docs/api/reference/impostors.md +92 -1
- package/docs/api/reference/input.md +3 -3
- package/docs/api/reference/lights.md +9 -9
- package/docs/api/reference/lines.md +7 -7
- package/docs/api/reference/materials.md +48 -48
- package/docs/api/reference/math.md +22 -22
- package/docs/api/reference/objects.md +9 -9
- package/docs/api/reference/points.md +4 -4
- package/docs/api/reference/post.md +18 -18
- package/docs/api/reference/quality.md +7 -3
- package/docs/api/reference/raycast.md +6 -6
- package/docs/api/reference/render.md +2 -2
- package/docs/api/reference/scene.md +29 -26
- package/docs/api/reference/sketch.md +4 -0
- package/docs/api/reference/sound.md +203 -0
- package/docs/api/reference/sprites.md +5 -5
- package/docs/api/reference/terrain.md +2 -1
- package/docs/api/reference/textures.md +4 -4
- package/docs/api/reference/ui.md +3 -3
- package/docs/api/reference/vertex-draws.md +3 -3
- package/docs/api/reference/water.md +77 -6
- package/docs/api/reference/wind.md +2 -2
- package/docs/api/render.md +12 -10
- package/docs/api/scene.md +40 -29
- package/docs/api/sketch.md +64 -3
- package/docs/api/sound.md +169 -0
- package/docs/api/splats.md +7 -0
- package/docs/api/sprites.md +4 -20
- package/docs/api/tasks.md +2 -2
- package/docs/api/terrain.md +2 -14
- package/docs/api/textures.md +9 -9
- package/docs/api/ui.md +3 -15
- package/docs/api/water.md +198 -15
- package/docs/api/wind.md +5 -5
- package/docs/cli/null3d.md +93 -18
- package/docs/concepts/architecture.md +10 -10
- package/docs/concepts/assets.md +2 -19
- package/docs/concepts/backends.md +7 -5
- package/docs/concepts/color-management.md +15 -26
- package/docs/concepts/culling.md +1 -1
- package/docs/concepts/instances.md +5 -5
- package/docs/concepts/large-worlds.md +1 -1
- package/docs/concepts/lighting.md +50 -55
- package/docs/concepts/lod.md +2 -15
- package/docs/concepts/materials.md +16 -16
- package/docs/concepts/post-processing.md +7 -29
- package/docs/concepts/quality-preset-tables.md +53 -50
- package/docs/concepts/quality-presets.md +56 -27
- package/docs/concepts/render-graph.md +19 -14
- package/docs/concepts/render-layers.md +3 -17
- package/docs/concepts/shadows.md +10 -28
- package/docs/concepts/static-dynamic.md +2 -2
- package/docs/cookbook/index.md +1 -1
- package/docs/data/threejs-mapping.json +136 -102
- package/docs/errors/E1214.md +3 -3
- package/docs/errors/E1307.md +23 -0
- package/docs/errors/E1420.md +3 -3
- package/docs/errors/index.md +3 -2
- package/docs/getting-started/cdn.md +17 -1
- package/docs/getting-started/first-scene.md +1 -1
- package/docs/getting-started/hosting.md +50 -9
- package/docs/getting-started/install.md +8 -7
- package/docs/getting-started/network-use.md +10 -2
- package/docs/getting-started/project-structure.md +15 -6
- package/docs/getting-started/third-party-notices.md +8 -6
- package/docs/guides/accessibility.md +1 -1
- package/docs/guides/add-ons.md +3 -2
- package/docs/guides/agents.md +16 -5
- package/docs/guides/assets-pipeline.md +13 -12
- package/docs/guides/audio.md +109 -124
- package/docs/guides/car-paint.md +1 -1
- package/docs/guides/content-pages.md +10 -6
- package/docs/guides/custom-passes.md +9 -8
- package/docs/guides/custom-shaders.md +6 -3
- package/docs/guides/debugging.md +78 -4
- package/docs/guides/deploying.md +105 -5
- package/docs/guides/deterministic-simulation.md +1 -1
- package/docs/guides/first-use-shaders.md +4 -4
- package/docs/guides/loading-screens.md +78 -33
- package/docs/guides/multiple-views.md +41 -2
- package/docs/guides/performance.md +6 -3
- package/docs/guides/phones.md +12 -1
- package/docs/guides/physics.md +1 -1
- package/docs/guides/screens.md +7 -5
- package/docs/guides/start-time.md +328 -0
- package/docs/guides/testing.md +23 -5
- package/docs/guides/ui-overlays.md +3 -3
- package/docs/index.md +12 -8
- package/docs/pages.md +26 -23
- package/docs/porting/react-three-fiber.md +228 -5
- package/docs/porting/threejs-loop-and-threads.md +220 -6
- package/docs/porting/threejs-mapping.md +86 -84
- package/docs/porting/threejs-materials.md +212 -5
- package/docs/porting/threejs-overview.md +218 -5
- package/docs/porting/threejs-postprocessing.md +2 -2
- package/docs/porting/threejs-shaders.md +298 -5
- package/docs/porting/threejs-unsupported.md +82 -6
- package/docs/porting/verification.md +181 -5
- package/docs/shaders/builtins.md +1 -1
- package/docs/shaders/library.md +63 -39
- package/docs/shaders/surface-functions.md +11 -10
- package/docs/shaders/wgsl-rules.md +1 -1
- package/lib/debug/channel.d.ts +103 -0
- package/lib/debug/channel.js +269 -0
- package/lib/debug/debug.d.ts +9 -7
- package/lib/debug/draw.d.ts +9 -0
- package/lib/debug/draw.js +49 -2
- package/lib/debug/inspector.d.ts +60 -0
- package/lib/debug/inspector.js +475 -0
- package/lib/debug/stats-panel.d.ts +1 -1
- package/lib/debug/stats.d.ts +2 -3
- package/lib/errors/codes.js +8 -2
- package/lib/errors/engine-error.js +25 -10
- package/lib/errors/fixes.d.ts +1 -0
- package/lib/errors/fixes.js +3 -2
- package/lib/generated/core.d.ts +1 -1
- package/lib/generated/core.js +1 -1
- package/lib/gpu/early-builds.d.ts +68 -0
- package/lib/gpu/early-builds.js +158 -0
- package/lib/gpu/pipeline-name.d.ts +6 -0
- package/lib/gpu/pipeline-name.js +23 -0
- package/lib/gpu/webgl2/backend.d.ts +63 -2
- package/lib/gpu/webgl2/backend.js +226 -8
- package/lib/gpu/webgl2/programs.d.ts +18 -0
- package/lib/gpu/webgl2/programs.js +4 -1
- package/lib/gpu/webgpu/backend.d.ts +89 -2
- package/lib/gpu/webgpu/backend.js +255 -8
- package/lib/gpu/webgpu/pipelines.d.ts +13 -0
- package/lib/gpu/webgpu/pipelines.js +15 -1
- package/lib/index.d.ts +6 -4
- package/lib/index.js +3 -2
- package/lib/math/color.d.ts +5 -5
- package/lib/math/color.js +5 -5
- package/lib/math/mat4.d.ts +6 -12
- package/lib/math/mat4.js +6 -12
- package/lib/math/namespaces/quat.d.ts +3 -3
- package/lib/math/namespaces/quat.js +3 -3
- package/lib/math/quat.d.ts +8 -12
- package/lib/math/quat.js +8 -12
- package/lib/math/random.d.ts +2 -3
- package/lib/math/random.js +2 -3
- package/lib/math/types.d.ts +4 -4
- package/lib/math/vec3.d.ts +3 -6
- package/lib/math/vec3.js +3 -6
- package/lib/page/capabilities.d.ts +7 -7
- package/lib/page/capabilities.js +39 -25
- package/lib/page/check-store.d.ts +14 -2
- package/lib/page/check-store.js +34 -11
- package/lib/page/engine.d.ts +103 -26
- package/lib/page/engine.js +420 -97
- package/lib/page/first-frame.d.ts +16 -0
- package/lib/page/first-frame.js +35 -0
- package/lib/page/frame-stats.d.ts +34 -1
- package/lib/page/frame-stats.js +15 -0
- package/lib/page/label-loop.d.ts +7 -3
- package/lib/page/label-loop.js +17 -10
- package/lib/page/labels.d.ts +3 -3
- package/lib/page/pipeline-store.d.ts +25 -0
- package/lib/page/pipeline-store.js +84 -0
- package/lib/page/start-marker.d.ts +4 -1
- package/lib/page/start-marker.js +5 -2
- package/lib/page/switches.d.ts +32 -2
- package/lib/page/switches.js +9 -1
- package/lib/quality/check.d.ts +24 -3
- package/lib/quality/check.js +21 -7
- package/lib/quality/chooser.d.ts +6 -0
- package/lib/quality/chooser.js +8 -0
- package/lib/quality/governor.d.ts +98 -6
- package/lib/quality/governor.js +250 -20
- package/lib/quality/preset-docs.d.ts +16 -1
- package/lib/quality/preset-docs.js +3 -0
- package/lib/quality/presets.d.ts +84 -7
- package/lib/quality/presets.js +94 -2
- package/lib/render/draw.d.ts +3 -2
- package/lib/render/draw.js +15 -5
- package/lib/render/load-draw.d.ts +7 -5
- package/lib/render/load-draw.js +7 -5
- package/lib/render/loss.d.ts +28 -10
- package/lib/render/loss.js +50 -22
- package/lib/render/recovery.d.ts +20 -0
- package/lib/render/recovery.js +44 -4
- package/lib/render/renderer.d.ts +85 -9
- package/lib/render/renderer.js +181 -42
- package/lib/render/scene-renderer.d.ts +19 -1
- package/lib/render/scene-renderer.js +25 -1
- package/lib/render/webgl2-renderers.js +8 -5
- package/lib/render/webgpu-renderers.js +5 -4
- package/lib/scene/animation.d.ts +28 -32
- package/lib/scene/animation.js +12 -15
- package/lib/scene/assets.d.ts +61 -86
- package/lib/scene/assets.js +103 -236
- package/lib/scene/background.d.ts +14 -18
- package/lib/scene/background.js +5 -2
- package/lib/scene/color.d.ts +3 -3
- package/lib/scene/downloads.d.ts +2 -0
- package/lib/scene/downloads.js +371 -0
- package/lib/scene/environment.d.ts +7 -7
- package/lib/scene/environment.js +1 -1
- package/lib/scene/fake-call-values.js +1 -1
- package/lib/scene/fog.d.ts +11 -4
- package/lib/scene/fog.js +8 -2
- package/lib/scene/frame-cameras.d.ts +19 -0
- package/lib/scene/frame-cameras.js +58 -0
- package/lib/scene/gltf.d.ts +32 -2
- package/lib/scene/gltf.js +78 -49
- package/lib/scene/grading.d.ts +2 -2
- package/lib/scene/grading.js +3 -3
- package/lib/scene/ktx2.d.ts +9 -1
- package/lib/scene/ktx2.js +3 -2
- package/lib/scene/level-rule.d.ts +120 -0
- package/lib/scene/level-rule.js +130 -0
- package/lib/scene/lines.d.ts +13 -17
- package/lib/scene/lines.js +3 -3
- package/lib/scene/lut.d.ts +1 -2
- package/lib/scene/lut.js +1 -2
- package/lib/scene/picks.d.ts +2 -2
- package/lib/scene/pointer-events.d.ts +4 -7
- package/lib/scene/post.d.ts +38 -43
- package/lib/scene/post.js +4 -1
- package/lib/scene/prefab.d.ts +7 -8
- package/lib/scene/prefab.js +7 -8
- package/lib/scene/property-animation.d.ts +1 -1
- package/lib/scene/property-animation.js +1 -1
- package/lib/scene/queries.d.ts +7 -13
- package/lib/scene/resources.d.ts +225 -254
- package/lib/scene/resources.js +179 -81
- package/lib/scene/scene.d.ts +149 -118
- package/lib/scene/scene.js +196 -98
- package/lib/scene/serial-loads.d.ts +29 -0
- package/lib/scene/serial-loads.js +68 -0
- package/lib/scene/shader-preloads.d.ts +34 -0
- package/lib/scene/shader-preloads.js +38 -0
- package/lib/scene/sprites.d.ts +14 -17
- package/lib/scene/sprites.js +5 -6
- package/lib/scene/textures.d.ts +11 -12
- package/lib/scene/textures.js +9 -10
- package/lib/scene/time-of-day.d.ts +3 -4
- package/lib/scene/time-of-day.js +2 -3
- package/lib/scene/vertex-draws.d.ts +5 -4
- package/lib/scene/vertex-draws.js +7 -5
- package/lib/shader-artifact.json +1 -0
- package/lib/shared/core.d.ts +5 -0
- package/lib/shared/core.js +1 -0
- package/lib/shared/import-once.d.ts +6 -0
- package/lib/shared/import-once.js +19 -0
- package/lib/shared/metrics.d.ts +38 -0
- package/lib/shared/metrics.js +62 -1
- package/lib/shared/run-task.js +7 -1
- package/lib/shared/task-pending.d.ts +12 -0
- package/lib/shared/task-pending.js +61 -1
- package/lib/shared/tasks.js +79 -32
- package/lib/shared/version.d.ts +17 -1
- package/lib/shared/version.js +19 -1
- package/lib/shared/wasm.d.ts +12 -4
- package/lib/shared/wasm.js +50 -27
- package/lib/shared/worker-start.d.ts +7 -0
- package/lib/shared/worker-start.js +27 -0
- package/lib/sketch/define-sketch.d.ts +35 -0
- package/lib/sketch/input.d.ts +2 -2
- package/lib/sketch/preset-check.d.ts +20 -6
- package/lib/sketch/preset-check.js +42 -17
- package/lib/sketch/quality.d.ts +69 -11
- package/lib/sketch/quality.js +54 -13
- package/lib/sketch/runner.d.ts +76 -9
- package/lib/sketch/runner.js +385 -52
- package/lib/sketch/ui.d.ts +5 -8
- package/lib/workers/probe-worker.d.ts +5 -0
- package/lib/workers/probe-worker.js +13 -4
- package/lib/workers/protocol.d.ts +61 -13
- package/lib/workers/protocol.js +4 -0
- package/lib/workers/render-worker.js +25 -4
- package/lib/workers/sketch-worker.js +104 -15
- package/package.json +2 -2
package/docs/guides/phones.md
CHANGED
|
@@ -10,7 +10,7 @@ summary: "Pixel-ratio caps; memory budgets; heat; testing on real devices."
|
|
|
10
10
|
|
|
11
11
|
> Roadmap step 0.1, first released in null3D 0.1.0. The API is experimental, so it can still change between versions.
|
|
12
12
|
|
|
13
|
-
Phones have small GPUs, sharp screens and little memory, and they slow down when they heat up. The quality presets set how much work the engine does on each device. This guide says what the engine does on a phone or a tablet, and how to test your sketch on one.
|
|
13
|
+
A null3D sketch runs on current phones and tablets with no changes, on WebGPU or on WebGL2. Phones have small GPUs, sharp screens and little memory, and they slow down when they heat up. The quality presets set how much work the engine does on each device. This guide says what the engine does on a phone or a tablet, and how to test your sketch on one.
|
|
14
14
|
|
|
15
15
|
## The preset on a phone
|
|
16
16
|
|
|
@@ -100,8 +100,18 @@ The engine reads touches as it reads the mouse: the first finger presses `Mouse0
|
|
|
100
100
|
|
|
101
101
|
## Networks and repeat visits
|
|
102
102
|
|
|
103
|
+
On a phone, a start is mostly downloads, the round trips between them, and the GPU's pipeline builds. A host that compresses every file, `.wasm` included, and lets the browser keep the build's files saves seconds. So does a sketch that starts its downloads together and draws before its large models arrive. A first view with few pipelines saves more: 55 pipelines took 10.9 seconds to build on a Galaxy Tab A9 Plus. [A fast start](start-time.md) gives each step, with measured times on real phones.
|
|
104
|
+
|
|
103
105
|
Phones often lose their network. A game that must play offline caches the engine's files and its own in a service worker, as [Hosting](../getting-started/hosting.md#offline-play) shows. The engine keeps each transcoded KTX2 texture in its [cache of derived data](../api/assets.md#the-cache-of-derived-data), so a repeat visit skips the transcoder. On phones that saves less time than on a tablet, because other start work takes most of a phone's start.
|
|
104
106
|
|
|
107
|
+
## When the GPU's driver refuses a shader
|
|
108
|
+
|
|
109
|
+
A phone's GPU driver can refuse to build one pipeline, such as a custom material's, though the shader is valid. The engine then builds that pipeline once more, alone. When the driver refuses it again, the engine leaves that pipeline's objects out of the frame and draws on. It reports [E1307](../errors/E1307.md) once, which does not stop the engine. A validation error, and a refused pipeline of a full-screen pass, still stop drawing with [E1404](../errors/E1404.md) ([Debugging](debugging.md)).
|
|
110
|
+
|
|
111
|
+
On a Galaxy Tab A9 Plus, the driver refused the island demo's far tree cards, and the island then drew on without them. The creek demo reached its first frame at 71 seconds there, but the tablet ran out of GPU memory 4 seconds later ([E1302](../errors/E1302.md)).
|
|
112
|
+
|
|
113
|
+
On phones and tablets, the engine also gives back its GPU device while the browser keeps the page in its back-forward cache. It starts a new one when the page comes back ([Page API](../api/engine.md#the-running-engine)).
|
|
114
|
+
|
|
105
115
|
## Browsers on iPhone and iPad
|
|
106
116
|
|
|
107
117
|
Every browser on iPhone and iPad runs Safari's WebKit engine. null3D needs Safari 18 or later there, and `createEngine` fails with [E1306](../errors/E1306.md) on an older version. [GPU tiers and backends](../concepts/backends.md#minimum-browsers) says why.
|
|
@@ -113,6 +123,7 @@ Check every rendering mode and the whole camera path, with repeats, as [Testing
|
|
|
113
123
|
Desktop browsers that emulate a phone show neither its GPU nor its heat, so test on the phones and tablets that your audience uses.
|
|
114
124
|
|
|
115
125
|
- Serve the page over HTTPS, or reach it as `localhost` over USB. A secure origin is what makes WebGPU, and so the High and Ultra presets, available. On a network address over plain HTTP, the engine silently falls back to WebGL2 at Medium. [Hosting and cross-origin isolation](../getting-started/hosting.md#during-development) shows both.
|
|
126
|
+
- Install the root of the page's certificate on the device. Chrome keeps no file in its cache from a site whose certificate it accepted after a warning. Every load is then as slow as a first visit.
|
|
116
127
|
- Check the preset that the engine chose in `engine.mode.preset`. The capability report in `engine.report` holds the facts that it chose from: `coarsePointer`, `screenMinEdge` and `deviceMemoryGB`.
|
|
117
128
|
- Add `?preset=low`, `?preset=medium`, `?preset=high` or `?preset=ultra` to the page's address to test each preset on one device. The GPU path still caps the preset.
|
|
118
129
|
- Add `?gpu=webgl2` to test the WebGL2 path, which many phones use.
|
package/docs/guides/physics.md
CHANGED
|
@@ -192,7 +192,7 @@ ball.addEventListener('collide', (event: { contact: CANNON.ContactEquation }) =>
|
|
|
192
192
|
|
|
193
193
|
On the page, `onSketchMessage` receives each `bounce` message with its position and speed.
|
|
194
194
|
|
|
195
|
-
[Messages between sketch and page](../api/page.md) covers messages, and [
|
|
195
|
+
[Messages between sketch and page](../api/page.md) covers messages, and [Sound in a scene](audio.md) plays a sound at the bounce's place.
|
|
196
196
|
|
|
197
197
|
## Related pages
|
|
198
198
|
|
package/docs/guides/screens.md
CHANGED
|
@@ -51,11 +51,13 @@ screen.mesh.setPosition(0, 1.4, -3);
|
|
|
51
51
|
changes its reading each frame repaints only the part that changed:
|
|
52
52
|
|
|
53
53
|
```ts
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
return {
|
|
55
|
+
onUpdate() {
|
|
56
|
+
paintTheReading(screen.context); // the number, the bar and the lights
|
|
57
|
+
screen.mark({ x: 24, y: 150, width: 464, height: 90 });
|
|
58
|
+
screen.flush(); // sends a change that the rate held back
|
|
59
|
+
},
|
|
60
|
+
};
|
|
59
61
|
```
|
|
60
62
|
|
|
61
63
|
`screen.paint(draw, changed)` draws and uploads the rectangle that changed. Without a rectangle it
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: guides/start-time
|
|
3
|
+
title: A fast start
|
|
4
|
+
status: experimental
|
|
5
|
+
since: "0.1"
|
|
6
|
+
summary: "Where a page's start goes, on a simulated phone link and on real phones; compression, cache headers, the compiled core and HTTP/2 on the host; the early core script; what the engine does while the core downloads; downloads of the first view and of the rest; the preset check; pipelines on phones; testing and measuring a start."
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# A fast start
|
|
10
|
+
|
|
11
|
+
> Roadmap step 0.1, first released in null3D 0.1.0. The API is experimental, so it can still change between versions.
|
|
12
|
+
|
|
13
|
+
```mermaid
|
|
14
|
+
flowchart LR
|
|
15
|
+
html["The HTML page"] --> early["The early script<br/>starts the core's download"]
|
|
16
|
+
html --> scripts["The page's scripts<br/>call createEngine"]
|
|
17
|
+
early --> core["The engine core<br/>downloads and compiles"]
|
|
18
|
+
scripts --> during["While the core downloads:<br/>workers, the sketch module,<br/>the GPU device, the shader file"]
|
|
19
|
+
during --> setup["The setup downloads<br/>and builds the first view"]
|
|
20
|
+
core --> setup
|
|
21
|
+
setup --> frame["The first frame<br/>builds its pipelines"]
|
|
22
|
+
frame --> later["Large models and the<br/>preset check during play"]
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
A visitor waits from the moment the page's address loads until the first frame shows. Most of that wait is downloads, the round trips between them, and on a phone the GPU's pipeline builds. A round trip takes 150 to 560 ms on a phone's network, so each download that waits for another one adds that much. The host, the page and the sketch each decide part of the start. This guide gives the steps that shorten it, in the order of the start.
|
|
26
|
+
|
|
27
|
+
## Where the time goes
|
|
28
|
+
|
|
29
|
+
The engine's demos were timed as a production build over a simulated phone connection. It had 150 ms for each round trip and 10 Mbit/s, and the browser's cache was empty. Before the changes that this guide describes, a first visit spent its time on these steps:
|
|
30
|
+
|
|
31
|
+
| Step | Time | What the browser waited for |
|
|
32
|
+
| --- | --- | --- |
|
|
33
|
+
| The HTML page | 0.5 s | Three round trips on a new connection: TCP, TLS and the request |
|
|
34
|
+
| The engine core | 2.3 s | The core's WebAssembly file, 2.0 MB as the server sent it, with no compression. Brotli makes it about 0.6 MB |
|
|
35
|
+
| The sketch module's imports | 0.6 to 1.0 s | Three or four rounds of imports, one after another, which started once the core was ready |
|
|
36
|
+
| The sketch module's top-level code | 1.2 s in one scene | Terrain that the module built as it loaded, before its setup could start |
|
|
37
|
+
| The scene's own files | 22 s in one scene | 18 MB of models in two batches. The second batch started only once the first was built |
|
|
38
|
+
| The first frame's pipelines | 0.7 to 1.3 s | The shaders that the first frame needs, compiled while the last files downloaded |
|
|
39
|
+
|
|
40
|
+
Three demos whose first view needs no large file drew their first frame 4.6 to 8.9 seconds after the address loaded. The demo that waited for 18 MB of models took 25.7 seconds. The same demos took 27 to 85 seconds from the Vite dev server over the same connection, as [Test a production build](#test-a-production-build) explains.
|
|
41
|
+
|
|
42
|
+
Each change below was then measured alone, on the same connection:
|
|
43
|
+
|
|
44
|
+
| Change | Measured | Before | After |
|
|
45
|
+
| --- | --- | --- | --- |
|
|
46
|
+
| [Compress every file](#compress-every-file), `.wasm` included, with a smaller page script and no offline cache | A small demo's first frame | 4.6 s | 3.0 s |
|
|
47
|
+
| The same | The creek demo's repeat visit | 3.0 s, or 5.6 s with its offline cache | 1.7 s |
|
|
48
|
+
| [The sketch module loads while the core downloads](#what-the-engine-does-while-the-core-downloads) | From the core's arrival to the setup's start | 0.64 to 0.96 s | 0.15 to 0.51 s |
|
|
49
|
+
| [The sketch's whole import chain is asked for at once](#what-the-engine-does-while-the-core-downloads), over HTTP/2 with Brotli | A small demo's first frame, and the skyway demo's | 3.24 s and 3.52 s | 2.90 s and 3.23 s |
|
|
50
|
+
| [The stored list of the first frame's pipelines](#pipelines-on-phones) | The island's repeat visit on a Galaxy S25, from the setup's end to the first frame | 3.81 s | 1.56 s |
|
|
51
|
+
| [The first frame before the large models](#draw-the-first-frame-before-the-large-models) | The creek demo's first frame | 25.7 s | 5.7 s, with every model in at 25.0 s |
|
|
52
|
+
| The same for the island's trees, town and people, with its heavy work moved to first use | The island demo's first frame on WebGPU, and on WebGL2 | 9.37 s and 23.56 s | 6.84 s and 7.97 s |
|
|
53
|
+
| The splat scan draws once the nearest parts are in | The splat demo's first frame | 29.1 s | 8.8 s, with every part in at 28.2 s |
|
|
54
|
+
| The splats add-on starts its decoder and its selection beside its first download | The splat demo's first parts on screen | 8.3 s | 7.0 s |
|
|
55
|
+
| [The download list](#start-the-first-views-downloads-at-the-top-of-the-setup) names the creek demo's eleven models, with every model drawn before the first frame | The creek demo's first frame, and the time with nothing downloading before it | 25.9 s and 3.3 s | 21.3 s and 0.2 s |
|
|
56
|
+
| [The first view's downloads start together](#start-the-first-views-downloads-at-the-top-of-the-setup): a light map and a model | The character demo's first frame | 8.55 s | 8.2 s |
|
|
57
|
+
| [The preset check during play](#the-preset-check) | A small demo's loading screen on a first visit, at full speed on a MacBook Pro | 1.18 s | 0.49 s |
|
|
58
|
+
| [Chrome keeps the compiled core](#let-the-browser-keep-the-files) | A repeat visit's first frame on the engine's test page, at full speed, and the core's functions that it compiled again | 176 to 180 ms, 273 functions | 160 ms, 3 functions |
|
|
59
|
+
|
|
60
|
+
With every change together, the same Mac timed the engine before and after the changes in turns, over the same simulated phone connection. Each figure is the median of three loads, in seconds to the first finished frame. A cold load starts with an empty cache. A reload comes after a first visit that ran for 30 seconds. The load average is the Mac's during each pair of loads, before and after.
|
|
61
|
+
|
|
62
|
+
Over HTTP/1.1:
|
|
63
|
+
|
|
64
|
+
| Demo and load | Before | After | Load average, before and after |
|
|
65
|
+
| --- | --- | --- | --- |
|
|
66
|
+
| Small demo, cold | 4.6 s | 2.9 s | 4.2 and 3.5 |
|
|
67
|
+
| Skyway, cold | 5.7 s | 3.5 s | 7.0 and 5.7 |
|
|
68
|
+
| Island, cold | 8.9 s | 7.6 s | 11.5 and 7.9 |
|
|
69
|
+
| Creek, cold | 25.7 s | 4.3 s | 3.9 and 4.2 |
|
|
70
|
+
| Island, reload | 4.7 s | 2.2 s | 3.9 and 4.1 |
|
|
71
|
+
| Creek, reload | 2.6 s | 1.3 s | 9.6 and 4.2 |
|
|
72
|
+
|
|
73
|
+
Over HTTP/2:
|
|
74
|
+
|
|
75
|
+
| Demo and load | Before | After | Load average, before and after |
|
|
76
|
+
| --- | --- | --- | --- |
|
|
77
|
+
| Small demo, cold | 4.5 s | 2.7 s | 13.7 and 10.7 |
|
|
78
|
+
| Skyway, cold | 5.3 s | 2.8 s | 3.5 and 3.3 |
|
|
79
|
+
| Island, cold | 10.2 s | 7.0 s | 4.4 and 3.1 |
|
|
80
|
+
| Creek, cold | 27.7 s | 3.3 s | 9.4 and 4.3 |
|
|
81
|
+
| Island, reload | 3.9 s | 2.4 s | 3.8 and 5.1 |
|
|
82
|
+
| Creek, reload | 2.3 s | 0.9 s | 3.3 and 2.7 |
|
|
83
|
+
|
|
84
|
+
### On real phones
|
|
85
|
+
|
|
86
|
+
The same demos also ran on real phones, over a tunnel of about 105 ms for each round trip and 1 to 60 Mbit/s. Before the changes, a first visit drew its first frame in these times:
|
|
87
|
+
|
|
88
|
+
| Device | Small demo | Skyway | Island | Creek |
|
|
89
|
+
| --- | --- | --- | --- | --- |
|
|
90
|
+
| Galaxy S25, Chrome | 4.7 s | 7.8 s | 13.4 s | 25.1 s |
|
|
91
|
+
| Pixel 9, Chrome | 6.5 s | 10.3 s | 18.8 s | 38.8 s |
|
|
92
|
+
| Galaxy Tab A9 Plus, Chrome | 9.1 s | 20.2 s | 46.7 s | failed |
|
|
93
|
+
| iPhone 17, Safari | 11.6 s | 19.0 s | 24.4 s | 34.5 s |
|
|
94
|
+
|
|
95
|
+
Safari on the iPhone 17 kept the files and its compiled shaders between visits. Its repeat visits drew their first frame in 0.9 to 5.5 seconds. Chrome on the Android devices kept no file between visits, because they had accepted the test server's certificate after a warning ([Test a production build](#test-a-production-build)).
|
|
96
|
+
|
|
97
|
+
With the changes, on the same devices, a first visit in a fresh session drew its first frame in these times. The tunnel ran at about 100 ms for each round trip and 4 to 9 Mbit/s:
|
|
98
|
+
|
|
99
|
+
| Device | Small demo | Skyway | Island | Creek |
|
|
100
|
+
| --- | --- | --- | --- | --- |
|
|
101
|
+
| Galaxy S25, Chrome | 3.5 to 7.3 s | 5.7 s | 8.1 s | 5.7 s |
|
|
102
|
+
| Pixel 9, Chrome | 4.0 s | 6.5 s | 13.4 s | 8.7 s |
|
|
103
|
+
| Galaxy Tab A9 Plus, Chrome | 11.3 s | 17.7 s | 39 s | 31 s |
|
|
104
|
+
| iPhone 17, Safari | 8.9 s | 17.2 s | 20.4 s | 11.1 s |
|
|
105
|
+
|
|
106
|
+
The phones start at Low and run no preset check. On the Galaxy Tab A9 Plus, the check runs during play for 12 to 38 seconds after the first frame, and settles on Low. There the creek demo lost its GPU in 2 of 6 loads. The iPhone 17's repeat visits drew their first frame in 0.4 to 3.1 seconds. The small demo's times follow the tunnel's speed, which differed between the two runs.
|
|
107
|
+
|
|
108
|
+
A phone's processor makes the largest difference from a computer. The first frame's pipeline builds take seconds there, as [Pipelines on phones](#pipelines-on-phones) shows. The Galaxy Tab A9 Plus failed to build one custom material's pipeline in the creek demo, and on repeat visits of the island.
|
|
109
|
+
|
|
110
|
+
The engine builds a pipeline that the driver refuses once more, alone. When the driver refuses it again, the engine leaves that pipeline's objects out and draws on, with [E1307](../errors/E1307.md), which does not stop it. So the island draws on that tablet without its far tree cards, at 1.1 frames a second at Low. The creek demo reaches its first frame at 71 seconds there, but the tablet runs out of GPU memory 4 seconds later ([E1302](../errors/E1302.md)).
|
|
111
|
+
|
|
112
|
+
## Compress every file
|
|
113
|
+
|
|
114
|
+
The host's compression decides the size of the start's largest downloads. Send every file of the build with Brotli where the host has it, and with gzip where it does not:
|
|
115
|
+
|
|
116
|
+
| File | As it is | gzip | Brotli |
|
|
117
|
+
| --- | --- | --- | --- |
|
|
118
|
+
| The engine core, `null3d_bg-<hash>.wasm` | 2.0 MB | 0.8 MB | 0.6 MB |
|
|
119
|
+
| The WebGL2 start shader file | 1.2 MB | 0.21 MB | 0.05 MB |
|
|
120
|
+
| The WebGPU start shader file | 0.42 MB | 0.09 MB | 0.04 MB |
|
|
121
|
+
|
|
122
|
+
Many servers compress only text, and send `.wasm` files as they are. Open the browser's network panel, and compare the core's transferred size with its size. With nginx, add `application/wasm` to `gzip_types`, or send files that you compress when you deploy, as [Hosting](../getting-started/hosting.md#send-the-files-with-brotli) shows.
|
|
123
|
+
|
|
124
|
+
The null3D Vite plugin compresses in both of its servers. `vite preview` compresses the build's files and models with Brotli, `.wasm` included, for every visitor. The dev server compresses its answers to other devices, such as a phone on the network, and leaves `localhost` as it is.
|
|
125
|
+
|
|
126
|
+
Models compress less, because their textures are compressed already. Brotli saved 0 to 25% on most of the demos' models, and 74% on one. The asset tool, `bunx @null3d/cli assets optimize`, makes models smaller to download before the host compresses them ([The asset pipeline](assets-pipeline.md)).
|
|
127
|
+
|
|
128
|
+
## Let the browser keep the files
|
|
129
|
+
|
|
130
|
+
A repeat visit is fast when the browser keeps what the first visit downloaded. Vite names each file in `assets/` with a hash of its content. Serve those files as immutable, and the HTML page so that the browser checks it each time, as [Hosting](../getting-started/hosting.md#let-browsers-keep-the-build-files) shows. A repeat visit then downloads only the page.
|
|
131
|
+
|
|
132
|
+
- A file served with `no-cache` costs one round trip on every visit, even when it has not changed. Give your own large files, such as models, a hash or a version in their addresses, such as `statue-v3.glb`, and serve those addresses as immutable. Serve every other address with `no-cache`, so a changed file never shows its old copy.
|
|
133
|
+
- Send no `Vary: Origin` header with the build's files when they come from the page's own origin. A worker's request for a module carries an `Origin` header that the page's own download of the file does not. With `Vary: Origin`, the browser checks the file again, one round trip, instead of taking its copy.
|
|
134
|
+
- Send `.wasm` files with `Content-Type: application/wasm`, with nothing after it. Chrome 157 and later then keep the compiled engine core beside the file, and a repeat visit skips most of its compile. Chrome writes that code a few seconds into a visit, about 6 seconds after the first frame on the engine's test page. Chrome 156 and earlier rarely write it ([Let Chrome keep the compiled core](../getting-started/hosting.md#let-chrome-keep-the-compiled-core)).
|
|
135
|
+
|
|
136
|
+
## Serve over HTTP/2
|
|
137
|
+
|
|
138
|
+
Over HTTP/1.1, a browser opens at most six connections to a host. The page, every engine worker and every download share them. A large download holds a connection, and the other requests wait in a queue. Over HTTP/2 or HTTP/3, one connection carries every request at once. Cloudflare Pages, Netlify, Vercel and most CDNs serve HTTP/2. The network panel's Protocol column shows `h2` or `h3` for each file.
|
|
139
|
+
|
|
140
|
+
The null3D Vite plugin serves its HTTPS over HTTP/1.1 by default, in `vite` and in `vite preview`. Over HTTP/2, Safari on an iPad sometimes stalls while a worker loads its modules from the dev server. The plugin's `http2: true` option serves HTTP/2 for other browsers. Over the simulated phone connection, it cut a small demo's first visit from the dev server from 13.8 to 7.2 seconds. Its reload fell from 11.7 to 4.7 seconds.
|
|
141
|
+
|
|
142
|
+
## Keep the early core script
|
|
143
|
+
|
|
144
|
+
A production build with the null3D Vite plugin adds a small script to the head of each page that starts the engine. The script starts the core's download as soon as the HTML arrives, before the page's own scripts have downloaded and run. It picks the build that `createEngine` will pick, and the engine takes its download. In the engine's startup benchmark on Slow 4G, the first frame came 0.2 seconds sooner on a MacBook Pro. On a Galaxy S24+ it came about 0.3 seconds sooner.
|
|
145
|
+
|
|
146
|
+
- Keep the script as the first tag in the page's head. A step that rewrites the built HTML must keep its `<script type="module" async>` tag.
|
|
147
|
+
- Add no `<link rel="preload">` for the core. The HTML cannot know which build the device takes, and a wrong guess downloads 0.6 MB more. Safari can also download the core twice.
|
|
148
|
+
- Create the engine as soon as the page can. A page that waits for something else first, such as a framework's hydration, delays every step that the engine takes while the core downloads.
|
|
149
|
+
- The dev server's pages have no early script.
|
|
150
|
+
- A page that loads the engine from a CDN adds the script itself, as [Try null3D from a CDN](../getting-started/cdn.md#start-the-core-early) shows.
|
|
151
|
+
|
|
152
|
+
## What the engine does while the core downloads
|
|
153
|
+
|
|
154
|
+
`createEngine` starts the rest of the start while the core downloads:
|
|
155
|
+
|
|
156
|
+
- It starts the sketch worker and the render worker, and the sketch worker imports the sketch module with all its imports.
|
|
157
|
+
- It tests the GPU, then asks for the WebGPU device and downloads the device's shader file and its renderer's code.
|
|
158
|
+
- It downloads the job workers' script, so a job worker that starts later takes it from the cache.
|
|
159
|
+
|
|
160
|
+
So when the core arrives, the setup starts almost at once.
|
|
161
|
+
|
|
162
|
+
The Vite plugin also writes into the built sketch module every file that the module reaches through its imports. So the sketch worker asks for all of them as soon as the module arrives. It needs no round trip for each step of the chain. A sketch's code then arrives in about 2 rounds instead of 4 to 6. Over HTTP/1.1 the six connections still queue those files, so the gain there is small. The engine's package keeps no `sideEffects` list: one was measured, and it made the start slower.
|
|
163
|
+
|
|
164
|
+
`engine.measure()` reports when the thread that draws had its device, its shader file and its renderer, in `load.drawingStart` ([Measure a start](#measure-a-start)).
|
|
165
|
+
|
|
166
|
+
The sketch module's top-level code therefore runs before the engine has started, and also when the start fails. Work there must not need the engine: a call that makes scene data before the core starts fails with [E1403](../errors/E1403.md). Work that needs no engine can run there and overlap the download, such as a height grid that the first view reads. Hold mode, a replay and a recording load the module only after the engine has started. There, such work still holds up the setup ([Sketch API](../api/sketch.md)).
|
|
167
|
+
|
|
168
|
+
## Start the first view's downloads at the top of the setup
|
|
169
|
+
|
|
170
|
+
A download that the setup starts after an `await` waits for that `await`, and the connection can stand idle meanwhile. So start every file that the first view needs on the setup's first lines, and await each one only where the scene needs it:
|
|
171
|
+
|
|
172
|
+
```ts
|
|
173
|
+
// sketch.ts
|
|
174
|
+
import { defineSketch } from '@null3d/engine';
|
|
175
|
+
|
|
176
|
+
const STATUE = '/models/statue-v3.glb';
|
|
177
|
+
|
|
178
|
+
export default defineSketch(async ({ assets, page, scene }) => {
|
|
179
|
+
page.post('loading', { text: 'Downloading the statue' });
|
|
180
|
+
// Both downloads start now, together.
|
|
181
|
+
const statue = assets.loadGltf(STATUE);
|
|
182
|
+
const sky = assets.loadEnvironment('/env/evening-v2.ktx2');
|
|
183
|
+
|
|
184
|
+
// Build what needs no file while the files download.
|
|
185
|
+
const camera = scene.createPerspectiveCamera({ position: [0, 2, 8], target: [0, 1, 0] });
|
|
186
|
+
scene.setActiveCamera(camera);
|
|
187
|
+
scene.createDirectionalLight({ direction: [-1, -2, -1], intensity: 3 });
|
|
188
|
+
|
|
189
|
+
scene.setEnvironment(await sky);
|
|
190
|
+
scene.instantiate(await statue);
|
|
191
|
+
});
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
`assets.preload` does the same for files that later code loads: it starts every download at once, and each later load takes its file from memory. A load of a file that is still downloading waits for that download, and starts no second one.
|
|
195
|
+
|
|
196
|
+
The engine's add-ons follow the same rule. The sound add-on downloads its recordings beside its mixer, and the splats add-on starts its decoder and its selection beside its first file.
|
|
197
|
+
|
|
198
|
+
Post the first loading message on the setup's first line, so the loading screen names the scene's own work from the start.
|
|
199
|
+
|
|
200
|
+
Name the first view's files in the `downloads` option of `defineSketch`, in the order that the setup needs them: `defineSketch(setup, { downloads: [...] })`. They start to download as soon as the sketch module loads, often before the core has arrived. Two download at a time, at a low priority, so the engine's own files still find free connections. A load that waits for a listed file moves it to the front, and up to four then download at once. Hold mode, replays and recordings ignore the list ([The download list](../api/sketch.md#the-download-list)).
|
|
201
|
+
|
|
202
|
+
List only the files that the first frame needs, and start the rest from `engine.firstFrame`, as the next section shows. A development build warns once in a live start when a scene's own load started only after another one finished, with nothing else downloading. Pass `serialLoadWarning: false` to turn the warning off where the second address comes from the first file.
|
|
203
|
+
|
|
204
|
+
## Draw the first frame before the large models
|
|
205
|
+
|
|
206
|
+
The first frame waits for the setup. When the setup awaits a large model, the visitor sees the loading screen for the whole download. So build the first view in the setup, and let the large models that it does not need arrive after the first frame. Each one appears as it lands.
|
|
207
|
+
|
|
208
|
+
Start those downloads after the first frame, not in the setup. Over HTTP/1.1, large files that the setup starts take all six connections, and the first frame's own shader and code files wait behind them. A lower fetch priority does not help: the large files take the free connections before the shader requests exist. Started with the setup, a scene's 2.85 MB of town models made its first frame 0.7 to 1.0 seconds later.
|
|
209
|
+
|
|
210
|
+
In the sketch, `engine.firstFrame` resolves once the GPU has finished the first frame, as `engine.firstFrame` does on the page. Unlike the page's promise, it never rejects: when the engine stops first, it stays pending. Start the later downloads when it resolves:
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
// sketch.ts
|
|
214
|
+
import { defineSketch } from '@null3d/engine';
|
|
215
|
+
|
|
216
|
+
const FOREST = '/models/forest-v2.glb';
|
|
217
|
+
|
|
218
|
+
export default defineSketch(async ({ assets, engine, scene }) => {
|
|
219
|
+
// Build the first view here.
|
|
220
|
+
|
|
221
|
+
const addForest = async () => {
|
|
222
|
+
scene.instantiate(await assets.loadGltf(FOREST));
|
|
223
|
+
};
|
|
224
|
+
// A held frame or a replay waits for the forest, so it shows the finished scene.
|
|
225
|
+
if (engine.held) await addForest();
|
|
226
|
+
else void engine.firstFrame.then(addForest).catch((error) => console.error(error)); // the forest appears as it lands
|
|
227
|
+
});
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Never await `engine.firstFrame` in the setup, because the first frame waits for the setup. A frame number is no such signal. The thread that draws can still be drawing the first frame while the sketch runs the second ([The engine field](../api/sketch.md#the-engine-field)).
|
|
231
|
+
|
|
232
|
+
`engine.held` is true in hold mode and in a replay, so tests still draw the finished scene. A held start that waits for many files starts them all on the setup's first line with `assets.preload`. It then builds the scene in one fixed order. The engine's showcase demos take a `?grown` switch that does the same on a live page. A page that measures frame rates then measures the finished scene.
|
|
233
|
+
|
|
234
|
+
While the engine holds frames or replays, the sketch's `assets` calls run one at a time, in the order the sketch made them. So the held picture never depends on which file lands first ([Hold mode](testing.md#hold-mode)).
|
|
235
|
+
|
|
236
|
+
A scene that streams its content, such as a splat scan, can draw once the parts nearest the camera are in. The rest then stream in after the first frame. The engine's splat demo drew its first frame after 8.8 seconds that way, over the simulated phone connection. It took 29.1 seconds when it waited for every part.
|
|
237
|
+
|
|
238
|
+
A model that appears after the first frame draws once its pipelines are built, on both GPU paths. Without `KHR_parallel_shader_compile`, as in Chrome on some Android phones, each new WebGL2 program compiles at its first draw. That frame then runs long, once for each new program. To show a later group of models whole, create them hidden and warm up, as [A later loading stage](loading-screens.md#a-later-loading-stage) shows.
|
|
239
|
+
|
|
240
|
+
The same holds for work that the first view does not need. Light maps that a scene can draw without, such as a sky's environment, need not be awaited: hand them over when they land. Make a map that only one mode of the page uses, such as a studio's room light, when that mode is first picked.
|
|
241
|
+
|
|
242
|
+
## The preset check
|
|
243
|
+
|
|
244
|
+
When the engine picks the quality preset itself, it checks the preset in the first frames of play on a first visit. The loading screen goes at the first frame, and the check measures while the sketch plays. Where the GPU misses the target frame rate, the engine lowers the preset in front of the viewer. `engine.presetChecked` resolves once the check has ended. A page or a tool that measures steady play waits for it, because the check can lower the preset inside the measured window. A repeat visit takes the stored result and runs no check, and a phone starts at Low, which has no check.
|
|
245
|
+
|
|
246
|
+
A check before play costs a slow tablet the most. On a Galaxy Tab A9 Plus, it held the loading screen 8 to 18 seconds after the first frame. A page that would rather hide a change of preset behind its loading screen passes `presetCheck: 'before-play'` to `createEngine`. The check then runs before play, and `createEngine` waits for it, at least three quarters of a second for each preset that it measures. The `?preset-check=` switch sets the same from the page's address ([The preset check](loading-screens.md#the-preset-check)).
|
|
247
|
+
|
|
248
|
+
On a slow tablet the check can take many seconds, as each lighter preset builds its pipelines. It stores its rounds each time it lowers the preset, so a viewer who leaves during the check loses none of them. The next start begins at the preset that the check had lowered to. The check's target starts at the display's rate measured before its first frame, and never falls under the check's own load. Its first round waits for the first frame's pipelines, then for frames at play's rate, for at most 4 seconds. A preset under a quarter of its target goes straight to Low. When Low is that slow too, the governor takes the [lowest quality tier](../concepts/quality-presets.md#the-lowest-quality-tier) during play, as it does on any device.
|
|
249
|
+
|
|
250
|
+
## Pipelines on phones
|
|
251
|
+
|
|
252
|
+
Building the first frame's pipelines is the largest processor cost of a start on a phone. Each pipeline is one compile on the device's GPU driver. The demos built these pipelines for their first frame, on a first visit:
|
|
253
|
+
|
|
254
|
+
| Device | Small demo | Skyway | Island | Creek |
|
|
255
|
+
| --- | --- | --- | --- | --- |
|
|
256
|
+
| Galaxy S25 | 0.4 s | 1.8 s | 4.1 s | 5.4 s |
|
|
257
|
+
| Pixel 9 | 0.9 s | 3.1 s | 6.0 s | 6.7 s |
|
|
258
|
+
| Galaxy Tab A9 Plus | 2.8 s | 10.9 s | 23.5 s | failed |
|
|
259
|
+
| iPhone 17 | 2.4 s | 11.8 s | 13.1 s | 16.5 s |
|
|
260
|
+
| MacBook Pro | 0.1 s | 0.2 s | 0.3 s | 0.7 s |
|
|
261
|
+
|
|
262
|
+
The phones built 16 to 17, 53 to 55, 61 to 63 and 45 to 46 pipelines for the four demos. The MacBook Pro built 31, 73, 84 and 73 at its higher preset, in a fraction of the time. With the changes, a first visit's builds took 0.4 to 3.6 seconds on the Galaxy S25, and 0.8 to 6.5 seconds on the Pixel 9. They took 3 to 23 seconds on the Galaxy Tab A9 Plus, and 2.4 to 13 seconds on the iPhone 17.
|
|
263
|
+
|
|
264
|
+
On a repeat visit, Safari reused its compiled shaders, and the iPhone 17 built each demo's pipelines in 0.2 seconds or less. In Chrome on Android, the small demo built its pipelines 4 to 5 times faster, and the larger demos built theirs no faster. Chrome on Android keeps about 2 MB of a site's compiled WebGPU pipelines between visits, and 128 KB on a low-end phone. A computer keeps 6 MB. A scene with many large shaders overflows it, so the engine keeps a list of its own.
|
|
265
|
+
|
|
266
|
+
- Keep the first view's pipelines few. A pipeline serves every object of one shading model, vertex format and set of material features, as the [Performance guide](performance.md#how-the-engine-batches-builds-pipelines-and-times-frames) lists. A new feature on one material, such as a normal map, makes a new pipeline.
|
|
267
|
+
- Warm up behind the loading screen, so play builds no pipeline ([Loading screens and warm-up](loading-screens.md#pipelines-and-warm-up)).
|
|
268
|
+
- Time the start on the phones and tablets of your audience. A desktop browser that emulates a phone builds pipelines at the computer's speed.
|
|
269
|
+
|
|
270
|
+
The engine keeps a list of the pipelines that a sketch's first frame built, in the page's `localStorage`. The list is kept for each engine version, GPU path, set of the device's shader bits, preset and canvas format. On the next start, the thread that draws builds each of those pipelines as soon as its shader arrives. The engine downloads and the setup runs meanwhile. Before the first frame, the engine also builds in the background the pipelines that the frame's list asks for partway through. Identical pipelines share one build. Hold mode, replays and recordings neither read nor store the list, and `?builds=fresh` turns it off ([Repeat visits](loading-screens.md#repeat-visits)).
|
|
271
|
+
|
|
272
|
+
These figures run from the setup's end to the first frame:
|
|
273
|
+
|
|
274
|
+
| Demo and device | Before | After |
|
|
275
|
+
| --- | --- | --- |
|
|
276
|
+
| Island, Galaxy S25, first visit | 5.79 s | 3.77 s |
|
|
277
|
+
| Island, Galaxy S25, repeat visit | 3.81 s | 1.56 s |
|
|
278
|
+
| Skyway, Galaxy S25, repeat visit | 2.29 s | about 1.5 s |
|
|
279
|
+
| Creek, Galaxy S25, repeat visit | 4.78 s | about 3.0 s |
|
|
280
|
+
| Island, Galaxy Tab A9 Plus, repeat visit | 23.6 s | 8.8 to 11.2 s |
|
|
281
|
+
|
|
282
|
+
## Cache for offline play after the first frame
|
|
283
|
+
|
|
284
|
+
A service worker that caches the build for offline play downloads files of its own. When it starts at the page's load, its downloads share the connection with the start. A worker that caches every file of a large build makes every first visit slower, and every repeat visit too until its cache is complete. The engine's demo page dropped such a worker: it sent about 1,570 requests and 820 MB over the start's connections.
|
|
285
|
+
|
|
286
|
+
- Register the service worker once `engine.firstFrame` has resolved.
|
|
287
|
+
- Cache only what the game needs: its pages, the start's files and the features that it uses, as [Offline play](../getting-started/hosting.md#offline-play) shows.
|
|
288
|
+
- Keep the list small. The call `cache.addAll` keeps nothing until every file of its list has arrived. A visitor who leaves early then starts the list again on the next visit.
|
|
289
|
+
|
|
290
|
+
## Test a production build
|
|
291
|
+
|
|
292
|
+
Judge a start only on a production build that a host serves as above. The Vite dev server sends each module as a file of its own, and asks the browser to check every module on each load. Each engine thread loads its own copy of each module. Over the simulated phone connection, the dev server took 27 to 85 seconds to the first frame. The production build took 4.6 to 25.7 seconds.
|
|
293
|
+
|
|
294
|
+
A phone or tablet that tests the page must trust its certificate. Chrome keeps no file in its cache from a site whose certificate it accepted after a warning. Every load then downloads every file again: a reload of the dev server took 30 seconds instead of 15. Install the certificate's root on the device, as [During development](../getting-started/hosting.md#during-development) shows.
|
|
295
|
+
|
|
296
|
+
## Measure a start
|
|
297
|
+
|
|
298
|
+
`engine.measure()` gives the start's times in its `load` figures ([Performance guide](performance.md#measure)):
|
|
299
|
+
|
|
300
|
+
| Figure | What it is |
|
|
301
|
+
| --- | --- |
|
|
302
|
+
| `load.coreMs` | From the start of `createEngine` until the core was downloaded and compiled |
|
|
303
|
+
| `load.probeMs` | From the start of `createEngine` until the probe of the GPU paths finished |
|
|
304
|
+
| `load.drawingStart` | When the thread that draws got its WebGPU adapter and device, its shader file, the core and its renderer, in milliseconds from the page's navigation |
|
|
305
|
+
| `load.engineStartMs` | How long `createEngine` took, with the setup, and with the preset check before play |
|
|
306
|
+
| `load.firstFrameMs` and `load.firstFrameDoneMs` | From the page's navigation until the first frame was submitted, and until the GPU finished it |
|
|
307
|
+
| `load.warmUpMs` and `load.firstFramePipelines` | How long the first frame's pipelines took to build, and how many it built |
|
|
308
|
+
|
|
309
|
+
In the browser's developer tools, pick the Slow 4G profile. Time a first visit with the cache turned off, then a repeat visit with it on:
|
|
310
|
+
|
|
311
|
+
- In the network panel, check the transferred size of the core's `.wasm` file and of the shader files. A transferred size equal to the size means no compression.
|
|
312
|
+
- Check the Protocol column for `h2` or `h3`.
|
|
313
|
+
- In each request's timing, a long Queueing or Stalled time means the six connections of HTTP/1.1 are full.
|
|
314
|
+
- Look along the waterfall for gaps with nothing downloading, and for downloads that start only when another one ends.
|
|
315
|
+
- On a repeat visit, every build file should come from the cache. A `304` answer is a round trip that immutable files avoid.
|
|
316
|
+
- In the Performance panel, look for long tasks in the sketch worker before the setup's first message.
|
|
317
|
+
|
|
318
|
+
Chrome's network throttling does not slow a service worker's own downloads. Its CPU throttling slows the page's thread, while the engine's setup and drawing run in workers. So time the setup's work and the pipeline builds on a real phone, through remote debugging.
|
|
319
|
+
|
|
320
|
+
The engine's repository times the engine's own start with `bun run bench:startup`. It loads the engine's test page cold and warm in Chrome, on Slow 4G by default. It prints the median of each stage, with the drawing thread's device, shader file and renderer.
|
|
321
|
+
|
|
322
|
+
## Related pages
|
|
323
|
+
|
|
324
|
+
- [Hosting and cross-origin isolation](../getting-started/hosting.md): compression, cache headers, the compiled core and offline play.
|
|
325
|
+
- [Loading screens and warm-up](loading-screens.md): progress, warm-up and the preset check.
|
|
326
|
+
- [Quality presets](../concepts/quality-presets.md#the-preset-check): the preset check's rules.
|
|
327
|
+
- [Phones and tablets](phones.md): networks and repeat visits.
|
|
328
|
+
- [Network use](../getting-started/network-use.md): what the engine downloads, and when.
|
package/docs/guides/testing.md
CHANGED
|
@@ -3,7 +3,7 @@ id: guides/testing
|
|
|
3
3
|
title: Testing your sketch
|
|
4
4
|
status: experimental
|
|
5
5
|
since: "0.1"
|
|
6
|
-
summary: "Hold mode; image tests; reading results; frames that stay the same on every run."
|
|
6
|
+
summary: "Hold mode; image tests; reading results; frames that stay the same on every run; browser tests of a whole app."
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
# Testing your sketch
|
|
@@ -66,7 +66,7 @@ const { width, height, pixels } = await engine.captureFrame(); // RGBA8 rows, to
|
|
|
66
66
|
In hold mode, the engine does this:
|
|
67
67
|
|
|
68
68
|
1. It seeds the engine's random generator, [`math.random`](../api/math.md#random-numbers), in the sketch's thread, and makes `Math.random` draw from it too. This happens before the sketch module loads.
|
|
69
|
-
2. It runs the sketch's setup.
|
|
69
|
+
2. It runs the sketch's setup. The sketch's `assets` calls run one at a time, each once the call before it has answered, in the order the sketch made them. A load makes its textures, meshes and materials when its files arrive, and files arrive in another order on each run. Loads that ran side by side would put the scene's content in another order each time. The held frame would then draw its objects in another order.
|
|
70
70
|
3. It steps the sketch from time 0 to the held time. The first frame is at time 0 and its `onUpdate` gets a step of 0. Each later frame adds a fixed step of 1/60 second, and the last one lands on the held time exactly. The sketch's own fixed steps fall due from the sketch time, so every hold runs the same ones. At the default rate, each frame after the first runs one.
|
|
71
71
|
4. It draws the last frame on the canvas, and reads its pixels back through its own GPU code. Motion vectors read the frame before, so with them it draws the frame before the last one too. A mirror or a light probe shows its result a frame late, so with one it draws one more frame at the held time. The GPU passes of the other frames never run, and [`time.drawn`](../api/time.md#the-time-object) is false in them.
|
|
72
72
|
5. It publishes the frame, or the error that stopped it, as `window.__null3dHold`.
|
|
@@ -75,7 +75,7 @@ In hold mode, the engine does this:
|
|
|
75
75
|
|
|
76
76
|
A hold at 1.5 seconds runs 91 frames: frame 1 at time 0, then 90 steps. In the last `onUpdate`, `time.now` is 1.5 and `time.frame` is 91. When a pass reads the frame before it, as screen-space bounce light does, the engine draws one more frame at the same sketch time after the held one, so the picture has the light that the earlier frame showed. That frame runs none of the sketch's code and adds no step, so the sketch still ends at frame 91 and the hold reports that number. It draws the debug lines of the last `onUpdate` again, so the picture shows the same lines as the held frame.
|
|
77
77
|
|
|
78
|
-
Before it draws the held frame, hold mode waits for the tasks that the sketch queued on the job workers
|
|
78
|
+
Before it draws the held frame, hold mode waits for the tasks that the sketch queued on the job workers. It then runs one more frame at the held time, which draws what they wrote. It waits up to 10 seconds for a task, then warns and draws anyway. The levels of detail that meshes made in code plan are different. Hold mode waits for them until they are in, however long the plans take on a busy machine. It says every 10 seconds which meshes still plan. So the held frame always draws every planned level. A plan that has not answered after five minutes stops the hold with [E1408](../errors/E1408.md), which names the meshes. Give a mesh `levels: false` when a test should draw it without levels. Hold mode also waits for the tasks and plans that the setup started before the first step, with the same limits. So a mesh made in the setup has its levels in every held frame, and a task that never answers delays the hold twice. The plans hand over their levels one at a time in the order they started, whatever order the job workers answer in. So the steps find the same scene on every run, and the meshes of the levels take the same places in engine memory.
|
|
79
79
|
|
|
80
80
|
The switch wins over the option. A bare `?hold` holds at the time of the `hold` option, or at 0 without one. The time must be from 0 to 600 seconds, or the start fails with [E1407](../errors/E1407.md).
|
|
81
81
|
|
|
@@ -186,13 +186,29 @@ A live engine logs an error in `onUpdate` and carries on. Hold mode stops instea
|
|
|
186
186
|
- Move things with `time.now`, the frame's step (`dt` or `time.dt`), or in `onFixedUpdate`. `Date.now()` and `performance.now()` change from run to run.
|
|
187
187
|
- Use `math.random` or `Math.random`: hold mode seeds both. Random numbers from another source, such as `crypto.getRandomValues`, are not seeded.
|
|
188
188
|
- Expect no input, unless the test gives a timed script. A plain hold reads none: every key and button stays up, and the pointer stays at the canvas's top-left corner. A script's key and pointer steps reach the sketch at their times.
|
|
189
|
-
- Finish loading in the setup. Await every asset there, because the hold starts when the setup's promise resolves.
|
|
189
|
+
- Finish loading in the setup. Await every asset there, because the hold starts when the setup's promise resolves. A sketch that adds large models after the first frame on a live page waits for them when `engine.held` is true ([A fast start](start-time.md#draw-the-first-frame-before-the-large-models)).
|
|
190
190
|
- Pass test settings in the sketch module's address, such as `new URL('./sketch.ts?view=harbor', import.meta.url)`, and read them in the sketch with `new URL(import.meta.url).searchParams`. The page's messages reach the sketch only after the hold, because `createEngine` resolves after it.
|
|
191
191
|
- Keep a reference image per GPU tier, and force the tier with `?gpu=webgpu`, `?gpu=compat` or `?gpu=webgl2`. The tiers can differ slightly at edges.
|
|
192
|
-
- Compare with a small tolerance. A software GPU in CI and a real GPU differ at object edges.
|
|
192
|
+
- Compare with a small tolerance. A software GPU in CI and a real GPU differ at object edges. `bunx @null3d/cli test` counts a pixel as different past 10% of the color range. It fails an image when more than 0.1% of its pixels differ ([References and results](../cli/null3d.md#references-and-results)).
|
|
193
|
+
|
|
194
|
+
Loads that run side by side are safe in a held frame. While the engine holds frames or replays, the sketch's `assets` calls run one at a time, in the order the sketch made them. A model makes its textures in the file's order. So a held scene puts its content together in the same order on every run, however its files arrive ([Hold mode](#hold-mode)).
|
|
193
195
|
|
|
194
196
|
The [hold mode demo](https://github.com/null3d-engine/null3d/tree/main/examples/hold-mode) drops 400 balls from random places, and moves them by each frame's step. Every live run differs. With `?hold=3`, every run draws the same frame.
|
|
195
197
|
|
|
198
|
+
## Browser tests of a whole app
|
|
199
|
+
|
|
200
|
+
Image tests check pictures. A game or an app also needs a suite that opens its real page in a browser, drives it and checks what it did. The null3d-develop agent skill's `references/e2e-testing.md` gives the whole setup, with a worked Playwright config and spec. Its main rules:
|
|
201
|
+
|
|
202
|
+
- Run Playwright Test with its own pinned Chromium, installed with `bunx playwright install chromium`. Use one browser version on every machine, and never the installed Google Chrome.
|
|
203
|
+
- Start the real app with Playwright's `webServer`: the dev server, and the production build through `vite preview`. CI tests the production build.
|
|
204
|
+
- Serve the page from `localhost` or over HTTPS, with the null3D Vite plugin, which sends the isolation headers.
|
|
205
|
+
- Wait for `engine.firstFrame`, for `window.__null3dHold` in a held page, or for the app's own hook. Never wait with a fixed sleep.
|
|
206
|
+
- Give the page a read-only test hook. It holds the state, a hash of it and the input recording, and the same input functions that the UI calls. The sketch has no DOM, so input starts on the page and reaches the sketch by [message](../api/page.md).
|
|
207
|
+
- Assert game logic on state and hashes. Assert pictures with hold-mode image tests, never with browser screenshots.
|
|
208
|
+
- Step the logic in fixed ticks, seed every random number with [`math.seed`](../api/math.md#random-numbers), and keep `Date.now()` and `performance.now()` out of it. A recording then replays to the same hash.
|
|
209
|
+
- Give each copy of the project its own port, fail a test on any console error, and record a trace on the first retry.
|
|
210
|
+
- Keep real phones and tablets, and frame-rate timing, out of CI.
|
|
211
|
+
|
|
196
212
|
## Switches for tests
|
|
197
213
|
|
|
198
214
|
The engine reads these switches from the page's address in development builds. These are the dev server, the `null3d` command's runs and the CDN build's development entry, `lib-dev/index.js`. A production build ignores them, so a link cannot change how a shipped game runs. The CDN build's production entry, `lib/index.js`, ignores them too. To use them in a production build of test pages, turn on the Vite plugin's `urlSwitches` option: `null3d({ urlSwitches: true })`. For a benchmark page that loads the CDN build, `bun run build:cdn --url-switches` does the same ([Try null3D from a CDN](../getting-started/cdn.md#production-and-development-entries)).
|
|
@@ -207,6 +223,7 @@ The engine reads these switches from the page's address in development builds. T
|
|
|
207
223
|
| `?multidraw=off` | On WebGL2, draw as a browser without the `WEBGL_multi_draw` extension does: the engine probes none and draws the whole levels of a cluster tree in place of its patches ([Levels of detail](../concepts/lod.md#cluster-levels)) |
|
|
208
224
|
| `?compile=wait` | On WebGL2, wait for each shader program's compile at its first draw, as browsers without the `KHR_parallel_shader_compile` extension do |
|
|
209
225
|
| `?check=fresh` | Measure the quality preset again, as on a first visit, instead of taking the stored result of an earlier [preset check](../concepts/quality-presets.md#repeat-visits) |
|
|
226
|
+
| `?builds=fresh` | Start each pipeline build when the first frame asks for it, as on a first visit, instead of building the [stored list](loading-screens.md#repeat-visits) of an earlier start's first frame ahead of it |
|
|
210
227
|
| `?compression=bc`, `?compression=astc,etc2`, `?compression=none` | Keep KTX2 textures to the compressed formats that the list names, of those the device has, as on a device with only those. `none` gives every KTX2 texture `rgba8unorm` |
|
|
211
228
|
| `?derived-cache=off` | Turn the [cache of derived data](../api/assets.md#the-cache-of-derived-data) off, so every load makes its data again, as on a first visit: KTX2 files transcode, and `assets.cache` keeps nothing |
|
|
212
229
|
| `?threads=off` | The single-threaded build |
|
|
@@ -224,4 +241,5 @@ The engine reads these switches from the page's address in development builds. T
|
|
|
224
241
|
| `?still-camera=off` | Draw every frame of a view that holds still, without the [still-camera accumulation](../concepts/post-processing.md#still-camera-accumulation): the view neither blends nor rests. Hold mode draws without it too |
|
|
225
242
|
| `?preset=low`, `?preset=medium`, `?preset=high`, `?preset=ultra` | Fix the quality preset, within the GPU path's highest; the engine then ignores starts that crashed before |
|
|
226
243
|
| `?target-fps=display`, `?target-fps=90` | Set the frame rate that the preset check and the governor defend, in place of the `targetFps` option: the display's full rate, or at most that many frames per second ([The target frame rate](../concepts/quality-presets.md#the-target-frame-rate)) |
|
|
244
|
+
| `?preset-check=during-play`, `?preset-check=before-play` | Set when the preset check measures, in place of the `presetCheck` option: in the first frames of play, or before play, with `createEngine` waiting for it ([The preset check](../concepts/quality-presets.md#the-preset-check)) |
|
|
227
245
|
| `?view=levels` | Draw a debug view, here the levels of detail, with no code change ([Debug views](../api/debug.md#the-view-from-the-address)). The switch takes any view name that `debug.view` takes |
|
|
@@ -102,8 +102,8 @@ The engine holds 4,096 labels at once by default. For more, set `createEngine`'s
|
|
|
102
102
|
|
|
103
103
|
A label can also be a plane of the scene. It then scales with the distance, and it leans as its object or the camera turns. Give `ui.trackLabel` a `transform`:
|
|
104
104
|
|
|
105
|
-
- `'world'` turns and scales the element with the object
|
|
106
|
-
- `'billboard'` keeps the element facing the camera
|
|
105
|
+
- `'world'` turns and scales the element with the object.
|
|
106
|
+
- `'billboard'` keeps the element facing the camera. Its `rotation` turns the content in the element's own plane.
|
|
107
107
|
|
|
108
108
|
```ts
|
|
109
109
|
// sketch.ts
|
|
@@ -121,7 +121,7 @@ layer.append(card);
|
|
|
121
121
|
engine.labels.bind('card-3', card);
|
|
122
122
|
```
|
|
123
123
|
|
|
124
|
-
An element's CSS pixels are the scene's units for these labels
|
|
124
|
+
An element's CSS pixels are the scene's units for these labels. An element 200 pixels wide is 200 units wide. Size the scene around it to match, and the browser keeps the text sharp at any distance.
|
|
125
125
|
|
|
126
126
|
A plane follows either lens. An orthographic camera turns and scales the element as a perspective camera does. An element can hold any markup, such as an iframe or a form. Give it `pointer-events: auto` if it takes the pointer, because the layer around it passes the pointer through.
|
|
127
127
|
|
package/docs/index.md
CHANGED
|
@@ -8,11 +8,14 @@ summary: "What null3D is; how the docs are organized; status labels."
|
|
|
8
8
|
|
|
9
9
|
# null3D documentation
|
|
10
10
|
|
|
11
|
-
null3D is a browser 3D engine for
|
|
11
|
+
null3D is a high-performance browser 3D engine for coding agents and the developers who work with them. It is built for two things: speed, and scenes that work on every current device.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
- **Faster than three.js.** null3D beats three.js in five of its six benchmark scenes. A scene graph of 5,096 objects costs null3D 0.35 ms of CPU time per frame, and three.js 3.18 ms. The engine loses one scene, in which 100,000 boxes stand still. The [performance guide](guides/performance.md) shows how to keep your own scene fast.
|
|
14
|
+
- **Wide device compatibility.** One sketch runs on current computers, tablets and phones. The engine draws with WebGPU, and with WebGL2 where WebGPU is missing, from the same code. [GPU tiers and backends](concepts/backends.md) lists the browsers, and [Quality presets](concepts/quality-presets.md) says how the engine fits its work to each device.
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
Its core is Rust compiled to WebAssembly, and it runs on worker threads, so the page's main thread stays free.
|
|
17
|
+
|
|
18
|
+
In null3D, a 3D scene is called a **sketch**. A sketch is a TypeScript module that builds its scene with `defineSketch` and updates it every frame. It runs in a worker of its own, while the page keeps the HTML.
|
|
16
19
|
|
|
17
20
|
## Status labels
|
|
18
21
|
|
|
@@ -20,12 +23,11 @@ Every page has a status in its front matter:
|
|
|
20
23
|
|
|
21
24
|
| Status | Meaning |
|
|
22
25
|
| --- | --- |
|
|
23
|
-
| `
|
|
24
|
-
| `experimental` | The feature works, but its API can still change between versions. When the engine has only part of a page's feature, the note at the top of the page names the parts that are not built yet. |
|
|
26
|
+
| `experimental` | The feature works, but its API can still change between versions. |
|
|
25
27
|
| `stable` | The API follows semantic versioning. |
|
|
26
|
-
| `generated` | A tool writes the page from a single source, such as the
|
|
28
|
+
| `generated` | A tool writes the page from a single source, such as the engine's doc comments. |
|
|
27
29
|
|
|
28
|
-
Coding agents
|
|
30
|
+
Each page names the limits of its feature, with a workaround where one exists. Coding agents use only the APIs that these pages and the engine's type declarations show. The null3D agent skills follow the same rule.
|
|
29
31
|
|
|
30
32
|
Each `api/` page links to its API reference, which the engine's doc comments generate, so it always matches the code.
|
|
31
33
|
|
|
@@ -35,8 +37,10 @@ The step column in [All pages](pages.md) gives the roadmap step that adds the pa
|
|
|
35
37
|
|
|
36
38
|
- [Architecture: threads and the frame](concepts/architecture.md) explains where sketch code runs, and why.
|
|
37
39
|
- [GPU tiers and backends](concepts/backends.md) shows which browsers get WebGPU and which get WebGL2.
|
|
40
|
+
- The [performance guide](guides/performance.md) shows where frame time goes, and how to measure your scene.
|
|
41
|
+
- [Phones and tablets](guides/phones.md) says what the engine does on a small device, and how to test on one.
|
|
38
42
|
- [Hosting and cross-origin isolation](getting-started/hosting.md) covers the two HTTP headers that turn on worker threads.
|
|
39
|
-
-
|
|
43
|
+
- To port an app from three.js, the [three.js to null3D mapping](porting/threejs-mapping.md) gives the null3D equivalent of each three.js API that a port is likely to meet.
|
|
40
44
|
|
|
41
45
|
Coding agents can look pages up by ID. A page's ID is its path under `docs/` without `.md`, such as `concepts/architecture`. From version 0.1, the same pages ship inside the `@null3d/engine` package, so they always match the installed engine.
|
|
42
46
|
|