@null3d/engine 0.0.0 → 0.1.1

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 (517) hide show
  1. package/README.md +109 -0
  2. package/THIRD-PARTY-NOTICES.txt +0 -1
  3. package/dist/wasm/single/null3d.js +25 -10
  4. package/dist/wasm/single/null3d_bg.wasm +0 -0
  5. package/dist/wasm/threaded/null3d.js +25 -10
  6. package/dist/wasm/threaded/null3d_bg.wasm +0 -0
  7. package/docs/api/animation.md +114 -86
  8. package/docs/api/assets.md +135 -49
  9. package/docs/api/cameras.md +45 -12
  10. package/docs/api/controls.md +88 -62
  11. package/docs/api/debug.md +116 -41
  12. package/docs/api/engine.md +117 -35
  13. package/docs/api/feature-draws.md +23 -17
  14. package/docs/api/feature-effects.md +11 -11
  15. package/docs/api/feature-instances.md +70 -19
  16. package/docs/api/features.md +77 -47
  17. package/docs/api/geometry.md +132 -82
  18. package/docs/api/grass.md +55 -13
  19. package/docs/api/impostors.md +175 -22
  20. package/docs/api/input.md +24 -18
  21. package/docs/api/lights.md +78 -51
  22. package/docs/api/lines.md +41 -33
  23. package/docs/api/materials.md +248 -121
  24. package/docs/api/math.md +12 -13
  25. package/docs/api/objects.md +47 -22
  26. package/docs/api/page.md +58 -7
  27. package/docs/api/particles.md +33 -20
  28. package/docs/api/points.md +19 -31
  29. package/docs/api/post.md +75 -42
  30. package/docs/api/quality.md +42 -17
  31. package/docs/api/raycast.md +65 -51
  32. package/docs/api/reference/animation.md +10 -11
  33. package/docs/api/reference/assets.md +25 -22
  34. package/docs/api/reference/cameras.md +8 -4
  35. package/docs/api/reference/controls.md +134 -25
  36. package/docs/api/reference/debug.md +81 -14
  37. package/docs/api/reference/engine.md +58 -17
  38. package/docs/api/reference/feature-draws.md +3 -4
  39. package/docs/api/reference/feature-effects.md +2 -3
  40. package/docs/api/reference/feature-instances.md +5 -4
  41. package/docs/api/reference/features.md +7 -4
  42. package/docs/api/reference/geometry.md +287 -97
  43. package/docs/api/reference/grass.md +63 -3
  44. package/docs/api/reference/impostors.md +208 -13
  45. package/docs/api/reference/input.md +4 -5
  46. package/docs/api/reference/lights.md +13 -12
  47. package/docs/api/reference/lines.md +10 -11
  48. package/docs/api/reference/materials.md +54 -53
  49. package/docs/api/reference/math.md +35 -24
  50. package/docs/api/reference/objects.md +11 -12
  51. package/docs/api/reference/particles.md +31 -6
  52. package/docs/api/reference/points.md +6 -7
  53. package/docs/api/reference/post.md +21 -20
  54. package/docs/api/reference/quality.md +8 -5
  55. package/docs/api/reference/raycast.md +7 -8
  56. package/docs/api/reference/render.md +5 -4
  57. package/docs/api/reference/scene.md +52 -30
  58. package/docs/api/reference/sketch.md +15 -11
  59. package/docs/api/reference/sound.md +234 -0
  60. package/docs/api/reference/splats.md +42 -3
  61. package/docs/api/reference/sprites.md +7 -8
  62. package/docs/api/reference/tasks.md +16 -3
  63. package/docs/api/reference/terrain.md +27 -5
  64. package/docs/api/reference/textures.md +5 -6
  65. package/docs/api/reference/three-compat.md +18 -7
  66. package/docs/api/reference/time.md +1 -2
  67. package/docs/api/reference/ui.md +12 -9
  68. package/docs/api/reference/vertex-draws.md +5 -6
  69. package/docs/api/reference/water.md +153 -9
  70. package/docs/api/reference/wind.md +17 -4
  71. package/docs/api/render.md +73 -29
  72. package/docs/api/scene.md +164 -60
  73. package/docs/api/sketch.md +102 -15
  74. package/docs/api/sound.md +205 -0
  75. package/docs/api/splats.md +46 -12
  76. package/docs/api/sprites.md +10 -24
  77. package/docs/api/tasks.md +33 -24
  78. package/docs/api/terrain.md +42 -22
  79. package/docs/api/textures.md +68 -19
  80. package/docs/api/three-compat.md +15 -7
  81. package/docs/api/time.md +3 -5
  82. package/docs/api/ui.md +19 -23
  83. package/docs/api/vertex-draws.md +13 -12
  84. package/docs/api/water.md +262 -35
  85. package/docs/api/wind.md +63 -17
  86. package/docs/cli/null3d.md +177 -27
  87. package/docs/concepts/architecture.md +73 -27
  88. package/docs/concepts/assets.md +57 -33
  89. package/docs/concepts/backends.md +69 -27
  90. package/docs/concepts/color-management.md +54 -36
  91. package/docs/concepts/culling.md +68 -47
  92. package/docs/concepts/handles.md +14 -5
  93. package/docs/concepts/instances.md +74 -25
  94. package/docs/concepts/large-worlds.md +18 -8
  95. package/docs/concepts/lighting.md +155 -87
  96. package/docs/concepts/lod.md +126 -44
  97. package/docs/concepts/materials.md +58 -27
  98. package/docs/concepts/particle-buffer.md +48 -35
  99. package/docs/concepts/post-processing.md +84 -43
  100. package/docs/concepts/quality-preset-tables.md +56 -52
  101. package/docs/concepts/quality-presets.md +164 -52
  102. package/docs/concepts/render-graph.md +69 -29
  103. package/docs/concepts/render-layers.md +11 -21
  104. package/docs/concepts/shadows.md +105 -52
  105. package/docs/concepts/static-dynamic.md +22 -7
  106. package/docs/cookbook/index.md +164 -120
  107. package/docs/data/threejs-mapping.json +362 -367
  108. package/docs/errors/E1101.md +23 -5
  109. package/docs/errors/E1102.md +11 -3
  110. package/docs/errors/E1103.md +11 -3
  111. package/docs/errors/E1104.md +11 -3
  112. package/docs/errors/E1105.md +13 -5
  113. package/docs/errors/E1106.md +11 -3
  114. package/docs/errors/E1107.md +15 -5
  115. package/docs/errors/E1108.md +11 -3
  116. package/docs/errors/E1109.md +32 -6
  117. package/docs/errors/E1110.md +23 -5
  118. package/docs/errors/E1111.md +11 -3
  119. package/docs/errors/E1112.md +11 -3
  120. package/docs/errors/E1203.md +12 -4
  121. package/docs/errors/E1204.md +11 -3
  122. package/docs/errors/E1205.md +11 -3
  123. package/docs/errors/E1206.md +28 -6
  124. package/docs/errors/E1207.md +11 -3
  125. package/docs/errors/E1208.md +12 -3
  126. package/docs/errors/E1209.md +11 -3
  127. package/docs/errors/E1213.md +27 -5
  128. package/docs/errors/E1214.md +14 -6
  129. package/docs/errors/E1215.md +31 -6
  130. package/docs/errors/E1216.md +31 -6
  131. package/docs/errors/E1217.md +29 -6
  132. package/docs/errors/E1218.md +22 -6
  133. package/docs/errors/E1219.md +11 -3
  134. package/docs/errors/E1220.md +24 -5
  135. package/docs/errors/E1221.md +24 -5
  136. package/docs/errors/E1222.md +11 -3
  137. package/docs/errors/E1223.md +39 -6
  138. package/docs/errors/E1224.md +11 -3
  139. package/docs/errors/E1225.md +11 -3
  140. package/docs/errors/E1301.md +11 -3
  141. package/docs/errors/E1302.md +11 -3
  142. package/docs/errors/E1303.md +11 -3
  143. package/docs/errors/E1304.md +11 -3
  144. package/docs/errors/E1305.md +13 -3
  145. package/docs/errors/E1306.md +11 -3
  146. package/docs/errors/E1307.md +40 -0
  147. package/docs/errors/E1401.md +11 -3
  148. package/docs/errors/E1402.md +13 -5
  149. package/docs/errors/E1403.md +11 -3
  150. package/docs/errors/E1404.md +13 -3
  151. package/docs/errors/E1405.md +15 -4
  152. package/docs/errors/E1406.md +31 -5
  153. package/docs/errors/E1407.md +11 -3
  154. package/docs/errors/E1408.md +11 -3
  155. package/docs/errors/E1409.md +11 -3
  156. package/docs/errors/E1410.md +13 -5
  157. package/docs/errors/E1411.md +11 -3
  158. package/docs/errors/E1412.md +29 -6
  159. package/docs/errors/E1413.md +11 -3
  160. package/docs/errors/E1414.md +11 -3
  161. package/docs/errors/E1415.md +11 -3
  162. package/docs/errors/E1416.md +27 -6
  163. package/docs/errors/E1417.md +11 -3
  164. package/docs/errors/E1418.md +12 -3
  165. package/docs/errors/E1419.md +13 -5
  166. package/docs/errors/E1420.md +14 -6
  167. package/docs/errors/E1421.md +11 -3
  168. package/docs/errors/E1422.md +12 -3
  169. package/docs/errors/E1423.md +12 -3
  170. package/docs/errors/E1424.md +24 -5
  171. package/docs/errors/E1425.md +11 -3
  172. package/docs/errors/E1426.md +11 -3
  173. package/docs/errors/E1430.md +11 -3
  174. package/docs/errors/E1431.md +11 -3
  175. package/docs/errors/E1432.md +11 -3
  176. package/docs/errors/E1433.md +11 -3
  177. package/docs/errors/E1434.md +15 -6
  178. package/docs/errors/E1435.md +11 -3
  179. package/docs/errors/E1436.md +11 -3
  180. package/docs/errors/E1437.md +14 -6
  181. package/docs/errors/E1501.md +41 -6
  182. package/docs/errors/E1502.md +13 -3
  183. package/docs/errors/E1503.md +11 -3
  184. package/docs/errors/E1504.md +11 -3
  185. package/docs/errors/E1505.md +23 -5
  186. package/docs/errors/E1506.md +11 -3
  187. package/docs/errors/index.md +54 -30
  188. package/docs/getting-started/cdn.md +32 -10
  189. package/docs/getting-started/first-scene.md +21 -13
  190. package/docs/getting-started/hosting.md +152 -63
  191. package/docs/getting-started/install.md +44 -28
  192. package/docs/getting-started/network-use.md +33 -15
  193. package/docs/getting-started/project-structure.md +33 -12
  194. package/docs/getting-started/third-party-notices.md +12 -14
  195. package/docs/guides/accessibility.md +5 -5
  196. package/docs/guides/add-ons.md +86 -15
  197. package/docs/guides/agents.md +16 -9
  198. package/docs/guides/assets-pipeline.md +259 -82
  199. package/docs/guides/audio.md +115 -128
  200. package/docs/guides/baked-light-data.md +44 -23
  201. package/docs/guides/car-paint.md +38 -32
  202. package/docs/guides/content-pages.md +63 -35
  203. package/docs/guides/custom-passes.md +65 -22
  204. package/docs/guides/custom-shaders.md +59 -39
  205. package/docs/guides/debugging.md +74 -10
  206. package/docs/guides/deploying.md +85 -6
  207. package/docs/guides/deterministic-simulation.md +24 -17
  208. package/docs/guides/first-use-shaders.md +83 -45
  209. package/docs/guides/lens-kit.md +29 -26
  210. package/docs/guides/loading-screens.md +132 -47
  211. package/docs/guides/multiple-views.md +63 -13
  212. package/docs/guides/performance.md +192 -38
  213. package/docs/guides/phones.md +78 -15
  214. package/docs/guides/physics.md +7 -11
  215. package/docs/guides/screens.md +47 -33
  216. package/docs/guides/start-time.md +363 -0
  217. package/docs/guides/testing.md +152 -95
  218. package/docs/guides/ui-overlays.md +19 -14
  219. package/docs/guides/video-textures.md +14 -13
  220. package/docs/images/api/animation/character.webp +0 -0
  221. package/docs/images/api/animation/look-at-ring.webp +0 -0
  222. package/docs/images/api/animation/morph-tulips.webp +0 -0
  223. package/docs/images/api/animation/skeleton-lines.webp +0 -0
  224. package/docs/images/api/controls/gizmo-handles.webp +0 -0
  225. package/docs/images/api/controls/walk-and-fly.webp +0 -0
  226. package/docs/images/api/debug/debug-shapes.webp +0 -0
  227. package/docs/images/api/debug/levels-view.webp +0 -0
  228. package/docs/images/api/engine/transparent-canvas.webp +0 -0
  229. package/docs/images/api/feature-draws/feature-draw-clouds.webp +0 -0
  230. package/docs/images/api/feature-instances/compute-instances.webp +0 -0
  231. package/docs/images/api/feature-instances/instances-shadow.webp +0 -0
  232. package/docs/images/api/geometry/extra-shapes.webp +0 -0
  233. package/docs/images/api/geometry/generators.webp +0 -0
  234. package/docs/images/api/geometry/mesh-arrays.webp +0 -0
  235. package/docs/images/api/geometry/vertex-updates.webp +0 -0
  236. package/docs/images/api/grass/grass-grove.webp +0 -0
  237. package/docs/images/api/grass/grass-presets.webp +0 -0
  238. package/docs/images/api/grass/grass-shadow.webp +0 -0
  239. package/docs/images/api/impostors/impostor-handover.webp +0 -0
  240. package/docs/images/api/impostors/impostor-shadow.webp +0 -0
  241. package/docs/images/api/impostors/impostors-forest.webp +0 -0
  242. package/docs/images/api/lights/spot-cookies.webp +0 -0
  243. package/docs/images/api/lines/lines-lit.webp +0 -0
  244. package/docs/images/api/lines/lines-widths.webp +0 -0
  245. package/docs/images/api/materials/coat-and-sheen.webp +0 -0
  246. package/docs/images/api/materials/decals.webp +0 -0
  247. package/docs/images/api/materials/iridescence-and-anisotropy.webp +0 -0
  248. package/docs/images/api/materials/relief.webp +0 -0
  249. package/docs/images/api/materials/shader-inputs.webp +0 -0
  250. package/docs/images/api/materials/standard-grid.webp +0 -0
  251. package/docs/images/api/materials/subsurface.webp +0 -0
  252. package/docs/images/api/materials/translucency.webp +0 -0
  253. package/docs/images/api/objects/objects-turntable.webp +0 -0
  254. package/docs/images/api/particles/campfire.webp +0 -0
  255. package/docs/images/api/points/galaxy.webp +0 -0
  256. package/docs/images/api/reference/textures/texture-wrap.webp +0 -0
  257. package/docs/images/api/render/fullscreen-glow.webp +0 -0
  258. package/docs/images/api/render/reflection-mirror.webp +0 -0
  259. package/docs/images/api/render/security-camera.webp +0 -0
  260. package/docs/images/api/scene/aurora-sky-layer.webp +0 -0
  261. package/docs/images/api/sound/sound-demo.webp +0 -0
  262. package/docs/images/api/splats/splats-demo.webp +0 -0
  263. package/docs/images/api/sprites/sprites-lines.webp +0 -0
  264. package/docs/images/api/terrain/terrain-demo.webp +0 -0
  265. package/docs/images/api/textures/canvas-screen.webp +0 -0
  266. package/docs/images/api/textures/mipmaps.webp +0 -0
  267. package/docs/images/api/vertex-draws/rain.webp +0 -0
  268. package/docs/images/api/water/ocean.webp +0 -0
  269. package/docs/images/api/water/water-demo.webp +0 -0
  270. package/docs/images/api/water/water-rain.webp +0 -0
  271. package/docs/images/api/water/waterfall.webp +0 -0
  272. package/docs/images/concepts/assets/gltf-model.webp +0 -0
  273. package/docs/images/concepts/color-management/tone-mapped.webp +0 -0
  274. package/docs/images/concepts/culling/far-from-origin.webp +0 -0
  275. package/docs/images/concepts/instances/instances.webp +0 -0
  276. package/docs/images/concepts/instances/per-row-colors.webp +0 -0
  277. package/docs/images/concepts/large-worlds/large-world.webp +0 -0
  278. package/docs/images/concepts/lighting/area-lights.webp +0 -0
  279. package/docs/images/concepts/lighting/atmosphere.webp +0 -0
  280. package/docs/images/concepts/lighting/environment.webp +0 -0
  281. package/docs/images/concepts/lighting/light-shafts.webp +0 -0
  282. package/docs/images/concepts/lighting/reflection-probes.webp +0 -0
  283. package/docs/images/concepts/lod/forest.webp +0 -0
  284. package/docs/images/concepts/materials/weighted-transparency.webp +0 -0
  285. package/docs/images/concepts/post-processing/auto-exposure.webp +0 -0
  286. package/docs/images/concepts/post-processing/bounce-light.webp +0 -0
  287. package/docs/images/concepts/post-processing/depth-of-field.webp +0 -0
  288. package/docs/images/concepts/post-processing/post-effects-alley.webp +0 -0
  289. package/docs/images/concepts/post-processing/sharpen.webp +0 -0
  290. package/docs/images/concepts/post-processing/ssr-wet-street.webp +0 -0
  291. package/docs/images/concepts/render-layers/layers-cottages.webp +0 -0
  292. package/docs/images/concepts/shadows/hero-shadow.webp +0 -0
  293. package/docs/images/cookbook/index/picking.webp +0 -0
  294. package/docs/images/cookbook/index/time-of-day.webp +0 -0
  295. package/docs/images/errors/E1431/area-lights-no-tables.webp +0 -0
  296. package/docs/images/guides/custom-passes/reflection-water.webp +0 -0
  297. package/docs/images/guides/deterministic-simulation/replay-demo.webp +0 -0
  298. package/docs/images/guides/multiple-views/split-screen.webp +0 -0
  299. package/docs/images/guides/performance/overdraw-view.webp +0 -0
  300. package/docs/images/guides/testing/hold-mode-frame.webp +0 -0
  301. package/docs/images/index/showcase-island.webp +0 -0
  302. package/docs/images/porting/threejs-shaders/dissolve.webp +0 -0
  303. package/docs/images/shaders/builtins/builtins.webp +0 -0
  304. package/docs/images/shaders/surface-functions/custom-surface.webp +0 -0
  305. package/docs/images/shaders/surface-functions/vertex-offset.webp +0 -0
  306. package/docs/images/shots.json +2231 -0
  307. package/docs/index.md +18 -23
  308. package/docs/moves.json +1 -0
  309. package/docs/nav.json +300 -0
  310. package/docs/pages.md +230 -209
  311. package/docs/porting/react-three-fiber.md +225 -6
  312. package/docs/porting/threejs-loop-and-threads.md +217 -7
  313. package/docs/porting/threejs-mapping.md +1249 -233
  314. package/docs/porting/threejs-materials.md +218 -6
  315. package/docs/porting/threejs-overview.md +240 -7
  316. package/docs/porting/threejs-postprocessing.md +4 -8
  317. package/docs/porting/threejs-shaders.md +301 -6
  318. package/docs/porting/threejs-unsupported.md +83 -7
  319. package/docs/porting/verification.md +178 -6
  320. package/docs/shaders/builtins.md +15 -4
  321. package/docs/shaders/library.md +72 -45
  322. package/docs/shaders/surface-functions.md +59 -23
  323. package/docs/shaders/wgsl-rules.md +12 -5
  324. package/lib/debug/channel.d.ts +103 -0
  325. package/lib/debug/channel.js +269 -0
  326. package/lib/debug/debug.d.ts +11 -9
  327. package/lib/debug/draw.d.ts +11 -2
  328. package/lib/debug/draw.js +57 -6
  329. package/lib/debug/inspector.d.ts +60 -0
  330. package/lib/debug/inspector.js +475 -0
  331. package/lib/debug/overlay-look.d.ts +6 -0
  332. package/lib/debug/overlay-look.js +29 -7
  333. package/lib/debug/overlay.js +15 -11
  334. package/lib/debug/stats-options.d.ts +13 -0
  335. package/lib/debug/stats-panel.d.ts +22 -7
  336. package/lib/debug/stats-panel.js +80 -13
  337. package/lib/debug/stats.d.ts +2 -3
  338. package/lib/errors/codes.d.ts +17 -3
  339. package/lib/errors/codes.js +117 -105
  340. package/lib/errors/engine-error.js +25 -10
  341. package/lib/errors/fixes.d.ts +1 -0
  342. package/lib/errors/fixes.js +20 -19
  343. package/lib/generated/core.d.ts +1 -1
  344. package/lib/generated/core.js +1 -1
  345. package/lib/gpu/early-builds.d.ts +68 -0
  346. package/lib/gpu/early-builds.js +158 -0
  347. package/lib/gpu/pipeline-name.d.ts +6 -0
  348. package/lib/gpu/pipeline-name.js +23 -0
  349. package/lib/gpu/variants.d.ts +8 -2
  350. package/lib/gpu/variants.js +39 -7
  351. package/lib/gpu/webgl2/backend.d.ts +63 -2
  352. package/lib/gpu/webgl2/backend.js +226 -8
  353. package/lib/gpu/webgl2/programs.d.ts +18 -0
  354. package/lib/gpu/webgl2/programs.js +5 -2
  355. package/lib/gpu/webgpu/backend.d.ts +89 -2
  356. package/lib/gpu/webgpu/backend.js +255 -8
  357. package/lib/gpu/webgpu/pipelines.d.ts +13 -0
  358. package/lib/gpu/webgpu/pipelines.js +28 -14
  359. package/lib/index.d.ts +7 -5
  360. package/lib/index.js +3 -2
  361. package/lib/math/color.d.ts +5 -5
  362. package/lib/math/color.js +5 -5
  363. package/lib/math/mat4.d.ts +6 -12
  364. package/lib/math/mat4.js +6 -12
  365. package/lib/math/namespaces/quat.d.ts +3 -3
  366. package/lib/math/namespaces/quat.js +3 -3
  367. package/lib/math/quat.d.ts +8 -12
  368. package/lib/math/quat.js +8 -12
  369. package/lib/math/random.d.ts +2 -3
  370. package/lib/math/random.js +2 -3
  371. package/lib/math/types.d.ts +4 -4
  372. package/lib/math/vec3.d.ts +3 -6
  373. package/lib/math/vec3.js +3 -6
  374. package/lib/page/capabilities.d.ts +8 -8
  375. package/lib/page/capabilities.js +39 -25
  376. package/lib/page/check-store.d.ts +14 -2
  377. package/lib/page/check-store.js +34 -11
  378. package/lib/page/engine.d.ts +117 -31
  379. package/lib/page/engine.js +438 -99
  380. package/lib/page/first-frame.d.ts +16 -0
  381. package/lib/page/first-frame.js +35 -0
  382. package/lib/page/frame-stats.d.ts +34 -1
  383. package/lib/page/frame-stats.js +15 -0
  384. package/lib/page/label-loop.d.ts +7 -3
  385. package/lib/page/label-loop.js +26 -14
  386. package/lib/page/labels.d.ts +3 -3
  387. package/lib/page/pipeline-store.d.ts +25 -0
  388. package/lib/page/pipeline-store.js +84 -0
  389. package/lib/page/start-marker.d.ts +4 -1
  390. package/lib/page/start-marker.js +5 -2
  391. package/lib/page/stats-switch.js +2 -0
  392. package/lib/page/switches.d.ts +38 -6
  393. package/lib/page/switches.js +29 -5
  394. package/lib/quality/check.d.ts +24 -3
  395. package/lib/quality/check.js +21 -7
  396. package/lib/quality/chooser.d.ts +6 -0
  397. package/lib/quality/chooser.js +8 -0
  398. package/lib/quality/governor.d.ts +98 -6
  399. package/lib/quality/governor.js +250 -20
  400. package/lib/quality/preset-docs.d.ts +16 -1
  401. package/lib/quality/preset-docs.js +3 -0
  402. package/lib/quality/presets.d.ts +84 -7
  403. package/lib/quality/presets.js +94 -2
  404. package/lib/render/draw.d.ts +3 -2
  405. package/lib/render/draw.js +15 -5
  406. package/lib/render/load-draw.d.ts +7 -5
  407. package/lib/render/load-draw.js +7 -5
  408. package/lib/render/loss.d.ts +28 -10
  409. package/lib/render/loss.js +50 -22
  410. package/lib/render/recovery.d.ts +20 -0
  411. package/lib/render/recovery.js +44 -4
  412. package/lib/render/renderer.d.ts +85 -9
  413. package/lib/render/renderer.js +181 -42
  414. package/lib/render/scene-renderer.d.ts +19 -1
  415. package/lib/render/scene-renderer.js +25 -1
  416. package/lib/render/webgl2-renderers.js +8 -5
  417. package/lib/render/webgpu-renderers.js +5 -4
  418. package/lib/scene/animation.d.ts +28 -32
  419. package/lib/scene/animation.js +12 -15
  420. package/lib/scene/assets.d.ts +61 -86
  421. package/lib/scene/assets.js +103 -236
  422. package/lib/scene/background.d.ts +14 -18
  423. package/lib/scene/background.js +5 -2
  424. package/lib/scene/baked-light.d.ts +2 -2
  425. package/lib/scene/color.d.ts +3 -3
  426. package/lib/scene/downloads.d.ts +2 -0
  427. package/lib/scene/downloads.js +371 -0
  428. package/lib/scene/environment.d.ts +7 -7
  429. package/lib/scene/environment.js +1 -1
  430. package/lib/scene/fake-call-values.js +3 -3
  431. package/lib/scene/fog.d.ts +11 -4
  432. package/lib/scene/fog.js +8 -2
  433. package/lib/scene/frame-cameras.d.ts +35 -4
  434. package/lib/scene/frame-cameras.js +86 -10
  435. package/lib/scene/gltf.d.ts +33 -3
  436. package/lib/scene/gltf.js +78 -49
  437. package/lib/scene/grading.d.ts +2 -2
  438. package/lib/scene/grading.js +3 -3
  439. package/lib/scene/ktx2.d.ts +9 -1
  440. package/lib/scene/ktx2.js +3 -2
  441. package/lib/scene/level-rule.d.ts +121 -0
  442. package/lib/scene/level-rule.js +130 -0
  443. package/lib/scene/lines.d.ts +13 -17
  444. package/lib/scene/lines.js +3 -3
  445. package/lib/scene/lut.d.ts +1 -2
  446. package/lib/scene/lut.js +1 -2
  447. package/lib/scene/particles.d.ts +7 -3
  448. package/lib/scene/particles.js +3 -1
  449. package/lib/scene/picks.d.ts +2 -2
  450. package/lib/scene/pointer-events.d.ts +4 -7
  451. package/lib/scene/post.d.ts +39 -43
  452. package/lib/scene/post.js +4 -1
  453. package/lib/scene/prefab.d.ts +7 -8
  454. package/lib/scene/prefab.js +7 -8
  455. package/lib/scene/property-animation.d.ts +1 -1
  456. package/lib/scene/property-animation.js +1 -1
  457. package/lib/scene/queries.d.ts +7 -13
  458. package/lib/scene/resources.d.ts +238 -261
  459. package/lib/scene/resources.js +179 -81
  460. package/lib/scene/scene.d.ts +167 -120
  461. package/lib/scene/scene.js +243 -103
  462. package/lib/scene/serial-loads.d.ts +29 -0
  463. package/lib/scene/serial-loads.js +68 -0
  464. package/lib/scene/shader-preloads.d.ts +34 -0
  465. package/lib/scene/shader-preloads.js +38 -0
  466. package/lib/scene/sprites.d.ts +14 -17
  467. package/lib/scene/sprites.js +5 -6
  468. package/lib/scene/textures.d.ts +11 -12
  469. package/lib/scene/textures.js +9 -10
  470. package/lib/scene/time-of-day.d.ts +11 -7
  471. package/lib/scene/time-of-day.js +11 -8
  472. package/lib/scene/vertex-draws.d.ts +5 -4
  473. package/lib/scene/vertex-draws.js +7 -5
  474. package/lib/shader-artifact.json +1 -0
  475. package/lib/shared/core.d.ts +5 -0
  476. package/lib/shared/core.js +1 -0
  477. package/lib/shared/import-once.d.ts +6 -0
  478. package/lib/shared/import-once.js +19 -0
  479. package/lib/shared/labels.d.ts +5 -2
  480. package/lib/shared/labels.js +5 -2
  481. package/lib/shared/metrics.d.ts +38 -0
  482. package/lib/shared/metrics.js +62 -1
  483. package/lib/shared/permutation-words.d.ts +2 -0
  484. package/lib/shared/permutation-words.js +8 -0
  485. package/lib/shared/recording.d.ts +13 -5
  486. package/lib/shared/recording.js +31 -10
  487. package/lib/shared/run-task.js +7 -1
  488. package/lib/shared/sketch-data.d.ts +9 -0
  489. package/lib/shared/sketch-data.js +57 -0
  490. package/lib/shared/task-pending.d.ts +12 -0
  491. package/lib/shared/task-pending.js +61 -1
  492. package/lib/shared/tasks.js +79 -32
  493. package/lib/shared/version.d.ts +17 -1
  494. package/lib/shared/version.js +19 -1
  495. package/lib/shared/wasm.d.ts +12 -4
  496. package/lib/shared/wasm.js +50 -27
  497. package/lib/shared/worker-start.d.ts +7 -0
  498. package/lib/shared/worker-start.js +27 -0
  499. package/lib/sketch/define-sketch.d.ts +51 -7
  500. package/lib/sketch/define-sketch.js +2 -1
  501. package/lib/sketch/input.d.ts +2 -2
  502. package/lib/sketch/preset-check.d.ts +20 -6
  503. package/lib/sketch/preset-check.js +42 -17
  504. package/lib/sketch/quality.d.ts +69 -11
  505. package/lib/sketch/quality.js +54 -13
  506. package/lib/sketch/runner.d.ts +80 -9
  507. package/lib/sketch/runner.js +390 -52
  508. package/lib/sketch/ui.d.ts +5 -8
  509. package/lib/sketch/ui.js +4 -2
  510. package/lib/stats.d.ts +1 -0
  511. package/lib/workers/probe-worker.d.ts +5 -0
  512. package/lib/workers/probe-worker.js +13 -4
  513. package/lib/workers/protocol.d.ts +71 -13
  514. package/lib/workers/protocol.js +4 -0
  515. package/lib/workers/render-worker.js +29 -5
  516. package/lib/workers/sketch-worker.js +108 -16
  517. package/package.json +2 -2
