@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,8 +1,7 @@
1
1
  ---
2
2
  id: api/reference/geometry
3
3
  title: "Geometry: API reference"
4
- status: generated
5
- since: "0.1"
4
+ generated: true
6
5
  summary: "Every export of the Geometry API, from the engine's doc comments."
7
6
  ---
8
7
 
@@ -14,7 +13,9 @@ summary: "Every export of the Geometry API, from the engine's doc comments."
14
13
 
15
14
  Class `ArcCurve`, which extends `EllipseCurve`.
16
15
 
17
- A 2D circle or part of one, like three.js's `ArcCurve`: an `EllipseCurve` with one radius.
16
+ Import from `@null3d/geometry`.
17
+
18
+ A 2D circle or part of one: an `EllipseCurve` with one radius.
18
19
 
19
20
  ## `BoxOptions`
20
21
 
@@ -57,9 +58,11 @@ Options for `geometry.capsule`: a cylinder with a half sphere on each end. The c
57
58
 
58
59
  ## `CatmullRomCurve3`
59
60
 
60
- Class `CatmullRomCurve3`, which extends `Curve`.
61
+ Class `CatmullRomCurve3`, which extends `Curve<[number, number, number]>`.
62
+
63
+ Import from `@null3d/geometry`.
61
64
 
62
- A smooth 3D curve through a list of points, like three.js's `CatmullRomCurve3`.
65
+ A smooth 3D curve through a list of points.
63
66
 
64
67
  | Member | Description |
65
68
  | --- | --- |
@@ -75,6 +78,8 @@ A smooth 3D curve through a list of points, like three.js's `CatmullRomCurve3`.
75
78
  type CatmullRomCurveType = 'centripetal' | 'chordal' | 'catmullrom';
76
79
  ```
77
80
 
81
+ Import from `@null3d/geometry`.
82
+
78
83
  How a `CatmullRomCurve3` spaces its spline between points. `'centripetal'` uses the fourth root of the distance, `'chordal'` the square root, and `'catmullrom'` even steps with a tension.
79
84
 
80
85
  ## `CircleOptions`
@@ -108,9 +113,11 @@ Options for `geometry.cone`. The cone stands on the Y axis, centered on its orig
108
113
 
109
114
  ## `CubicBezierCurve`
110
115
 
111
- Class `CubicBezierCurve`, which extends `Curve`.
116
+ Class `CubicBezierCurve`, which extends `Curve<[number, number]>`.
112
117
 
113
- A 2D cubic Bézier curve from `v0` to `v3`, shaped by the control points `v1` and `v2`, like three.js's `CubicBezierCurve`.
118
+ Import from `@null3d/geometry`.
119
+
120
+ A 2D cubic Bézier curve from `v0` to `v3`, shaped by the control points `v1` and `v2`.
114
121
 
115
122
  | Member | Description |
116
123
  | --- | --- |
@@ -122,9 +129,11 @@ A 2D cubic Bézier curve from `v0` to `v3`, shaped by the control points `v1` an
122
129
 
123
130
  ## `CubicBezierCurve3`
124
131
 
125
- Class `CubicBezierCurve3`, which extends `Curve`.
132
+ Class `CubicBezierCurve3`, which extends `Curve<[number, number, number]>`.
133
+
134
+ Import from `@null3d/geometry`.
126
135
 
127
- A 3D cubic Bézier curve from `v0` to `v3`, shaped by the control points `v1` and `v2`, like three.js's `CubicBezierCurve3`.
136
+ A 3D cubic Bézier curve from `v0` to `v3`, shaped by the control points `v1` and `v2`.
128
137
 
129
138
  | Member | Description |
130
139
  | --- | --- |
@@ -138,7 +147,9 @@ A 3D cubic Bézier curve from `v0` to `v3`, shaped by the control points `v1` an
138
147
 
139
148
  Class `Curve`.
140
149
 
141
- The base class of all curves, like three.js's `Curve`. A subclass gives `getPoint`. The class adds sampling by arc length, tangents and, for 3D curves, Frenet frames. `Point` is the type of the curve's points. It is `[number, number]` for a 2D curve and `[number, number, number]` for a 3D curve.
150
+ Import from `@null3d/geometry`.
151
+
152
+ The base class of all curves. A subclass gives `getPoint`. The class adds sampling by arc length, tangents and, for 3D curves, Frenet frames. `Point` is the type of the curve's points. It is `[number, number]` for a 2D curve and `[number, number, number]` for a 3D curve.
142
153
 
143
154
  | Member | Description |
144
155
  | --- | --- |
@@ -155,13 +166,15 @@ The base class of all curves, like three.js's `Curve`. A subclass gives `getPoin
155
166
  | `getUtoTmapping(u: number, distance: number \| null = null): number` | The `t` that lies at the fraction `u` of the curve's length. A truthy `distance` gives the length from the start in place of `u`. |
156
167
  | `getTangent(t: number, out?: Point): Point` | The unit direction of the curve at `t`, from two points a small step apart. Writes into `out` when given. |
157
168
  | `getTangentAt(u: number, out?: Point): Point` | The unit direction at the fraction `u` of the curve's length. Writes into `out` when given. |
158
- | `computeFrenetFrames(segments: number, closed = false): FrenetFrames` | The Frenet frames of a 3D curve at `segments + 1` points spaced along its length, as three.js computes them for tubes and extrusions. A closed curve gets a twist spread over its length, so the last frame matches the first. |
169
+ | `computeFrenetFrames(segments: number, closed = false): FrenetFrames` | The Frenet frames of a 3D curve at `segments + 1` points spaced along its length, which `tube` and `extrude` follow. A closed curve gets a twist spread over its length, so the last frame matches the first. |
159
170
 
160
171
  ## `CurvePath`
161
172
 
162
- Class `CurvePath`, which extends `Curve`.
173
+ Class `CurvePath`, which extends `Curve<Point>`.
163
174
 
164
- A list of curves joined end to end and treated as one curve, like three.js's `CurvePath`. Its `t` runs over the whole path by length.
175
+ Import from `@null3d/geometry`.
176
+
177
+ A list of curves joined end to end and treated as one curve. Its `t` runs over the whole path by length.
165
178
 
166
179
  | Member | Description |
167
180
  | --- | --- |
@@ -170,7 +183,7 @@ A list of curves joined end to end and treated as one curve, like three.js's `Cu
170
183
  | `cacheLengths: number[] \| null` | The lengths that `getCurveLengths` measured last, or null before the first call. |
171
184
  | `add(curve: Curve<Point>): void` | Adds a curve to the end of the path. |
172
185
  | `closePath(): this` | Adds a straight line from the path's end to its start, when they differ. |
173
- | `getPoint(t: number, out?: Point): Point` | The point at `t` over the whole path by length. Writes into `out` when given. Throws a `RangeError` when `t` is above 1 or the path is empty, where three.js returns null. |
186
+ | `getPoint(t: number, out?: Point): Point` | The point at `t` over the whole path by length. Writes into `out` when given. Throws a `RangeError` when `t` is above 1 or the path is empty. |
174
187
  | `getLength(): number` | The path's length: the sum of its curves' lengths. |
175
188
  | `updateArcLengths(): void` | Measures the path again. Call it after a curve's points change. |
176
189
  | `getCurveLengths(): number[]` | The length from the start of the path to the end of each curve. The path keeps the list while the number of curves stays the same. |
@@ -200,13 +213,17 @@ Options for `geometry.cylinder`. The cylinder stands on the Y axis, centered on
200
213
  function dodecahedron(options: PolyhedronShapeOptions = {}): GeneratedArrays
