@null3d/engine 0.1.0 → 0.1.2

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.
Files changed (388) hide show
  1. package/dist/wasm/single/null3d.js +10 -8
  2. package/dist/wasm/single/null3d_bg.wasm +0 -0
  3. package/dist/wasm/threaded/null3d.js +10 -8
  4. package/dist/wasm/threaded/null3d_bg.wasm +0 -0
  5. package/docs/api/animation.md +96 -24
  6. package/docs/api/assets.md +99 -29
  7. package/docs/api/cameras.md +38 -7
  8. package/docs/api/controls.md +47 -23
  9. package/docs/api/debug.md +105 -35
  10. package/docs/api/engine.md +108 -32
  11. package/docs/api/feature-draws.md +21 -15
  12. package/docs/api/feature-effects.md +8 -8
  13. package/docs/api/feature-instances.md +68 -17
  14. package/docs/api/features.md +68 -37
  15. package/docs/api/geometry.md +83 -14
  16. package/docs/api/grass.md +55 -13
  17. package/docs/api/impostors.md +92 -50
  18. package/docs/api/input.md +22 -9
  19. package/docs/api/lights.md +67 -16
  20. package/docs/api/lines.md +38 -13
  21. package/docs/api/materials.md +187 -59
  22. package/docs/api/math.md +6 -6
  23. package/docs/api/objects.md +40 -15
  24. package/docs/api/page.md +58 -7
  25. package/docs/api/particles.md +36 -11
  26. package/docs/api/points.md +18 -8
  27. package/docs/api/post.md +57 -23
  28. package/docs/api/quality.md +36 -16
  29. package/docs/api/raycast.md +57 -24
  30. package/docs/api/reference/animation.md +1 -2
  31. package/docs/api/reference/assets.md +7 -4
  32. package/docs/api/reference/cameras.md +3 -2
  33. package/docs/api/reference/controls.md +59 -2
  34. package/docs/api/reference/debug.md +58 -6
  35. package/docs/api/reference/engine.md +40 -10
  36. package/docs/api/reference/feature-draws.md +3 -4
  37. package/docs/api/reference/feature-effects.md +2 -3
  38. package/docs/api/reference/feature-instances.md +5 -4
  39. package/docs/api/reference/features.md +7 -4
  40. package/docs/api/reference/geometry.md +132 -21
  41. package/docs/api/reference/grass.md +62 -2
  42. package/docs/api/reference/impostors.md +120 -16
  43. package/docs/api/reference/input.md +1 -2
  44. package/docs/api/reference/lights.md +4 -3
  45. package/docs/api/reference/lines.md +3 -4
  46. package/docs/api/reference/materials.md +7 -6
  47. package/docs/api/reference/math.md +13 -2
  48. package/docs/api/reference/objects.md +2 -3
  49. package/docs/api/reference/particles.md +31 -6
  50. package/docs/api/reference/points.md +2 -3
  51. package/docs/api/reference/post.md +4 -3
  52. package/docs/api/reference/quality.md +1 -2
  53. package/docs/api/reference/raycast.md +1 -2
  54. package/docs/api/reference/render.md +4 -3
  55. package/docs/api/reference/scene.md +24 -5
  56. package/docs/api/reference/sketch.md +11 -11
  57. package/docs/api/reference/sound.md +33 -2
  58. package/docs/api/reference/splats.md +42 -3
  59. package/docs/api/reference/sprites.md +2 -3
  60. package/docs/api/reference/tasks.md +16 -3
  61. package/docs/api/reference/terrain.md +26 -5
  62. package/docs/api/reference/textures.md +1 -2
  63. package/docs/api/reference/three-compat.md +18 -7
  64. package/docs/api/reference/time.md +1 -2
  65. package/docs/api/reference/ui.md +10 -7
  66. package/docs/api/reference/vertex-draws.md +2 -3
  67. package/docs/api/reference/water.md +78 -5
  68. package/docs/api/reference/wind.md +15 -2
  69. package/docs/api/render.md +67 -25
  70. package/docs/api/scene.md +129 -36
  71. package/docs/api/sketch.md +45 -19
  72. package/docs/api/sound.md +48 -12
  73. package/docs/api/splats.md +42 -15
  74. package/docs/api/sprites.md +8 -6
  75. package/docs/api/tasks.md +31 -22
  76. package/docs/api/terrain.md +44 -12
  77. package/docs/api/textures.md +61 -12
  78. package/docs/api/three-compat.md +15 -7
  79. package/docs/api/time.md +3 -5
  80. package/docs/api/ui.md +18 -10
  81. package/docs/api/vertex-draws.md +13 -12
  82. package/docs/api/water.md +111 -67
  83. package/docs/api/wind.md +61 -15
  84. package/docs/cli/null3d.md +90 -15
  85. package/docs/concepts/architecture.md +69 -23
  86. package/docs/concepts/assets.md +57 -16
  87. package/docs/concepts/backends.md +68 -24
  88. package/docs/concepts/color-management.md +42 -13
  89. package/docs/concepts/culling.md +68 -47
  90. package/docs/concepts/handles.md +14 -5
  91. package/docs/concepts/instances.md +72 -23
  92. package/docs/concepts/large-worlds.md +17 -7
  93. package/docs/concepts/lighting.md +117 -44
  94. package/docs/concepts/lod.md +128 -33
  95. package/docs/concepts/materials.md +43 -12
  96. package/docs/concepts/particle-buffer.md +48 -35
  97. package/docs/concepts/post-processing.md +77 -14
  98. package/docs/concepts/quality-preset-tables.md +3 -2
  99. package/docs/concepts/quality-presets.md +122 -39
  100. package/docs/concepts/render-graph.md +56 -21
  101. package/docs/concepts/render-layers.md +9 -5
  102. package/docs/concepts/shadows.md +96 -25
  103. package/docs/concepts/static-dynamic.md +22 -7
  104. package/docs/cookbook/index.md +163 -119
  105. package/docs/data/threejs-mapping.json +301 -340
  106. package/docs/errors/E1101.md +23 -5
  107. package/docs/errors/E1102.md +11 -3
  108. package/docs/errors/E1103.md +11 -3
  109. package/docs/errors/E1104.md +11 -3
  110. package/docs/errors/E1105.md +13 -5
  111. package/docs/errors/E1106.md +11 -3
  112. package/docs/errors/E1107.md +15 -5
  113. package/docs/errors/E1108.md +11 -3
  114. package/docs/errors/E1109.md +32 -6
  115. package/docs/errors/E1110.md +23 -5
  116. package/docs/errors/E1111.md +11 -3
  117. package/docs/errors/E1112.md +11 -3
  118. package/docs/errors/E1203.md +12 -4
  119. package/docs/errors/E1204.md +11 -3
  120. package/docs/errors/E1205.md +11 -3
  121. package/docs/errors/E1206.md +28 -6
  122. package/docs/errors/E1207.md +11 -3
  123. package/docs/errors/E1208.md +12 -3
  124. package/docs/errors/E1209.md +11 -3
  125. package/docs/errors/E1213.md +27 -5
  126. package/docs/errors/E1214.md +11 -3
  127. package/docs/errors/E1215.md +31 -6
  128. package/docs/errors/E1216.md +31 -6
  129. package/docs/errors/E1217.md +29 -6
  130. package/docs/errors/E1218.md +22 -6
  131. package/docs/errors/E1219.md +11 -3
  132. package/docs/errors/E1220.md +24 -5
  133. package/docs/errors/E1221.md +24 -5
  134. package/docs/errors/E1222.md +11 -3
  135. package/docs/errors/E1223.md +39 -6
  136. package/docs/errors/E1224.md +11 -3
  137. package/docs/errors/E1225.md +11 -3
  138. package/docs/errors/E1301.md +11 -3
  139. package/docs/errors/E1302.md +11 -3
  140. package/docs/errors/E1303.md +11 -3
  141. package/docs/errors/E1304.md +11 -3
  142. package/docs/errors/E1305.md +13 -3
  143. package/docs/errors/E1306.md +11 -3
  144. package/docs/errors/E1307.md +23 -6
  145. package/docs/errors/E1308.md +31 -0
  146. package/docs/errors/E1401.md +11 -3
  147. package/docs/errors/E1402.md +13 -5
  148. package/docs/errors/E1403.md +11 -3
  149. package/docs/errors/E1404.md +13 -3
  150. package/docs/errors/E1405.md +15 -4
  151. package/docs/errors/E1406.md +31 -5
  152. package/docs/errors/E1407.md +11 -3
  153. package/docs/errors/E1408.md +11 -3
  154. package/docs/errors/E1409.md +11 -3
  155. package/docs/errors/E1410.md +13 -5
  156. package/docs/errors/E1411.md +11 -3
  157. package/docs/errors/E1412.md +29 -6
  158. package/docs/errors/E1413.md +11 -3
  159. package/docs/errors/E1414.md +11 -3
  160. package/docs/errors/E1415.md +11 -3
  161. package/docs/errors/E1416.md +27 -6
  162. package/docs/errors/E1417.md +11 -3
  163. package/docs/errors/E1418.md +12 -3
  164. package/docs/errors/E1419.md +13 -5
  165. package/docs/errors/E1420.md +11 -3
  166. package/docs/errors/E1421.md +11 -3
  167. package/docs/errors/E1422.md +12 -3
  168. package/docs/errors/E1423.md +12 -3
  169. package/docs/errors/E1424.md +24 -5
  170. package/docs/errors/E1425.md +11 -3
  171. package/docs/errors/E1426.md +11 -3
  172. package/docs/errors/E1430.md +11 -3
  173. package/docs/errors/E1431.md +11 -3
  174. package/docs/errors/E1432.md +11 -3
  175. package/docs/errors/E1433.md +11 -3
  176. package/docs/errors/E1434.md +15 -6
  177. package/docs/errors/E1435.md +11 -3
  178. package/docs/errors/E1436.md +11 -3
  179. package/docs/errors/E1437.md +14 -6
  180. package/docs/errors/E1501.md +41 -6
  181. package/docs/errors/E1502.md +13 -3
  182. package/docs/errors/E1503.md +11 -3
  183. package/docs/errors/E1504.md +11 -3
  184. package/docs/errors/E1505.md +23 -5
  185. package/docs/errors/E1506.md +11 -3
  186. package/docs/errors/index.md +53 -29
  187. package/docs/getting-started/cdn.md +15 -9
  188. package/docs/getting-started/first-scene.md +20 -12
  189. package/docs/getting-started/hosting.md +113 -63
  190. package/docs/getting-started/install.md +39 -24
  191. package/docs/getting-started/network-use.md +31 -21
  192. package/docs/getting-started/project-structure.md +20 -8
  193. package/docs/getting-started/third-party-notices.md +6 -10
  194. package/docs/guides/accessibility.md +4 -4
  195. package/docs/guides/add-ons.md +83 -13
  196. package/docs/guides/agents.md +13 -14
  197. package/docs/guides/assets-pipeline.md +294 -72
  198. package/docs/guides/audio.md +17 -15
  199. package/docs/guides/baked-light-data.md +44 -23
  200. package/docs/guides/car-paint.md +37 -31
  201. package/docs/guides/content-pages.md +86 -29
  202. package/docs/guides/custom-passes.md +59 -17
  203. package/docs/guides/custom-shaders.md +54 -37
  204. package/docs/guides/debugging.md +31 -41
  205. package/docs/guides/deploying.md +10 -27
  206. package/docs/guides/deterministic-simulation.md +23 -16
  207. package/docs/guides/first-use-shaders.md +83 -45
  208. package/docs/guides/lens-kit.md +29 -26
  209. package/docs/guides/loading-screens.md +74 -30
  210. package/docs/guides/multiple-views.md +22 -11
  211. package/docs/guides/performance.md +188 -37
  212. package/docs/guides/phones.md +71 -19
  213. package/docs/guides/physics.md +6 -10
  214. package/docs/guides/screens.md +41 -29
  215. package/docs/guides/start-time.md +126 -85
  216. package/docs/guides/testing.md +137 -98
  217. package/docs/guides/ui-overlays.md +17 -12
  218. package/docs/guides/video-textures.md +14 -13
  219. package/docs/images/api/animation/character.webp +0 -0
  220. package/docs/images/api/animation/look-at-ring.webp +0 -0
  221. package/docs/images/api/animation/morph-tulips.webp +0 -0
  222. package/docs/images/api/animation/skeleton-lines.webp +0 -0
  223. package/docs/images/api/controls/gizmo-handles.webp +0 -0
  224. package/docs/images/api/controls/walk-and-fly.webp +0 -0
  225. package/docs/images/api/debug/debug-shapes.webp +0 -0
  226. package/docs/images/api/debug/levels-view.webp +0 -0
  227. package/docs/images/api/engine/transparent-canvas.webp +0 -0
  228. package/docs/images/api/feature-draws/feature-draw-clouds.webp +0 -0
  229. package/docs/images/api/feature-instances/compute-instances.webp +0 -0
  230. package/docs/images/api/feature-instances/instances-shadow.webp +0 -0
  231. package/docs/images/api/geometry/extra-shapes.webp +0 -0
  232. package/docs/images/api/geometry/generators.webp +0 -0
  233. package/docs/images/api/geometry/mesh-arrays.webp +0 -0
  234. package/docs/images/api/geometry/vertex-updates.webp +0 -0
  235. package/docs/images/api/grass/grass-grove.webp +0 -0
  236. package/docs/images/api/grass/grass-presets.webp +0 -0
  237. package/docs/images/api/grass/grass-shadow.webp +0 -0
  238. package/docs/images/api/impostors/impostor-handover.webp +0 -0
  239. package/docs/images/api/impostors/impostor-shadow.webp +0 -0
  240. package/docs/images/api/impostors/impostors-forest.webp +0 -0
  241. package/docs/images/api/lights/spot-cookies.webp +0 -0
  242. package/docs/images/api/lines/lines-lit.webp +0 -0
  243. package/docs/images/api/lines/lines-widths.webp +0 -0
  244. package/docs/images/api/materials/coat-and-sheen.webp +0 -0
  245. package/docs/images/api/materials/decals.webp +0 -0
  246. package/docs/images/api/materials/iridescence-and-anisotropy.webp +0 -0
  247. package/docs/images/api/materials/relief.webp +0 -0
  248. package/docs/images/api/materials/shader-inputs.webp +0 -0
  249. package/docs/images/api/materials/standard-grid.webp +0 -0
  250. package/docs/images/api/materials/subsurface.webp +0 -0
  251. package/docs/images/api/materials/translucency.webp +0 -0
  252. package/docs/images/api/objects/objects-turntable.webp +0 -0
  253. package/docs/images/api/particles/campfire.webp +0 -0
  254. package/docs/images/api/points/galaxy.webp +0 -0
  255. package/docs/images/api/reference/textures/texture-wrap.webp +0 -0
  256. package/docs/images/api/render/fullscreen-glow.webp +0 -0
  257. package/docs/images/api/render/reflection-mirror.webp +0 -0
  258. package/docs/images/api/render/security-camera.webp +0 -0
  259. package/docs/images/api/scene/aurora-sky-layer.webp +0 -0
  260. package/docs/images/api/sound/sound-demo.webp +0 -0
  261. package/docs/images/api/splats/splats-demo.webp +0 -0
  262. package/docs/images/api/sprites/sprites-lines.webp +0 -0
  263. package/docs/images/api/terrain/terrain-demo.webp +0 -0
  264. package/docs/images/api/textures/canvas-screen.webp +0 -0
  265. package/docs/images/api/textures/mipmaps.webp +0 -0
  266. package/docs/images/api/vertex-draws/rain.webp +0 -0
  267. package/docs/images/api/water/ocean.webp +0 -0
  268. package/docs/images/api/water/water-demo.webp +0 -0
  269. package/docs/images/api/water/water-rain.webp +0 -0
  270. package/docs/images/api/water/waterfall.webp +0 -0
  271. package/docs/images/concepts/assets/gltf-model.webp +0 -0
  272. package/docs/images/concepts/color-management/tone-mapped.webp +0 -0
  273. package/docs/images/concepts/culling/far-from-origin.webp +0 -0
  274. package/docs/images/concepts/instances/instances.webp +0 -0
  275. package/docs/images/concepts/instances/per-row-colors.webp +0 -0
  276. package/docs/images/concepts/large-worlds/large-world.webp +0 -0
  277. package/docs/images/concepts/lighting/area-lights.webp +0 -0
  278. package/docs/images/concepts/lighting/atmosphere.webp +0 -0
  279. package/docs/images/concepts/lighting/environment.webp +0 -0
  280. package/docs/images/concepts/lighting/light-shafts.webp +0 -0
  281. package/docs/images/concepts/lighting/reflection-probes.webp +0 -0
  282. package/docs/images/concepts/lod/forest.webp +0 -0
  283. package/docs/images/concepts/materials/weighted-transparency.webp +0 -0
  284. package/docs/images/concepts/post-processing/auto-exposure.webp +0 -0
  285. package/docs/images/concepts/post-processing/bounce-light.webp +0 -0
  286. package/docs/images/concepts/post-processing/depth-of-field.webp +0 -0
  287. package/docs/images/concepts/post-processing/post-effects-alley.webp +0 -0
  288. package/docs/images/concepts/post-processing/sharpen.webp +0 -0
  289. package/docs/images/concepts/post-processing/ssr-wet-street.webp +0 -0
  290. package/docs/images/concepts/render-layers/layers-cottages.webp +0 -0
  291. package/docs/images/concepts/shadows/hero-shadow.webp +0 -0
  292. package/docs/images/cookbook/index/picking.webp +0 -0
  293. package/docs/images/cookbook/index/time-of-day.webp +0 -0
  294. package/docs/images/errors/E1431/area-lights-no-tables.webp +0 -0
  295. package/docs/images/guides/custom-passes/reflection-water.webp +0 -0
  296. package/docs/images/guides/deterministic-simulation/replay-demo.webp +0 -0
  297. package/docs/images/guides/multiple-views/split-screen.webp +0 -0
  298. package/docs/images/guides/performance/overdraw-view.webp +0 -0
  299. package/docs/images/guides/testing/hold-mode-frame.webp +0 -0
  300. package/docs/images/index/showcase-island.webp +0 -0
  301. package/docs/images/porting/threejs-shaders/dissolve.webp +0 -0
  302. package/docs/images/shaders/builtins/builtins.webp +0 -0
  303. package/docs/images/shaders/surface-functions/custom-surface.webp +0 -0
  304. package/docs/images/shaders/surface-functions/vertex-offset.webp +0 -0
  305. package/docs/images/shots.json +2231 -0
  306. package/docs/index.md +14 -23
  307. package/docs/moves.json +1 -0
  308. package/docs/nav.json +300 -0
  309. package/docs/pages.md +230 -212
  310. package/docs/porting/react-three-fiber.md +2 -6
  311. package/docs/porting/threejs-loop-and-threads.md +1 -5
  312. package/docs/porting/threejs-mapping.md +1248 -234
  313. package/docs/porting/threejs-materials.md +10 -5
  314. package/docs/porting/threejs-overview.md +26 -6
  315. package/docs/porting/threejs-postprocessing.md +2 -6
  316. package/docs/porting/threejs-shaders.md +16 -14
  317. package/docs/porting/threejs-unsupported.md +6 -6
  318. package/docs/porting/verification.md +0 -4
  319. package/docs/shaders/builtins.md +15 -4
  320. package/docs/shaders/library.md +9 -6
  321. package/docs/shaders/surface-functions.md +51 -16
  322. package/docs/shaders/wgsl-rules.md +12 -5
  323. package/lib/debug/debug.d.ts +2 -2
  324. package/lib/debug/draw.d.ts +2 -2
  325. package/lib/debug/draw.js +8 -4
  326. package/lib/debug/overlay-look.d.ts +6 -0
  327. package/lib/debug/overlay-look.js +29 -7
  328. package/lib/debug/overlay.js +15 -11
  329. package/lib/debug/stats-options.d.ts +13 -0
  330. package/lib/debug/stats-panel.d.ts +21 -6
  331. package/lib/debug/stats-panel.js +80 -13
  332. package/lib/errors/codes.d.ts +17 -3
  333. package/lib/errors/codes.js +116 -105
  334. package/lib/errors/engine-error.js +1 -1
  335. package/lib/errors/fixes.d.ts +1 -0
  336. package/lib/errors/fixes.js +19 -18
  337. package/lib/generated/shader-permutations.d.ts +6 -0
  338. package/lib/generated/shader-permutations.js +6 -0
  339. package/lib/gpu/variants.d.ts +8 -2
  340. package/lib/gpu/variants.js +39 -7
  341. package/lib/gpu/webgl2/programs.js +1 -1
  342. package/lib/gpu/webgpu/pipelines.js +13 -13
  343. package/lib/index.d.ts +1 -1
  344. package/lib/page/capabilities.d.ts +1 -1
  345. package/lib/page/engine.d.ts +29 -7
  346. package/lib/page/engine.js +79 -7
  347. package/lib/page/label-loop.js +9 -4
  348. package/lib/page/stats-switch.js +2 -0
  349. package/lib/page/switches.d.ts +6 -4
  350. package/lib/page/switches.js +20 -4
  351. package/lib/scene/baked-light.d.ts +2 -2
  352. package/lib/scene/fake-call-values.js +2 -2
  353. package/lib/scene/frame-cameras.d.ts +16 -4
  354. package/lib/scene/frame-cameras.js +28 -10
  355. package/lib/scene/gltf.d.ts +1 -1
  356. package/lib/scene/level-rule.d.ts +6 -5
  357. package/lib/scene/level-rule.js +2 -2
  358. package/lib/scene/particles.d.ts +7 -3
  359. package/lib/scene/particles.js +3 -1
  360. package/lib/scene/post.d.ts +3 -2
  361. package/lib/scene/resources.d.ts +15 -9
  362. package/lib/scene/scene.d.ts +18 -2
  363. package/lib/scene/scene.js +47 -5
  364. package/lib/scene/time-of-day.d.ts +10 -5
  365. package/lib/scene/time-of-day.js +11 -7
  366. package/lib/shader-artifact.json +1 -1
  367. package/lib/shared/labels.d.ts +5 -2
  368. package/lib/shared/labels.js +5 -2
  369. package/lib/shared/permutation-words.d.ts +8 -0
  370. package/lib/shared/permutation-words.js +14 -0
  371. package/lib/shared/recording.d.ts +13 -5
  372. package/lib/shared/recording.js +31 -10
  373. package/lib/shared/sketch-data.d.ts +9 -0
  374. package/lib/shared/sketch-data.js +57 -0
  375. package/lib/shared/tier.d.ts +9 -0
  376. package/lib/shared/tier.js +4 -1
  377. package/lib/shared/version.d.ts +1 -1
  378. package/lib/shared/version.js +1 -1
  379. package/lib/sketch/define-sketch.d.ts +16 -7
  380. package/lib/sketch/define-sketch.js +2 -1
  381. package/lib/sketch/runner.d.ts +4 -0
  382. package/lib/sketch/runner.js +5 -0
  383. package/lib/sketch/ui.js +4 -2
  384. package/lib/stats.d.ts +1 -0
  385. package/lib/workers/protocol.d.ts +10 -0
  386. package/lib/workers/render-worker.js +4 -1
  387. package/lib/workers/sketch-worker.js +4 -1
  388. package/package.json +1 -1