@@ -1,92 +1,116 @@
1
1
  ---
2
2
  id: errors/index
3
3
  title: Error codes
4
- status: generated
5
- since: "0.1"
4
+ generated: true
6
5
  summary: Every EngineError code with its cause and fix.
7
6
  ---
8
7
 
9
8
  # Error codes
10
9
 
11
- Every error the engine throws is an `EngineError` with a code. Its message names the call and the object, says what failed and how to fix it, and links to the code's page here.
10
+ Every error the engine reports is an `EngineError` with a code. Its message names the call and the object, says what failed and how to fix it, and links to the code's page here. [Where problems appear](../guides/debugging.md#where-problems-appear) says where each kind of error reaches your code.
11
+
12
+ Codes from E2000 to E9999 belong to add-ons. An add-on's message starts with its name, such as `splats E2101`, and the add-on's page lists its codes: [Gaussian splats](../api/splats.md), [Sound](../api/sound.md).
13
+
14
+ ## Objects, handles and engine memory
12
15
 
13
16
  | Code | Error | What happened |
14
17
  | --- | --- | --- |
15
- | [E1101](E1101.md) | Stale handle | A call used an object after it was destroyed. Its slot may already hold a new object. |
18
+ | [E1101](E1101.md) | Stale handle | A call used an object, instance batch or resource after you destroyed it. The engine reuses the freed slot, but a call through the old handle never changes the object that takes it. |
16
19
  | [E1102](E1102.md) | Too many objects | The scene, the table of instance batches or the queue of changes for the next frame is full. The message names which one, and how many it holds. |