201
214
  ```
202
215
 
203
- The arrays of a dodecahedron, like three.js's `DodecahedronGeometry`. The mesh has no indices.
216
+ Import from `@null3d/geometry`.
217
+
218
+ The arrays of a dodecahedron. The mesh has no indices.
204
219
 
205
220
  ## `EllipseCurve`
206
221
 
207
- Class `EllipseCurve`, which extends `Curve`.
222
+ Class `EllipseCurve`, which extends `Curve<[number, number]>`.
223
+
224
+ Import from `@null3d/geometry`.
208
225
 
209
- A 2D ellipse or part of one, like three.js's `EllipseCurve`. Angles are in radians, measured from the positive x axis.
226
+ A 2D ellipse or part of one. Angles are in radians, measured from the positive x axis.
210
227
 
211
228
  | Member | Description |
212
229
  | --- | --- |
@@ -226,17 +243,23 @@ A 2D ellipse or part of one, like three.js's `EllipseCurve`. Angles are in radia
226
243
  function extrude(options: ExtrudeOptions = {}): GeneratedArrays
227
244
  ```
228
245
 
229
- The arrays of an extruded shape, like three.js's `ExtrudeGeometry`. The mesh has no indices: each three vertices in a row make a triangle. Its normals are flat, one per face. three.js puts the caps in one group and the side walls in another, so each can take its own material. Here they form one mesh, caps first. A material per group needs two meshes.
246
+ Import from `@null3d/geometry`.
247
+
248
+ The arrays of an extruded shape. The mesh has no indices: each three vertices in a row make a triangle. Its normals are flat, one per face.
249
+
250
+ The caps and the side walls form one mesh, caps first. To give each its own material, make two meshes.
230
251
 
231
252
  ## `ExtrudeOptions`
232
253
 
233
254
  Interface `ExtrudeOptions`.
234
255
 
235
- Options for `extrude`, with the names and defaults of three.js's `ExtrudeGeometry`.
256
+ Import from `@null3d/geometry`.
257
+
258
+ Options for `extrude`.
236
259
 
237
260
  | Member | Description |
238
261
  | --- | --- |
239
- | `shapes?: Shape \| readonly Shape[]` | One shape or a list of shapes. The default is three.js's square with corners at x and y of 0.5 and -0.5. |
262
+ | `shapes?: Shape \| readonly Shape[]` | One shape or a list of shapes. The default is a square with corners at x and y of 0.5 and -0.5. |
240
263
  | `curveSegments?: number` | The number of points along each curve of a shape. The default is 12. |
241
264
  | `steps?: number` | The number of steps along the depth or the path. The default is 1. |
242
265
  | `depth?: number` | How far the shape moves along +Z. The default is 1. A path sets the length instead. |
@@ -252,6 +275,8 @@ Options for `extrude`, with the names and defaults of three.js's `ExtrudeGeometr
252
275
 
253
276
  Interface `FrenetFrames`.
254
277
 
278
+ Import from `@null3d/geometry`.
279
+
255
280
  The frames along a 3D curve that `computeFrenetFrames` returns: one tangent, normal and binormal per sample, each a unit vector.
256
281
 
257
282
  | Member | Description |
@@ -264,20 +289,22 @@ The frames along a 3D curve that `computeFrenetFrames` returns: one tangent, nor
264
289
 
265
290
  Interface `GeneratedArrays`.
266
291
 
267
- The arrays that a generator returns, ready for `geometry.fromArrays`. Each array holds the values of vertex 0, then vertex 1, and so on, as three.js's `BufferGeometry` keeps its attributes.
292
+ Import from `@null3d/geometry`.
293
+
294
+ The arrays that a generator returns, ready for `geometry.fromArrays`. Each array holds the values of vertex 0, then vertex 1, and so on.
268
295
 
269
296
  | Member | Description |
270
297
  | --- | --- |
271
- | `positions: Float32Array` | Three numbers per vertex: x, y and z. Like three.js's `position` attribute. |
272
- | `normals: Float32Array` | Three numbers per vertex: the unit normal. Like three.js's `normal` attribute. |
273
- | `uvs: Float32Array` | Two numbers per vertex: u and v. Like three.js's `uv` attribute. |
274
- | `indices?: Uint16Array \| Uint32Array` | Three vertex indices per triangle. The array holds 32-bit indices when an index reaches 65535, as three.js's `setIndex` chooses, and 16-bit indices otherwise. Absent when each three vertices in a row make a triangle. |
298
+ | `positions: Float32Array` | Three numbers per vertex: x, y and z. |
299
+ | `normals: Float32Array` | Three numbers per vertex: the unit normal. |
300
+ | `uvs: Float32Array` | Two numbers per vertex: u and v. |
301
+ | `indices?: Uint16Array \| Uint32Array` | Three vertex indices per triangle. The array holds 32-bit indices when an index reaches 65535, and 16-bit indices otherwise. Absent when each three vertices in a row make a triangle. |
275
302
 
276
303
  ## `Geometry`
277
304
 
278
305
  Class `Geometry`.
279
306
 
280
- Mesh generators with the parameters and defaults of three.js's geometry classes, and meshes from arrays.
307
+ Mesh generators for common shapes, and meshes from arrays.
281
308
 
282
309
  | Member | Description |
283
310
  | --- | --- |
@@ -285,16 +312,16 @@ Mesh generators with the parameters and defaults of three.js's geometry classes,
285
312
  | `readonly automaticLevelTriangles: number` | The triangles from which a mesh made in code plans its levels of detail, the first time the scene draws it, unless its options say `levels: false`. A smaller mesh drawn a few times costs little at any distance, and each level adds draw work to every pipeline that draws it. |
286
313
  | `readonly automaticDrawnTriangles: number` | The triangles of the copies that the scene draws, together, from which a smaller mesh of at least `automaticCopyTriangles` triangles plans its levels too, as a batch of pebbles does. |
287
314
  | `readonly automaticCopyTriangles: number` | The fewest triangles of a mesh that plans its levels because of its copies. |
288
- | `box(options: BoxOptions = {}): MeshGeometry` | A box, like three.js's `BoxGeometry`. |
289
- | `sphere(options: SphereOptions = {}): MeshGeometry` | A sphere, like three.js's `SphereGeometry`. |
290
- | `plane(options: PlaneOptions = {}): MeshGeometry` | A flat rectangle, like three.js's `PlaneGeometry`. |
291
- | `cylinder(options: CylinderOptions = {}): MeshGeometry` | A cylinder, like three.js's `CylinderGeometry`. |
292
- | `cone(options: ConeOptions = {}): MeshGeometry` | A cone, like three.js's `ConeGeometry`: a cylinder whose top is a point. |
293
- | `torus(options: TorusOptions = {}): MeshGeometry` | A torus, like three.js's `TorusGeometry`. |
294
- | `capsule(options: CapsuleOptions = {}): MeshGeometry` | A capsule, like three.js's `CapsuleGeometry`. |
295
- | `circle(options: CircleOptions = {}): MeshGeometry` | A flat circle, like three.js's `CircleGeometry`. |
296
- | `ring(options: RingOptions = {}): MeshGeometry` | A flat ring, like three.js's `RingGeometry`. |
297
- | `fromArrays(arrays: MeshArrays): MeshGeometry` | A mesh from arrays of vertex attributes and triangle indices, like three.js's `BufferGeometry` with `setAttribute` and `setIndex`. The mesh keeps the attributes it gets, each in the type of number it came in, and meshes whose attributes have the same types share GPU buffers. A mesh can have any number of vertices. Throws E1206 when an array's length does not fit the vertex count, when its attribute does not take its type of number, when an index names no vertex, for a value that is not a finite number, and for morph targets whose arrays do not fit the vertices or whose lists hold different numbers of targets. |
315
+ | `box(options: BoxOptions = {}): MeshGeometry` | A box, centered on its origin. |
316
+ | `sphere(options: SphereOptions = {}): MeshGeometry` | A sphere with its poles on the Y axis, or a part of one. |
317
+ | `plane(options: PlaneOptions = {}): MeshGeometry` | A flat rectangle in the XY plane that faces +Z. |
318
+ | `cylinder(options: CylinderOptions = {}): MeshGeometry` | A cylinder on the Y axis, closed at each end unless `openEnded` is true. |
319
+ | `cone(options: ConeOptions = {}): MeshGeometry` | A cone on the Y axis: a cylinder whose top is a point. |
320
+ | `torus(options: TorusOptions = {}): MeshGeometry` | A torus: a tube bent into a ring around the Z axis. |
321
+ | `capsule(options: CapsuleOptions = {}): MeshGeometry` | A capsule: a cylinder on the Y axis with a half sphere on each end. |
322
+ | `circle(options: CircleOptions = {}): MeshGeometry` | A flat circle in the XY plane that faces +Z, or a slice of one. |
323
+ | `ring(options: RingOptions = {}): MeshGeometry` | A flat ring: a disc with a hole, in the XY plane, that faces +Z. |
324
+ | `fromArrays(arrays: MeshArrays): MeshGeometry` | A mesh from arrays of vertex attributes and triangle indices. The mesh keeps the attributes it gets, each in the type of number it came in, and meshes whose attributes have the same types share GPU buffers. A mesh can have any number of vertices. Throws E1206 when an array's length does not fit the vertex count, when its attribute does not take its type of number, when an index names no vertex, for a value that is not a finite number, and for morph targets whose arrays do not fit the vertices or whose lists hold different numbers of targets. |
298
325
 
