@null3d/engine 0.1.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 (381) 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 +39 -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 +65 -25
  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/E1401.md +11 -3
  146. package/docs/errors/E1402.md +13 -5
  147. package/docs/errors/E1403.md +11 -3
  148. package/docs/errors/E1404.md +13 -3
  149. package/docs/errors/E1405.md +15 -4
  150. package/docs/errors/E1406.md +31 -5
  151. package/docs/errors/E1407.md +11 -3
  152. package/docs/errors/E1408.md +11 -3
  153. package/docs/errors/E1409.md +11 -3
  154. package/docs/errors/E1410.md +13 -5
  155. package/docs/errors/E1411.md +11 -3
  156. package/docs/errors/E1412.md +29 -6
  157. package/docs/errors/E1413.md +11 -3
  158. package/docs/errors/E1414.md +11 -3
  159. package/docs/errors/E1415.md +11 -3
  160. package/docs/errors/E1416.md +27 -6
  161. package/docs/errors/E1417.md +11 -3
  162. package/docs/errors/E1418.md +12 -3
  163. package/docs/errors/E1419.md +13 -5
  164. package/docs/errors/E1420.md +11 -3
  165. package/docs/errors/E1421.md +11 -3
  166. package/docs/errors/E1422.md +12 -3
  167. package/docs/errors/E1423.md +12 -3
  168. package/docs/errors/E1424.md +24 -5
  169. package/docs/errors/E1425.md +11 -3
  170. package/docs/errors/E1426.md +11 -3
  171. package/docs/errors/E1430.md +11 -3
  172. package/docs/errors/E1431.md +11 -3
  173. package/docs/errors/E1432.md +11 -3
  174. package/docs/errors/E1433.md +11 -3
  175. package/docs/errors/E1434.md +15 -6
  176. package/docs/errors/E1435.md +11 -3
  177. package/docs/errors/E1436.md +11 -3
  178. package/docs/errors/E1437.md +14 -6
  179. package/docs/errors/E1501.md +41 -6
  180. package/docs/errors/E1502.md +13 -3
  181. package/docs/errors/E1503.md +11 -3
  182. package/docs/errors/E1504.md +11 -3
  183. package/docs/errors/E1505.md +23 -5
  184. package/docs/errors/E1506.md +11 -3
  185. package/docs/errors/index.md +52 -29
  186. package/docs/getting-started/cdn.md +15 -9
  187. package/docs/getting-started/first-scene.md +20 -12
  188. package/docs/getting-started/hosting.md +111 -63
  189. package/docs/getting-started/install.md +39 -24
  190. package/docs/getting-started/network-use.md +31 -21
  191. package/docs/getting-started/project-structure.md +20 -8
  192. package/docs/getting-started/third-party-notices.md +6 -10
  193. package/docs/guides/accessibility.md +4 -4
  194. package/docs/guides/add-ons.md +83 -13
  195. package/docs/guides/agents.md +2 -6
  196. package/docs/guides/assets-pipeline.md +248 -72
  197. package/docs/guides/audio.md +17 -15
  198. package/docs/guides/baked-light-data.md +44 -23
  199. package/docs/guides/car-paint.md +37 -31
  200. package/docs/guides/content-pages.md +53 -29
  201. package/docs/guides/custom-passes.md +59 -17
  202. package/docs/guides/custom-shaders.md +54 -37
  203. package/docs/guides/debugging.md +31 -41
  204. package/docs/guides/deploying.md +6 -27
  205. package/docs/guides/deterministic-simulation.md +23 -16
  206. package/docs/guides/first-use-shaders.md +83 -45
  207. package/docs/guides/lens-kit.md +29 -26
  208. package/docs/guides/loading-screens.md +70 -30
  209. package/docs/guides/multiple-views.md +22 -11
  210. package/docs/guides/performance.md +188 -37
  211. package/docs/guides/phones.md +71 -19
  212. package/docs/guides/physics.md +6 -10
  213. package/docs/guides/screens.md +41 -29
  214. package/docs/guides/start-time.md +120 -85
  215. package/docs/guides/testing.md +137 -98
  216. package/docs/guides/ui-overlays.md +17 -12
  217. package/docs/guides/video-textures.md +14 -13
  218. package/docs/images/api/animation/character.webp +0 -0
  219. package/docs/images/api/animation/look-at-ring.webp +0 -0
  220. package/docs/images/api/animation/morph-tulips.webp +0 -0
  221. package/docs/images/api/animation/skeleton-lines.webp +0 -0
  222. package/docs/images/api/controls/gizmo-handles.webp +0 -0
  223. package/docs/images/api/controls/walk-and-fly.webp +0 -0
  224. package/docs/images/api/debug/debug-shapes.webp +0 -0
  225. package/docs/images/api/debug/levels-view.webp +0 -0
  226. package/docs/images/api/engine/transparent-canvas.webp +0 -0
  227. package/docs/images/api/feature-draws/feature-draw-clouds.webp +0 -0
  228. package/docs/images/api/feature-instances/compute-instances.webp +0 -0
  229. package/docs/images/api/feature-instances/instances-shadow.webp +0 -0
  230. package/docs/images/api/geometry/extra-shapes.webp +0 -0
  231. package/docs/images/api/geometry/generators.webp +0 -0
  232. package/docs/images/api/geometry/mesh-arrays.webp +0 -0
  233. package/docs/images/api/geometry/vertex-updates.webp +0 -0
  234. package/docs/images/api/grass/grass-grove.webp +0 -0
  235. package/docs/images/api/grass/grass-presets.webp +0 -0
  236. package/docs/images/api/grass/grass-shadow.webp +0 -0
  237. package/docs/images/api/impostors/impostor-handover.webp +0 -0
  238. package/docs/images/api/impostors/impostor-shadow.webp +0 -0
  239. package/docs/images/api/impostors/impostors-forest.webp +0 -0
  240. package/docs/images/api/lights/spot-cookies.webp +0 -0
  241. package/docs/images/api/lines/lines-lit.webp +0 -0
  242. package/docs/images/api/lines/lines-widths.webp +0 -0
  243. package/docs/images/api/materials/coat-and-sheen.webp +0 -0
  244. package/docs/images/api/materials/decals.webp +0 -0
  245. package/docs/images/api/materials/iridescence-and-anisotropy.webp +0 -0
  246. package/docs/images/api/materials/relief.webp +0 -0
  247. package/docs/images/api/materials/shader-inputs.webp +0 -0
  248. package/docs/images/api/materials/standard-grid.webp +0 -0
  249. package/docs/images/api/materials/subsurface.webp +0 -0
  250. package/docs/images/api/materials/translucency.webp +0 -0
  251. package/docs/images/api/objects/objects-turntable.webp +0 -0
  252. package/docs/images/api/particles/campfire.webp +0 -0
  253. package/docs/images/api/points/galaxy.webp +0 -0
  254. package/docs/images/api/reference/textures/texture-wrap.webp +0 -0
  255. package/docs/images/api/render/fullscreen-glow.webp +0 -0
  256. package/docs/images/api/render/reflection-mirror.webp +0 -0
  257. package/docs/images/api/render/security-camera.webp +0 -0
  258. package/docs/images/api/scene/aurora-sky-layer.webp +0 -0
  259. package/docs/images/api/sound/sound-demo.webp +0 -0
  260. package/docs/images/api/splats/splats-demo.webp +0 -0
  261. package/docs/images/api/sprites/sprites-lines.webp +0 -0
  262. package/docs/images/api/terrain/terrain-demo.webp +0 -0
  263. package/docs/images/api/textures/canvas-screen.webp +0 -0
  264. package/docs/images/api/textures/mipmaps.webp +0 -0
  265. package/docs/images/api/vertex-draws/rain.webp +0 -0
  266. package/docs/images/api/water/ocean.webp +0 -0
  267. package/docs/images/api/water/water-demo.webp +0 -0
  268. package/docs/images/api/water/water-rain.webp +0 -0
  269. package/docs/images/api/water/waterfall.webp +0 -0
  270. package/docs/images/concepts/assets/gltf-model.webp +0 -0
  271. package/docs/images/concepts/color-management/tone-mapped.webp +0 -0
  272. package/docs/images/concepts/culling/far-from-origin.webp +0 -0
  273. package/docs/images/concepts/instances/instances.webp +0 -0
  274. package/docs/images/concepts/instances/per-row-colors.webp +0 -0
  275. package/docs/images/concepts/large-worlds/large-world.webp +0 -0
  276. package/docs/images/concepts/lighting/area-lights.webp +0 -0
  277. package/docs/images/concepts/lighting/atmosphere.webp +0 -0
  278. package/docs/images/concepts/lighting/environment.webp +0 -0
  279. package/docs/images/concepts/lighting/light-shafts.webp +0 -0
  280. package/docs/images/concepts/lighting/reflection-probes.webp +0 -0
  281. package/docs/images/concepts/lod/forest.webp +0 -0
  282. package/docs/images/concepts/materials/weighted-transparency.webp +0 -0
  283. package/docs/images/concepts/post-processing/auto-exposure.webp +0 -0
  284. package/docs/images/concepts/post-processing/bounce-light.webp +0 -0
  285. package/docs/images/concepts/post-processing/depth-of-field.webp +0 -0
  286. package/docs/images/concepts/post-processing/post-effects-alley.webp +0 -0
  287. package/docs/images/concepts/post-processing/sharpen.webp +0 -0
  288. package/docs/images/concepts/post-processing/ssr-wet-street.webp +0 -0
  289. package/docs/images/concepts/render-layers/layers-cottages.webp +0 -0
  290. package/docs/images/concepts/shadows/hero-shadow.webp +0 -0
  291. package/docs/images/cookbook/index/picking.webp +0 -0
  292. package/docs/images/cookbook/index/time-of-day.webp +0 -0
  293. package/docs/images/errors/E1431/area-lights-no-tables.webp +0 -0
  294. package/docs/images/guides/custom-passes/reflection-water.webp +0 -0
  295. package/docs/images/guides/deterministic-simulation/replay-demo.webp +0 -0
  296. package/docs/images/guides/multiple-views/split-screen.webp +0 -0
  297. package/docs/images/guides/performance/overdraw-view.webp +0 -0
  298. package/docs/images/guides/testing/hold-mode-frame.webp +0 -0
  299. package/docs/images/index/showcase-island.webp +0 -0
  300. package/docs/images/porting/threejs-shaders/dissolve.webp +0 -0
  301. package/docs/images/shaders/builtins/builtins.webp +0 -0
  302. package/docs/images/shaders/surface-functions/custom-surface.webp +0 -0
  303. package/docs/images/shaders/surface-functions/vertex-offset.webp +0 -0
  304. package/docs/images/shots.json +2231 -0
  305. package/docs/index.md +14 -23
  306. package/docs/moves.json +1 -0
  307. package/docs/nav.json +300 -0
  308. package/docs/pages.md +230 -212
  309. package/docs/porting/react-three-fiber.md +2 -6
  310. package/docs/porting/threejs-loop-and-threads.md +1 -5
  311. package/docs/porting/threejs-mapping.md +1248 -234
  312. package/docs/porting/threejs-materials.md +10 -5
  313. package/docs/porting/threejs-overview.md +26 -6
  314. package/docs/porting/threejs-postprocessing.md +2 -6
  315. package/docs/porting/threejs-shaders.md +16 -14
  316. package/docs/porting/threejs-unsupported.md +6 -6
  317. package/docs/porting/verification.md +0 -4
  318. package/docs/shaders/builtins.md +15 -4
  319. package/docs/shaders/library.md +9 -6
  320. package/docs/shaders/surface-functions.md +51 -16
  321. package/docs/shaders/wgsl-rules.md +12 -5
  322. package/lib/debug/debug.d.ts +2 -2
  323. package/lib/debug/draw.d.ts +2 -2
  324. package/lib/debug/draw.js +8 -4
  325. package/lib/debug/overlay-look.d.ts +6 -0
  326. package/lib/debug/overlay-look.js +29 -7
  327. package/lib/debug/overlay.js +15 -11
  328. package/lib/debug/stats-options.d.ts +13 -0
  329. package/lib/debug/stats-panel.d.ts +21 -6
  330. package/lib/debug/stats-panel.js +80 -13
  331. package/lib/errors/codes.d.ts +17 -3
  332. package/lib/errors/codes.js +111 -105
  333. package/lib/errors/fixes.js +18 -18
  334. package/lib/gpu/variants.d.ts +8 -2
  335. package/lib/gpu/variants.js +39 -7
  336. package/lib/gpu/webgl2/programs.js +1 -1
  337. package/lib/gpu/webgpu/pipelines.js +13 -13
  338. package/lib/index.d.ts +1 -1
  339. package/lib/page/capabilities.d.ts +1 -1
  340. package/lib/page/engine.d.ts +14 -5
  341. package/lib/page/engine.js +18 -2
  342. package/lib/page/label-loop.js +9 -4
  343. package/lib/page/stats-switch.js +2 -0
  344. package/lib/page/switches.d.ts +6 -4
  345. package/lib/page/switches.js +20 -4
  346. package/lib/scene/baked-light.d.ts +2 -2
  347. package/lib/scene/fake-call-values.js +2 -2
  348. package/lib/scene/frame-cameras.d.ts +16 -4
  349. package/lib/scene/frame-cameras.js +28 -10
  350. package/lib/scene/gltf.d.ts +1 -1
  351. package/lib/scene/level-rule.d.ts +6 -5
  352. package/lib/scene/level-rule.js +2 -2
  353. package/lib/scene/particles.d.ts +7 -3
  354. package/lib/scene/particles.js +3 -1
  355. package/lib/scene/post.d.ts +3 -2
  356. package/lib/scene/resources.d.ts +15 -9
  357. package/lib/scene/scene.d.ts +18 -2
  358. package/lib/scene/scene.js +47 -5
  359. package/lib/scene/time-of-day.d.ts +10 -5
  360. package/lib/scene/time-of-day.js +11 -7
  361. package/lib/shader-artifact.json +1 -1
  362. package/lib/shared/labels.d.ts +5 -2
  363. package/lib/shared/labels.js +5 -2
  364. package/lib/shared/permutation-words.d.ts +2 -0
  365. package/lib/shared/permutation-words.js +8 -0
  366. package/lib/shared/recording.d.ts +13 -5
  367. package/lib/shared/recording.js +31 -10
  368. package/lib/shared/sketch-data.d.ts +9 -0
  369. package/lib/shared/sketch-data.js +57 -0
  370. package/lib/shared/version.d.ts +1 -1
  371. package/lib/shared/version.js +1 -1
  372. package/lib/sketch/define-sketch.d.ts +16 -7
  373. package/lib/sketch/define-sketch.js +2 -1
  374. package/lib/sketch/runner.d.ts +4 -0
  375. package/lib/sketch/runner.js +5 -0
  376. package/lib/sketch/ui.js +4 -2
  377. package/lib/stats.d.ts +1 -0
  378. package/lib/workers/protocol.d.ts +10 -0
  379. package/lib/workers/render-worker.js +4 -1
  380. package/lib/workers/sketch-worker.js +4 -1
  381. package/package.json +1 -1