17
20
  | [E1103](E1103.md) | Object from another engine | A call received an object that this engine did not create. |
18
21
  | [E1104](E1104.md) | Parent loop | A call would make an object its own ancestor: the new parent is the object itself or one of its descendants. |
19
- | [E1105](E1105.md) | Unknown command | The engine core received a structural change it does not know, so the TypeScript side and the core come from different builds. |
22
+ | [E1105](E1105.md) | Unknown command | The engine core received a structural change it does not know, so the engine's JavaScript and its core come from different builds. |
20
23
  | [E1106](E1106.md) | Object never created | A call such as `setVisible` or `setParent` queued a change for an object that the engine never created. The engine creates an object when the next frame starts. When that fails, for example because its parent was destroyed, the object never joins the scene. |
21
- | [E1107](E1107.md) | Object created twice | The engine core received a second create command for one object, so the TypeScript side and the core disagree about the scene. |
24
+ | [E1107](E1107.md) | Object created twice | The engine core received a second create command for one object, so the engine's JavaScript and its core disagree about the scene. The core skips that command, and the scene keeps running. |
22
25
  | [E1108](E1108.md) | Value out of range | A call received a number outside the range it takes. Examples are a row past the capacity of an instance batch, an opacity above 1, a negative radius, and a camera's far plane that does not lie beyond its near plane. |