299
326
  ## `icosahedron`
300
327
 
@@ -302,7 +329,9 @@ Mesh generators with the parameters and defaults of three.js's geometry classes,
302
329
  function icosahedron(options: PolyhedronShapeOptions = {}): GeneratedArrays
303
330
  ```
304
331
 
305
- The arrays of an icosahedron, like three.js's `IcosahedronGeometry`. The mesh has no indices.
332
+ Import from `@null3d/geometry`.
333
+
334
+ The arrays of an icosahedron. The mesh has no indices.
306
335
 
307
336
  ## `IntegerArray`
308
337
 
@@ -318,34 +347,149 @@ The integer typed arrays that vertex attributes take: 8-bit and 16-bit, signed a
318
347
  function lathe(options: LatheOptions = {}): GeneratedArrays
319
348
  ```
320
349
 
321
- The arrays of a lathe, like three.js's `LatheGeometry`. The mesh has indices.
350
+ Import from `@null3d/geometry`.
351
+
352
+ The arrays of a lathe: a profile of points turned around the Y axis. The mesh has indices.
322
353
 
323
354
  ## `LatheOptions`
324
355
 
325
356
  Interface `LatheOptions`.
326
357
 
327
- Options for `lathe`, with the names and defaults of three.js's `LatheGeometry`.
358
+ Import from `@null3d/geometry`.
359
+
360
+ Options for `lathe`.
328
361
 
329
362
  | Member | Description |
330
363
  | --- | --- |
331
- | `points?: readonly Vec2Like[]` | The profile: points (x, y), where x is the distance from the Y axis and must be 0 or more. The default is three.js's diamond: (0, -0.5), (0.5, 0) and (0, 0.5). |
364
+ | `points?: readonly Vec2Like[]` | The profile: points (x, y), where x is the distance from the Y axis and must be 0 or more. The default is a diamond: (0, -0.5), (0.5, 0) and (0, 0.5). |
332
365
  | `segments?: number` | The number of segments around the axis, rounded down. The default is 12. |
333
366
  | `phiStart?: number` | The start angle in radians. The default is 0. |
334
367
  | `phiLength?: number` | The angle the lathe turns through, in radians, clamped to 0 to 2π. The default is 2π. |
335
368
 
369
+ ## `LEAST_LEVEL_DISTANCE`
370
+
371
+ ```ts
372
+ const LEAST_LEVEL_DISTANCE: 0.001
373
+ ```
374
+
375
+ The smallest distance that the rule measures, in meters: a camera inside the bounds reads it.
376
+
377
+ ## `levelAt`
378
+
379
+ ```ts
380
+ function levelAt(view: LevelView, levels: readonly LevelSwitch[], scale: number, radius: number, distance: number | LevelDistances): number
381
+ ```
382
+
383
+ The level of detail that a source draws: 0 for the base mesh, 1 for the first lower level, and so on, as `setLevels` takes them. The level is the last one whose switch distance lies under the distance, which is how the core's culling picks every source. This gives the level alone, not whether the source draws at all: a bound that covers fewer pixels than the threshold is hidden, and a draw range hides a source outside it.
384
+
385
+ | Parameter | Description |
386
+ | --- | --- |
387
+ | `view` | The view that measures the levels. |
388
+ | `levels` | The lower levels, from the finest to the coarsest. |
389
+ | `scale` | The largest axis scale of the source's world matrix. |
390
+ | `radius` | The radius of the source's world bounds, in meters, which a coverage reads. |
391
+ | `distance` | A distance, which both measures read as a camera does, or the two distances that `levelDistances` gives. |
392
+
393
+ Returns: The level's index among the base mesh and `levels`.
394
+
395
+ ## `LevelBounds`
396
+
397
+ Interface `LevelBounds`.
398
+
399
+ A source's world bounds about the camera: the center of its bounding sphere relative to the camera, and the sphere's radius.
400
+
401
+ | Member | Description |
402
+ | --- | --- |
403
+ | `readonly centre: readonly [number, number, number]` | The bounding sphere's center, relative to the camera. |
404
+ | `readonly radius: number` | The bounding sphere's radius, in meters. |
405
+
406
+ ## `levelDistances`
407
+
408
+ ```ts
409
+ function levelDistances(view: LevelView, bounds: LevelBounds): LevelDistances
410
+ ```
411
+
412
+ Both distances that a view's rule compares for a source's bounds. An error measures to a point halfway into the sphere, capped at twice the distance to its nearest point, so a camera beside a large mesh measures the surface below it. A distance or a coverage, and a distance band, measure to the nearest point. Both are at least `LEAST_LEVEL_DISTANCE`. An orthographic view compares an error at a distance of 1, since its pixels do not shrink with distance, and keeps the nearest point for the other measures.
413
+
414
+ | Parameter | Description |
415
+ | --- | --- |
416
+ | `view` | The view that measures the source. |
417
+ | `bounds` | The source's bounds, with the center relative to the camera. |
418
+
419
+ Returns: The two distances, in meters.
420
+
421
+ ## `LevelDistances`
422
+
423
+ Interface `LevelDistances`.
424
+
425
+ The two distances that the rule compares for a source's bounds. A level given by its error reads `error`, and a level given by a distance or by a coverage, a draw range and the rule that hides a small bound read `camera`.
426
+
427
+ | Member | Description |
428
+ | --- | --- |
429
+ | `readonly camera: number` | The distance to the nearest point of the bounds, which a distance or a coverage compares. |
430
+ | `readonly error: number` | The distance at which an error is compared, which a level given by its error compares. |
431
+
336
432
  ## `LevelsOption`
337
433
 
338
434
  ```ts
339
435
  type LevelsOption = boolean | BuildLevelsOptions | 'pieces';
340
436
  ```
341
437
 