@@ -1,15 +1,11 @@
1
1
  ---
2
2
  id: guides/phones
3
3
  title: Phones and tablets
4
- status: experimental
5
- since: "0.1"
6
4
  summary: "Pixel-ratio caps; memory budgets; heat; testing on real devices."
7
5
  ---
8
6
 
9
7
  # Phones and tablets
10
8
 
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
9
  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
10
 
15
11
  ## The preset on a phone
@@ -26,7 +22,7 @@ export default defineSketch(({ quality }) => {
26
22
  });
27
23
  ```
28
24
 
29
- Do not force a heavier preset on phones. When a player picks one in a menu, pass it to `createEngine` with the `preset` option.
25
+ Do not force a heavier preset on phones. When a player picks one in a menu, switch to it with `quality.setPreset` in the sketch ([Quality API](../api/quality.md#switching-presets)). The GPU path still caps it, and `quality.highest` names the cap. To start at a choice that the page remembers, pass it to `createEngine` with the `preset` option. The [instancing demo](https://github.com/null3d-engine/null3d/tree/main/examples/instances) draws a 101 x 101 grid of columns on Low, and 317 x 317 above it.
30
26
 
31
27
  Low, the phone's preset, leaves out the costliest work:
32
28
 
@@ -54,14 +50,27 @@ The engine caps the ratio at the preset's value, which is lowest on the Low pres
54
50
 
55
51
  When frames take too long, the engine draws the scene at a lower render scale: a part of the canvas's width and height. It then scales the image up to the canvas. On the Low preset, the scale can drop to 0.5, a quarter of the pixels. It rises again when the frames have time to spare. [Quality presets](../concepts/quality-presets.md#dynamic-resolution) explains when the scale moves.
56
52
 
57
- Text and fine lines in the scene get softer at a lower scale. The scaling also takes the place of FXAA, which Low uses to smooth edges. Draw your interface in HTML over the canvas, where it stays sharp. To keep the whole canvas on a device, set `quality.set({ minRenderScale: 1 })`. The savings of the pixel ratio cap and the render scale multiply. At a ratio of 1.5 and a scale of 0.5, the phone above fills 0.19 million pixels.
53
+ Text and fine lines in the scene get softer at a lower scale. On Low, the final pass still smooths edges with FXAA at the render size. It then scales the image up to the canvas with an edge-aware upscaler.
54
+
55
+ Draw your interface in HTML over the canvas, where it stays sharp. To keep the whole canvas on a device, set `quality.set({ minRenderScale: 1 })`. The savings of the pixel ratio cap and the render scale multiply. At a ratio of 1.5 and a scale of 0.5, the phone above fills 0.19 million pixels.
58
56
 
59
57
  ## Shadows
60
58
 
61
- A directional light's shadows draw the shadow casters once for each cascade, into a map whose texels the GPU fills each frame. The preset sets the cascade count and the map size of each light whose options name neither. Low draws fewer cascades than Medium, with smaller maps, and blends fewer texels at each shadow's edge. So leave `cascades` and `mapSize` out of the light's `shadow` options, and phones draw lighter shadows by themselves. [Shadows](../concepts/shadows.md#settings) lists the options, and [Quality presets](../concepts/quality-presets.md#the-settings-of-each-preset) each preset's values. The shadow map stores each depth in 16 bits, which takes half the memory of 32-bit depths.
59
+ A directional light's shadows draw the shadow casters once for each cascade, into a map whose texels the GPU fills each frame. The preset sets the cascade count and the map size of each light whose options name neither. Low draws fewer cascades than Medium, with smaller maps, and blends fewer texels at each shadow's edge.
60
+
61
+ So leave `cascades` and `mapSize` out of the light's `shadow` options, and phones draw lighter shadows by themselves. [Shadows](../concepts/shadows.md#settings) lists the options, and [Quality presets](../concepts/quality-presets.md#the-settings-of-each-preset) each preset's values.
62
+
63
+ <details>
64
+ <summary>Technical details: how a shadow map stores depth</summary>
65
+
66
+ The shadow map stores each depth in 16 bits, which takes half the memory of 32-bit depths.
67
+
68
+ </details>
62
69
 
63
70
  ## Memory
64
71
 
72
+ ### How much memory a tab gets
73
+
65
74
  A phone closes a tab that uses too much memory, with no warning. The engine's tab memory test grew one kind of GPU memory in a tab, in steps of 32 MiB, until the tab died:
66
75
 
67
76
  | Device and browser | GPU textures | GPU buffers |
@@ -70,25 +79,65 @@ A phone closes a tab that uses too much memory, with no warning. The engine's ta
70
79
  | 11-inch iPad Pro, Safari, WebGL2 | 2,528 MiB | 2,496 MiB |
71
80
  | Galaxy S24+, Chrome, WebGL2 | 7,296 MiB | 7,616 MiB |
72
81
 
73
- No allocation failed first, and no error came. A scene holds its textures, buffers, render targets and WebAssembly memory at once, and a device with less memory gives a tab less. So the quality preset's texture memory budget keeps textures under 256 MiB on Low and 512 MiB on Medium. On phones and tablets, no preset gives textures more than 1,008 MiB. The iPad's WebGPU path can stop answering at 512 MiB of GPU buffers, though not in every run. Keep a scene's GPU buffers under half the point in the table.
82
+ No allocation failed first, and no error came. A scene holds its textures, buffers, render targets and WebAssembly memory at once, and a device with less memory gives a tab less.
83
+
84
+ So the quality preset's texture memory budget keeps textures under 256 MiB on Low and 512 MiB on Medium. On phones and tablets, no preset gives textures more than 1,008 MiB. The iPad's WebGPU path can stop answering at 512 MiB of GPU buffers, though not in every run. Keep a scene's GPU buffers under half the point in the table.
85
+
86
+ ### The engine's WebAssembly memory
74
87
 
75
88
  On a page with worker threads, the engine's threads share one WebAssembly memory, whose maximum the preset sets. The browser reserves address space for the whole maximum, and every other engine and WebAssembly module on the page shares what is left. [Page API: createEngine](../api/engine.md#memory) says when to ask for more.
76
89
 
90
+ ### Use less memory
91
+
77
92
  To use less memory, share meshes and materials, draw many copies with instance batches, and create objects during setup. `engine.measure` reports the WebAssembly memory in use. [Performance: memory peak](performance.md#memory-peak) shows how to read a scene's distance from its limit.
78
93
 
79
- Textures take GPU memory too. A texture of 1024 x 1024 texels takes about 5.3 MiB with its mip levels. When the textures pass their budget, the engine drops the largest mip levels of textures from files, and loads them again once room returns. The sketch reads the memory and the dropped levels in `quality.textureMemory`, and [Quality presets](../concepts/quality-presets.md#texture-memory) explains the order. A texture that the sketch makes from an image or from data keeps its levels, so free one that the scene no longer needs with `texture.destroy()`. The engine keeps no copy of an image once its upload is done. [Textures](../api/textures.md#gpu-memory) gives the sizes.
94
+ ### Textures
95
+
96
+ Textures take GPU memory too. A texture of 1024 x 1024 texels takes about 5.3 MiB with its mip levels. When the textures pass their budget, the engine drops the largest mip levels of textures from files, and loads them again once room returns. The sketch reads the memory and the dropped levels in `quality.textureMemory`, and [Quality presets](../concepts/quality-presets.md#texture-memory) explains the order.
97
+
98
+ A texture that the sketch makes from an image or from data keeps its levels, so free one that the scene no longer needs with `texture.destroy()`. The engine keeps no copy of an image once its upload is done. [Textures](../api/textures.md#gpu-memory) gives the sizes.
99
+
100
+ Load large textures from KTX2 files. `bunx @null3d/cli assets optimize` encodes them ([The asset pipeline](assets-pipeline.md)). Phones and tablets have the ASTC and ETC2 formats, so a KTX2 texture stays compressed on the GPU. The same 1024 x 1024 texture then takes about 1.3 MiB. [Textures](../api/textures.md#ktx2-files) covers KTX2 files.
101
+
102
+ <details>
103
+ <summary>Technical details: encoding KTX2 textures by hand</summary>
104
+
105
+ The same texture takes 0.7 MiB in ETC2 without alpha. Encode the mip levels into the file, as `basisu -mipmap` does, because the GPU cannot make them for compressed texels. Use UASTC for normal maps and detailed color maps, and ETC1S where the download must stay small. `texture.format` tells which format the device got.
106
+
107
+ </details>
80
108
 
81
- Load large textures from KTX2 files. `bunx @null3d/cli assets optimize` encodes them ([The asset pipeline](assets-pipeline.md)). Phones and tablets have the ASTC and ETC2 formats, so a KTX2 texture stays compressed on the GPU. The same 1024 x 1024 texture then takes about 1.3 MiB, or 0.7 MiB in ETC2 without alpha. Encode its mip levels into the file, as `basisu -mipmap` does, because the GPU cannot make them for compressed texels. Use UASTC for normal maps and detailed color maps, and ETC1S where the download must stay small. `texture.format` tells which format the device got. [Textures](../api/textures.md#ktx2-files) covers KTX2 files.
109
+ ### A second engine on the page
82
110
 
83
111
  A page that starts a second engine, for example in a single-page app, waits for the first engine's `destroy()` promise. The page keeps the first engine's shared memory for about 30 seconds, and the second engine takes it. So the browser need not give new memory. When the browser refuses memory at the start, the engine tries again for about 45 seconds. Then it fails with [E1109](../errors/E1109.md). `onProgress` reports `memory-wait` after 10 seconds, so the page can tell the user ([Engine](../api/engine.md#the-running-engine)).
84
112
 
85
- The scene's object tables start small and double as the scene grows. On a Galaxy S25 or a Pixel 9, a growth from 16,383 to 32,767 objects took 2.4 to 5.3 ms. For a large scene, set `createEngine`'s `expectedObjects` option, so the tables never grow during play.
113
+ ### Large scenes
114
+
115
+ The scene's object tables start small and double as the scene grows. On a Galaxy S25 or a Pixel 9, a growth from 16,383 to 32,767 objects took 2.4 to 5.3 ms. For a large scene, set `createEngine`'s `expectedObjects` option, so the tables never grow during play ([Objects during play](performance.md#objects-during-play)).
116
+
117
+ ### After a crash
86
118
 
87
119
  When the tab crashes during a start, the next start of the sketch runs one preset lower. A second crash in a row starts it at Low. [Quality presets](../concepts/quality-presets.md#starts-that-crashed-the-tab) explains the note that the engine keeps for this. The page reads the count in `engine.mode.crashedStarts`.
88
120
 
121
+ ### A page in the back-forward cache
122
+
123
+ On phones and tablets, the engine 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)).
124
+
89
125
  ## Heat
90
126
 
91
- A phone lowers its clock speeds when it heats up, often after a few minutes of play. Leave room for it: aim for about 70% of the frame budget, and test runs of 10 minutes. When frames still take too long, the frame-budget governor lowers a sketch's budgets and the render scale in turn, a budget's step first. Then it lowers the live shadow settings, bloom's base and the size of ambient occlusion. The `quality.onChange` handlers run after each step that follows the render scale, so the sketch can lighten its own work too ([Quality presets](../concepts/quality-presets.md#the-frame-budget-governor)). In the engine's benchmarks, a warm Galaxy S24+ took about 70% longer per frame than a cool one ([Performance guide](performance.md#phones-and-tablets)). Tablets heat up too. A warm 11-inch iPad Pro took about 17 ms of GPU time per S4 frame at Medium, against about 12.6 ms a minute earlier. It then ran at about 45 frames per second. At Low, it held 60 frames per second after 5 minutes of warm-up ([Quality presets](../concepts/quality-presets.md#how-the-engine-chooses-a-preset)). The [Performance guide](performance.md) also shows how to measure the frame.
127
+ A phone lowers its clock speeds when it heats up, often after a few minutes of play. Leave room for it: aim for about 70% of the frame budget, and test runs of 10 minutes. In the engine's benchmarks, a warm Galaxy S24+ took about 70% longer per frame than a cool one. The [Performance guide](performance.md#phones-and-tablets) also shows how to measure the frame.
128
+
129
+ When frames still take too long, the frame-budget governor lowers the quality step by step. The `quality.onChange` handlers run after each shadow step, so the sketch can lighten its own work too ([Quality presets](../concepts/quality-presets.md#the-frame-budget-governor)).
130
+
131
+ Tablets heat up too. A warm iPad can drop from 60 to about 45 frames per second at Medium, and Low holds 60 ([Quality presets](../concepts/quality-presets.md#how-the-engine-chooses-a-preset)).
132
+
133
+ <details>
134
+ <summary>Technical details: what the governor lowers, and measured heat on an iPad</summary>
135
+
136
+ The governor lowers a sketch's budgets and the render scale first. It then lowers the level of detail threshold, the far shadow cascades, the shadow filter, bloom's base and ambient occlusion's size. After those, it lowers screen-space reflections, contact shadows, far characters' update interval and the volumetric fog.
137
+
138
+ The warm 11-inch iPad Pro took about 17 ms of GPU time per S4 frame at Medium, against about 12.6 ms a minute earlier. It ran at about 45 frames per second. At Low, it held 60 frames per second after 5 minutes of warm-up.
139
+
140
+ </details>
92
141
 
93
142
  ## Power
94
143
 
@@ -96,11 +145,17 @@ A view that holds still stops drawing after about a second. The engine first ble
96
145
 
97
146
  ## Touch input
98
147
 
99
- The engine reads touches as it reads the mouse: the first finger presses `Mouse0`, and `input.touches` lists every finger on the canvas. A canvas that takes touch gestures needs `touch-action: none` in its CSS. Without it, the browser scrolls or zooms the page, and it cancels the touch. [Input](../api/input.md#touches) explains touches and pinches. A tap on an object calls its `click` handler, as a mouse click does ([Pointer events on objects](../api/input.md#pointer-events-on-objects)).
148
+ The engine reads touches as it reads the mouse: the first finger presses `Mouse0`, and `input.touches` lists every finger on the canvas. A tap on an object calls its `click` handler, as a mouse click does ([Pointer events on objects](../api/input.md#pointer-events-on-objects)). The [picking demo](https://github.com/null3d-engine/null3d/tree/main/examples/picking) shows such a handler.
149
+
150
+ A canvas that takes touch gestures needs `touch-action: none` in its CSS. Without it, the browser scrolls or zooms the page, and it cancels the touch. [Input](../api/input.md#touches) explains touches and pinches.
151
+
152
+ ```css
153
+ canvas { touch-action: none; }
154
+ ```
100
155
 
101
156
  ## Networks and repeat visits
102
157
 
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.
158
+ 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. The [Island showcase sketch](https://github.com/null3d-engine/null3d/tree/main/examples/showcase/island) starts its downloads together and draws before its large models arrive.
104
159
 
105
160
  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.
106
161
 
@@ -108,10 +163,7 @@ Phones often lose their network. A game that must play offline caches the engine
108
163
 
109
164
  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
165
 
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
-
166
+ On a Galaxy Tab A9 Plus, the driver refused the island demo's far tree cards, and the island drew on without them ([A fast start](start-time.md#where-the-time-goes)).
115
167
  ## Browsers on iPhone and iPad
116
168
 
117
169
  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.
@@ -122,7 +174,7 @@ Check every rendering mode and the whole camera path, with repeats, as [Testing
122
174
 
123
175
  Desktop browsers that emulate a phone show neither its GPU nor its heat, so test on the phones and tablets that your audience uses.
124
176
 
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.
177
+ - 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, which caps the preset at Medium. [Hosting and cross-origin isolation](../getting-started/hosting.md#during-development) shows both.
126
178
  - 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.
127
179
  - 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`.