23
- | [E1109](E1109.md) | Engine memory full | The engine could not create or grow its WebAssembly memory. A page with worker threads gives the engine 1 GiB by default, and up to 4 GiB through the memory option of createEngine. Each instance row takes about 210 bytes, or about 300 with per-row colors or values. So about 5 million rows fill 1 GiB, along with the rest of the scene. A mesh of millions of vertices can fill it too, from geometry.fromArrays or a model file. Building such a mesh with normals to compute takes about 100 bytes per vertex for a moment. A frame can fail too, because the first frame copies every mesh of the scene. Its need is largest on the direct draw path: a scene with 84 MiB of meshes peaks at about 270 MiB there and about 205 MiB on the indirect path. The engine also keeps the last 8 MiB under the limit for its own small requests, so a scene stops once it reaches them. A browser can refuse memory sooner, as phones often do. It can also refuse a new engine's memory while the memory of an engine that stopped before is not free yet. The engine then tries again for about 45 seconds before it fails, and reports memory-wait through onProgress after 10 seconds. |
24
- | [E1110](E1110.md) | Unmarked write to a static object | A static object's position, rotation, scale or bounding sphere changed without a setter. The engine recomputes a static object only in a frame where a setter marks it or its parent moves. So such a change can show late, or never. Development builds check these values of every static object before each transform update. Each frame has one transform update, and a sketch with onLateUpdate gets a second one after that callback. A row of a static instance, sprite or point batch that changed without markDirty() raises it too: the engine updates only the marked rows, and development builds check the drawn rows before each batch update, a share of a large batch in each frame. Release builds leave the check out. |
26
+ | [E1109](E1109.md) | Engine memory full | The engine could not create or grow its WebAssembly memory. A page with worker threads gives the engine 1 GiB by default, and the memory option of `createEngine()` can raise it to 4 GiB. Many instance rows, a mesh of millions of vertices, or the first frame that copies every mesh can fill it. |
27
+ | [E1110](E1110.md) | Unmarked write to a static object | A static object's position, rotation, scale or bounding sphere changed without a setter. The engine updates a static object only in a frame where a setter marks it or its parent moves. A row of a static instance, sprite or point batch that changed without `markDirty()` raises it too. |
25
28
  | [E1111](E1111.md) | Mesh or model still in use | A call to destroy() named a mesh, or a model that assets.loadGltf loaded, while an object or an instance batch still uses it. For a model, that includes objects that use one of its meshes or materials, and objects that its animation clips move. The engine keeps the mesh or model, so nothing draws freed memory. |
26
29
  | [E1112](E1112.md) | Unsupported cookie texture | A spot light's map copies its picture once, when the texture's texels reach the GPU. A video's texture and a render pass's texture change every frame, and a 3D or cube texture holds more than one image, so none of them fits the copy. |
30
+
31
+ ## Values passed to calls
32
+
33
+ | Code | Error | What happened |
34
+ | --- | --- | --- |
27
35
  | [E1203](E1203.md) | Invalid number | A call received a number that is not finite, such as NaN or Infinity. |
28
36
  | [E1204](E1204.md) | Invalid color | A call received a color that is not a hex string, a number from 0 to 0xffffff, or three numbers from 0 to 1. |
29
37
  | [E1205](E1205.md) | Unknown input name | An input call received a name that no key, button or action has, or `input.actions.define()` received an action name that a key or button already has. `on()` and `off()` received an event type that objects do not have. Names are case-sensitive: `KeyW` is the W key, and `keyW` names nothing. |
30
- | [E1206](E1206.md) | Invalid mesh arrays | geometry.fromArrays() received arrays that make no mesh, scene.createLines() received points that make no line, or scene.createPoints() received arrays that make no points. An array can have the wrong length for the vertex count, an index can name no vertex, or a value can be NaN or Infinity. Normals can also be missing, or both given and computed. A mesh can also take `targets` or `morphTargets`, not both. A line needs at least 2 points, and pairs of points need an even number. Points need at least 1 point, with 3 or 4 numbers of color each. Or mesh.updateVertices() received values that do not fit the mesh: an attribute the mesh lacks or that takes no updates, another array type than the mesh keeps, or vertices past its last one. |
38
+ | [E1206](E1206.md) | Invalid mesh arrays | A call that builds or updates a mesh, a line or a set of points got arrays that do not fit. An array can have the wrong length, an index can name no vertex, or a value can be NaN or Infinity. |
31
39
  | [E1207](E1207.md) | Invalid layer mask | A call that sets layers received a number that is not a 32-bit layer mask: a fraction, NaN, or a number past 32 bits. |
32
40
  | [E1208](E1208.md) | Invalid texture | A call that makes or updates a texture received something it cannot use. It can be an option the engine does not know, or an image without pixels or larger than the device takes. It can also be data that does not fit the texture's size and format, or numbers that make no color grading table. With a KTX2 file, it can be an option that the file cannot take, or an update of its texture. |
33
41
  | [E1209](E1209.md) | Too many textures | A material whose shader reads more textures than a WebGL2 shader stage has units. The engine numbers the textures that a program reads, and WebGL2 gives every stage at least 16 units, as many as the device reports. The lit shader reads most of them, so a custom material or add-on draw reaches the limit with its own textures, beside the maps and the shadows. |