342
- The levels of detail that a mesh made in code plans on its own. By default it plans them the first time the scene draws it, when it holds `geometry.automaticLevelTriangles` triangles or more, or when it holds at least `geometry.automaticCopyTriangles` triangles and its copies hold `geometry.automaticDrawnTriangles` together; `false` plans none, and `true` or options plan them when the mesh is made, at any size. `'pieces'` plans no lower levels, and sorts a mesh of 32,768 triangles or more into pieces by space at its first draw, as a merged far cell or a large ground whose levels come from elsewhere gains from.
438
+ The levels of detail that a mesh made in code plans on its own. By default it plans them the first time the scene draws it, when it holds `geometry.automaticLevelTriangles` triangles or more, or when it holds at least `geometry.automaticCopyTriangles` triangles and its copies hold `geometry.automaticDrawnTriangles` together; `false` plans none, and `true` or options plan them when the mesh is made, at any size.
439
+
440
+ `'pieces'` plans no lower levels, and sorts a mesh of 32,768 triangles or more into pieces by space at its first draw, as a merged far cell or a large ground whose levels come from elsewhere gains from.
441
+
442
+ ## `LevelSwitch`
443
+
444
+ ```ts
445
+ type LevelSwitch =
446
+ | { readonly error: number; }
447
+ | { readonly distance: number; }
448
+ | { readonly coverage: number; };
449
+ ```
450
+
451
+ One of a mesh's lower levels and the measure that sets its switch: give exactly one. The fields have the meanings that `MeshLevel` gives them.
452
+
453
+ ## `levelSwitchDistance`
454
+
455
+ ```ts
456
+ function levelSwitchDistance(view: LevelView, level: LevelSwitch, scale: number, radius = 0): number
457
+ ```
458
+
459
+ The distance at which one of a part's levels switches in.
460
+
461
+ An error switches where it covers the view's threshold in pixels; a distance at its own figure, scaled by the source; and a coverage where the bounds' radius covers that share of the render height. A bias above 1 divides every result, so the level switches nearer.
462
+
463
+ | Parameter | Description |
464
+ | --- | --- |
465
+ | `view` | The view that measures the level. |
466
+ | `level` | The level's switch measure. |
467
+ | `scale` | The largest axis scale of the source's world matrix. |
468
+ | `radius` | The radius of the source's world bounds, in meters, which a coverage reads. |
469
+
470
+ Returns: The distance in meters at which the level draws, or `Infinity` for a coverage that is not above 0.
471
+
472
+ ## `LevelView`
473
+
474
+ Interface `LevelView`.
475
+
476
+ A view that measures levels of detail: the height it renders, its vertical field of view, and the threshold under which a coarser level draws.
477
+
478
+ | Member | Description |
479
+ | --- | --- |
480
+ | `readonly height: number` | The render height in pixels. |
481
+ | `readonly fov: number` | The vertical field of view in degrees, between 0 and 180. |
482
+ | `readonly threshold?: number` | The largest change, in pixels, that a coarser level may make to the picture. The default is 1, the setting of the presets that High and above draw. A larger threshold draws coarser levels from nearer. |
483
+ | `readonly orthographic?: boolean` | True for an orthographic camera, whose pixels do not shrink with distance. The default is false. An orthographic view compares a level's error at a distance of 1, so the source's scale alone picks the level. |
484
+ | `readonly bias?: number` | The source's threshold bias, as the inverse of Godot's `lod_bias`: a Godot bias of 2 is about a null3D bias of 0.5. Above 1 switches every level nearer, so coarser levels draw, and below 1 keeps its detail. The default is 1. |
343
485
 
344
486
  ## `LineCurve`
345
487
 
346
- Class `LineCurve`, which extends `Curve`.
488
+ Class `LineCurve`, which extends `Curve<[number, number]>`.
489
+
490
+ Import from `@null3d/geometry`.
347
491
 
348
- A straight 2D line from `v1` to `v2`, like three.js's `LineCurve`.
492
+ A straight 2D line from `v1` to `v2`.
349
493
 
350
494
  | Member | Description |
351
495
  | --- | --- |
@@ -358,9 +502,11 @@ A straight 2D line from `v1` to `v2`, like three.js's `LineCurve`.
358
502
 
359
503
  ## `LineCurve3`
360
504
 
361
- Class `LineCurve3`, which extends `Curve`.
505
+ Class `LineCurve3`, which extends `Curve<[number, number, number]>`.
362
506
 
363
- A straight 3D line from `v1` to `v2`, like three.js's `LineCurve3`.
507
+ Import from `@null3d/geometry`.
508
+
509
+ A straight 3D line from `v1` to `v2`.
364
510
 
365
511
  | Member | Description |
366
512
  | --- | --- |
@@ -375,22 +521,24 @@ A straight 3D line from `v1` to `v2`, like three.js's `LineCurve3`.
375
521
 
376
522
  Interface `MeshArrays`.
377
523
 
378
- The arrays of a mesh for `geometry.fromArrays`. Each array holds its values for vertex 0, then vertex 1, and so on, as three.js's `BufferGeometry` keeps its attributes. The engine copies them. An attribute can come as 32-bit floats, or as the 8-bit and 16-bit integers that glTF's `KHR_mesh_quantization` allows for it. The mesh keeps that type on the GPU. Smaller types take less memory and upload faster. Integer positions keep their own scale, so give the object the scale that turns them into meters, as a glTF node does. Meshes share GPU buffers with the meshes whose attributes have the same types.
524
+ The arrays of a mesh for `geometry.fromArrays`. Each array holds its values for vertex 0, then vertex 1, and so on. The engine copies them.
525
+
526
+ An attribute can come as 32-bit floats, or as the 8-bit and 16-bit integers that glTF's `KHR_mesh_quantization` allows for it. The mesh keeps that type on the GPU. Smaller types take less memory and upload faster. Integer positions keep their own scale, so give the object the scale that turns them into meters, as a glTF node does. Meshes share GPU buffers with the meshes whose attributes have the same types.
379
527
 
380
528
  | Member | Description |
381
529
  | --- | --- |
382
- | `positions: VertexValues` | Three numbers per vertex: x, y and z. Like three.js's `position` attribute. Takes floats, or 8-bit or 16-bit integers, normalized or plain. |
383
- | `normals?: VertexValues` | Three numbers per vertex: a direction of length 1 away from the surface. Like three.js's `normal` attribute. Pass normals, or set `computeNormals` instead. Takes floats, or an `Int8Array` or `Int16Array`, whose integers read as fractions from -1 to 1. |
384
- | `uvs?: VertexValues` | Texture coordinates: two numbers per vertex, u and v. Like three.js's `uv` attribute. Takes floats, or 8-bit or 16-bit integers, normalized or plain. |
385
- | `uvs1?: VertexValues` | A second set of texture coordinates, two numbers per vertex, such as those of a light map. Like three.js's `uv1` attribute. Takes the same types as `uvs`. |
386
- | `colors?: VertexValues` | Linear colors, three numbers per vertex from 0 to 1, or four with alpha. Like three.js's `color` attribute. Takes floats, or a `Uint8Array` or `Uint16Array`, whose integers read as fractions from 0 to 1. |
387
- | `tangents?: VertexValues` | Four numbers per vertex: the direction in which u grows along the surface, then 1 or -1 for the direction in which v grows. Like three.js's `tangent` attribute. Takes the same types as `normals`. |
388
- | `joints?: VertexValues` | The joints that move each vertex of a skinned mesh: four joint indices per vertex, in a `Uint8Array`, a `Uint16Array` or a plain array. Like three.js's `skinIndex` attribute. Give `weights` with them. |
389
- | `weights?: VertexValues` | How much each of a vertex's four joints moves it: four numbers per vertex, which add up to 1. Like three.js's `skinWeight` attribute. Takes floats, or a `Uint8Array` or `Uint16Array`, whose integers read as fractions from 0 to 1. |
530
+ | `positions: VertexValues` | Three numbers per vertex: x, y and z. Takes floats, or 8-bit or 16-bit integers, normalized or plain. |
531
+ | `normals?: VertexValues` | Three numbers per vertex: a direction of length 1 away from the surface. Pass normals, or set `computeNormals` instead. Takes floats, or an `Int8Array` or `Int16Array`, whose integers read as fractions from -1 to 1. |
532
+ | `uvs?: VertexValues` | Texture coordinates: two numbers per vertex, u and v. Takes floats, or 8-bit or 16-bit integers, normalized or plain. |
533
+ | `uvs1?: VertexValues` | A second set of texture coordinates, two numbers per vertex, such as those of a light map. Takes the same types as `uvs`. |
534
+ | `colors?: VertexValues` | Linear colors, three numbers per vertex from 0 to 1, or four with alpha. Takes floats, or a `Uint8Array` or `Uint16Array`, whose integers read as fractions from 0 to 1. |
535
+ | `tangents?: VertexValues` | Four numbers per vertex: the direction in which u grows along the surface, then 1 or -1 for the direction in which v grows. Takes the same types as `normals`. |
536
+ | `joints?: VertexValues` | The joints that move each vertex of a skinned mesh: four joint indices per vertex, in a `Uint8Array`, a `Uint16Array` or a plain array. Give `weights` with them. |
537
+ | `weights?: VertexValues` | How much each of a vertex's four joints moves it: four numbers per vertex, which add up to 1. Takes floats, or a `Uint8Array` or `Uint16Array`, whose integers read as fractions from 0 to 1. |
390
538
  | `targets?: VertexValues` | Four numbers per vertex for a shape that a custom material moves between levels of detail: the position that the vertex takes at the next coarser level, and that level's error in meters. The material's `vertexOffset` reads them as `input.vertexRecord`. Takes floats. The vertex record also holds a morphed mesh's morph data, so a mesh takes `targets` or `morphTargets`, never both. |