128
180
  - 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.
@@ -1,15 +1,11 @@
1
1
  ---
2
2
  id: guides/physics
3
3
  title: Using a physics library
4
- status: experimental
5
- since: "0.1"
6
4
  summary: "Running Rapier or cannon-es in the sketch worker; copying transforms."
7
5
  ---
8
6
 
9
7
  # Using a physics library
10
8
 
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
9
  ```mermaid
14
10
  flowchart LR
15
11
  fixed["onFixedUpdate(step)<br/>0 or more times"] --> step["The physics world<br/>takes one step"]
@@ -26,10 +22,10 @@ Physics in the sketch only moves what the player sees. A game whose server repla
26
22
 
27
23
  Two libraries work well in a sketch:
28
24
 
29
- | Library | Package | What it is |
30
- | --- | --- | --- |
31
- | Rapier | `@dimforge/rapier3d-compat` | A Rust engine compiled to WebAssembly. It is fast with many bodies. |
32
- | cannon-es | `cannon-es` | A JavaScript engine. It is small and simple to use. |
25
+ | Library | Package | What it is | Download size |
26
+ | --- | --- | --- | --- |
27
+ | Rapier | `@dimforge/rapier3d-compat` | A Rust engine compiled to WebAssembly. It is fast with many bodies. | About 1.2 MB after Brotli compression |
28
+ | cannon-es | `cannon-es` | A JavaScript engine. It is small and simple to use. | About 20 KB for the example on this page |
33
29
 
34
30
  Install one with Bun, as any other package:
35
31
 
@@ -37,6 +33,8 @@ Install one with Bun, as any other package:
37
33
  bun add @dimforge/rapier3d-compat@^0.20.0
38
34
  ```