34
- | [E1213](E1213.md) | Invalid setting | A call received a setting that it does not have, or a value that the setting does not take. Examples are a tone mapping that the engine does not know, a negative exposure, a grading control outside its range, and a built-in environment that the engine does not have. It also covers a glTF extension handler that names no extension, that another handler reads, or that returns a part without a mesh or a material. |
35
- | [E1214](E1214.md) | Invalid sketch option | defineSketch() received an option out of its range. fixedRate must be a number above 0, and maxFixedSteps a whole number of 1 or more. The engine checks the options before it runs the setup function. |
36
- | [E1215](E1215.md) | Invalid custom WGSL | materials.shader(), post.addEffect(), post.set() or scene.setSkyLayer() received WGSL that it cannot draw with. The null3D Vite plugin compiles WGSL while it builds the project. The engine therefore takes only what the plugin compiled: a template literal after a /* wgsl */ comment, or a .wgsl file that a module imports. The WGSL of a custom material declares a surface function, a vertex offset or a lobe. A full shader instead has a @vertex entry point that takes an InstanceIn from null3d::mesh. An effect declares fn effect, a tone curve fn toneCurve, and a sky layer fn skyLayer. |
37
- | [E1216](E1216.md) | Invalid uniform or texture | A custom material's or effect's uniforms or textures did not match its WGSL. The uniforms option and set() take the names of the fields of struct Uniforms in the WGSL, each with a value of its type. A field cannot have the name of a standard value, such as color or roughness, because set() takes those too. The textures option takes the names of the WGSL's `var name: texture_2d<f32>;` and `var name: texture_2d_array<f32>;` declarations, each with a texture of the layers that its declaration takes. |
38
- | [E1217](E1217.md) | Invalid material option | A material factory or scene.createLines() received an option value that it does not take, such as an unknown alpha mode, blending or line mode. Custom materials refuse the 'weighted' blending, and take alpha to coverage or the hash mode only where their WGSL sets or reads the surface's alpha. A material that lets light through refuses the hash alpha mode and the weighted blending. A layered material, with a clear coat, a sheen, iridescence or anisotropy, refuses a light map, specular maps, and two textures for a pair of layer maps that glTF packs into one. It refuses a transmission or a thickness map only where one of its layer maps fills the array that the map samples: the clear coat's normal map and iridescence's thickness map fill the array that the transmission map samples, and the sheen's maps and the anisotropy map fill the array that the thickness map samples. A material with transmission refuses a thickness map beside a specular color map, whose sRGB texture never shares the thickness map's array, and other materials refuse those two maps. A material that lets light through to its other side refuses the specular maps, whose places its diffuse transmission maps take, a clear coat, a sheen and the weighted blending, and other materials refuse the diffuse transmission maps. A custom material refuses subsurfaceRadius, which only a standard material takes. A custom material whose WGSL declares a coverage function takes the mask mode, or the blend mode with the cutoff that its shadow caster tests. |
39
- | [E1218](E1218.md) | Invalid animation call | An animator call named a clip, layer or joint that the object's animation does not have. Or it got an option out of range, such as a negative fade. animator() was called on an object that has no animation clips. Or the engine refused animation data, such as a skeleton that lists a joint before its parent. Or setMorphWeight or getMorphWeight named a morph target that the mesh does not have. A clip of more than 4,194,304 keys, its frames times its tracks, is refused too, as a clip whose keys lie hours apart is. |
42
+ | [E1213](E1213.md) | Invalid setting | A call received a setting that it does not have, or a value that the setting does not take. A tone mapping that the engine does not know, or a grading control outside its range, are examples. |
43
+ | [E1214](E1214.md) | Invalid sketch option | defineSketch() received an option out of its range. fixedRate must be a number above 0, and maxFixedSteps a whole number of 1 or more. downloads must be an array of file addresses: an empty string, or a string that is not an address, fails. The engine checks the options before it runs the setup function. |
44
+ | [E1215](E1215.md) | Invalid custom WGSL | `materials.shader()`, `post.addEffect()`, `post.set()` or `scene.setSkyLayer()` received WGSL that it cannot draw with. The engine takes only WGSL that the null3D Vite plugin compiled, as a shader of the kind that the call takes. |
45
+ | [E1216](E1216.md) | Invalid uniform or texture | A custom material's or effect's uniforms or textures did not match its WGSL. The options take the names of the fields of `struct Uniforms` and of the WGSL's texture declarations. Give each one a value or texture of the type that its declaration takes, and leave standard values such as `color` to `set()`. |
46
+ | [E1217](E1217.md) | Invalid material option | A material factory or scene.createLines() got an option value that it does not take, or two options that cannot go together. The message names the option and the rule it breaks. |
47
+ | [E1218](E1218.md) | Invalid animation call | An animation call, or animation data that the engine loads, named something that does not exist or gave a value out of range. The call can be an animator call, a morph-weight call or `animateProperty()`. |
40
48
  | [E1219](E1219.md) | Invalid label | ui.trackLabel() or ui.untrackLabel() got an id that is not a string with at least one character. Or trackLabel() got a transform that is not 'screen', 'world' or 'billboard', or a rotation that is not a number for a label that faces the camera. Or the sketch tracked more labels at once than createEngine's maxLabels option allows: 4,096 by default. A label that is a plane of the scene counts against maxLabels3d instead, which holds 256 by default. |
41
- | [E1220](E1220.md) | Invalid render pass | render.addPass() got options that it does not take: an unknown kind or option, no camera, a size outside 1 to the largest texture, both a size and a scale, an input image it does not know, a workgroup size or dispatch that a device cannot run, a format that a compute pass does not write, a compute pass on WebGL2 with no fallback, or a texture name or pass name that another pass has. Or the sketch added more passes than draw at once: 31. Or textures.fromPass(), render.setPassEnabled(), render.setPassUniform(), render.setPassUniforms() or render.removePass() got something that is not a render pass, render.setPassUniform() got a pass that is not a full-screen pass, or render.setPassUniforms() got a pass that is not a compute pass. |
42
- | [E1221](E1221.md) | Invalid levels of detail | mesh.setLevels() received levels that the mesh cannot take, or a glTF file's MSFT_lod levels could not become them. Each level's error, distance or coverage must be a finite number above 0, and its switch distance must lie farther than the level's before it. A coarser level covers more of the screen, so its coverage is smaller. A mesh takes at most 15 lower levels. Each level must be another live mesh of the same engine, with the same vertex attributes as the base mesh. A level's material, where it gives one, must be a live material of the same engine. mesh.buildLevels() refuses a mesh with joints, morph targets or a vertex record, whose shape poses or moves. |
49
+ | [E1220](E1220.md) | Invalid render pass | A render pass call got options that it does not take, or a pass of a kind that it does not work on. The message names the call and the rule that it breaks. |
50
+ | [E1221](E1221.md) | Invalid levels of detail | `mesh.setLevels()` received levels that the mesh cannot take, or a glTF file's MSFT_lod levels could not become them. Each level gives one of an error, a distance and a coverage, and the switch distances grow from level to level. |
43
51
  | [E1222](E1222.md) | Invalid light probe grid texture | scene.setLightProbeGrid() received a texture that is not a 3D texture. A probe grid sample reads a 3D texture, so the frame cannot bind a texture array in its place. setLightProbeGrid() also refuses a texture that is not live. |
44
- | [E1223](E1223.md) | Invalid feature description | defineFeature(), FeatureRegistry.add(), addFeatureDraw(), post.addFeatureEffect(), scene.setSkyLayer() or a compute pass of render.addPass() got a description that it cannot take: an unknown option, a name that is empty or longer than 64 characters, a frame point or kind that does not exist or does not go together, an order outside its band, an unknown resource, lighting slot or view, a resource or view without a frame point, an output with no neutral default, a feature name, output name or debug view name that another feature has, a lighting slot that another feature provides, a debug view name that names one of the views that the engine draws itself or gives no set callback, a draw at a frame point, view or alpha mode that the draw adapter does not place, a full-screen effect at another frame point or view, writing another resource, reading one the effect chain does not bind, publishing an output, providing a slot, or disagreeing with its WGSL about the scene depth, a sky layer that does not record at the background point, as a draw, providing the sky and drawing in the three views, or a compute pass at a frame point, view, scene resource read or output that the compute adapter does not place. |
52
+ | [E1223](E1223.md) | Invalid feature description | A call that registers a feature, a feature draw, a full-screen effect, a sky layer or a compute pass got a description it cannot take. The message names the value and the rule that it breaks. |
45
53
  | [E1224](E1224.md) | Material cannot draw a mesh | scene.overrideMaterial received a sprite, point or line material. Such a material draws the rows of its batch, or a sprite or line of its own, rather than the surface of a mesh, so it cannot stand in for every mesh of the pass. |
46
54
  | [E1225](E1225.md) | Add-on name clash | An add-on registered a name that the engine or another add-on holds: its namespace, its shader library, an error-code range, a quality key, or the name of a feature, output or lighting slot. A namespace also names the package that owns it, so a second add-on that takes the name is refused even when its other fields match, while a reload of the same package keeps its namespace. Two add-ons cannot share a name, a range or a key, because the engine would have two answers for one of them. |
55
+
56
+ ## Browsers and GPUs
57
+
58
+ | Code | Error | What happened |
59
+ | --- | --- | --- |
47
60
  | [E1301](E1301.md) | No usable GPU path | The browser offers neither WebGPU nor WebGL2 for the way the engine was asked to draw. |
48
61
  | [E1302](E1302.md) | GPU lost | The browser took the GPU away while the engine drew, for example after a driver reset or a GPU crash, and the engine could not carry on. No new GPU device started, or the GPU was lost more than twice within a minute. The engine stopped drawing. |
49
62
  | [E1303](E1303.md) | WebAssembly SIMD missing | The browser runs WebAssembly without SIMD, which the engine's core needs. |
50
63
  | [E1304](E1304.md) | GPU out of memory | The GPU had no room for a buffer or texture that the engine made after the start. The objects that use it draw wrong or not at all. The engine reports the first time this happens on each GPU device, and draws on. |
51
64
  | [E1305](E1305.md) | GPU rejected work | The GPU path refused a command that the engine gave it after the start, such as a buffer larger than the device allows. The objects that the command made or drew are missing, and the canvas can stay black. The engine reports the first time this happens on each GPU device, and draws on. |
52
65
  | [E1306](E1306.md) | Safari before 18 | The browser runs the WebKit engine of a Safari before 18, which null3D does not support. Every browser on iPhone and iPad runs WebKit, so Chrome, Edge and Firefox there count too. |
66
+ | [E1307](E1307.md) | Pipeline not built | After the start, the GPU's driver could not build one pipeline that draws objects of the scene. The objects that draw with it are missing from the pass that the message names, and the engine draws on. |
67
+
68
+ ## Setup, loading and runtime
69
+
70
+ | Code | Error | What happened |
71
+ | --- | --- | --- |
53
72
  | [E1401](E1401.md) | Not a sketch module | The module passed to createEngine as the sketch does not export a sketch as its default export. |
54
- | [E1402](E1402.md) | Engine core out of date | The engine core WebAssembly file lacks functions that the TypeScript side calls, so the two come from different builds. Development builds check this when the core loads. When null3D's own dev server serves the engine from a checkout of its repository, the check also compares the stamp of the Rust sources that the core was built from with the stamp of the checkout's sources. A core built before a merge or an edit of those sources then fails at once, before it can run with code that expects another core. |
73
+ | [E1402](E1402.md) | Engine core out of date | The engine core's WebAssembly file lacks functions that the engine's JavaScript calls, so the two come from different builds. Development builds check this when the core loads. When null3D's own dev server serves the engine from a checkout of its repository, the check also compares the stamp of the Rust sources that the core was built from with the stamp of the checkout's sources. A core built before a merge or an edit of those sources then fails at once, before it can run with code that expects another core. |
55
74
  | [E1403](E1403.md) | Engine core not ready | An engine call ran before the engine core started in this worker, or the core started twice. |