391
- | `indices?: Uint16Array \| Uint32Array \| readonly number[]` | Three vertex indices per triangle, counter-clockwise when you look at its front. 16-bit and 32-bit indices both work. Without indices, each three vertices in a row make a triangle. Like three.js's `setIndex`. |
392
- | `computeNormals?: boolean` | Computes the normals from the triangles, as three.js's `computeVertexNormals` does: each vertex gets the average of its triangles' normals, weighted by their areas. |
393
- | `computeTangents?: boolean` | Computes the tangents from the positions, the normals and `uvs`, as three.js's `computeTangents` does, on the job workers. |
539
+ | `indices?: Uint16Array \| Uint32Array \| readonly number[]` | Three vertex indices per triangle, counter-clockwise when you look at its front. 16-bit and 32-bit indices both work. Without indices, each three vertices in a row make a triangle. |
540
+ | `computeNormals?: boolean` | Computes the normals from the triangles: each vertex gets the average of its triangles' normals, weighted by their areas. |
541
+ | `computeTangents?: boolean` | Computes the tangents on the job workers, from the positions, the normals and `uvs`, with Eric Lengyel's method. |
394
542
  | `morphTargets?: MorphTargets` | The mesh's morph targets: shapes that each object of the mesh blends in by its own weights. The engine keeps, for each vertex, only the targets that move it. |
395
543
  | `levels?: LevelsOption` | The levels of detail that the mesh plans on its own, on the job workers, as `mesh.buildLevels` plans them. By default it plans them the first time the scene draws it, when it holds `geometry.automaticLevelTriangles` triangles or more, or when it holds at least `geometry.automaticCopyTriangles` triangles and its copies hold `geometry.automaticDrawnTriangles` together. A mesh with joints, morph targets or `targets` plans none, and neither does one that lies flat or that a material with moving vertices draws. `false` plans none: give it to a mesh whose shape a shader moves, or whose levels you set by hand. `true` plans them when the mesh is made, at any size, and options such as `{ cards: true }` plan them with those options. `'pieces'` plans no levels, and sorts a mesh of 32,768 triangles or more into pieces by space at its first draw. |
396
544
 
@@ -404,19 +552,21 @@ A mesh the engine can draw: its id in the engine core, its bounding radius, and
404
552
  | --- | --- |
405
553
  | `readonly radius: number` | The distance from the mesh's bounding center (`center`) to its farthest vertex, at rest. |
406
554
  | `readonly morphTargets: number` | How many morph targets the mesh has. 0 for a mesh without any. |
407
- | `readonly morphTargetNames: readonly string[]` | The morph targets' names, by target, or none when the mesh's arrays named none. Like three.js's `morphTargetDictionary`, turned around. `mesh.setMorphWeight` takes a name too. |
555
+ | `readonly morphTargetNames: readonly string[]` | The morph targets' names, in target order, or none when the mesh's arrays named none. `mesh.setMorphWeight` takes a name too. |
408
556
  | `readonly center: readonly [number, number, number]` | The center of the box around the mesh's vertices at rest, in the mesh's own space. The mesh's bounding sphere lies around it with `radius`, and culling tests that sphere. A mesh whose positions start at a corner, as quantized glTF files store them, has its center away from the origin. |
409
- | `destroy(): void` | Destroys the mesh, like three.js's `geometry.dispose()`. The engine frees its GPU memory and its other data at once, and later meshes take its room. Destroy the objects and instance batches that use it first, in the same frame or before. Its lower levels go with it, since a level draws its base's vertices. Throws E1111 while one still uses it, and E1101 for a mesh that is destroyed already. Later calls that pass the mesh throw E1101. |
410
- | `updateVertices(name: UpdatableAttribute, values: Float32Array \| IntegerArray \| readonly number[], start = 0, count?: number): void` | Writes new values into one attribute of the mesh's vertices, like setting three.js's `attribute.needsUpdate` after a change. `values` holds the attribute's values of every vertex, in the array type the mesh was made with, as `geometry.fromArrays` takes them. Only vertices `start` to `start + count - 1` change, which the next frame uploads. The defaults update every vertex. Colors take three or four values per vertex: three keep each vertex's alpha. The mesh keeps the bounding sphere it was made with, so give objects that draw vertices outside it bounds with `setBounds`. The four-number vertex record takes updates as `targets`. Joints, weights, and a mesh with joints or morph targets take no updates. A level that draws its base mesh's vertices writes them, so the base and every level of it draw the new values. The levels that `buildLevels` or the automatic default planned measured the old shape, so the first update takes them away, and the mesh plans no automatic levels again; `buildLevels` plans them for the new shape. Throws E1206 for values that do not fit the mesh, and E1101 for a destroyed mesh. Allocates nothing, so a call in every frame makes no garbage. |
557
+ | `destroy(): void` | Destroys the mesh. The engine frees its GPU memory and its other data at once, and later meshes take its room. Destroy the objects and instance batches that use it first, in the same frame or before. Its lower levels go with it, since a level draws its base's vertices. Throws E1111 while one still uses it, and E1101 for a mesh that is destroyed already. Later calls that pass the mesh throw E1101. |
558
+ | `updateVertices(name: UpdatableAttribute, values: Float32Array \| IntegerArray \| readonly number[], start = 0, count?: number): void` | Writes new values into one attribute of the mesh's vertices. `values` holds the attribute's values of every vertex, in the array type the mesh was made with, as `geometry.fromArrays` takes them. Only vertices `start` to `start + count - 1` change, which the next frame uploads. The defaults update every vertex. Colors take three or four values per vertex: three keep each vertex's alpha. The mesh keeps the bounding sphere it was made with, so give objects that draw vertices outside it bounds with `setBounds`. The four-number vertex record takes updates as `targets`. Joints, weights, and a mesh with joints or morph targets take no updates. A level that draws its base mesh's vertices writes them, so the base and every level of it draw the new values. The levels that `buildLevels` or the automatic default planned measured the old shape, so the first update takes them away, and the mesh plans no automatic levels again; `buildLevels` plans them for the new shape. Throws E1206 for values that do not fit the mesh, and E1101 for a destroyed mesh. Allocates nothing, so a call in every frame makes no garbage. |
411
559
  | `readonly levels: readonly MeshLevel[]` | The mesh's lower levels of detail, from the most detailed down, as `setLevels` gave them. A destroyed level takes every level away, as the engine does. |