@@ -26,7 +26,7 @@ export interface BakedLightMap {
26
26
  * little-endian half floats. Rows run along v from the first texel at u = 0, v = 0.
27
27
  */
28
28
  readonly radiance: Uint8Array;
29
- /** Three signed bytes per texel, each axis divided by 127, or undefined without one. */
29
+ /** Three signed bytes per texel, each axis times 127, or undefined without one. */
30
30
  readonly direction: Int8Array | undefined;
31
31
  }
32
32
  /** A baked light file that this engine reads. */
@@ -45,7 +45,7 @@ export interface LightMapData {
45
45
  /** The radiance, as a texture that a material takes as `lightMap`. */
46
46
  readonly texture: Texture;
47
47
  /**
48
- * Three signed bytes per texel, from -127 to 127, each axis a direction divided by 127. It runs
48
+ * Three signed bytes per texel, from -127 to 127: each axis of the direction times 127. It runs
49
49
  * from the same first texel as the radiance, and it is undefined for a light map without a
50
50
  * direction.
51
51
  */
@@ -11,8 +11,8 @@ const READS = {
11
11
  setBatchBounds: 1,
12
12
  setMaterialValue: 3,
13
13
  setMaterialValues: 4,
14
- setPerspectiveCamera: 3,
15
- setOrthographicCamera: 6,
14
+ setPerspectiveCamera: 5,
15
+ setOrthographicCamera: 8,
16
16
  addSceneView: 4,
17
17
  setSceneViewRect: 4,
18
18
  setLightColor: 3,
@@ -49,7 +49,13 @@ export declare const LENS_CENTER_Y = 4;
49
49
  /** The distances along the view to the near and far planes. */
50
50
  export declare const LENS_NEAR = 5;
51
51
  export declare const LENS_FAR = 6;
52
- export declare const LENS_FLOATS = 7;
52
+ /**
53
+ * The lens shift: how far the view sits right of and above the camera's axis, or an orthographic
54
+ * view's center, as fractions of the view's width and height.
55
+ */
56
+ export declare const LENS_SHIFT_X = 7;
57
+ export declare const LENS_SHIFT_Y = 8;
58
+ export declare const LENS_FLOATS = 9;
53
59
  /** The cameras of the last frames, and the math of rays and projections from them. */
54
60
  export declare class FrameCameras {
55
61
  private readonly core;
@@ -153,10 +159,10 @@ export declare class FrameCameras {
153
159
  * A camera's projection, made once and used for many points. The first 9 numbers are the inverse
154
160
  * of the 3 × 3 part of the camera's world matrix, row by row, then the camera's position. Then come
155
161
  * half the view's width and height (one unit in front of a perspective camera, or across an
156
- * orthographic view), 1 for an orthographic lens or 0, the orthographic view's center, and the
157
- * distances to the near and far planes.
162
+ * orthographic view), 1 for an orthographic lens or 0, the orthographic view's center, the
163
+ * distances to the near and far planes, and the lens shift.
158
164
  */
159
- export declare const VIEW_FLOATS = 19;
165
+ export declare const VIEW_FLOATS = 21;
160
166
  export declare const VIEW_SCALE_Y = 13;
161
167
  /** 1 in a view that `viewOf` wrote for an orthographic lens, or 0. */
162
168
  export declare const VIEW_ORTHO = 14;
@@ -166,6 +172,12 @@ export declare const VIEW_CENTER_Y = 16;
166
172
  /** The distances to the near and far planes in a view that `viewOf` wrote. */
167
173
  export declare const VIEW_NEAR = 17;
168
174
  export declare const VIEW_FAR = 18;
175
+ /**
176
+ * The lens shift in a view that `viewOf` wrote, as fractions of the view's width and height. It moves
177
+ * the image by twice that fraction in normalized device coordinates.
178
+ */
179
+ export declare const VIEW_SHIFT_X = 19;
180
+ export declare const VIEW_SHIFT_Y = 20;
169
181
  /**
170
182
  * Writes where `point` lies for the camera of `view` into `out`: x and y in normalized device
171
183
  * coordinates, from -1 to 1 across the canvas with y up, then the distance in front of the camera
@@ -27,7 +27,13 @@ export const LENS_CENTER_Y = 4;
27
27
  /** The distances along the view to the near and far planes. */
28
28
  export const LENS_NEAR = 5;
29
29
  export const LENS_FAR = 6;
30
- export const LENS_FLOATS = 7;
30
+ /**
31
+ * The lens shift: how far the view sits right of and above the camera's axis, or an orthographic
32
+ * view's center, as fractions of the view's width and height.
33
+ */
34
+ export const LENS_SHIFT_X = 7;
35
+ export const LENS_SHIFT_Y = 8;
36
+ export const LENS_FLOATS = 9;
31
37
  /** The views whose cameras the ring keeps. */
32
38
  const RING_VIEWS = 4;
33
39
  /** The frames of an entry that holds no frame yet. */
@@ -301,10 +307,10 @@ function sameView(ring, at, view) {
301
307
  * A camera's projection, made once and used for many points. The first 9 numbers are the inverse
302
308
  * of the 3 × 3 part of the camera's world matrix, row by row, then the camera's position. Then come
303
309
  * half the view's width and height (one unit in front of a perspective camera, or across an
304
- * orthographic view), 1 for an orthographic lens or 0, the orthographic view's center, and the
305
- * distances to the near and far planes.
310
+ * orthographic view), 1 for an orthographic lens or 0, the orthographic view's center, the
311
+ * distances to the near and far planes, and the lens shift.
306
312
  */
307
- export const VIEW_FLOATS = 19;
313
+ export const VIEW_FLOATS = 21;
308
314
  const VIEW_POSITION = 9;
309
315
  /** Half the view's width and height in a view that `viewOf` wrote. */
310
316
  const VIEW_SCALE_X = 12;
@@ -317,6 +323,12 @@ export const VIEW_CENTER_Y = 16;
317
323
  /** The distances to the near and far planes in a view that `viewOf` wrote. */
318
324
  export const VIEW_NEAR = 17;
319
325
  export const VIEW_FAR = 18;
326
+ /**
327
+ * The lens shift in a view that `viewOf` wrote, as fractions of the view's width and height. It moves
328
+ * the image by twice that fraction in normalized device coordinates.
329
+ */
330
+ export const VIEW_SHIFT_X = 19;
331
+ export const VIEW_SHIFT_Y = 20;
320
332
  /** Writes the projection of the camera of the entry at `at` into `view`. */
321
333
  function writeView(e, at, view) {
322
334
  const m = at + MATRIX;
@@ -350,6 +362,8 @@ function writeView(e, at, view) {
350
362
  view[VIEW_CENTER_Y] = e[lens + LENS_CENTER_Y];
351
363
  view[VIEW_NEAR] = e[lens + LENS_NEAR];
352
364
  view[VIEW_FAR] = e[lens + LENS_FAR];
365
+ view[VIEW_SHIFT_X] = e[lens + LENS_SHIFT_X];
366
+ view[VIEW_SHIFT_Y] = e[lens + LENS_SHIFT_Y];
353
367
  }
354
368
  /**
355
369
  * Writes where `point` lies for the camera of `view` into `out`: x and y in normalized device
@@ -366,13 +380,16 @@ export function projectPoint(view, point, out) {
366
380
  const lz = view[6] * px + view[7] * py + view[8] * pz;
367
381
  const sx = view[VIEW_SCALE_X];
368
382
  const sy = view[VIEW_SCALE_Y];
383
+ // A lens shift moves the whole image, after the perspective division.
384
+ const shiftX = 2 * view[VIEW_SHIFT_X];
385
+ const shiftY = 2 * view[VIEW_SHIFT_Y];
369
386
  if (view[VIEW_ORTHO] !== 0) {
370
- out[0] = (lx - view[VIEW_CENTER_X]) / sx;
371
- out[1] = (ly - view[VIEW_CENTER_Y]) / sy;
387
+ out[0] = (lx - view[VIEW_CENTER_X]) / sx - shiftX;
388
+ out[1] = (ly - view[VIEW_CENTER_Y]) / sy - shiftY;
372
389
  }
373
390
  else {
374
- out[0] = lx / (-lz * sx);
375
- out[1] = ly / (-lz * sy);
391
+ out[0] = lx / (-lz * sx) - shiftX;
392
+ out[1] = ly / (-lz * sy) - shiftY;
376
393
  }
377
394
  out[2] = -lz;
378
395
  }
@@ -448,9 +465,10 @@ function writeRay(e, at, point, out) {
448
465
  const y = point[1];
449
466
  const width = e[at + CSS_WIDTH];
450
467
  const height = e[at + CSS_HEIGHT];
451
- const ndcX = width > 0 ? (x / width) * 2 - 1 : 0;
452
- const ndcY = height > 0 ? 1 - (y / height) * 2 : 0;
453
468
  const lens = at + LENS;
469
+ // A lens shift moves the view right and up, so a point of the canvas sees that much further.
470
+ const ndcX = (width > 0 ? (x / width) * 2 - 1 : 0) + 2 * e[lens + LENS_SHIFT_X];
471
+ const ndcY = (height > 0 ? 1 - (y / height) * 2 : 0) + 2 * e[lens + LENS_SHIFT_Y];
454
472
  writeScaleX(e, at, rayScale, 0);
455
473
  const sx = ndcX * rayScale[0];
456
474
  const sy = ndcY * e[lens + LENS_HALF_HEIGHT];
@@ -92,7 +92,7 @@ export declare function fileLevelMeasure(errors: readonly number[] | undefined,
92
92
  };
93
93
  /** One band of a tree of cluster patches, as a stage file holds it. */
94
94
  export interface StageBand {
95
- /** Each patch's bounding sphere: its centre, then its radius. */
95
+ /** Each patch's bounding sphere: its center, then its radius. */
96
96
  bounds: Float32Array;
97
97
  /** Each patch's first index, count, parent's place plus one, and error's bits. */
98
98
  records: Uint32Array;
@@ -22,8 +22,9 @@ export interface LevelView {
22
22
  */
23
23
  readonly orthographic?: boolean;
24
24
  /**
25
- * The source's threshold bias, as Godot's `lod_bias`: above 1 switches every level nearer, so
26
- * coarser levels draw, and below 1 keeps its detail. The default is 1.
25
+ * The source's threshold bias, as the inverse of Godot's `lod_bias`: a Godot bias of 2 is
26
+ * about a null3D bias of 0.5. Above 1 switches every level nearer, so coarser levels draw, and
27
+ * below 1 keeps its detail. The default is 1.
27
28
  */
28
29
  readonly bias?: number;
29
30
  }
@@ -41,13 +42,13 @@ export type LevelSwitch = {
41
42
  readonly coverage: number;
42
43
  };
43
44
  /**
44
- * A source's world bounds about the camera: the centre of its bounding sphere relative to the
45
+ * A source's world bounds about the camera: the center of its bounding sphere relative to the
45
46
  * camera, and the sphere's radius.
46
47
  *
47
48
  * @category api/geometry
48
49
  */
49
50
  export interface LevelBounds {
50
- /** The bounding sphere's centre, relative to the camera. */
51
+ /** The bounding sphere's center, relative to the camera. */
51
52
  readonly centre: readonly [number, number, number];
52
53
  /** The bounding sphere's radius, in meters. */
53
54
  readonly radius: number;
@@ -96,7 +97,7 @@ export declare function levelSwitchDistance(view: LevelView, level: LevelSwitch,
96
97
  * point for the other measures.
97
98
  *
98
99
  * @param view The view that measures the source.
99
- * @param bounds The source's bounds, with the centre relative to the camera.
100
+ * @param bounds The source's bounds, with the center relative to the camera.
100
101
  * @returns The two distances, in meters.
101
102
  * @category api/geometry
102
103
  */
@@ -26,7 +26,7 @@
26
26
  * @category api/geometry
27
27
  */
28
28
  export const LEAST_LEVEL_DISTANCE = 1e-3;
29
- /** The share of the bounds' radius that an error's distance takes off the distance to the centre. */
29
+ /** The share of the bounds' radius that an error's distance takes off the distance to the center. */
30
30
  const ERROR_RADIUS_SHARE = 0.5;
31
31
  /** The multiple of the distance to the nearest point that caps an error's distance. */
32
32
  const ERROR_NEAREST_SHARE = 2;
@@ -84,7 +84,7 @@ export function levelSwitchDistance(view, level, scale, radius = 0) {
84
84
  * point for the other measures.
85
85
  *
86
86
  * @param view The view that measures the source.
87
- * @param bounds The source's bounds, with the centre relative to the camera.
87
+ * @param bounds The source's bounds, with the center relative to the camera.
88
88
  * @returns The two distances, in meters.
89
89
  * @category api/geometry
90
90
  */
@@ -198,8 +198,10 @@ export interface ParticleBufferOptions extends ParticleValues {
198
198
  /**
199
199
  * Where an emitter's particles are born, in its own space, and which way they set off. A `point`
200
200
  * emits at the emitter, along `direction`. A `sphere` emits inside a ball of `radius`, or on its
201
- * surface with `surface`, and sends particles outward. A `cone` emits on a disc of `radius` across
202
- * the emitter's +y axis. It sends particles up within `angle` radians of that axis. A `box` emits
201
+ * surface with `surface`, and sends particles outward.
202
+ *
203
+ * A `cone` emits on a disc of `radius` across the emitter's +y axis. It sends particles up within
204
+ * `angle` radians of that axis. A `box` emits
203
205
  * inside a box of `size`, centered on the emitter, along `direction`. A `disc` emits on a disc of
204
206
  * `radius` across the +y axis, along `direction`.
205
207
  *
@@ -294,7 +296,9 @@ export interface ParticleEmitterOptions {
294
296
  * particles add-on's emitters write records into it. Write a particle's record once, when it is
295
297
  * born, with `write`, or write a frame's births in one call with `writeRecords`. The GPU moves it
296
298
  * and changes its look as it ages, as the buffer's values say. It stops drawing the particle at
297
- * the end of its lifetime. Once per frame, write the buffer's time and the records the GPU reads
299
+ * the end of its lifetime.
300
+ *
301
+ * Once per frame, write the buffer's time and the records the GPU reads
298
302
  * into `frame`, and call `commit`. Every call takes typed arrays and whole numbers, so a frame's
299
303
  * calls allocate nothing.
300
304
  *
@@ -202,7 +202,9 @@ const NO_FLOAT64 = new Float64Array(0);
202
202
  * particles add-on's emitters write records into it. Write a particle's record once, when it is
203
203
  * born, with `write`, or write a frame's births in one call with `writeRecords`. The GPU moves it
204
204
  * and changes its look as it ages, as the buffer's values say. It stops drawing the particle at
205
- * the end of its lifetime. Once per frame, write the buffer's time and the records the GPU reads
205
+ * the end of its lifetime.
206
+ *
207
+ * Once per frame, write the buffer's time and the records the GPU reads
206
208
  * into `frame`, and call `commit`. Every call takes typed arrays and whole numbers, so a frame's
207
209
  * calls allocate nothing.
208
210
  *
@@ -17,8 +17,9 @@ export type { GradingSettings, SplitToningSettings, WhiteBalanceSettings, } from
17
17
  * AgX, the curve of Blender and Filament. The `'agx-punchy'` curve is AgX with Filament's punchy
18
18
  * look, which adds contrast and color. The `'neutral'` curve is Khronos PBR Neutral, which keeps
19
19
  * base colors as they are until they near white. The `'aces'` curve is a fit of the ACES filmic
20
- * curve, which first scales the color by 1 / 0.6 and shifts the hues of bright colors. The value
21
- * `'none'` clips the exposed color at 1.
20
+ * curve, which first scales the color by 1 / 0.6 and shifts the hues of bright colors.
21
+ *
22
+ * The value `'none'` clips the exposed color at 1.
22
23
  *
23
24
  * @category api/post
24
25
  */
@@ -7,9 +7,11 @@ import type { TextureValues, UniformValues } from './wgsl-uniforms.js';
7
7
  * A lower level of detail of a mesh: a simpler mesh that draws in the base mesh's place. Give its
8
8
  * `error`, the `distance` at which it switches in, or the screen `coverage` under which it draws.
9
9
  * A level with a measured error, which the asset tool writes, changes the picture by under a pixel
10
- * at a small threshold and switches at once. When the governor raises the threshold above about
11
- * one and a half pixels, that switch shows, and such a level then fades too. A level given by a distance, by
12
- * a coverage or by a hand-set error fades over a short band, so its switch does not pop.
10
+ * at a small threshold and switches at once.
11
+ *
12
+ * When the governor raises the threshold above about one and a half pixels, that switch shows, and
13
+ * such a level then fades too. A level given by a distance, by a coverage or by a hand-set error
14
+ * fades over a short band, so its switch does not pop.
13
15
  *
14
16
  * @category api/geometry
15
17
  */
@@ -110,8 +112,10 @@ export interface BuildLevelsOptions {
110
112
  * The levels of detail that a mesh made in code plans on its own. By default it plans them the
111
113
  * first time the scene draws it, when it holds `geometry.automaticLevelTriangles` triangles or
112
114
  * more, or when it holds at least `geometry.automaticCopyTriangles` triangles and its copies hold `geometry.automaticDrawnTriangles` together; `false` plans none,
113
- * and `true` or options plan them when the mesh is made, at any size. `'pieces'` plans no lower
114
- * levels, and sorts a mesh of 32,768 triangles or more into pieces by space at its first draw, as
115
+ * and `true` or options plan them when the mesh is made, at any size.
116
+ *
117
+ * `'pieces'` plans no lower levels, and sorts a mesh of 32,768 triangles or more into pieces by
118
+ * space at its first draw, as
115
119
  * a merged far cell or a large ground whose levels come from elsewhere gains from.
116
120
  *
117
121
  * @category api/geometry
@@ -764,8 +768,10 @@ export interface MaterialOptions {
764
768
  /**
765
769
  * How a material uses its alpha: its opacity, times its base color map's alpha, and times its
766
770
  * mesh's vertex alpha with `vertexColors`. The `opaque` mode ignores the alpha. The `mask` mode
767
- * draws nothing where the alpha falls below `alphaCutoff`, and draws the rest opaque. The `hash`
768
- * mode draws each point of the surface opaque or not at all, by a pattern that stays on the mesh.
771
+ * draws nothing where the alpha falls below `alphaCutoff`, and draws the rest opaque.
772
+ *
773
+ * The `hash` mode draws each point of the surface opaque or not at all, by a pattern that stays on
774
+ * the mesh.
769
775
  * The alpha then sets how much of the surface draws. The `blend` mode blends the surface over what
770
776
  * lies behind it. Blended objects draw after the opaque ones, farthest first.
771
777
  *
@@ -1083,8 +1089,8 @@ export interface StandardMaps {
1083
1089
  /**
1084
1090
  * The thickness of the volume under the surface, in green, in linear color. Its green
1085
1091
  * multiplies `thickness`. Only a material created with `transmission` takes it. It keeps a row
1086
- * slot of its own and samples the specular color map's texture array at its own layer, so a
1087
- * specular color map may draw beside it when the two textures share an array. A material with
1092
+ * slot of its own and samples the specular color map's texture array at its own layer, so it
1093
+ * takes no specular color map, whose sRGB texture never shares that array. A material with
1088
1094
  * layers keeps it unless a layer map fills that slot: the sheen's maps and an anisotropy map do.
1089
1095
  */
1090
1096
  thicknessMap?: Texture;
@@ -833,8 +833,9 @@ export declare class Mesh extends Object3D {
833
833
  */
834
834
  setRenderOrder(order: number): void;
835
835
  /**
836
- * Raises or lowers the threshold that picks this mesh's levels of detail, as Godot's
837
- * `lod_bias` does. A bias above 1 makes every switch happen nearer, so the object draws
836
+ * Raises or lowers the threshold that picks this mesh's levels of detail, as the inverse of
837
+ * Godot's `lod_bias`: a Godot bias of 2 is about a null3D bias of 0.5. A bias above 1 makes
838
+ * every switch happen nearer, so the object draws
838
839
  * coarser levels. A bias below 1 keeps its detail, which a hero object wants. The bias
839
840
  * multiplies the threshold of the level switches and of the distance at which the object
840
841
  * hides, so both move by the same factor. The default is 1. The object's mesh needs levels
@@ -882,6 +883,21 @@ export declare abstract class Camera extends Object3D {
882
883
  setLayers(mask: number): void;
883
884
  /** Sets the distances to the near and far clipping planes. */
884
885
  setNearFar(near: number, far: number): void;
886
+ /**
887
+ * The lens shift: how far the view sits right of and above the camera's axis, as fractions of the
888
+ * view's width and height. The array is the camera's own and changes with `setLensShift`, so
889
+ * copy it to keep a value.
890
+ */
891
+ get lensShift(): readonly [number, number];
892
+ /**
893
+ * Moves the view off the camera's axis, as a shift lens on a real camera does: right by `x`
894
+ * times the view's width, and up by `y` times its height. The perspective stays as it is, so the
895
+ * image is a crop of a wider view from the same place. A shift of 0.25 across puts the camera's
896
+ * axis, and a `target` it looks at, a quarter of the width left of the middle. Culling,
897
+ * shadows, picking, `screenToRay`, `worldToScreen`, views and labels all follow the shifted
898
+ * view. The default is no shift. It allocates nothing.
899
+ */
900
+ setLensShift(x: number, y: number): void;
885
901
  /**
886
902
  * Writes the ray from the camera through a point on the canvas into `out`: `x` and `y` are CSS
887
903
  * pixels from the canvas's top-left corner, as `input.pointer` gives them. A perspective ray
@@ -17,7 +17,7 @@ import { Cubemap, isAtmosphereBackground, isSkyBackground, SceneBackground, Scen
17
17
  import { linearColor, writeLinearColor } from './color.js';
18
18
  import { Environment, SceneEnvironment } from './environment.js';
19
19
  import { setSceneFog } from './fog.js';
20
- import { FrameCameras, LENS_CENTER_X, LENS_CENTER_Y, LENS_FAR, LENS_FLOATS, LENS_HALF_HEIGHT, LENS_HALF_WIDTH, LENS_NEAR, LENS_ORTHO, } from './frame-cameras.js';
20
+ import { FrameCameras, LENS_CENTER_X, LENS_CENTER_Y, LENS_FAR, LENS_FLOATS, LENS_HALF_HEIGHT, LENS_HALF_WIDTH, LENS_NEAR, LENS_ORTHO, LENS_SHIFT_X, LENS_SHIFT_Y, } from './frame-cameras.js';
21
21
  import { checkFov, checkNearFar, checkOrthographicSize, checkSize, DEFAULT_FAR, DEFAULT_FOV, DEFAULT_NEAR, HALF_SENSOR_MM, newCamera, orthographicView, setViewHeight, } from './lens.js';
22
22
  import { SceneLightProbeGrid } from './light-probes.js';
23
23
  import { ScenePicks } from './picks.js';
@@ -999,8 +999,9 @@ export class Mesh extends Object3D {
999
999
  this.renderOrder = order;
1000
1000
  }
1001
1001
  /**
1002
- * Raises or lowers the threshold that picks this mesh's levels of detail, as Godot's
1003
- * `lod_bias` does. A bias above 1 makes every switch happen nearer, so the object draws
1002
+ * Raises or lowers the threshold that picks this mesh's levels of detail, as the inverse of
1003
+ * Godot's `lod_bias`: a Godot bias of 2 is about a null3D bias of 0.5. A bias above 1 makes
1004
+ * every switch happen nearer, so the object draws
1004
1005
  * coarser levels. A bias below 1 keeps its detail, which a hero object wants. The bias
1005
1006
  * multiplies the threshold of the level switches and of the distance at which the object
1006
1007
  * hides, so both move by the same factor. The default is 1. The object's mesh needs levels
@@ -1074,6 +1075,8 @@ export class Camera extends Object3D {
1074
1075
  layers = C.LAYERS_DEFAULT;
1075
1076
  /** @internal The lens as the frame cameras keep it, which `updateLens` writes. */
1076
1077
  lens = new Float64Array(LENS_FLOATS);
1078
+ /** @internal The lens shift across and up, which `lensShift` gives. */
1079
+ shift = [0, 0];
1077
1080
  /** @internal */
1078
1081
  constructor(scene, handle, name, nearPlane, farPlane) {
1079
1082
  super(scene, handle, name);
@@ -1110,6 +1113,32 @@ export class Camera extends Object3D {
1110
1113
  this.farPlane = far;
1111
1114
  this.scene.lensChanged(this);
1112
1115
  }
1116
+ /**
1117
+ * The lens shift: how far the view sits right of and above the camera's axis, as fractions of the
1118
+ * view's width and height. The array is the camera's own and changes with `setLensShift`, so
1119
+ * copy it to keep a value.
1120
+ */
1121
+ get lensShift() {
1122
+ return this.shift;
1123
+ }
1124
+ /**
1125
+ * Moves the view off the camera's axis, as a shift lens on a real camera does: right by `x`
1126
+ * times the view's width, and up by `y` times its height. The perspective stays as it is, so the
1127
+ * image is a crop of a wider view from the same place. A shift of 0.25 across puts the camera's
1128
+ * axis, and a `target` it looks at, a quarter of the width left of the middle. Culling,
1129
+ * shadows, picking, `screenToRay`, `worldToScreen`, views and labels all follow the shifted
1130
+ * view. The default is no shift. It allocates nothing.
1131
+ */
1132
+ setLensShift(x, y) {
1133
+ if (DEV) {
1134
+ checkLive('setLensShift', this);
1135
+ checkNumber('setLensShift', 'x', x, this);
1136
+ checkNumber('setLensShift', 'y', y, this);
1137
+ }
1138
+ this.shift[0] = x;
1139
+ this.shift[1] = y;
1140
+ this.scene.lensChanged(this);
1141
+ }
1113
1142
  /**
1114
1143
  * Writes the ray from the camera through a point on the canvas into `out`: `x` and `y` are CSS
1115
1144
  * pixels from the canvas's top-left corner, as `input.pointer` gives them. A perspective ray
@@ -1150,6 +1179,15 @@ export class Camera extends Object3D {
1150
1179
  this.writeLensShape(lens);
1151
1180
  lens[LENS_NEAR] = this.nearPlane;
1152
1181
  lens[LENS_FAR] = this.farPlane;
1182
+ lens[LENS_SHIFT_X] = this.shift[0];
1183
+ lens[LENS_SHIFT_Y] = this.shift[1];
1184
+ }
1185
+ /** @internal Gives a copy of this camera the layers and the lens shift that this one has. */
1186
+ copyLensTo(twin) {
1187
+ twin.layers = this.layers;
1188
+ twin.shift[0] = this.shift[0];
1189
+ twin.shift[1] = this.shift[1];
1190
+ twin.updateLens();
1153
1191
  }
1154
1192
  }
1155
1193
  /**
@@ -1209,7 +1247,7 @@ export class PerspectiveCamera extends Camera {
1209
1247
  /** @internal */
1210
1248
  twin(handle) {
1211
1249
  const twin = new PerspectiveCamera(this.scene, handle, this.name, this.verticalFov, this.near, this.far);
1212
- twin.layers = this.layers;
1250
+ this.copyLensTo(twin);
1213
1251
  return twin;
1214
1252
  }
1215
1253
  /** @internal */
@@ -1218,6 +1256,8 @@ export class PerspectiveCamera extends Camera {
1218
1256
  values[0] = this.verticalFov;
1219
1257
  values[1] = this.near;
1220
1258
  values[2] = this.far;
1259
+ values[3] = this.shift[0];
1260
+ values[4] = this.shift[1];
1221
1261
  core.glue.setPerspectiveCamera(this.handle, layers, target);
1222
1262
  }
1223
1263
  }
@@ -1273,7 +1313,7 @@ export class OrthographicCamera extends Camera {
1273
1313
  /** @internal */
1274
1314
  twin(handle) {
1275
1315
  const twin = new OrthographicCamera(this.scene, handle, this.name, { ...this.view }, this.near, this.far);
1276
- twin.layers = this.layers;
1316
+ this.copyLensTo(twin);
1277
1317
  return twin;
1278
1318
  }
1279
1319
  /** @internal */
@@ -1286,6 +1326,8 @@ export class OrthographicCamera extends Camera {
1286
1326
  values[3] = view.centerY;
1287
1327
  values[4] = this.near;
1288
1328
  values[5] = this.far;
1329
+ values[6] = this.shift[0];
1330
+ values[7] = this.shift[1];
1289
1331
  core.glue.setOrthographicCamera(this.handle, layers, target);
1290
1332
  }
1291
1333
  }
@@ -92,8 +92,10 @@ export interface TimeOfDay {
92
92
  intensity: number;
93
93
  };
94
94
  /**
95
- * The fog's linear color, the sky's color along the horizon, and the glow toward the main
96
- * light, for `scene.setFog`.
95
+ * The fog's linear color and the glow toward the main light, for `scene.setFog`. With the
96
+ * analytic model the color is the sky's horizon by day and its average at dusk. With the
97
+ * physical model it is the sky's mean light by day and through dusk, then the moon sky's
98
+ * horizon light at night.
97
99
  */
98
100
  fog: {
99
101
  color: [number, number, number];
@@ -113,9 +115,12 @@ export interface TimeOfDay {
113
115
  /**
114
116
  * Works out the settings of a time of day: an hour from 0 to 24, or a named preset. The sun rises
115
117
  * at 6, stands highest at 12 and sets at 18. After sunset the sky dims to a deep blue, and then to
116
- * a navy night sky lit from the moon's place, and the moon takes over as the main light. Each value
117
- * comes from the model of the sky that the background draws, so the fog fades into the sky's
118
- * horizon. Throws a `RangeError` for an hour that is not a finite number, or an unknown preset.
118
+ * a navy night sky lit from the moon's place, and the moon takes over as the main light.
119
+ *
120
+ * Each value comes from the model of the sky that the background draws, so the fog takes that sky's horizon
121
+ * color by day and its average at dusk. With the physical model it takes the sky's mean light by
122
+ * day and through dusk, then the moon sky's horizon light at night. Throws a `RangeError` for an
123
+ * hour that is not a finite number, or an unknown preset.
119
124
  *
120
125
  * Give it `out`, an object of a previous call, and it writes the new settings into that object: a
121
126
  * day cycle then allocates nothing, so a sketch can move the time in every frame. `bun run
@@ -16,7 +16,7 @@ const PRESET_HOURS = {
16
16
  const DEGREE = Math.PI / 180;
17
17
  /**
18
18
  * How low the sky's own sun sinks after sunset, in degrees. three.js's sky gives no sun light once
19
- * its sun is about 2.3 degrees under the horizon, which leaves only a flat grey that the tone curve
19
+ * its sun is about 2.3 degrees under the horizon, which leaves only a flat gray that the tone curve
20
20
  * maps to black. So after sunset the sky keeps its sun just above that, which keeps the sunset's
21
21
  * glow, and `skyIntensity` sets how bright it shows.
22
22
  */
@@ -81,9 +81,12 @@ const EXPOSURE = [
81
81
  /**
82
82
  * Works out the settings of a time of day: an hour from 0 to 24, or a named preset. The sun rises
83
83
  * at 6, stands highest at 12 and sets at 18. After sunset the sky dims to a deep blue, and then to
84
- * a navy night sky lit from the moon's place, and the moon takes over as the main light. Each value
85
- * comes from the model of the sky that the background draws, so the fog fades into the sky's
86
- * horizon. Throws a `RangeError` for an hour that is not a finite number, or an unknown preset.
84
+ * a navy night sky lit from the moon's place, and the moon takes over as the main light.
85
+ *
86
+ * Each value comes from the model of the sky that the background draws, so the fog takes that sky's horizon
87
+ * color by day and its average at dusk. With the physical model it takes the sky's mean light by
88
+ * day and through dusk, then the moon sky's horizon light at night. Throws a `RangeError` for an
89
+ * hour that is not a finite number, or an unknown preset.
87
90
  *
88
91
  * Give it `out`, an object of a previous call, and it writes the new settings into that object: a
89
92
  * day cycle then allocates nothing, so a sketch can move the time in every frame. `bun run
@@ -474,10 +477,11 @@ function physicalDay(hours, atmosphere, elevation, out) {
474
477
  // the twilight's fill does not fall away between the two.
475
478
  const sunShare = sunLight * (1 - handover);
476
479
  const moonSkyShare = MOON_SKY_LIGHT * handover * moonShare;
477
- // The fog takes the sky's mean light at every hour, not its light along the horizon. A fog of the
478
- // horizon's light carries the brightest band of the sky over the whole scene and washes its shaded
480
+ // The physical model's fog takes the sky's mean light by day and through dusk, then the moon
481
+ // sky's horizon light at night, not the sky's light along the horizon. A fog of the horizon's
482
+ // light carries the brightest band of the sky over the whole scene and washes its shaded
479
483
  // surfaces, while the exposure follows the mean; a low sun makes that band its own glow. The
480
- // analytic model's fog takes the mean too.
484
+ // analytic model's fog takes the horizon color by day and fades to its average at dusk.
481
485
  const fogColor = out.fog.color;
482
486
  scale(fogColor, SET_MEAN, sunShare);
483
487
  add(fogColor, fogColor, scale(MOON_HORIZON, MOON_HORIZON, moonSkyShare));
@@ -1 +1 @@
1
- {"tag":"0.1.0","file":"0.1.0-shaders.tar.br","url":"https://github.com/null3d-engine/null3d/releases/download/0.1.0/0.1.0-shaders.tar.br","sha256":"fceebb2a12304cd05f72299b670a305318af470b187a49724714aed47725b8dd"}
1
+ {"tag":"0.1.1","file":"0.1.1-shaders.tar.br","url":"https://github.com/null3d-engine/null3d/releases/download/0.1.1/0.1.1-shaders.tar.br","sha256":"be65517c3b8351b5756a8d38967fa37d102daab39fa4152db245ad658c6f39de"}
@@ -33,7 +33,8 @@ export declare const LABEL3D_STATE = 12;
33
33
  * The frame's camera, as the page needs it to build the perspective that turns a 3D label's matrix
34
34
  * into a place on the canvas: the inverse of its world matrix's 3 × 3 part, row by row; the camera's
35
35
  * position; half the view's height at one unit in front of a perspective camera, or across an
36
- * orthographic view; 1 for an orthographic lens; and that view's center.
36
+ * orthographic view; 1 for an orthographic lens; that view's center; and the lens shift, as fractions
37
+ * of the view's width and height.
37
38
  */
38
39
  export declare const CAMERA_ROTATION = 0;
39
40
  export declare const CAMERA_POSITION = 9;
@@ -41,7 +42,9 @@ export declare const CAMERA_HALF_HEIGHT = 12;
41
42
  export declare const CAMERA_ORTHO = 13;
42
43
  export declare const CAMERA_CENTER_X = 14;
43
44
  export declare const CAMERA_CENTER_Y = 15;
44
- export declare const CAMERA_FLOATS = 16;
45
+ export declare const CAMERA_SHIFT_X = 16;
46
+ export declare const CAMERA_SHIFT_Y = 17;
47
+ export declare const CAMERA_FLOATS = 18;
45
48
  /** The labels' part of the control buffer. */
46
49
  export interface LabelRegion {
47
50
  /** The header and the tables, as integers. */
@@ -45,7 +45,8 @@ export const LABEL3D_STATE = 12;
45
45
  * The frame's camera, as the page needs it to build the perspective that turns a 3D label's matrix
46
46
  * into a place on the canvas: the inverse of its world matrix's 3 × 3 part, row by row; the camera's
47
47
  * position; half the view's height at one unit in front of a perspective camera, or across an
48
- * orthographic view; 1 for an orthographic lens; and that view's center.
48
+ * orthographic view; 1 for an orthographic lens; that view's center; and the lens shift, as fractions
49
+ * of the view's width and height.
49
50
  */
50
51
  export const CAMERA_ROTATION = 0;
51
52
  export const CAMERA_POSITION = 9;
@@ -53,7 +54,9 @@ export const CAMERA_HALF_HEIGHT = 12;
53
54
  export const CAMERA_ORTHO = 13;
54
55
  export const CAMERA_CENTER_X = 14;
55
56
  export const CAMERA_CENTER_Y = 15;
56
- export const CAMERA_FLOATS = 16;
57
+ export const CAMERA_SHIFT_X = 16;
58
+ export const CAMERA_SHIFT_Y = 17;
59
+ export const CAMERA_FLOATS = 18;
57
60
  /** The header's words, before the tables. */
58
61
  const SEQUENCE = 0;
59
62
  const FRAME = 1;
@@ -0,0 +1,2 @@
1
+ /** The event on the page's global object that carries a word that the page draws with. */
2
+ export declare const PERMUTATION_WORD_EVENT = "null3d:permutation";
@@ -0,0 +1,8 @@
1
+ // The permutation words that a page draws with, on the dev server. In a development build, the
2
+ // thread that draws hands each word to the page once, without the bits that a device fixes, and
3
+ // the engine fires an event with it on the page's global object. The null3D Vite plugin's client
4
+ // module sends the word to the dev server, which compares it with the project's shader list and
5
+ // warns about a word that the list lacks. The file imports nothing, so the plugin's tests read it
6
+ // too.
7
+ /** The event on the page's global object that carries a word that the page draws with. */
8
+ export const PERMUTATION_WORD_EVENT = 'null3d:permutation';