56
75
  | [E1404](E1404.md) | Engine thread failed | An engine thread, or the drawing on the page, hit an error it could not handle, such as a trap in the engine core. After the start, the thread stops its loop: the engine draws no new frames, and engine.onFailure receives this error. During the start, createEngine() stops the engine and rejects with this error. |
57
76
  | [E1405](E1405.md) | Engine thread did not start | An engine worker failed while the engine started. The worker's script, the engine core or the renderer did not start there, or the sketch's setup function threw an error without an engine code. |
58
- | [E1406](E1406.md) | Engine file not downloaded | A file of the engine core did not download whole, or a file that a call loads the first time. The first KTX2 file loads the KTX2 transcoder, and the first glTF file the glTF loader. The first mesh that plans its levels of detail loads the level planner and its simplifier. The first glTF file with meshopt compression loads the meshopt decoder, and the first with Draco compression the Draco decoder. The first color grading table loads its readers, and the first environment its reader. The first sprite or point batch loads the sprite code, and the first line batch the line code. The first feature draw, instance draw or full-screen effect loads that adapter. The server answered with an error or sent another file in its place, such as a web page, or the connection broke off. |
77
+ | [E1406](E1406.md) | Engine file not downloaded | A file of the engine core did not download whole, or a file that a call loads the first time it runs. The server answered with an error, sent another file in its place, such as a web page, or the connection broke off. |
59
78
  | [E1407](E1407.md) | Invalid hold time | The ?hold= switch or the hold option of createEngine gave a hold time that is not a number of seconds from 0 to 600. |
60
79
  | [E1408](E1408.md) | Hold failed | The sketch or the engine failed in hold mode, before the engine read the held frame back. A live engine logs an error in the sketch and carries on. Hold mode stops at the first one, so a test fails at once. |
61
80
  | [E1409](E1409.md) | Invalid memory maximum | The memory option of createEngine asked for a maximum that is not a whole number of MiB from 256 to 4096. |
62
- | [E1410](E1410.md) | Sketch module not loaded | The sketch module that createEngine got did not load. It did not download, or its code threw an error while the module loaded. The engine imports a module that does not load once more after a short wait, and the console notes that second import. The error comes only when the second import fails too, and it gives the reason of the first. A module whose code threw is not downloaded again, since it would throw again. |
81
+ | [E1410](E1410.md) | Sketch module not loaded | The sketch module that `createEngine()` got did not load: it did not download, or its code threw while the module loaded. The engine imports a module that does not load once more after a short wait, and notes that second import in the console. The error comes only when the second import fails too, and it gives the reason of the first. A module whose code threw is not downloaded again, since it would throw again. |
63
82
  | [E1411](E1411.md) | Asset not downloaded | A loading call could not download its file. The server answered with an error, such as 404 for a missing file, or the network failed. |
64
- | [E1412](E1412.md) | Asset not decoded | A loading call downloaded its file but could not read it. The browser could not decode the image, as with a format it does not support. Or the file was a KTX2 file that the engine does not load, or not valid JSON. Or it was a color grading table that the engine does not read, such as a 1D table or one with a texel missing. Or it was not an environment map that `bunx @null3d/cli assets env` writes. The message says what in the file the engine could not read, with its line where it has one. A KTX2 file also fails before it transcodes when it passes a limit. It may be wider or taller than textures.maxSize, or hold more than 256 layers. It may hold more mip levels than its size has, or texels of more than 256 MiB. A PNG or JPEG file fails before it decodes when its header gives a side longer than textures.maxSize, or 16,384 for loadImageBitmap. |
83
+ | [E1412](E1412.md) | Asset not decoded | A loading call downloaded its file but could not read it. The message says what in the file the engine could not read, with its line where it has one. |
65
84
  | [E1413](E1413.md) | Asset from another origin blocked | A loading call could not read a file from another origin. The browser reads such a file only when its server allows the page's origin with an Access-Control-Allow-Origin header. The browser gives no reason, so the server may also have been unreachable. |
66
85
  | [E1414](E1414.md) | Frame not captured | engine.capture() could not give an image of a frame. The engine had stopped, or the thread that draws could not read the frame back from the GPU or encode it. The thread that draws can also stop taking messages, as when a GPU call never returns: the engine then fails the request once its wait for the answer has taken longer than its limit, instead of leaving the call to wait with no end. |
67
86
  | [E1415](E1415.md) | Page thread already runs a sketch | createEngine() was asked to run a sketch on the page's thread while another engine still runs its sketch there. The page's copy of the engine core serves one engine at a time. This happens with sketchThread: 'main', and in the single-threaded build, which runs every sketch on the page's thread. |
68
- | [E1416](E1416.md) | glTF file not read | assets.loadGltf() downloaded a file that is not a glTF 2.0 model it can read. Its JSON or binary chunk may be broken, or an offset or a count may point past the data. A buffer or an image may be missing, or its nodes may form a loop. A skin or a clip may break glTF's rules, such as key times that fall back. Draco data may not decode, or decode to other counts than its accessors give. Or its skins and clips may move more than 1,024 nodes, which is more than one skeleton holds. Or the file would decode to more than the engine allows one file. That is 64 MiB, plus 32 bytes for each byte of the file and its buffers, up to 1 GiB. A block of meshopt data counts against that total. One array may hold at most 256 MiB. Or a clip would hold more than 4,194,304 keys, its frames times its tracks. A PNG or JPEG image inside the file may claim sides past 4,096, or its images may decode to more than 1 GiB. Or the rewriteUrl option refused an address that the file names. |
87
+ | [E1416](E1416.md) | glTF file not read | assets.loadGltf() could not read a file as a glTF 2.0 model. The file is broken, it goes past a limit of the engine, or the rewriteUrl option refused an address that it names. The message names the part that failed. |
69
88
  | [E1417](E1417.md) | glTF feature not supported | A glTF file needs an extension that the engine does not read, as its extensionsRequired list says. When a foundation add-on reads that extension, the message names the package to import, such as "Import @null3d/splats, which reads it", and that add-on registers the handler that loads the file. Or a call asked a model for something it cannot give, such as instance batches of a model with no meshes. |
70
89
  | [E1418](E1418.md) | WebAssembly blocked by the page | The page's Content-Security-Policy does not allow WebAssembly, so the engine core, the KTX2 transcoder, the meshopt decoder or the Draco decoder could not compile. A policy allows it only when its script-src, or its default-src without a script-src, holds 'wasm-unsafe-eval'. |
71
- | [E1419](E1419.md) | Canvas held by another engine | createEngine() got a canvas that another engine still draws on, or a canvas whose drawing thread ended, so no engine can draw on it again. That thread ends when it fails, or when the canvas leaves the page. It also ends when the page goes away, or when the browser refuses memory for a new engine. A canvas serves one engine at a time. After destroy(), a new engine can start on the same canvas. |
72
- | [E1420](E1420.md) | Engine stopped | Sketch code called the engine after the engine stopped, from a timer, a promise or an event handler that outlived destroy(). The call did nothing. |
90
+ | [E1419](E1419.md) | Canvas held by another engine | `createEngine()` got a canvas that another engine still draws on, or a canvas whose drawing thread ended, so no engine can draw on it again. That thread ends when it fails, when the canvas leaves the page, or when the browser refuses memory for a new engine. A canvas serves one engine at a time, but after `destroy()` a new engine can start on it. |
91
+ | [E1420](E1420.md) | Engine stopped | Sketch code called the engine after the engine stopped, from a timer, a promise or an event handler that outlived destroy(). The call did nothing. engine.firstFrame rejects with it too when the page destroys the engine before its first frame. |
73
92
  | [E1421](E1421.md) | Unknown feature to preload | createEngine()'s preload option names a feature whose shaders the engine does not have. The features are ao, background, bloom, coat_sheen, coverage, cutout, dof, effect_groups, hash, lines, lod_fade, morph, occlusion, row_values, skinning, sky, sprites, transmission and views, and instance_index and texcoords for the engine's own tests. |
74
93
  | [E1422](E1422.md) | Engine file blocked by the page | The engine's files come from another origin than the page, such as a CDN, and the page's Content-Security-Policy blocks one of them. The engine starts each worker from a blob: address that imports the worker's script from that origin, and downloads its .wasm files from there. So the policy's worker-src must allow blob: and the other origin, and its script-src and connect-src must allow the other origin too. Firefox checks the modules that a worker imports against worker-src. |
75
94
  | [E1423](E1423.md) | Engine file without CORS | The engine's files come from another origin than the page, such as a CDN. One of them came without a CORS header, or did not download. A page loads a module or a .wasm file from another origin only when the response carries Access-Control-Allow-Origin. |
76
- | [E1424](E1424.md) | Custom shader builds not downloaded | A set of a custom shader's builds did not download. The null3D Vite plugin builds each custom material, effect and tone curve for every GPU path, and puts the builds in files of their own beside the sketch's files. A material's files are named material-*.js: one for each GPU path, each kind of device, and the builds that skin. An effect's and a tone curve's are named effect-*.js and curve-*.js: one for each GPU path. A page downloads its device's file when the sketch first uses the shader, and another material file when a pipeline needs it, such as the builds that skin for the first skinned mesh. The server answered with an error or sent another file in its place, such as a web page, or the connection broke off. The engine then draws no new frames. |
95
+ | [E1424](E1424.md) | Custom shader builds not downloaded | A file that holds a custom shader's builds did not download, so the engine draws no new frames. The server answered with an error, sent another file in its place, such as a web page, or the connection broke off. |
77
96
  | [E1425](E1425.md) | Pointer lock refused | engine.requestPointerLock() asked the browser to lock the pointer to the canvas, and the browser refused or ended the lock before it began. Browsers lock the pointer only right after the user clicks or presses a key. They never lock it on phones or in some frames, and they refuse for a moment after the user pressed Esc. |
78
97
  | [E1426](E1426.md) | Pointer lock with input off | engine.requestPointerLock() asked for the pointer lock on an engine started with input: false. The lock is part of the engine's input: the sketch reads the mouse's movement through the engine's listeners, which that option turns off. So the engine takes no lock, and leaves the lock to the code that records the page's input. |