412
- | `setLevels(levels: readonly MeshLevel[], options: MeshLevelOptions = {}): void` | Gives the mesh lower levels of detail, from the most detailed down, like three.js's `LOD.addLevel`. A mesh takes at most 15 lower levels. Every object and instance batch that draws the mesh then picks one level per frame. It draws the coarsest level whose error covers fewer pixels on the screen than the `lodThreshold` quality setting. A level may name a material of its own, so a far level shades more cheaply; a level without one draws with the level before's material. A bound that covers fewer pixels than the threshold draws nothing, so the mesh's last level holds no geometry. The shadow maps pick their own levels, by each map's texel size, so a caster's shadow shows the detail that the map can hold. An empty list takes the levels away. Morphed objects, and materials that blend or let light through, draw the base mesh. A skinned object draws a level while the level names the base mesh's own vertices. Destroying a level's mesh takes every level away. Levels set here win over the ones that `buildLevels` or the automatic default plans: a plan that runs ends, and the planned levels go. Throws E1221 for levels the mesh cannot take, and E1101 for a destroyed mesh. |
560
+ | `setLevels(levels: readonly MeshLevel[], options: MeshLevelOptions = {}): void` | Gives the mesh lower levels of detail, from the most detailed down. A mesh takes at most 15 lower levels. Every object and instance batch that draws the mesh then picks one level per frame. It draws the coarsest level whose error covers fewer pixels on the screen than the `lodThreshold` quality setting. A level may name a material of its own, so a far level shades more cheaply; a level without one draws with the level before's material. A bound that covers fewer pixels than the threshold draws nothing, so the mesh's last level holds no geometry. The shadow maps pick their own levels, by each map's texel size, so a caster's shadow shows the detail that the map can hold. An empty list takes the levels away. Morphed objects, and materials that blend or let light through, draw the base mesh. A skinned object draws a level while the level names the base mesh's own vertices. Destroying a level's mesh takes every level away. Levels set here win over the ones that `buildLevels` or the automatic default plans: a plan that runs ends, and the planned levels go. Throws E1221 for levels the mesh cannot take, and E1101 for a destroyed mesh. |
413
561
  | `buildLevels(options: BuildLevelsOptions = {}): Promise<readonly MeshLevel[]>` | Plans the mesh's levels of detail on the job workers, as the asset tool's `--lod` plans a file's, and gives them to the mesh when they arrive, between two frames. Each level about halves the triangles of the level above, down to a few dozen, and stores the largest distance between its surface and the mesh's as its error, so it switches in at once where that distance covers less than the `lodThreshold` setting's pixels. The levels name the mesh's own vertices, in their own order, so they cost indices alone: the mesh keeps its vertices and triangles as they are. A mesh that the engine split into parts, past 65,535 vertices, shares them part by part, and copies only the vertices of the triangles that cross from one part to another. A large mesh spreads the work over frames. The engine reads one part of it in each frame for the plan. It makes one level in each frame when the plan is done, and gives the scene the whole set once, so the scene's draw tables rebuild once. The mesh draws its full shape until the levels arrive, and every object and instance batch that draws it then picks its level. The mesh and each level of 32,768 triangles or more also get 8 to 16 pieces, which each copy skips where they lie outside the view or face away. A smaller list that many copies draw gets a piece for each way it faces where its triangles face a few ways, as a building's walls do. A mesh that one object draws, or a smaller mesh, gets its own pieces over a sorted copy of its indices, in the frame after the last level; copies of a large mesh keep their levels' pieces alone. A mesh made in code plans its levels on its own the first time the scene draws it, when it holds `geometry.automaticLevelTriangles` triangles or more, or when it holds at least `geometry.automaticCopyTriangles` triangles and its copies hold `geometry.automaticDrawnTriangles` together. Call this to plan another mesh's, to plan again after `updateVertices`, or to await the levels of a plan that runs: a call while a plan with the same options runs returns that plan's promise. `setLevels` wins over a plan, and `updateVertices` takes the planned levels away. The promise resolves with the mesh's levels, which stay as they were when the planner finds no level worth making, and when `setLevels`, `updateVertices` or `destroy` ends the plan first. It rejects with E1221 for a mesh with joints, morph targets or a vertex record, whose shape poses or moves, and with E1406 when the planner does not download. The planner downloads with the first mesh that plans: meshoptimizer's simplifier, about 23 KB. Throws E1101 for a destroyed mesh. |
414
562
 
415
563
  ## `MeshLevel`
416
564
 
417
565
  Interface `MeshLevel`.
418
566
 
419
- A lower level of detail of a mesh: a simpler mesh that draws in the base mesh's place. Give its `error`, the `distance` at which it switches in, or the screen `coverage` under which it draws. A level with a measured error, which the asset tool writes, changes the picture by under a pixel at a small threshold and switches at once. When the governor raises the threshold above about one and a half pixels, that switch shows, and such a level then fades too. A level given by a distance, by a coverage or by a hand-set error fades over a short band, so its switch does not pop.
567
+ A lower level of detail of a mesh: a simpler mesh that draws in the base mesh's place. Give its `error`, the `distance` at which it switches in, or the screen `coverage` under which it draws. A level with a measured error, which the asset tool writes, changes the picture by under a pixel at a small threshold and switches at once.
568
+
569
+ When the governor raises the threshold above about one and a half pixels, that switch shows, and such a level then fades too. A level given by a distance, by a coverage or by a hand-set error fades over a short band, so its switch does not pop.
420
570
 
421
571
  | Member | Description |
422
572
  | --- | --- |
@@ -436,20 +586,20 @@ Options for `mesh.setLevels`.
436
586
  | Member | Description |
437
587
  | --- | --- |
438
588
  | `fade?: boolean` | True to hand over between two levels in a short band past each switch distance, where a dither pattern shares the pixels between them, so a switch does not pop. False to switch at once. The default is true. A level's own `fade` overrides it. A level with a measured error fades too once the governor raises the threshold above about one and a half pixels, where its switch shows. |
439
- | `fov?: number` | The vertical field of view, in degrees, that checks the order of the levels when the mesh takes them. Each frame compares a level's error or coverage with the field of view of the view that draws it, so this option moves no switch. The default is 50, three.js's default for a perspective camera. |
589
+ | `fov?: number` | The vertical field of view, in degrees, that checks the order of the levels when the mesh takes them. Each frame compares a level's error or coverage with the field of view of the view that draws it, so this option moves no switch. The default is 50, a perspective camera's default. |
440
590
 
441
591
  ## `MorphTargets`
442
592
 
443
593
  Interface `MorphTargets`.
444
594
 
445
- A mesh's morph targets, like three.js's `morphAttributes` with `morphTargetsRelative` set, as glTF stores them. Each list holds one array per target, of three numbers per vertex, or for colors as many as the mesh's `colors` hold. They say how far the target moves the vertex's position, normal, tangent or color at weight 1. Every list has the same number of targets, from 1 to 256. A mesh's targets move its vertices by their weights, which each object sets with `setMorphWeight`, and clips animate.
595
+ A mesh's morph targets, as glTF stores them. Each list holds one array per target, of three numbers per vertex, or for colors as many as the mesh's `colors` hold. They say how far the target moves the vertex's position, normal, tangent or color at weight 1. Every list has the same number of targets, from 1 to 256. A mesh's targets move its vertices by their weights, which each object sets with `setMorphWeight`, and clips animate.
446
596
 
447
597
  | Member | Description |
448
598
  | --- | --- |