39
35
 
36
+ The `-compat` package holds Rapier's WebAssembly inside its JavaScript, so it needs no extra Vite setup. That is why it is large.
37
+
40
38
  ## Example: crates that fall on a floor
41
39
 
42
40
  This sketch drops 300 crates onto a floor with Rapier. Each crate is a Rapier body and a row of one instance batch.
@@ -112,8 +110,6 @@ export default defineSketch(async ({ scene, geometry, materials }) => {
112
110
  - The rows are views of engine memory, so the copy costs no call to the engine per crate. A dynamic batch recomputes and uploads every row in each frame. [Instances and batching](../concepts/instances.md) explains the rows.
113
111
  - The floor never moves, so its mesh is static. A static mesh costs nothing in a frame where it does not change.
114
112
 
115
- The `-compat` package holds Rapier's WebAssembly inside its JavaScript, so it needs no extra Vite setup. That makes it large: it adds about 1.2 MB after Brotli compression to the sketch's download. With cannon-es, the example on this page adds about 20 KB.
116
-
117
113
  ## Step the world at a fixed rate
118
114
 
119
115
  A physics world stays stable when every step has the same length. A frame's step changes with the screen and with slow frames, so the examples step the world in `onFixedUpdate`. The engine calls it 60 times per second of sketch time, before `onUpdate`. The examples copy the transforms in `onUpdate`, once per frame, after the frame's steps.
@@ -1,15 +1,11 @@
1
1
  ---
2
2
  id: guides/screens
3
3
  title: In-world screens
4
- status: experimental
5
- since: "0.3"
6
- summary: "Displays painted on an OffscreenCanvas in the sketch, with a refresh rate for each screen, uploads of only the changed rectangles, an LCD look that changes with distance, a boot glitch, and clicks mapped back to the canvas's coordinates."
4
+ summary: "An example add-on you copy: displays painted on an OffscreenCanvas in the sketch, with a refresh rate for each screen, uploads of only the changed rectangles, an LCD look that changes with distance, a boot glitch, and clicks mapped back to the canvas's coordinates."
7
5
  ---
8
6
 
9
7
  # In-world screens
10
8
 
11
- > Roadmap step 0.3, first released in null3D 0.1.0. The API is experimental, so it can still change between versions.
12
-
13
9
  A screen is a plane in the world whose material samples an `OffscreenCanvas`. The sketch draws on
14
10
  the canvas with the 2D context, and the engine uploads only the rectangles that changed. Each screen
15
11
  keeps its own refresh rate, so a slow readout costs less than a fast one.
@@ -24,48 +20,64 @@ flowchart LR
24
20
  ```
25
21
 
26
22
  The screens add-on in the repository, in the `examples/addons/screens` folder, holds the pattern.
27
- It is not an npm package. Copy the folder into your project and import its entry point.
23
+ It is not an npm package. Copy the folder into your project and import its entry point. The [screens painted on an OffscreenCanvas](https://github.com/null3d-engine/null3d/tree/main/examples/canvas-screen) demo shows wall panels and a console, each at its own refresh rate.
28
24
 
29
25
  ## Make a screen
30
26
 
31
27
  ```ts
28
+ import { defineSketch } from '@null3d/engine';
32
29
  import { createScreen } from './addons/screens';
33
30
 
34
- const screen = createScreen(ctx, {
35
- width: 512,
36
- height: 256,
37
- refreshHz: 12,
38
- size: [2.4, 1.2],
39
- draw: (context) => {
40
- context.fillStyle = '#061019';
41
- context.fillRect(0, 0, 512, 256);
42
- context.fillStyle = '#9fe8ff';
43
- context.font = 'bold 48px sans-serif';
44
- context.fillText('REACTOR 62.0', 24, 90);
45
- },
31
+ export default defineSketch((ctx) => {
32
+ const screen = createScreen(ctx, {
33
+ width: 512,
34
+ height: 256,
35
+ refreshHz: 12,
36
+ size: [2.4, 1.2],
37
+ draw: (context) => {
38
+ context.fillStyle = '#061019';
39
+ context.fillRect(0, 0, 512, 256);
40
+ context.fillStyle = '#9fe8ff';
41
+ context.font = 'bold 48px sans-serif';
42
+ context.fillText('REACTOR 62.0', 24, 90);
43
+ },
44
+ });
45
+ screen.mesh.setPosition(0, 1.4, -3);
46
+
47
+ return { onUpdate() { /* below */ } };
46
48
  });
47
- screen.mesh.setPosition(0, 1.4, -3);
48
49
  ```
49
50
 
50
- `draw` runs in the setup, before the first upload, so a held frame shows the picture. A program that
51
- changes its reading each frame repaints only the part that changed:
51
+ `draw` runs in the setup, before the first upload, so every frame shows the picture, a held frame too. `screen.paint(draw, changed)` draws and uploads the rectangle that changed. Without a rectangle it uploads the whole canvas.
52
+
53
+ ```ts
54
+ screen.paint((context) => {
55
+ context.fillStyle = '#061019';
56
+ context.fillRect(24, 150, 464, 90);
57
+ context.fillStyle = '#9fe8ff';
58
+ context.fillText(`REACTOR ${reading.toFixed(1)}`, 24, 200);
59
+ }, { x: 24, y: 150, width: 464, height: 90 });
60
+ ```
61
+
62
+ A program that changes its reading each frame can draw straight on `screen.context`:
52
63
 
53
64
  ```ts
54
65
  return {
55
66
  onUpdate() {
56
- paintTheReading(screen.context); // the number, the bar and the lights
67
+ const context = screen.context;
68
+ context.fillStyle = '#061019';
69
+ context.fillRect(24, 150, 464, 90);
70
+ context.fillStyle = '#9fe8ff';
71
+ context.fillText(`REACTOR ${reading.toFixed(1)}`, 24, 200);
57
72
  screen.mark({ x: 24, y: 150, width: 464, height: 90 });
58
73
  screen.flush(); // sends a change that the rate held back
59
74
  },
60
75
  };
61
76
  ```
62
77
 
63
- `screen.paint(draw, changed)` draws and uploads the rectangle that changed. Without a rectangle it
64
- uploads the whole canvas. `screen.mark(rect)` adds a rectangle without drawing, and `screen.flush()`
65
- uploads the marked rectangles as one change.
78
+ `screen.mark(rect)` adds a rectangle without drawing, and `screen.flush()` uploads the marked rectangles as one change.
66
79
 
67
- A refresh that the rate or an upload in flight holds back returns false, and the change waits for
68
- the next call. Call `flush` from the frame's update so it goes out.
80
+ A refresh that the rate or an upload in flight holds back returns false, and the change waits for the next call. Call `flush` from the frame's update so it goes out.
69
81
 
70
82
  ## The LCD look
71
83
 
@@ -93,7 +105,7 @@ takes no values.
93
105
  ## Clicks on a screen
94
106
 
95
107
  A pointer hit on a mesh carries its texture coordinates. `screen.pointOf(event)` turns them into a
96
- canvas point. `screen.texelOf(event)` gives the whole texel under the point.
108
+ canvas point. `screen.texelOf(event)` gives the whole texel under the point. The [picking demo](https://github.com/null3d-engine/null3d/tree/main/examples/picking) shows an object's click handler and the point that the ray hit.
97
109
 
98
110
  ```ts
99
111
  screen.onClick((point) => {
@@ -116,7 +128,7 @@ that path's figures and its upload budget.
116
128
 
117
129
  - The shader draws on both GPU paths. It uses `fwidth`, which both paths have.
118
130
  - A screen's mesh needs texture coordinates, as `geometry.plane` gives.
119
- - A held frame runs no update. Paint the picture through `draw` or in the setup.
131
+ - In hold mode, the held frame shows the canvas as of its last read. A change that the refresh rate held back in the last updates does not show. Paint the picture that a test checks through `draw` or in the setup.
120
132
  - A large canvas at a high refresh rate costs its rectangle's bytes each read. Give a screen only
121
133
  the rate that its content needs.
122
134