79
98
  | [E1430](E1430.md) | Too many reflection probes | scene.createReflectionProbe() would make a 17th reflection probe, and a scene has at most 16. Or the scene's first probe needs 6 views of the scene for its captures. The scene and its passes share 32 views, and its passes left fewer than 6. |
80
99
  | [E1431](E1431.md) | Area lights' tables missing | The sketch made a rectangle or tube light, and the file of the area lights' fitted tables did not download. The engine's package ships the file, area-light-tables.bin, beside its code, and the engine downloads it with the first area light. Until the file arrives, area lights give no light. A server or a build that leaves out the file, or a Content-Security-Policy whose connect-src blocks its address, stops the download. |
81
100
  | [E1432](E1432.md) | Add-on for another engine version | An add-on package loaded beside an engine of another version. Each add-on ships in step with the engine and pins the engine version that it was built for, so a page may mix no two versions. The message names the add-on, its version and the engine version. |
82
101
  | [E1433](E1433.md) | Add-on for another plugin interface | An add-on from another developer loaded against a plugin interface that its declared range does not include, or the add-on declares no range of whole versions. An outside add-on declares the plugin interface versions that it works with, because it ships on its own schedule. The engine's own add-ons pin the engine version instead. The message names the add-on, the range it declares and this engine's plugin interface version. |
83
- | [E1434](E1434.md) | Baked light file not read | assets.loadLightProbeGrid() or assets.loadLightMap() downloaded a file that is not a baked light file that this engine reads. The file may not be JSON, or its format marker may be missing. Its version may not be the one that this engine reads, or its kind may not be the one that the call takes. A probe grid may have counts or spacing that a grid cannot take. Its coefficients may not hold 12 floats for each probe in the counts' product, or its validity or skyVisibility may not hold one float from 0 to 1 for each probe. A light map may have a width or height that a texture cannot take, or an encoding other than rgb8 or rgba16float. Its radiance or its direction may not hold the bytes that its size needs, which a cut-short file shows. The message names the fault. |
102
+ | [E1434](E1434.md) | Baked light file not read | assets.loadLightProbeGrid() or assets.loadLightMap() downloaded a file that this engine cannot read as baked light data. The file may not be JSON, may have the wrong format marker, version or kind, or may have a field whose size does not match the counts or size that the file gives. The message names the fault. |
84
103
  | [E1435](E1435.md) | Recording not read | createEngine() could not read the recording that ?replay= names, or the recording does not match this page. The file may not be a null3D recording, may come from another version of the format, may be cut short, or may name keys or fixed steps that this engine does not have. The message names the fault. |
85
104
  | [E1436](E1436.md) | Pick lost with the GPU | A pick waited for the GPU to copy its pixel back when the browser took the GPU away. The engine started a new device, but the frame that recorded the pick drew on the lost device, so its read never lands. The pick is rejected rather than repeated on the new device. |
86
- | [E1437](E1437.md) | Chrome for Testing refused | The null3D command-line tool did not install Chrome for Testing, the browser that draws on the computer's GPU. The archive it downloaded does not have the SHA-256 hash that the tool records for the pinned version on this platform. Or the tool has no build, and so no hash, for this platform. The tool deletes a refused archive before it unpacks it, and never runs it. |
87
- | [E1501](E1501.md) | Render space full | The scene needs more room than the renderer has. The message names the full part: the material table, the upload space, the culling pass, skinning on WebGPU, the draw list, one GPU buffer, or the shadow atlas. On WebGPU the culling pass covers 2,097,152 objects and instance rows on every device, and more on devices with larger GPU buffers. On WebGL2 the number follows the largest texture the device allows. The number for the device is in engine.capabilities.maxInstances. On WebGPU, skinned meshes keep their skinned vertices in at most 8 GPU buffers. Those hold 1 GiB in all on most devices. Skinned meshes fill at most 32 mesh buffers. The draw list grows with the scene, so it fills only when memory runs out. A frame that fails draws nothing, and the canvas keeps the last whole frame. |
105
+ | [E1437](E1437.md) | Chrome for Testing refused | The null3D command-line tool did not install Chrome for Testing, the browser that draws on the computer's GPU. The archive does not have the SHA-256 hash that the tool records for the pinned version, or the tool has no build for this platform. The tool deletes a refused archive before it unpacks it, and the command then draws with the installed Google Chrome. |
106
+
107
+ ## Render graph
108
+
109
+ | Code | Error | What happened |
110
+ | --- | --- | --- |
111
+ | [E1501](E1501.md) | Render space full | The scene needs more room than the renderer has. The message names the full part, such as the material table, the texture table, the culling pass or the shadow atlas. A frame that fails draws nothing, and the canvas keeps the last whole frame. |
88
112
  | [E1502](E1502.md) | Pass input missing | A render pass uses a target or buffer that no pass creates, or reads one that no pass running in the frame writes. The render graph checks the sketch's passes when render.addPass() or render.removePass() changes them, and every pass before the frame draws. |
89
113
  | [E1503](E1503.md) | Target created twice | Two render passes create the same target, or a pass creates a target that the render graph keeps between frames. A sketch's pass whose texture has the name of a target of the engine's own passes does this. Each target has one creator, which sets its format and size. |
90
114
  | [E1504](E1504.md) | Render pass cycle | Render passes need each other in a loop, so no order runs each pass after the passes whose output it reads. A sketch's pass that reads its own texture makes such a loop. |
91
- | [E1505](E1505.md) | Pass targets do not match | A render pass draws into targets that one GPU render pass cannot hold together. A target can have another size than the pass, or the targets can have different sample counts. The pass can also draw into two depth targets, into a whole texture array instead of one layer, or into no target. It can draw into more than four color targets, or into color targets of more than 32 bytes per sample, which some devices cannot hold. A resolve pass fails the same way when it cannot resolve its target into the canvas. That target must be multisampled, in the canvas's format and size, and read by no other running pass. |
115
+ | [E1505](E1505.md) | Pass targets do not match | A render pass draws into targets that one GPU render pass cannot hold together. A target can have another size or sample count than the pass, or the pass can name no target. |
92
116
  | [E1506](E1506.md) | Feature draw after the first frame | A draw whose instance count the GPU writes was created after the engine recorded its first frame, on a device that draws its scene directly. The direct path counts every draw on the CPU and keeps no indirect draw, so the frame has nowhere to copy the count. The frame records no draw. |
@@ -1,15 +1,11 @@
1
1
  ---
2
2
  id: getting-started/cdn
3
3
  title: Try null3D from a CDN
4
- status: experimental
5
- since: "0.2"
6
4
  summary: "The CDN build; its production and development entries; one HTML file with no bundler; import maps; the policy and CORS headers; both thread modes; what needs a build step."
7
5
  ---
8
6
 
9
7
  # Try null3D from a CDN
10
8
 
11
- > Roadmap step 0.2, first released in null3D 0.1.0. The API is experimental, so it can still change between versions.
12
-
13
9
  A page can draw a null3D scene with no build step: one HTML file that imports the engine from a CDN. This suits a quick trial, a documentation example or a CodePen-style page. A project that grows past a trial uses Vite and the plugin, as [Install null3D](install.md) shows.
14
10
 
15
11
  ```mermaid
@@ -21,9 +17,14 @@ flowchart LR
21
17
 
22
18
  ## Make the CDN build
23
19
 
24
- The build holds the engine's JavaScript, its shaders, both WebAssembly builds and its vendor files, with each foundation add-on under `addons/<name>/`. The npm package leaves the built shaders out, because they are large and a Vite build supplies them. A page with no build step therefore needs this folder.
20
+ The CDN build comes from the engine's source, not from npm. It holds the engine's JavaScript, its shaders, both WebAssembly builds and its vendor files, with each foundation add-on under `addons/<name>/`. The npm package leaves the built shaders out, because they are large and a Vite build supplies them. A page with no build step therefore needs this folder.
21
+
22
+ Install Bun and the Rust toolchain through [rustup](https://rustup.rs), then run these commands in a clone of the [repository](https://github.com/null3d-engine/null3d#development):
25
23
 
26
24
  ```sh
25
+ git clone https://github.com/null3d-engine/null3d.git
26
+ cd null3d
27
+ bun install
27
28
  bun run build
28
29
  bun run build:cdn
29
30
  ```
@@ -40,6 +41,8 @@ Give every file a CORS header, because the engine imports its modules and downlo
40
41
  Access-Control-Allow-Origin: *
41
42
  ```
42
43
 