449
- | `positions?: readonly (Float32Array \| readonly number[])[]` | For each target, how far it moves each position. Like `morphAttributes.position`. |
450
- | `normals?: readonly (Float32Array \| readonly number[])[]` | For each target, how far it turns each normal. Like `morphAttributes.normal`. |
451
- | `tangents?: readonly (Float32Array \| readonly number[])[]` | For each target, how far it turns each tangent's direction: three numbers per vertex, as glTF gives them. three.js does not morph tangents. |
452
- | `colors?: readonly (Float32Array \| readonly number[])[]` | For each target, how far it changes each vertex color: three or four numbers per vertex, as many as the mesh's `colors` hold, in linear color. Like `morphAttributes.color`. A morphed color is clamped to the range 0 to 1, as the glTF specification asks. Needs `colors`. |
599
+ | `positions?: readonly (Float32Array \| readonly number[])[]` | For each target, how far it moves each position. |
600
+ | `normals?: readonly (Float32Array \| readonly number[])[]` | For each target, how far it turns each normal. |
601
+ | `tangents?: readonly (Float32Array \| readonly number[])[]` | For each target, how far it turns each tangent's direction: three numbers per vertex, as glTF gives them. |
602
+ | `colors?: readonly (Float32Array \| readonly number[])[]` | For each target, how far it changes each vertex color: three or four numbers per vertex, as many as the mesh's `colors` hold, in linear color. A morphed color is clamped to the range 0 to 1, as the glTF specification asks. Needs `colors`. |
453
603
  | `names?: readonly string[]` | The targets' names, one per target, which `setMorphWeight` takes in place of numbers. |
454
604
 
455
605
  ## `octahedron`
@@ -458,13 +608,17 @@ A mesh's morph targets, like three.js's `morphAttributes` with `morphTargetsRela
458
608
  function octahedron(options: PolyhedronShapeOptions = {}): GeneratedArrays
459
609
  ```
460
610
 
461
- The arrays of an octahedron, like three.js's `OctahedronGeometry`. The mesh has no indices.
611
+ Import from `@null3d/geometry`.
612
+
613
+ The arrays of an octahedron. The mesh has no indices.
462
614
 
463
615
  ## `Path`
464
616
 
465
- Class `Path`, which extends `CurvePath`.
617
+ Class `Path`, which extends `CurvePath<[number, number]>`.
618
+
619
+ Import from `@null3d/geometry`.
466
620
 
467
- A 2D path drawn with commands like a canvas's, such as `moveTo`, `lineTo` and `bezierCurveTo`, like three.js's `Path`. Each command adds a curve that starts at the current point.
621
+ A 2D path drawn with commands like a canvas's, such as `moveTo`, `lineTo` and `bezierCurveTo`. Each command adds a curve that starts at the current point.
468
622
 
469
623
  | Member | Description |
470
624
  | --- | --- |
@@ -499,13 +653,17 @@ Options for `geometry.plane`. The plane lies in the XY plane, centered on its or
499
653
  function polyhedron(options: PolyhedronOptions = {}): GeneratedArrays
500
654
  ```
501
655
 
502
- The arrays of a polyhedron, like three.js's `PolyhedronGeometry`. The mesh has no indices: each three vertices in a row make a triangle.
656
+ Import from `@null3d/geometry`.
657
+
658
+ The arrays of a polyhedron from your own corners and faces, with its vertices on a sphere. The mesh has no indices: each three vertices in a row make a triangle.
503
659
 
504
660
  ## `PolyhedronOptions`
505
661
 
506
662
  Interface `PolyhedronOptions`.
507
663
 
508
- Options for `polyhedron`, with the names and defaults of three.js's `PolyhedronGeometry`.
664
+ Import from `@null3d/geometry`.
665
+
666
+ Options for `polyhedron`.
509
667
 
510
668
  | Member | Description |
511
669
  | --- | --- |
@@ -518,7 +676,9 @@ Options for `polyhedron`, with the names and defaults of three.js's `PolyhedronG
518
676
 
519
677
  Interface `PolyhedronShapeOptions`.
520
678
 
521
- Options for the named polyhedra, such as `icosahedron`, with three.js's names and defaults.
679
+ Import from `@null3d/geometry`.
680
+
681
+ Options for the named polyhedra, such as `icosahedron`.
522
682
 
523
683
  | Member | Description |
524
684
  | --- | --- |
@@ -527,9 +687,11 @@ Options for the named polyhedra, such as `icosahedron`, with three.js's names an
527
687
 
528
688
  ## `QuadraticBezierCurve`
529
689
 
530
- Class `QuadraticBezierCurve`, which extends `Curve`.
690
+ Class `QuadraticBezierCurve`, which extends `Curve<[number, number]>`.
691
+
692
+ Import from `@null3d/geometry`.
531
693
 
532
- A 2D quadratic Bézier curve from `v0` to `v2`, pulled toward the control point `v1`, like three.js's `QuadraticBezierCurve`.
694
+ A 2D quadratic Bézier curve from `v0` to `v2`, pulled toward the control point `v1`.
533
695
 
534
696
  | Member | Description |
535
697
  | --- | --- |
@@ -540,9 +702,11 @@ A 2D quadratic Bézier curve from `v0` to `v2`, pulled toward the control point
540
702
 
541
703
  ## `QuadraticBezierCurve3`
542
704
 
543
- Class `QuadraticBezierCurve3`, which extends `Curve`.
705
+ Class `QuadraticBezierCurve3`, which extends `Curve<[number, number, number]>`.
544
706
 
545
- A 3D quadratic Bézier curve from `v0` to `v2`, pulled toward the control point `v1`, like three.js's `QuadraticBezierCurve3`.
707
+ Import from `@null3d/geometry`.
708
+
709
+ A 3D quadratic Bézier curve from `v0` to `v2`, pulled toward the control point `v1`.
546
710
 
547
711
  | Member | Description |
548
712
  | --- | --- |
@@ -572,13 +736,17 @@ Options for `geometry.ring`: a flat disc with a hole. The ring lies in the XY pl
572
736
  function shape(options: ShapeOptions = {}): GeneratedArrays
573
737
  ```
574
738
 
575
- The arrays of flat shapes, like three.js's `ShapeGeometry`. The mesh has indices, and all its normals point along +Z. three.js gives each shape of a list a group of its own. Here the shapes form one mesh, so a material per shape needs one `shape` call per shape.
739
+ Import from `@null3d/geometry`.
740
+
741
+ The arrays of flat shapes. The mesh has indices, and all its normals point along +Z. The shapes of a list form one mesh, so a material per shape needs one `shape` call per shape.
576
742
 
577
743
  ## `Shape`
578
744
 
579
745
  Class `Shape`, which extends `Path`.
580
746
 
581
- A closed 2D outline with optional holes, like three.js's `Shape`. The `shape` and `extrude` generators fill it.
747
+ Import from `@null3d/geometry`.
748
+
749
+ A closed 2D outline with optional holes. The `shape` and `extrude` generators fill it.
582
750
 
583
751
  | Member | Description |
584
752
  | --- | --- |
@@ -600,24 +768,28 @@ The levels of detail that a generator's mesh plans on its own, as `MeshArrays.le
600
768
 
601
769
  Interface `ShapeOptions`.
602
770
 
603
- Options for `shape`, with the names and defaults of three.js's `ShapeGeometry`.
771
+ Import from `@null3d/geometry`.
772
+
773
+ Options for `shape`.
604
774
 
605
775
  | Member | Description |
606
776
  | --- | --- |
607
- | `shapes?: Shape \| readonly Shape[]` | One shape or a list of shapes. The default is three.js's triangle with corners (0, 0.5), (-0.5, -0.5) and (0.5, -0.5). |
777
+ | `shapes?: Shape \| readonly Shape[]` | One shape or a list of shapes. The default is a triangle with corners (0, 0.5), (-0.5, -0.5) and (0.5, -0.5). |
608
778
  | `curveSegments?: number` | The number of points along each curve of a shape. The default is 12. |
609
779
 
610
780
  ## `ShapeUtils`
611
781
 
612
782
  Namespace `ShapeUtils`.
613
783
 
614
- Helpers for 2D outlines, like three.js's `ShapeUtils`: `ShapeUtils.area`, `ShapeUtils.isClockWise` and `ShapeUtils.triangulateShape`.
784
+ Import from `@null3d/geometry`.
785
+
786
+ Helpers for 2D outlines: `ShapeUtils.area`, `ShapeUtils.isClockWise` and `ShapeUtils.triangulateShape`.
615
787
 
616
788
  | Member | Description |
617
789
  | --- | --- |
618
790
  | `area(contour: readonly Vec2Like[]): number` | The signed area of a closed outline. It is negative when the points run clockwise. |
619
791
  | `isClockWise(pts: readonly Vec2Like[]): boolean` | True when the points of a closed outline run clockwise. |
620
- | `triangulateShape(contour: Vec2Like[], holes: Vec2Like[][]): [number, number, number][]` | Cuts an outline with holes into triangles. It returns three point indices per triangle. The outline's points come first, then each hole's in turn. When the last point of a list repeats its first, it removes that last point, as three.js does. So the lists it takes can shrink. |
792
+ | `triangulateShape(contour: Vec2Like[], holes: Vec2Like[][]): [number, number, number][]` | Cuts an outline with holes into triangles. It returns three point indices per triangle. The outline's points come first, then each hole's in turn. When the last point of a list repeats its first, it removes that last point. So the lists it takes can shrink. |
621
793
 
622
794
  ## `SphereOptions`
623
795
 
@@ -637,9 +809,11 @@ Options for `geometry.sphere`. The sphere is centered on its origin, with its po
637
809
 
638
810
  ## `SplineCurve`
639
811
 
640
- Class `SplineCurve`, which extends `Curve`.
812
+ Class `SplineCurve`, which extends `Curve<[number, number]>`.
813
+
814
+ Import from `@null3d/geometry`.
641
815
 
642
- A smooth 2D curve through a list of points, like three.js's `SplineCurve`. It uses Catmull-Rom interpolation.
816
+ A smooth 2D curve through a list of points. It uses Catmull-Rom interpolation.
643
817
 
644
818
  | Member | Description |
645
819
  | --- | --- |
@@ -652,7 +826,9 @@ A smooth 2D curve through a list of points, like three.js's `SplineCurve`. It us
652
826
  function tetrahedron(options: PolyhedronShapeOptions = {}): GeneratedArrays
653
827
  ```
654
828
 
655
- The arrays of a tetrahedron, like three.js's `TetrahedronGeometry`. The mesh has no indices.
829
+ Import from `@null3d/geometry`.
830
+
831
+ The arrays of a tetrahedron. The mesh has no indices.
656
832
 
657
833
  ## `torusKnot`
658
834
 
@@ -660,13 +836,17 @@ The arrays of a tetrahedron, like three.js's `TetrahedronGeometry`. The mesh has
660
836
  function torusKnot(options: TorusKnotOptions = {}): GeneratedArrays
661
837
  ```
662
838
 
663
- The arrays of a torus knot, like three.js's `TorusKnotGeometry`. The mesh has indices.
839
+ Import from `@null3d/geometry`.
840
+
841
+ The arrays of a torus knot: a tube that winds around a torus. The mesh has indices.
664
842
 
665
843
  ## `TorusKnotOptions`
666
844
 
667
845
  Interface `TorusKnotOptions`.
668
846
 
669
- Options for `torusKnot`, with the names and defaults of three.js's `TorusKnotGeometry`.
847
+ Import from `@null3d/geometry`.
848
+
849
+ Options for `torusKnot`.
670
850
 
671
851
  | Member | Description |
672
852
  | --- | --- |
@@ -699,17 +879,21 @@ Options for `geometry.torus`. The torus is centered on its origin, around the Z
699
879
  function tube(options: TubeOptions = {}): GeneratedArrays
700
880
  ```
701
881
 
702
- The arrays of a tube, like three.js's `TubeGeometry`. The mesh has indices.
882
+ Import from `@null3d/geometry`.
883
+
884
+ The arrays of a tube along a 3D curve. The mesh has indices.
703
885
 
704
886
  ## `TubeOptions`
705
887
 
706
888
  Interface `TubeOptions`.
707
889
 
708
- Options for `tube`, with the names and defaults of three.js's `TubeGeometry`.
890
+ Import from `@null3d/geometry`.
891
+
892
+ Options for `tube`.
709
893
 
710
894
  | Member | Description |
711
895
  | --- | --- |
712
- | `path?: Curve<[number, number, number]>` | The 3D curve that the tube follows. The default is three.js's quadratic Bézier curve from (-1, -1, 0) through the control point (-1, 1, 0) to (1, 1, 0). |
896
+ | `path?: Curve<[number, number, number]>` | The 3D curve that the tube follows. The default is a quadratic Bézier curve from (-1, -1, 0) through the control point (-1, 1, 0) to (1, 1, 0). |
713
897
  | `tubularSegments?: number` | The number of segments along the curve. The default is 64. |
714
898
  | `radius?: number` | The radius of the tube. The default is 1. |
715
899
  | `radialSegments?: number` | The number of segments around the tube. The default is 8. |
@@ -734,7 +918,9 @@ The vertex attributes that `mesh.updateVertices` writes, by their names in `Mesh
734
918
 
735
919
  Interface `UVGenerator`.
736
920
 
737
- Makes the texture coordinates of an extrusion's triangles, like the `UVGenerator` option of three.js's `ExtrudeGeometry`. Each method gets the positions made so far, three numbers per vertex, and the vertex numbers of one triangle or one side quad. three.js's methods also take the geometry first. These do not, as there is no geometry object.
921
+ Import from `@null3d/geometry`.
922
+
923
+ Makes the texture coordinates of an extrusion's triangles, for the `UVGenerator` option of `extrude`. Each method gets the positions made so far, three numbers per vertex, and the vertex numbers of one triangle or one side quad.
738
924
 
739
925
  | Member | Description |
740
926
  | --- | --- |
@@ -747,18 +933,20 @@ Makes the texture coordinates of an extrusion's triangles, like the `UVGenerator
747
933
  type Vec2Like = { [index: number]: number; };
748
934
  ```
749
935
 
750
- A 2D vector (x, y) in an array: a tuple such as `[0, 1]`, a plain array or a typed array. Where three.js takes a `Vector2`, this package takes one of these and reads its first two elements.
936
+ Import from `@null3d/geometry`.
937
+
938
+ A 2D vector (x, y) in an array: a tuple such as `[0, 1]`, a plain array or a typed array. The package reads its first two elements.
751
939
 
752
940
  ## `VertexArray`
753
941
 
754
942
  Interface `VertexArray`.
755
943
 
756
- One attribute's numbers with a note on how its integers read, like three.js's `BufferAttribute`, whose `array` and `normalized` fields it shares. Normalized integers read as fractions: from 0 to 1 when unsigned, and from -1 to 1 when signed. Plain integers read as whole numbers.
944
+ One attribute's numbers with a note on how its integers read. Normalized integers read as fractions: from 0 to 1 when unsigned, and from -1 to 1 when signed. Plain integers read as whole numbers.
757
945
 
758
946
  | Member | Description |
759
947
  | --- | --- |
760
948
  | `array: Float32Array \| IntegerArray \| readonly number[]` | The numbers, as `MeshArrays` takes them. |
761
- | `normalized?: boolean` | True when the integers are normalized. The default is false, as in three.js and glTF. It applies to positions and texture coordinates. The other attributes read integers one way only, so they refuse a value that says otherwise. |
949
+ | `normalized?: boolean` | True when the integers are normalized. The default is false, as in glTF. It applies to positions and texture coordinates. The other attributes read integers one way only, so they refuse a value that says otherwise. |
762
950
 
763
951
  ## `VertexValues`
764
952
 
@@ -774,4 +962,6 @@ The numbers of one vertex attribute: a typed array, a plain array of numbers, or
774
962
  const WorldUVGenerator: UVGenerator
775
963
  ```
776
964
 
777
- three.js's default texture coordinates for an extrusion. A cap vertex takes its x and y. A side wall vertex takes its x or its y, whichever changes more along the wall, and 1 minus its z.
965
+ Import from `@null3d/geometry`.
966
+
967
+ The default texture coordinates for an extrusion. A cap vertex takes its x and y. A side wall vertex takes its x or its y, whichever changes more along the wall, and 1 minus its z.