44
+ Send each `.wasm` file with `Content-Type: application/wasm`, with nothing after it, and let browsers keep the files. Chrome then keeps the compiled engine core, and a repeat visit skips most of its compile ([Let Chrome keep the compiled core](hosting.md#let-chrome-keep-the-compiled-core)). The folder's file names hold no hash of their content. So upload each engine version under a prefix of its own, such as `https://cdn.example.com/null3d/0.1.0/`. Then serve its files with `Cache-Control: public, max-age=31536000, immutable`, so a repeat visit takes them from the browser's cache.
45
+
43
46
  ## Production and development entries
44
47
 
45
48
  The build holds the engine's entry point twice. Both draw the same scene. They differ in the checks that run and in the switches that the page's address can set.
@@ -51,16 +54,21 @@ The build holds the engine's entry point twice. Both draw the same scene. They d
51
54
 
52
55
  The development entry runs the same checks as the Vite dev server. A bad argument throws an error with its code, such as [E1203](../errors/E1203.md), and a call on a destroyed object throws [E1101](../errors/E1101.md). Debug drawing and debug views draw only in a development build, such as this entry ([Debugging](../guides/debugging.md#development-checks)). The entry also reads the switches in the page's address, such as `?gpu=`, `?hold=` and `?preset=` ([Switches for tests](../guides/testing.md#switches-for-tests)).
53
56
 
54
- In each frame, some of those checks read every static object and a share of the rows of static batches. So a large scene runs slower from the development entry than from the production entry. Time a page, judge its frame rate or compare it with three.js only from the production entry. A demo from the development entry is fine to try, but its frame rate is not what your users get.
57
+ In each frame, some of those checks read every static object and a share of the rows of static batches. So a large scene runs slower from the development entry than from the production entry. Time a page, judge its frame rate or compare it with another engine only from the production entry. A demo from the development entry is fine to try, but its frame rate is not what your users get.
55
58
 
56
59
  The production entry behaves like a production build from Vite and the plugin. The checks never run, and the page ignores address switches, so a link cannot change how it runs. Its files still hold the checks' code, which a Vite build removes from the download.
57
60
 
58
61
  Use one entry for the whole page: the page's import, the sketch's import, the import map and each add-on. An add-on's development entry is `addons/<name>/lib-dev/index.js`. A page that mixes the two loads two copies of the engine's code.
59
62
 
63
+ <details>
64
+ <summary>Technical details: telling the entries apart, and a benchmark build</summary>
65
+
60
66
  To see which entry a page runs, read the address that it imports. On a page with the [isolation headers](#both-thread-modes), the `?threads=off` switch also tells them apart. With it, `engine.mode.build` is `'single'` from the development entry and `'threaded'` from the production entry.
61
67
 
62
68
  A benchmark page may time a production build and still set switches, such as `?gpu=webgl2`. It needs a third form. `bun run build:cdn --url-switches` makes the production entry read the address switches. Use that build for benchmark pages only, and never ship it, because a link can then change how the page runs.
63
69
 
70
+ </details>
71
+
64
72
  ## One HTML file
65
73
 
66
74
  Save this page, change the CDN address to your own, and serve it from a web server. A browser refuses the modules and workers of a page opened from a file on disk.
@@ -110,6 +118,20 @@ The sketch is a module at a `blob:` address, which the page makes from the strin
110
118
 
111
119
  The page imports the production entry. While you work on the page, change both `lib/index.js` addresses to `lib-dev/index.js`, so the development checks run and their errors name your mistakes.
112
120
 
121
+ ## Start the core early
122
+
123
+ The engine core is the start's largest file. A page built with Vite and the null3D plugin starts the core's download from a small script in its head. That script runs before the page's own scripts. A page with no build step adds that script itself, as the first tag in its head:
124
+
125
+ ```html
126
+ <script type="module" async src="https://cdn.example.com/null3d/lib/page/early-core.js"></script>
127
+ ```
128
+
129
+ The script picks the build that `createEngine` will pick, and starts its download. The engine takes that download when it starts, so the core does not wait for the page's own scripts. Take the script from the page's entry: `lib-dev/page/early-core.js` with the development entry.
130
+
131
+ The build loads the engine as many small modules, and each thread finds them in several rounds of imports, one after another. So a page with no build step starts more slowly than a Vite build. Serve the folder over HTTP/2 or HTTP/3, as most CDNs do, so each round's requests go out at once.
132
+
133
+ Give the folder the headers of [Make the CDN build](#make-the-cdn-build) above, so a repeat visit downloads none of it. [A fast start](../guides/start-time.md) gives the other steps.
134
+
113
135
  ## Import maps
114
136
 
115
137
  An import map gives the engine its package name, as a bundled project has it. Then the sketch and the page write `@null3d/engine`:
@@ -153,9 +175,9 @@ Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' b
153
175
  ```
154
176
 
155
177
  - `blob:` in `script-src`: the page makes the sketch module at a `blob:` address.
156
- - `blob:` in `worker-src`: the engine starts each worker from a `blob:` address when its files come from another origin, and the sketch is one there.
157
- - The CDN in `worker-src`: Firefox checks the modules that a worker imports against it.
158
- - The CDN in `script-src` and `connect-src`: the scripts and the WebAssembly files come from there.
178
+ - `'unsafe-inline'` in `script-src` and `style-src`: the example page holds its script and style inline.
179
+
180
+ The `blob:` in `worker-src`, and the CDN in `script-src`, `worker-src` and `connect-src`, are there for the reasons that [Hosting](hosting.md#the-engines-files-on-a-cdn) gives, with the error that each missing item causes.
159
181
 
160
182
  Missing items give [E1422](../errors/E1422.md), [E1423](../errors/E1423.md) or [E1418](../errors/E1418.md), as [Hosting](hosting.md#the-engines-files-on-a-cdn) lists them.
161
183
 
@@ -209,7 +231,7 @@ export default defineSketch((ctx) => {
209
231
 
210
232
  An import map can name an add-on for the page's own modules, but a worker reads no import map. Name the add-on by its full address in the sketch, as the example does.
211
233
 
212
- The build also writes `null3d-third-party-notices.txt`, with the license notices of the engine and of each add-on that ships other projects' code. Keep that file with the folder when you publish it, or show its text in your credits.
234
+ The build also writes `null3d-third-party-notices.txt`, with the license notices of the engine and of each add-on that ships other projects' code. Keep that file with the folder when you publish it, or show its text in your credits ([Third-party notices](third-party-notices.md)).
213
235
 
214
236
  ## Related pages
215
237
 
@@ -1,15 +1,11 @@
1
1
  ---
2
2
  id: getting-started/first-scene
3
3
  title: Your first scene
4
- status: experimental
5
- since: "0.1"
6
4
  summary: "page.ts with createEngine; sketch.ts with defineSketch; camera, light, mesh; running it with Vite."
7
5
  ---
8
6
 
9
7
  # Your first scene
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
  html["index.html<br/>the canvas"] --> page["page.ts<br/>main thread: createEngine"]
@@ -19,7 +15,7 @@ flowchart LR
19
15
 
20
16
  A null3D project has two modules. The page module, `page.ts`, runs on the page's main thread: it creates the engine and keeps the HTML. The sketch module, `sketch.ts`, builds the 3D scene and updates it every frame, in a worker of its own. This page builds a turning box with a camera and two lights.
21
17
 
22
- Put the four files below in one folder. The project needs the `@null3d/engine` package, and Vite with the `@null3d/vite-plugin` package: [Install null3D](install.md) lists them.
18
+ Put the four files below in one folder. The project needs the `@null3d/engine` package, and Vite with the `@null3d/vite-plugin` package: [Install null3D](install.md) lists them. `bunx @null3d/cli create` writes this same project for you, with the two modules in `src/`. See [Project structure](project-structure.md).
23
19
 
24
20
  ## The HTML page
25
21
 
@@ -47,19 +43,26 @@ CSS sets the canvas's size. The engine draws at that size times the screen's pix
47
43
 
48
44
  ```ts
49
45
  // page.ts
50
- import { createEngine } from '@null3d/engine';
46
+ import { createEngine, EngineError } from '@null3d/engine';
51
47
 
52
48
  const canvas = document.querySelector('canvas')!;
53
- const engine = await createEngine({
54
- canvas,
55
- sketch: new URL('./sketch.ts', import.meta.url),
56
- });
57
- await engine.firstFrame; // the first frame is on the screen
49
+ try {
50
+ const engine = await createEngine({
51
+ canvas,
52
+ sketch: new URL('./sketch.ts', import.meta.url),
53
+ });
54
+ await engine.firstFrame; // the first frame is on the screen
55
+ } catch (error) {
56
+ if (!(error instanceof EngineError)) throw error;
57
+ const note = document.createElement('p');
58
+ note.textContent = 'This browser cannot show the 3D scene.';
59
+ canvas.replaceWith(note);
60
+ }
58
61
  ```
59
62
 
60
63
  `createEngine` picks the GPU path, starts the engine's threads and runs the sketch's setup. It resolves once the setup has run. `engine.firstFrame` resolves once the GPU has finished the first frame, which is the moment to remove a loading screen.
61
64
 
62
- `createEngine` rejects with an `EngineError` when the browser cannot run the engine. Examples are Safari before 18 ([E1306](../errors/E1306.md)), a browser without WebAssembly SIMD ([E1303](../errors/E1303.md)), and one without a usable GPU path ([E1301](../errors/E1301.md)). Catch it, and show the page without the scene.
65
+ `createEngine` rejects with an `EngineError` when the browser cannot run the engine. Examples are Safari before 18 ([E1306](../errors/E1306.md)), a browser without WebAssembly SIMD ([E1303](../errors/E1303.md)), and one without a usable GPU path ([E1301](../errors/E1301.md)). The `catch` above shows the page without the scene. [Debugging](../guides/debugging.md#where-problems-appear) lists every error the start can give, and `engine.onFailure` for failures after the start.
63
66
 
64
67
  ## The sketch module
65
68
 
@@ -96,7 +99,7 @@ The module's default export is `defineSketch(setup)`. The engine calls `setup` o
96
99
 
97
100
  - The camera's `fov` is vertical, in degrees, and `target` turns the camera toward a point. `setActiveCamera` draws the scene from it.
98
101
  - The directional light's `direction` is the way its light travels, like sunlight. The ambient light lights every surface equally.
99
- - `geometry.box` takes the parameters and defaults of three.js's `BoxGeometry`. `materials.standard` shades with the physically based formulas of three.js's `MeshStandardMaterial`.
102
+ - `geometry.box` makes a box centered on its origin. Its `width`, `height` and `depth` are 1 by default. `materials.standard` shades with glTF's physically based metallic-roughness model.
100
103
  - `dynamic: true` says that the cube moves in most frames. Objects are static by default, and a static object costs nothing in a frame where it does not change.
101
104
 
102
105
  The sketch worker has no `document` and no `window`. The page keeps the HTML, and the two sides talk through [messages](../api/page.md).
@@ -123,6 +126,11 @@ Open the address that Vite prints. `bunx vite build` writes the production files
123
126
 
124
127
  ## Next steps
125
128
 
129
+ - [Show a model](../cookbook/index.md#a-loading-screen-for-models): load a glTF file and an environment, and wait for the first frame.
130
+ - [Orbit controls](../api/controls.md): let the user turn and zoom the camera.
131
+ - [Lighting and environment](../concepts/lighting.md): light types, environment maps and fog.
132
+ - [Project structure](project-structure.md): start from the `product` template, which has orbit controls and soft studio light.
133
+ - glTF model example: a full sketch that shows a model on a turntable.
126
134
  - [Objects and transforms](../api/objects.md): move, turn, parent and hide objects.
127
135
  - [Static and dynamic objects](../concepts/static-dynamic.md): when to pass `dynamic: true`.
128
136
  - [Instances and batching](../concepts/instances.md): draw thousands of copies of one mesh.