@egret/engine 7.0.1-rc.3 → 7.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (304) hide show
  1. package/dist/Engine.js +7 -2
  2. package/dist/animation/sequenceResetTypes.d.ts +6 -0
  3. package/dist/animation/types.d.ts +6 -0
  4. package/dist/assetBundle.d.ts +2 -0
  5. package/dist/assetGroupTypes.d.ts +2 -0
  6. package/dist/audioCues.d.ts +4 -0
  7. package/dist/audioTypes.d.ts +13 -0
  8. package/dist/bitmapButtonTypes.d.ts +2 -0
  9. package/dist/bitmapFontTypes.d.ts +3 -0
  10. package/dist/bitmapResourceSlot.d.ts +1 -0
  11. package/dist/camera2d.js +10 -2
  12. package/dist/cameraTypes.d.ts +12 -0
  13. package/dist/contentTypes.d.ts +2 -0
  14. package/dist/createEngineForProfile.js +8 -5
  15. package/dist/fontContentTypes.d.ts +5 -0
  16. package/dist/gameClockTypes.d.ts +6 -0
  17. package/dist/gameRun.d.ts +3 -0
  18. package/dist/gamepadTypes.d.ts +8 -0
  19. package/dist/hoverInputTypes.d.ts +10 -0
  20. package/dist/index.d.ts +5 -2
  21. package/dist/index.js +2 -1
  22. package/dist/inputActions.d.ts +5 -0
  23. package/dist/internal/uiFactoryState.d.ts +4 -0
  24. package/dist/internal/uiFactoryState.js +18 -2
  25. package/dist/keyboardInput.d.ts +1 -0
  26. package/dist/keyboardInput.js +1 -0
  27. package/dist/keyboardInputTypes.d.ts +12 -0
  28. package/dist/kit.d.ts +3 -1
  29. package/dist/kit.js +2 -1
  30. package/dist/manifestResourceState.d.ts +1 -0
  31. package/dist/manifestResourceState.js +1 -0
  32. package/dist/manifestResourceTypes.d.ts +1 -0
  33. package/dist/motion.d.ts +2 -0
  34. package/dist/mouseInputTypes.d.ts +4 -0
  35. package/dist/particleEmitter.js +8 -0
  36. package/dist/particleTypes.d.ts +8 -0
  37. package/dist/physics2d.d.ts +2 -2
  38. package/dist/physics2d.js +1 -1
  39. package/dist/physics2dTypes.d.ts +55 -1
  40. package/dist/physics2dWorld.js +209 -9
  41. package/dist/pointerInput.d.ts +1 -0
  42. package/dist/pointerInput.js +1 -0
  43. package/dist/pointerInputTypes.d.ts +3 -0
  44. package/dist/random.d.ts +1 -0
  45. package/dist/rendering/packSharedDraws2D.js +53 -5
  46. package/dist/rendering/prepareSharedDraws2D.d.ts +2 -0
  47. package/dist/rendering/prepareSharedDraws2D.js +17 -6
  48. package/dist/rendering/sharedColor2D.d.ts +35 -1
  49. package/dist/rendering/sharedColor2D.js +131 -8
  50. package/dist/rendering/sharedEffects2D.js +16 -8
  51. package/dist/rendering/world3d/Animation3D.d.ts +9 -0
  52. package/dist/rendering/world3d/Animation3D.js +4 -0
  53. package/dist/rendering/world3d/AnimationTexture3D.d.ts +6 -0
  54. package/dist/rendering/world3d/AnimationTexture3D.js +2 -0
  55. package/dist/rendering/world3d/Batch3D.d.ts +4 -0
  56. package/dist/rendering/world3d/Batch3D.js +3 -0
  57. package/dist/rendering/world3d/Camera3D.d.ts +5 -0
  58. package/dist/rendering/world3d/Camera3D.js +3 -0
  59. package/dist/rendering/world3d/Character3D.d.ts +4 -0
  60. package/dist/rendering/world3d/Character3D.js +2 -0
  61. package/dist/rendering/world3d/Cloth3D.d.ts +18 -3
  62. package/dist/rendering/world3d/Cloth3D.js +6 -1
  63. package/dist/rendering/world3d/Compression3D.d.ts +1 -0
  64. package/dist/rendering/world3d/Compression3D.js +1 -0
  65. package/dist/rendering/world3d/Curves3D.d.ts +8 -0
  66. package/dist/rendering/world3d/Curves3D.js +5 -0
  67. package/dist/rendering/world3d/Decal3D.d.ts +2 -0
  68. package/dist/rendering/world3d/Decal3D.js +1 -0
  69. package/dist/rendering/world3d/Export3D.d.ts +13 -0
  70. package/dist/rendering/world3d/Export3D.js +263 -0
  71. package/dist/rendering/world3d/Geometry3D.d.ts +11 -1
  72. package/dist/rendering/world3d/Geometry3D.js +10 -1
  73. package/dist/rendering/world3d/GeometryBuilder3D.d.ts +2 -0
  74. package/dist/rendering/world3d/Gizmo3D.d.ts +5 -0
  75. package/dist/rendering/world3d/Gizmo3D.js +2 -0
  76. package/dist/rendering/world3d/Gltf3D.d.ts +6 -0
  77. package/dist/rendering/world3d/Gltf3D.js +25 -5
  78. package/dist/rendering/world3d/GpuParticles3D.d.ts +2 -0
  79. package/dist/rendering/world3d/GpuParticles3D.js +1 -0
  80. package/dist/rendering/world3d/Hdr3D.d.ts +2 -0
  81. package/dist/rendering/world3d/Hdr3D.js +1 -0
  82. package/dist/rendering/world3d/Jelly3D.d.ts +2 -0
  83. package/dist/rendering/world3d/Jelly3D.js +1 -0
  84. package/dist/rendering/world3d/Ktx23D.d.ts +3 -0
  85. package/dist/rendering/world3d/Light3D.d.ts +9 -0
  86. package/dist/rendering/world3d/Light3D.js +4 -0
  87. package/dist/rendering/world3d/Material3D.d.ts +10 -0
  88. package/dist/rendering/world3d/Material3D.js +2 -0
  89. package/dist/rendering/world3d/Mesh3D.d.ts +4 -0
  90. package/dist/rendering/world3d/Mesh3D.js +16 -2
  91. package/dist/rendering/world3d/Meshopt3D.d.ts +3 -0
  92. package/dist/rendering/world3d/Meshopt3D.js +1 -0
  93. package/dist/rendering/world3d/Navigation3D.d.ts +41 -1
  94. package/dist/rendering/world3d/Navigation3D.js +74 -2
  95. package/dist/rendering/world3d/Object3D.d.ts +11 -0
  96. package/dist/rendering/world3d/Object3D.js +10 -0
  97. package/dist/rendering/world3d/Particles3D.d.ts +5 -0
  98. package/dist/rendering/world3d/Particles3D.js +3 -0
  99. package/dist/rendering/world3d/Physics3D.d.ts +14 -0
  100. package/dist/rendering/world3d/Physics3D.js +5 -0
  101. package/dist/rendering/world3d/PhysicsHull3D.d.ts +2 -0
  102. package/dist/rendering/world3d/PhysicsHull3D.js +2 -0
  103. package/dist/rendering/world3d/PhysicsMesh3D.d.ts +2 -0
  104. package/dist/rendering/world3d/PhysicsMesh3D.js +2 -0
  105. package/dist/rendering/world3d/PhysicsRemote3D.d.ts +5 -0
  106. package/dist/rendering/world3d/PhysicsRemote3D.js +2 -0
  107. package/dist/rendering/world3d/Ragdoll3D.d.ts +5 -0
  108. package/dist/rendering/world3d/Ragdoll3D.js +2 -0
  109. package/dist/rendering/world3d/Raycast3D.d.ts +3 -0
  110. package/dist/rendering/world3d/Raycast3D.js +1 -0
  111. package/dist/rendering/world3d/RenderList3D.d.ts +3 -0
  112. package/dist/rendering/world3d/RenderList3D.js +12 -0
  113. package/dist/rendering/world3d/Retarget3D.d.ts +1 -0
  114. package/dist/rendering/world3d/Rig3D.d.ts +57 -0
  115. package/dist/rendering/world3d/Rig3D.js +219 -0
  116. package/dist/rendering/world3d/Sdf3D.d.ts +181 -0
  117. package/dist/rendering/world3d/Sdf3D.js +1136 -0
  118. package/dist/rendering/world3d/SdfLod3D.d.ts +17 -0
  119. package/dist/rendering/world3d/SdfLod3D.js +56 -0
  120. package/dist/rendering/world3d/Serialize3D.d.ts +17 -0
  121. package/dist/rendering/world3d/Serialize3D.js +22 -0
  122. package/dist/rendering/world3d/Simplify3D.d.ts +29 -0
  123. package/dist/rendering/world3d/Simplify3D.js +426 -0
  124. package/dist/rendering/world3d/StateMachine3D.d.ts +9 -0
  125. package/dist/rendering/world3d/StateMachine3D.js +3 -0
  126. package/dist/rendering/world3d/SurfaceMaterial3D.d.ts +26 -0
  127. package/dist/rendering/world3d/SurfaceMaterial3D.js +138 -0
  128. package/dist/rendering/world3d/Terrain3D.d.ts +21 -0
  129. package/dist/rendering/world3d/Terrain3D.js +25 -1
  130. package/dist/rendering/world3d/Text3D.d.ts +5 -0
  131. package/dist/rendering/world3d/Text3D.js +2 -0
  132. package/dist/rendering/world3d/Texture3D.d.ts +16 -1
  133. package/dist/rendering/world3d/Texture3D.js +19 -1
  134. package/dist/rendering/world3d/Trail3D.d.ts +3 -0
  135. package/dist/rendering/world3d/Trail3D.js +2 -0
  136. package/dist/rendering/world3d/Vehicle3D.d.ts +5 -0
  137. package/dist/rendering/world3d/Vehicle3D.js +2 -0
  138. package/dist/rendering/world3d/VolumetricFog3D.d.ts +2 -0
  139. package/dist/rendering/world3d/VolumetricFog3D.js +1 -0
  140. package/dist/rendering/world3d/Water3D.d.ts +2 -0
  141. package/dist/rendering/world3d/Water3D.js +1 -0
  142. package/dist/rendering/world3d/core3D.d.ts +2 -0
  143. package/dist/rendering/world3d/debug3D.d.ts +5 -0
  144. package/dist/rendering/world3d/debug3D.js +5 -0
  145. package/dist/rendering/world3d/geometries3D.d.ts +12 -0
  146. package/dist/rendering/world3d/geometries3D.js +5 -0
  147. package/dist/rendering/world3d/helpers3D.d.ts +2 -0
  148. package/dist/rendering/world3d/helpers3D.js +1 -0
  149. package/dist/rendering/world3d/index.d.ts +12 -0
  150. package/dist/rendering/world3d/index.js +6 -0
  151. package/dist/rendering/world3d/math3D.d.ts +36 -0
  152. package/dist/rendering/world3d/math3D.js +35 -0
  153. package/dist/rendering/world3d/primitives3D.d.ts +7 -0
  154. package/dist/rendering/world3d/primitives3D.js +1 -0
  155. package/dist/saveStore.d.ts +18 -3
  156. package/dist/saveStore.js +23 -4
  157. package/dist/semanticList.d.ts +4 -0
  158. package/dist/semanticList.js +1 -0
  159. package/dist/semanticTree.js +11 -4
  160. package/dist/semanticTypes.d.ts +8 -0
  161. package/dist/sequencePlaybackTypes.d.ts +3 -0
  162. package/dist/text.d.ts +1 -0
  163. package/dist/textTable.d.ts +41 -0
  164. package/dist/textTable.js +114 -0
  165. package/dist/tilemapTypes.d.ts +13 -0
  166. package/dist/timer.d.ts +34 -0
  167. package/dist/timer.js +119 -0
  168. package/dist/tweenTypes.d.ts +4 -0
  169. package/dist/ui/controlKeys.d.ts +4 -0
  170. package/dist/ui/controlKeys.js +1 -0
  171. package/dist/ui/controls.d.ts +6 -0
  172. package/dist/ui/controls.js +2 -0
  173. package/dist/ui/layerTypes.d.ts +7 -0
  174. package/dist/ui/rangeControl.d.ts +3 -0
  175. package/dist/ui/rangeControl.js +1 -0
  176. package/dist/ui/scrollControl.d.ts +12 -0
  177. package/dist/ui/scrollControl.js +5 -1
  178. package/dist/ui/stateControls.d.ts +8 -0
  179. package/dist/ui/stateControls.js +3 -0
  180. package/dist/ui/textEditor.d.ts +1 -0
  181. package/dist/ui/textEditor.js +1 -0
  182. package/dist/ui/textEditorTypes.d.ts +7 -0
  183. package/dist/ui/textFieldControl.d.ts +4 -0
  184. package/dist/ui/textFieldControl.js +1 -0
  185. package/dist/ui/theme.d.ts +5 -0
  186. package/dist/ui/theme.js +1 -0
  187. package/dist/ui/types.d.ts +20 -0
  188. package/dist/ui/uiRoot.js +38 -9
  189. package/dist/ui/uiRootModel.d.ts +3 -1
  190. package/dist/ui/uiRootModel.js +8 -2
  191. package/dist/videoTypes.d.ts +3 -0
  192. package/dist/web/BrowserAssetBundle.d.ts +2 -0
  193. package/dist/web/BrowserAudio.d.ts +34 -1
  194. package/dist/web/BrowserAudio.js +69 -39
  195. package/dist/web/BrowserFrameLoop.d.ts +4 -0
  196. package/dist/web/BrowserGame.d.ts +64 -2
  197. package/dist/web/BrowserGame.js +129 -8
  198. package/dist/web/BrowserGamepadInput.d.ts +3 -0
  199. package/dist/web/BrowserHoverInput.d.ts +1 -0
  200. package/dist/web/BrowserImageTextures.d.ts +6 -0
  201. package/dist/web/BrowserInputActions.d.ts +10 -0
  202. package/dist/web/BrowserInputActions.js +4 -1
  203. package/dist/web/BrowserPlay.d.ts +130 -2
  204. package/dist/web/BrowserPlay.js +366 -19
  205. package/dist/web/BrowserPreferences.d.ts +10 -0
  206. package/dist/web/BrowserPreferences.js +39 -0
  207. package/dist/web/BrowserSemantics.d.ts +2 -0
  208. package/dist/web/BrowserStatsPanel.d.ts +10 -0
  209. package/dist/web/BrowserStatsPanel.js +9 -3
  210. package/dist/web/BrowserStorage.d.ts +2 -0
  211. package/dist/web/BrowserTextEditor.d.ts +3 -0
  212. package/dist/web/BrowserTextInput.d.ts +6 -0
  213. package/dist/web/BrowserTextureProvider.d.ts +6 -0
  214. package/dist/web/BrowserVideo.d.ts +13 -1
  215. package/dist/web/BrowserVideo.js +28 -2
  216. package/dist/web/CanvasKitFontSetProvider.d.ts +3 -0
  217. package/dist/web/CanvasKitParagraphProvider.d.ts +4 -0
  218. package/dist/web/CanvasKitParagraphProvider.js +1 -0
  219. package/dist/web/ManifestByteSource.d.ts +4 -0
  220. package/dist/web/ManifestByteSource.js +1 -0
  221. package/dist/web/ManifestFontContentLoader.d.ts +1 -0
  222. package/dist/web/WebGL2Host.js +64 -25
  223. package/dist/web/WebGPUHost.d.ts +13 -0
  224. package/dist/web/WebGPUHost.js +117 -36
  225. package/dist/web/audio.d.ts +2 -2
  226. package/dist/web/audio.js +1 -1
  227. package/dist/web/editorFonts.d.ts +4 -0
  228. package/dist/web/game.d.ts +1 -1
  229. package/dist/web/imageProjections2D.d.ts +2 -0
  230. package/dist/web/kit.d.ts +1 -0
  231. package/dist/web/kit.js +1 -0
  232. package/dist/web/play.d.ts +6 -1
  233. package/dist/web/play.js +4 -1
  234. package/dist/web/playMusic.d.ts +33 -0
  235. package/dist/web/playMusic.js +194 -0
  236. package/dist/web/playTouch.d.ts +45 -0
  237. package/dist/web/playTouch.js +141 -0
  238. package/dist/web/playWidgets.d.ts +71 -0
  239. package/dist/web/playWidgets.js +431 -0
  240. package/dist/web/prepareSharedSubmission2D.js +9 -3
  241. package/dist/web/resources.d.ts +2 -0
  242. package/dist/web/sharedEffectShaders.d.ts +6 -2
  243. package/dist/web/sharedEffectShaders.js +23 -7
  244. package/dist/web/sharedSubmissionStorage2D.js +1 -1
  245. package/dist/web/sharedWebGL2Options.d.ts +3 -0
  246. package/dist/web/sharedWebGL2Options.js +8 -2
  247. package/dist/web/sharedWebGL2Shaders.d.ts +15 -2
  248. package/dist/web/sharedWebGL2Shaders.js +108 -14
  249. package/dist/web/sharedWebGPUOptions.d.ts +5 -1
  250. package/dist/web/sharedWebGPUOptions.js +6 -2
  251. package/dist/web/video.d.ts +1 -1
  252. package/dist/web/webgl2Native.d.ts +3 -1
  253. package/dist/web/webgl2Native.js +9 -5
  254. package/dist/web/webgl2Types.d.ts +18 -0
  255. package/dist/web/webgpuImageResidency.d.ts +5 -2
  256. package/dist/web/webgpuImageResidency.js +7 -3
  257. package/dist/web/webgpuRetentionPool.d.ts +2 -2
  258. package/dist/web/webgpuRetentionPool.js +2 -1
  259. package/dist/web/webgpuSharedPass.d.ts +1 -1
  260. package/dist/web/webgpuSharedPass.js +87 -5
  261. package/dist/web/webgpuSharedResolvePass.d.ts +1 -1
  262. package/dist/web/webgpuSharedResolvePass.js +9 -4
  263. package/dist/web/world3d/Audio3D.d.ts +18 -1
  264. package/dist/web/world3d/Audio3D.js +62 -3
  265. package/dist/web/world3d/BrowserPlay3D.d.ts +115 -2
  266. package/dist/web/world3d/BrowserPlay3D.js +448 -43
  267. package/dist/web/world3d/FlyControls3D.d.ts +4 -0
  268. package/dist/web/world3d/FlyControls3D.js +2 -0
  269. package/dist/web/world3d/FollowControls3D.d.ts +3 -0
  270. package/dist/web/world3d/FollowControls3D.js +2 -0
  271. package/dist/web/world3d/OrbitControls3D.d.ts +3 -0
  272. package/dist/web/world3d/OrbitControls3D.js +2 -0
  273. package/dist/web/world3d/TransformControls3D.d.ts +5 -2
  274. package/dist/web/world3d/TransformControls3D.js +7 -4
  275. package/dist/web/world3d/WebGL2Renderer3D.d.ts +3 -0
  276. package/dist/web/world3d/WebGL2Renderer3D.js +2 -0
  277. package/dist/web/world3d/WebGPURenderer3D.d.ts +2 -0
  278. package/dist/web/world3d/WebGPURenderer3D.js +1 -0
  279. package/dist/web/world3d/World3DView.d.ts +3 -0
  280. package/dist/web/world3d/World3DView.js +2 -0
  281. package/dist/web/world3d/app3D.d.ts +7 -0
  282. package/dist/web/world3d/app3D.js +1 -0
  283. package/dist/web/world3d/assets3D.d.ts +1 -0
  284. package/dist/web/world3d/atmosphere3D.d.ts +9 -0
  285. package/dist/web/world3d/atmosphere3D.js +19 -4
  286. package/dist/web/world3d/canvasFont3D.d.ts +21 -0
  287. package/dist/web/world3d/canvasFont3D.js +165 -0
  288. package/dist/web/world3d/frame3D.d.ts +2 -0
  289. package/dist/web/world3d/host3D.d.ts +1 -0
  290. package/dist/web/world3d/index.d.ts +4 -2
  291. package/dist/web/world3d/index.js +2 -1
  292. package/dist/web/world3d/loaders3D.d.ts +1 -0
  293. package/dist/web/world3d/markers3D.d.ts +4 -0
  294. package/dist/web/world3d/overlay3D.d.ts +19 -0
  295. package/dist/web/world3d/overlay3D.js +21 -4
  296. package/dist/web/world3d/post3D.d.ts +4 -0
  297. package/dist/web/world3d/post3D.js +3 -0
  298. package/dist/web/world3d/probe3D.d.ts +1 -0
  299. package/dist/web/world3d/stats3D.d.ts +3 -0
  300. package/dist/web/world3d/stats3D.js +1 -0
  301. package/dist/web/world3d/webGL2FrameMetrics3D.d.ts +5 -0
  302. package/dist/web/world3d/webgpu.d.ts +2 -0
  303. package/dist/web/world3d/webgpu.js +1 -0
  304. package/package.json +3 -3
@@ -535,6 +535,7 @@ export class Water3D extends Mesh3D {
535
535
  this.reflection?.dispose();
536
536
  }
537
537
  }
538
+ /** Makes a water surface with waves, reflections and foam. */
538
539
  export function createWater3D(options = {}) {
539
540
  return new Water3D(options);
540
541
  }
@@ -1,3 +1,4 @@
1
+ /** What went wrong in the 3D world. */
1
2
  export type World3DErrorCode = 'WORLD3D_INPUT_INVALID' | 'WORLD3D_BUDGET' | 'WORLD3D_DISPOSED' | 'WORLD3D_HIERARCHY_INVALID' | 'WORLD3D_GLTF_INVALID' | 'WORLD3D_GLTF_UNSUPPORTED' | 'WORLD3D_RESOURCE_FAILED' | 'WORLD3D_CONTEXT_UNAVAILABLE' | 'WORLD3D_CONTEXT_LOST' | 'WORLD3D_SHADER_FAILED';
2
3
  /** Stable machine-readable code plus a human-readable detail and the original cause. */
3
4
  export declare class World3DError extends Error {
@@ -10,6 +11,7 @@ export declare function allocateId3D(): number;
10
11
  export declare function requireFinite3D(value: unknown, field: string): number;
11
12
  export declare function requirePositive3D(value: unknown, field: string): number;
12
13
  export declare function requireCount3D(value: unknown, field: string, max: number): number;
14
+ /** Called when something is disposed of. */
13
15
  export type DisposeListener3D = () => void;
14
16
  /**
15
17
  * CPU-side resource with a version counter and terminal disposal.
@@ -56,9 +56,14 @@ export declare class SkeletonHelper3D extends LineHelper3D {
56
56
  constructor(root: Object3D, color?: ColorInput3D);
57
57
  update(): void;
58
58
  }
59
+ /** Makes lines that show an object's bounding box. */
59
60
  export declare function createBoxHelper3D(target: Object3D, color?: ColorInput3D): BoxHelper3D;
61
+ /** Makes an arrow from a point in a direction. */
60
62
  export declare function createArrowHelper3D(direction: ArrayLike<number>, origin?: ArrayLike<number>, length?: number, color?: ColorInput3D): ArrowHelper3D;
63
+ /** Makes lines that show what a camera sees. */
61
64
  export declare function createCameraHelper3D(camera: Camera3D, color?: ColorInput3D): CameraHelper3D;
65
+ /** Makes lines that show where a light is and where it shines. */
62
66
  export declare function createLightHelper3D(light: Light3D, size?: number, color?: ColorInput3D): LightHelper3D;
67
+ /** Makes lines that show the bones of a skeleton. */
63
68
  export declare function createSkeletonHelper3D(root: Object3D, color?: ColorInput3D): SkeletonHelper3D;
64
69
  //# sourceMappingURL=debug3D.d.ts.map
@@ -239,18 +239,23 @@ export class SkeletonHelper3D extends LineHelper3D {
239
239
  this.commit();
240
240
  }
241
241
  }
242
+ /** Makes lines that show an object's bounding box. */
242
243
  export function createBoxHelper3D(target, color) {
243
244
  return new BoxHelper3D(target, color);
244
245
  }
246
+ /** Makes an arrow from a point in a direction. */
245
247
  export function createArrowHelper3D(direction, origin, length, color) {
246
248
  return new ArrowHelper3D(direction, origin, length, color);
247
249
  }
250
+ /** Makes lines that show what a camera sees. */
248
251
  export function createCameraHelper3D(camera, color) {
249
252
  return new CameraHelper3D(camera, color);
250
253
  }
254
+ /** Makes lines that show where a light is and where it shines. */
251
255
  export function createLightHelper3D(light, size, color) {
252
256
  return new LightHelper3D(light, size, color);
253
257
  }
258
+ /** Makes lines that show the bones of a skeleton. */
254
259
  export function createSkeletonHelper3D(root, color) {
255
260
  return new SkeletonHelper3D(root, color);
256
261
  }
@@ -1,5 +1,6 @@
1
1
  import { Curve3D, Shape3D } from './Curves3D.js';
2
2
  import { Geometry3D } from './Geometry3D.js';
3
+ /** A circle to make: its radius, segments and arc. */
3
4
  export interface CircleGeometryOptions3D {
4
5
  readonly radius?: number;
5
6
  readonly segments?: number;
@@ -8,6 +9,7 @@ export interface CircleGeometryOptions3D {
8
9
  }
9
10
  /** Flat disc or sector in the XY plane, facing +Z. */
10
11
  export declare function createCircleGeometry3D(options?: CircleGeometryOptions3D): Geometry3D;
12
+ /** A ring to make: its inner and outer radius, segments and arc. */
11
13
  export interface RingGeometryOptions3D {
12
14
  readonly innerRadius?: number;
13
15
  readonly outerRadius?: number;
@@ -18,6 +20,7 @@ export interface RingGeometryOptions3D {
18
20
  }
19
21
  /** Flat ring in the XY plane, facing +Z. An inner radius of 0 gives a disc. */
20
22
  export declare function createRingGeometry3D(options?: RingGeometryOptions3D): Geometry3D;
23
+ /** A torus knot to make: its radius and tube, segments, and its windings p and q. */
21
24
  export interface TorusKnotGeometryOptions3D {
22
25
  readonly radius?: number;
23
26
  readonly tube?: number;
@@ -27,6 +30,7 @@ export interface TorusKnotGeometryOptions3D {
27
30
  readonly p?: number;
28
31
  readonly q?: number;
29
32
  }
33
+ /** Makes a torus knot. */
30
34
  export declare function createTorusKnotGeometry3D(options?: TorusKnotGeometryOptions3D): Geometry3D;
31
35
  /**
32
36
  * Project a convex solid's triangles onto a sphere, subdividing each `detail`
@@ -38,15 +42,21 @@ export declare function createPolyhedronGeometry3D(vertices: ArrayLike<number>,
38
42
  readonly detail?: number;
39
43
  readonly smooth?: boolean;
40
44
  }): Geometry3D;
45
+ /** A regular solid to make: its radius, how often it is subdivided, and whether it is smooth. */
41
46
  export interface PolyhedronOptions3D {
42
47
  readonly radius?: number;
43
48
  readonly detail?: number;
44
49
  readonly smooth?: boolean;
45
50
  }
51
+ /** Makes a tetrahedron. */
46
52
  export declare function createTetrahedronGeometry3D(options?: PolyhedronOptions3D): Geometry3D;
53
+ /** Makes an octahedron. */
47
54
  export declare function createOctahedronGeometry3D(options?: PolyhedronOptions3D): Geometry3D;
55
+ /** Makes an icosahedron. */
48
56
  export declare function createIcosahedronGeometry3D(options?: PolyhedronOptions3D): Geometry3D;
57
+ /** Makes a dodecahedron. */
49
58
  export declare function createDodecahedronGeometry3D(options?: PolyhedronOptions3D): Geometry3D;
59
+ /** A lathe to make: its segments and the arc it turns through. */
50
60
  export interface LatheGeometryOptions3D {
51
61
  readonly segments?: number;
52
62
  readonly phiStart?: number;
@@ -54,6 +64,7 @@ export interface LatheGeometryOptions3D {
54
64
  }
55
65
  /** Revolve a profile of [x, y] points (x is the distance from the Y axis) around Y. */
56
66
  export declare function createLatheGeometry3D(profile: readonly (readonly [number, number])[], options?: LatheGeometryOptions3D): Geometry3D;
67
+ /** A tube to make along a curve: its segments, radius and whether it closes. */
57
68
  export interface TubeGeometryOptions3D {
58
69
  readonly tubularSegments?: number;
59
70
  readonly radius?: number;
@@ -64,6 +75,7 @@ export interface TubeGeometryOptions3D {
64
75
  export declare function createTubeGeometry3D(curve: Curve3D, options?: TubeGeometryOptions3D): Geometry3D;
65
76
  /** Fill one or more outlines in the XY plane, facing +Z. UVs equal the XY coordinates. */
66
77
  export declare function createShapeGeometry3D(shapes: Shape3D | readonly Shape3D[]): Geometry3D;
78
+ /** An extrusion to make: how deep, in how many steps, and along which path. */
67
79
  export interface ExtrudeGeometryOptions3D {
68
80
  /** Thickness along +Z. Ignored when `path` is given. */
69
81
  readonly depth?: number;
@@ -60,6 +60,7 @@ export function createRingGeometry3D(options = {}) {
60
60
  }
61
61
  return build(l);
62
62
  }
63
+ /** Makes a torus knot. */
63
64
  export function createTorusKnotGeometry3D(options = {}) {
64
65
  const radius = requirePositive3D(options.radius ?? 0.5, 'radius'), tube = requirePositive3D(options.tube ?? 0.15, 'tube');
65
66
  const ts = count(options.tubularSegments, 96, 3, 'tubularSegments'), rs = count(options.radialSegments, 12, 3, 'radialSegments');
@@ -133,12 +134,15 @@ function mix(a, b, t) {
133
134
  return [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t];
134
135
  }
135
136
  const PHI = (1 + Math.sqrt(5)) / 2, INVERSE_PHI = 1 / PHI;
137
+ /** Makes a tetrahedron. */
136
138
  export function createTetrahedronGeometry3D(options = {}) {
137
139
  return createPolyhedronGeometry3D([1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1], [2, 1, 0, 0, 3, 2, 1, 3, 0, 2, 3, 1], options);
138
140
  }
141
+ /** Makes an octahedron. */
139
142
  export function createOctahedronGeometry3D(options = {}) {
140
143
  return createPolyhedronGeometry3D([1, 0, 0, -1, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 1, 0, 0, -1], [0, 2, 4, 0, 4, 3, 0, 3, 5, 0, 5, 2, 1, 2, 5, 1, 5, 3, 1, 3, 4, 1, 4, 2], options);
141
144
  }
145
+ /** Makes an icosahedron. */
142
146
  export function createIcosahedronGeometry3D(options = {}) {
143
147
  return createPolyhedronGeometry3D([
144
148
  -1,
@@ -182,6 +186,7 @@ export function createIcosahedronGeometry3D(options = {}) {
182
186
  2, 3, 2, 6, 3, 6, 8, 3, 8, 9, 4, 9, 5, 2, 4, 11, 6, 2, 10, 8, 6, 7, 9, 8, 1
183
187
  ], options);
184
188
  }
189
+ /** Makes a dodecahedron. */
185
190
  export function createDodecahedronGeometry3D(options = {}) {
186
191
  const r = INVERSE_PHI, t = PHI;
187
192
  return createPolyhedronGeometry3D([
@@ -36,6 +36,7 @@ export declare class Lod3D extends Object3D {
36
36
  select(x: number, y: number, z: number): void;
37
37
  clone(): this;
38
38
  }
39
+ /** A screen layer to make: its order and opacity, whether it updates itself, and which way its rows run. */
39
40
  export interface ScreenLayerOptions3D {
40
41
  /** 'overlay' draws after the scene with blending; 'underlay' draws first and is covered by it. */
41
42
  readonly order?: 'overlay' | 'underlay';
@@ -61,5 +62,6 @@ export declare class ScreenLayer3D extends Mesh3D {
61
62
  dispose(): void;
62
63
  clone(): this;
63
64
  }
65
+ /** Makes a picture drawn over the whole screen, above or below the scene. */
64
66
  export declare function createScreenLayer3D(source: TextureSource3D, options?: ScreenLayerOptions3D): ScreenLayer3D;
65
67
  //# sourceMappingURL=helpers3D.d.ts.map
@@ -171,6 +171,7 @@ export class ScreenLayer3D extends Mesh3D {
171
171
  throw new World3DError('WORLD3D_INPUT_INVALID', 'a screen layer cannot be cloned; create a new one from the same source');
172
172
  }
173
173
  }
174
+ /** Makes a picture drawn over the whole screen, above or below the scene. */
174
175
  export function createScreenLayer3D(source, options = {}) {
175
176
  return new ScreenLayer3D(source, options);
176
177
  }
@@ -86,6 +86,18 @@ export { GpuParticles3D, createGpuParticles3D, type GpuParticlesOptions3D } from
86
86
  export { VolumetricFog3D, createVolumetricFog3D, type VolumetricFogOptions3D } from './VolumetricFog3D.js';
87
87
  export { createGeometryBuilder3D, linearColor3D, projectToViewport3D } from './GeometryBuilder3D.js';
88
88
  export type { GeometryBuilder3D, GeometryPart3D, ViewportPoint3D } from './GeometryBuilder3D.js';
89
+ export { SdfShape3D, createSdfGeometry3D, sdfBox, sdfCapsule, sdfCone, sdfCylinder, sdfDisplace, sdfEllipsoid, sdfExtrude, sdfIntersect, sdfLathe, sdfMirror, sdfPattern, sdfRound, sdfShell, sdfSphere, sdfSubtract, sdfTorus, sdfUnion } from './Sdf3D.js';
90
+ export type { SdfDisplaceOptions3D, SdfGroupOptions3D, SdfMeshOptions3D, SdfOptions3D, SdfPatternOptions3D } from './Sdf3D.js';
91
+ export { simplifyGeometry3D } from './Simplify3D.js';
92
+ export { exportGlb3D } from './Export3D.js';
93
+ export { createSdfRig3D } from './Rig3D.js';
94
+ export { createSdfLod3D } from './SdfLod3D.js';
95
+ export { createSurfaceMaterial3D, surfaceShaderSources3D } from './SurfaceMaterial3D.js';
96
+ export type { SurfaceKind3D, SurfaceMaterialOptions3D } from './SurfaceMaterial3D.js';
97
+ export type { SdfLodOptions3D } from './SdfLod3D.js';
98
+ export type { SdfBone3D, SdfPoseKey3D, SdfRig3D, SdfRigOptions3D } from './Rig3D.js';
99
+ export type { GlbExportOptions3D } from './Export3D.js';
100
+ export type { SimplifyOptions3D, SimplifyResult3D } from './Simplify3D.js';
89
101
  export { retargetAnimationClip3D } from './Retarget3D.js';
90
102
  export type { RetargetOptions3D } from './Retarget3D.js';
91
103
  //# sourceMappingURL=index.d.ts.map
@@ -52,5 +52,11 @@ export { createDecalGeometry3D, createDecal3D, DECAL3D_LIMITS } from './Decal3D.
52
52
  export { GpuParticles3D, createGpuParticles3D } from './GpuParticles3D.js';
53
53
  export { VolumetricFog3D, createVolumetricFog3D } from './VolumetricFog3D.js';
54
54
  export { createGeometryBuilder3D, linearColor3D, projectToViewport3D } from './GeometryBuilder3D.js';
55
+ export { SdfShape3D, createSdfGeometry3D, sdfBox, sdfCapsule, sdfCone, sdfCylinder, sdfDisplace, sdfEllipsoid, sdfExtrude, sdfIntersect, sdfLathe, sdfMirror, sdfPattern, sdfRound, sdfShell, sdfSphere, sdfSubtract, sdfTorus, sdfUnion } from './Sdf3D.js';
56
+ export { simplifyGeometry3D } from './Simplify3D.js';
57
+ export { exportGlb3D } from './Export3D.js';
58
+ export { createSdfRig3D } from './Rig3D.js';
59
+ export { createSdfLod3D } from './SdfLod3D.js';
60
+ export { createSurfaceMaterial3D, surfaceShaderSources3D } from './SurfaceMaterial3D.js';
55
61
  export { retargetAnimationClip3D } from './Retarget3D.js';
56
62
  //# sourceMappingURL=index.js.map
@@ -1,26 +1,44 @@
1
+ /** An array of numbers the 3D math writes into. */
1
2
  export type NumericArray3D = Float32Array | Float64Array | number[];
3
+ /** How close two numbers must be to count as equal. */
2
4
  export declare const EPSILON_3D = 1e-8;
5
+ /** Sets a vector's x, y and z. */
3
6
  export declare function vec3Set(out: NumericArray3D, x: number, y: number, z: number): NumericArray3D;
7
+ /** Copies a vector. */
4
8
  export declare function vec3Copy(out: NumericArray3D, a: ArrayLike<number>): NumericArray3D;
9
+ /** Adds two vectors. */
5
10
  export declare function vec3Add(out: NumericArray3D, a: ArrayLike<number>, b: ArrayLike<number>): NumericArray3D;
11
+ /** Takes one vector from another. */
6
12
  export declare function vec3Sub(out: NumericArray3D, a: ArrayLike<number>, b: ArrayLike<number>): NumericArray3D;
13
+ /** Multiplies a vector by a number. */
7
14
  export declare function vec3Scale(out: NumericArray3D, a: ArrayLike<number>, s: number): NumericArray3D;
15
+ /** The dot product of two vectors. */
8
16
  export declare function vec3Dot(a: ArrayLike<number>, b: ArrayLike<number>): number;
17
+ /** The cross product of two vectors. */
9
18
  export declare function vec3Cross(out: NumericArray3D, a: ArrayLike<number>, b: ArrayLike<number>): NumericArray3D;
19
+ /** The length of a vector. */
10
20
  export declare function vec3Length(a: ArrayLike<number>): number;
21
+ /** The distance between two points. */
11
22
  export declare function vec3Distance(a: ArrayLike<number>, b: ArrayLike<number>): number;
12
23
  /** A zero-length input yields the zero vector instead of NaN. */
13
24
  export declare function vec3Normalize(out: NumericArray3D, a: ArrayLike<number>): NumericArray3D;
25
+ /** The point a fraction of the way from one vector to another. */
14
26
  export declare function vec3Lerp(out: NumericArray3D, a: ArrayLike<number>, b: ArrayLike<number>, t: number): NumericArray3D;
15
27
  /** Transform a point (w = 1) with perspective division. */
16
28
  export declare function vec3TransformMat4(out: NumericArray3D, a: ArrayLike<number>, m: ArrayLike<number>): NumericArray3D;
17
29
  /** Transform a direction (w = 0) by the upper 3x3; the result is not normalized. */
18
30
  export declare function vec3TransformDirection(out: NumericArray3D, a: ArrayLike<number>, m: ArrayLike<number>): NumericArray3D;
31
+ /** Turns a vector by a quaternion. */
19
32
  export declare function vec3TransformQuat(out: NumericArray3D, a: ArrayLike<number>, q: ArrayLike<number>): NumericArray3D;
33
+ /** Sets a quaternion to no rotation. */
20
34
  export declare function quatIdentity(out: NumericArray3D): NumericArray3D;
35
+ /** Copies a quaternion. */
21
36
  export declare function quatCopy(out: NumericArray3D, a: ArrayLike<number>): NumericArray3D;
37
+ /** Scales a quaternion to length 1. */
22
38
  export declare function quatNormalize(out: NumericArray3D, a: ArrayLike<number>): NumericArray3D;
39
+ /** Multiplies two quaternions: the rotation of b, then a. */
23
40
  export declare function quatMultiply(out: NumericArray3D, a: ArrayLike<number>, b: ArrayLike<number>): NumericArray3D;
41
+ /** A quaternion that turns by an angle about an axis. */
24
42
  export declare function quatFromAxisAngle(out: NumericArray3D, axis: ArrayLike<number>, radians: number): NumericArray3D;
25
43
  /** Intrinsic XYZ Euler angles in radians (rotate X, then Y, then Z in local axes). */
26
44
  export declare function quatFromEuler(out: NumericArray3D, x: number, y: number, z: number): NumericArray3D;
@@ -30,7 +48,9 @@ export declare function quatToEuler(out: NumericArray3D, q: ArrayLike<number>):
30
48
  export declare function quatSlerp(out: NumericArray3D, a: ArrayLike<number>, b: ArrayLike<number>, t: number): NumericArray3D;
31
49
  /** Rotation part of a matrix without scale or shear. */
32
50
  export declare function quatFromRotationMatrix(out: NumericArray3D, m: ArrayLike<number>): NumericArray3D;
51
+ /** Sets a 4x4 matrix to the identity. */
33
52
  export declare function mat4Identity(out: NumericArray3D): NumericArray3D;
53
+ /** Copies a 4x4 matrix. */
34
54
  export declare function mat4Copy(out: NumericArray3D, a: ArrayLike<number>): NumericArray3D;
35
55
  /** out = a * b: with column vectors, b applies first. */
36
56
  export declare function mat4Multiply(out: NumericArray3D, a: ArrayLike<number>, b: ArrayLike<number>): NumericArray3D;
@@ -38,6 +58,7 @@ export declare function mat4Multiply(out: NumericArray3D, a: ArrayLike<number>,
38
58
  export declare function mat4Compose(out: NumericArray3D, t: ArrayLike<number>, q: ArrayLike<number>, s: ArrayLike<number>): NumericArray3D;
39
59
  /** Split an affine matrix; a negative determinant is folded into scale X. */
40
60
  export declare function mat4Decompose(m: ArrayLike<number>, t: NumericArray3D, q: NumericArray3D, s: NumericArray3D): void;
61
+ /** The determinant of a 4x4 matrix. */
41
62
  export declare function mat4Determinant(m: ArrayLike<number>): number;
42
63
  /** Returns false and leaves `out` untouched when the matrix is singular. */
43
64
  export declare function mat4Invert(out: NumericArray3D, m: ArrayLike<number>): boolean;
@@ -45,20 +66,31 @@ export declare function mat4Invert(out: NumericArray3D, m: ArrayLike<number>): b
45
66
  export declare function mat4LookAt(out: NumericArray3D, eye: ArrayLike<number>, target: ArrayLike<number>, up: ArrayLike<number>): NumericArray3D;
46
67
  /** Right-handed perspective projection to clip depth [-1, 1]. */
47
68
  export declare function mat4Perspective(out: NumericArray3D, verticalFov: number, aspect: number, near: number, far: number): NumericArray3D;
69
+ /** Sets a 4x4 matrix to an orthographic projection. */
48
70
  export declare function mat4Orthographic(out: NumericArray3D, left: number, right: number, bottom: number, top: number, near: number, far: number): NumericArray3D;
49
71
  /** 3x3 inverse transpose of the upper-left block, written as nine column-major floats. */
50
72
  export declare function mat3NormalFromMat4(out: NumericArray3D, m: ArrayLike<number>): NumericArray3D;
73
+ /** The largest scale a 4x4 matrix applies along an axis. */
51
74
  export declare function mat4MaxScaleOnAxis(m: ArrayLike<number>): number;
75
+ /** Sets a box to empty. */
52
76
  export declare function box3Empty(out: NumericArray3D): NumericArray3D;
77
+ /** Whether a box is empty. */
53
78
  export declare function box3IsEmpty(box: ArrayLike<number>): boolean;
79
+ /** Grows a box to hold a point. */
54
80
  export declare function box3ExpandByPoint(box: NumericArray3D, x: number, y: number, z: number): void;
81
+ /** The box that holds two boxes. */
55
82
  export declare function box3Union(out: NumericArray3D, a: ArrayLike<number>, b: ArrayLike<number>): NumericArray3D;
56
83
  /** Axis-aligned bounds of a transformed box (Arvo's method). */
57
84
  export declare function box3Transform(out: NumericArray3D, box: ArrayLike<number>, m: ArrayLike<number>): NumericArray3D;
85
+ /** The sphere around a box. */
58
86
  export declare function sphereFromBox(out: NumericArray3D, box: ArrayLike<number>): NumericArray3D;
87
+ /** Moves and scales a sphere by a 4x4 matrix. */
59
88
  export declare function sphereTransform(out: NumericArray3D, sphere: ArrayLike<number>, m: ArrayLike<number>): NumericArray3D;
89
+ /** The six planes of the frustum a projection-view matrix sees. */
60
90
  export declare function frustumFromMatrix(out: NumericArray3D, m: ArrayLike<number>): NumericArray3D;
91
+ /** Whether a sphere is at least partly inside a frustum. */
61
92
  export declare function frustumIntersectsSphere(frustum: ArrayLike<number>, sphere: ArrayLike<number>): boolean;
93
+ /** Whether a box is at least partly inside a frustum. */
62
94
  export declare function frustumIntersectsBox(frustum: ArrayLike<number>, box: ArrayLike<number>): boolean;
63
95
  /** Distance along the ray to the sphere, or -1 when it misses. */
64
96
  export declare function rayIntersectSphere(origin: ArrayLike<number>, direction: ArrayLike<number>, sphere: ArrayLike<number>): number;
@@ -69,10 +101,14 @@ export declare function rayIntersectBox(origin: ArrayLike<number>, direction: Ar
69
101
  * `cull` rejects back faces (counter-clockwise triangles face the ray origin).
70
102
  */
71
103
  export declare function rayIntersectTriangle(out: NumericArray3D, origin: ArrayLike<number>, direction: ArrayLike<number>, p: ArrayLike<number>, a: number, b: number, c: number, cull: boolean): boolean;
104
+ /** Turns an sRGB color value into a linear one. */
72
105
  export declare function srgbToLinear(value: number): number;
106
+ /** Turns a linear color value into an sRGB one. */
73
107
  export declare function linearToSrgb(value: number): number;
74
108
  /** Decode a 0xRRGGBB sRGB color into linear RGB in [0, 1]. */
75
109
  export declare function colorFromHex(out: NumericArray3D, hex: number): NumericArray3D;
110
+ /** The value, kept between `min` and `max`. */
76
111
  export declare function clamp(value: number, min: number, max: number): number;
112
+ /** Degrees times this are radians. */
77
113
  export declare const DEG_TO_RAD_3D: number;
78
114
  //# sourceMappingURL=math3D.d.ts.map
@@ -2,41 +2,49 @@
2
2
  // Allocation-free 3D math over caller-owned numeric storage. Matrices are
3
3
  // column-major with column vectors; cameras look down negative view Z.
4
4
  // Every function writes into `out` and tolerates `out` aliasing an input.
5
+ /** How close two numbers must be to count as equal. */
5
6
  export const EPSILON_3D = 1e-8;
6
7
  // ---- vec3 -----------------------------------------------------------------
8
+ /** Sets a vector's x, y and z. */
7
9
  export function vec3Set(out, x, y, z) {
8
10
  out[0] = x;
9
11
  out[1] = y;
10
12
  out[2] = z;
11
13
  return out;
12
14
  }
15
+ /** Copies a vector. */
13
16
  export function vec3Copy(out, a) {
14
17
  out[0] = a[0];
15
18
  out[1] = a[1];
16
19
  out[2] = a[2];
17
20
  return out;
18
21
  }
22
+ /** Adds two vectors. */
19
23
  export function vec3Add(out, a, b) {
20
24
  out[0] = a[0] + b[0];
21
25
  out[1] = a[1] + b[1];
22
26
  out[2] = a[2] + b[2];
23
27
  return out;
24
28
  }
29
+ /** Takes one vector from another. */
25
30
  export function vec3Sub(out, a, b) {
26
31
  out[0] = a[0] - b[0];
27
32
  out[1] = a[1] - b[1];
28
33
  out[2] = a[2] - b[2];
29
34
  return out;
30
35
  }
36
+ /** Multiplies a vector by a number. */
31
37
  export function vec3Scale(out, a, s) {
32
38
  out[0] = a[0] * s;
33
39
  out[1] = a[1] * s;
34
40
  out[2] = a[2] * s;
35
41
  return out;
36
42
  }
43
+ /** The dot product of two vectors. */
37
44
  export function vec3Dot(a, b) {
38
45
  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
39
46
  }
47
+ /** The cross product of two vectors. */
40
48
  export function vec3Cross(out, a, b) {
41
49
  const ax = a[0], ay = a[1], az = a[2], bx = b[0], by = b[1], bz = b[2];
42
50
  out[0] = ay * bz - az * by;
@@ -44,9 +52,11 @@ export function vec3Cross(out, a, b) {
44
52
  out[2] = ax * by - ay * bx;
45
53
  return out;
46
54
  }
55
+ /** The length of a vector. */
47
56
  export function vec3Length(a) {
48
57
  return Math.hypot(a[0], a[1], a[2]);
49
58
  }
59
+ /** The distance between two points. */
50
60
  export function vec3Distance(a, b) {
51
61
  return Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]);
52
62
  }
@@ -59,6 +69,7 @@ export function vec3Normalize(out, a) {
59
69
  out[2] = a[2] * inverse;
60
70
  return out;
61
71
  }
72
+ /** The point a fraction of the way from one vector to another. */
62
73
  export function vec3Lerp(out, a, b, t) {
63
74
  out[0] = a[0] + (b[0] - a[0]) * t;
64
75
  out[1] = a[1] + (b[1] - a[1]) * t;
@@ -83,6 +94,7 @@ export function vec3TransformDirection(out, a, m) {
83
94
  out[2] = m[2] * x + m[6] * y + m[10] * z;
84
95
  return out;
85
96
  }
97
+ /** Turns a vector by a quaternion. */
86
98
  export function vec3TransformQuat(out, a, q) {
87
99
  const x = a[0], y = a[1], z = a[2], qx = q[0], qy = q[1], qz = q[2], qw = q[3];
88
100
  // t = 2 * cross(q.xyz, v); v' = v + qw * t + cross(q.xyz, t)
@@ -93,6 +105,7 @@ export function vec3TransformQuat(out, a, q) {
93
105
  return out;
94
106
  }
95
107
  // ---- quaternion (x, y, z, w) -----------------------------------------------
108
+ /** Sets a quaternion to no rotation. */
96
109
  export function quatIdentity(out) {
97
110
  out[0] = 0;
98
111
  out[1] = 0;
@@ -100,6 +113,7 @@ export function quatIdentity(out) {
100
113
  out[3] = 1;
101
114
  return out;
102
115
  }
116
+ /** Copies a quaternion. */
103
117
  export function quatCopy(out, a) {
104
118
  out[0] = a[0];
105
119
  out[1] = a[1];
@@ -107,6 +121,7 @@ export function quatCopy(out, a) {
107
121
  out[3] = a[3];
108
122
  return out;
109
123
  }
124
+ /** Scales a quaternion to length 1. */
110
125
  export function quatNormalize(out, a) {
111
126
  const length = Math.hypot(a[0], a[1], a[2], a[3]);
112
127
  if (length === 0)
@@ -118,6 +133,7 @@ export function quatNormalize(out, a) {
118
133
  out[3] = a[3] * inverse;
119
134
  return out;
120
135
  }
136
+ /** Multiplies two quaternions: the rotation of b, then a. */
121
137
  export function quatMultiply(out, a, b) {
122
138
  const ax = a[0], ay = a[1], az = a[2], aw = a[3], bx = b[0], by = b[1], bz = b[2], bw = b[3];
123
139
  out[0] = ax * bw + aw * bx + ay * bz - az * by;
@@ -126,6 +142,7 @@ export function quatMultiply(out, a, b) {
126
142
  out[3] = aw * bw - ax * bx - ay * by - az * bz;
127
143
  return out;
128
144
  }
145
+ /** A quaternion that turns by an angle about an axis. */
129
146
  export function quatFromAxisAngle(out, axis, radians) {
130
147
  const half = radians * 0.5, s = Math.sin(half);
131
148
  const length = Math.hypot(axis[0], axis[1], axis[2]) || 1;
@@ -223,6 +240,7 @@ export function quatFromRotationMatrix(out, m) {
223
240
  return out;
224
241
  }
225
242
  // ---- mat4 -------------------------------------------------------------------
243
+ /** Sets a 4x4 matrix to the identity. */
226
244
  export function mat4Identity(out) {
227
245
  out[0] = 1;
228
246
  out[1] = 0;
@@ -242,6 +260,7 @@ export function mat4Identity(out) {
242
260
  out[15] = 1;
243
261
  return out;
244
262
  }
263
+ /** Copies a 4x4 matrix. */
245
264
  export function mat4Copy(out, a) {
246
265
  for (let i = 0; i < 16; i++)
247
266
  out[i] = a[i];
@@ -310,6 +329,7 @@ export function mat4Decompose(m, t, q, s) {
310
329
  s[1] = sy;
311
330
  s[2] = sz;
312
331
  }
332
+ /** The determinant of a 4x4 matrix. */
313
333
  export function mat4Determinant(m) {
314
334
  const a00 = m[0], a01 = m[1], a02 = m[2], a03 = m[3], a10 = m[4], a11 = m[5], a12 = m[6], a13 = m[7];
315
335
  const a20 = m[8], a21 = m[9], a22 = m[10], a23 = m[11], a30 = m[12], a31 = m[13], a32 = m[14], a33 = m[15];
@@ -410,6 +430,7 @@ export function mat4Perspective(out, verticalFov, aspect, near, far) {
410
430
  out[15] = 0;
411
431
  return out;
412
432
  }
433
+ /** Sets a 4x4 matrix to an orthographic projection. */
413
434
  export function mat4Orthographic(out, left, right, bottom, top, near, far) {
414
435
  const w = 1 / (right - left), h = 1 / (top - bottom), d = 1 / (near - far);
415
436
  mat4Identity(out);
@@ -438,6 +459,7 @@ export function mat3NormalFromMat4(out, m) {
438
459
  out[8] = (a00 * a11 - a01 * a10) * d;
439
460
  return out;
440
461
  }
462
+ /** The largest scale a 4x4 matrix applies along an axis. */
441
463
  export function mat4MaxScaleOnAxis(m) {
442
464
  const x = m[0] * m[0] + m[1] * m[1] + m[2] * m[2];
443
465
  const y = m[4] * m[4] + m[5] * m[5] + m[6] * m[6];
@@ -445,14 +467,17 @@ export function mat4MaxScaleOnAxis(m) {
445
467
  return Math.sqrt(Math.max(x, y, z));
446
468
  }
447
469
  // ---- bounds: box = [minX, minY, minZ, maxX, maxY, maxZ], sphere = [x, y, z, radius]
470
+ /** Sets a box to empty. */
448
471
  export function box3Empty(out) {
449
472
  out[0] = out[1] = out[2] = Infinity;
450
473
  out[3] = out[4] = out[5] = -Infinity;
451
474
  return out;
452
475
  }
476
+ /** Whether a box is empty. */
453
477
  export function box3IsEmpty(box) {
454
478
  return box[3] < box[0] || box[4] < box[1] || box[5] < box[2];
455
479
  }
480
+ /** Grows a box to hold a point. */
456
481
  export function box3ExpandByPoint(box, x, y, z) {
457
482
  if (x < box[0])
458
483
  box[0] = x;
@@ -467,6 +492,7 @@ export function box3ExpandByPoint(box, x, y, z) {
467
492
  if (z > box[5])
468
493
  box[5] = z;
469
494
  }
495
+ /** The box that holds two boxes. */
470
496
  export function box3Union(out, a, b) {
471
497
  out[0] = Math.min(a[0], b[0]);
472
498
  out[1] = Math.min(a[1], b[1]);
@@ -496,6 +522,7 @@ export function box3Transform(out, box, m) {
496
522
  out[5] = max[2];
497
523
  return out;
498
524
  }
525
+ /** The sphere around a box. */
499
526
  export function sphereFromBox(out, box) {
500
527
  if (box3IsEmpty(box)) {
501
528
  out[0] = out[1] = out[2] = 0;
@@ -508,6 +535,7 @@ export function sphereFromBox(out, box) {
508
535
  out[3] = Math.hypot(box[3] - box[0], box[4] - box[1], box[5] - box[2]) / 2;
509
536
  return out;
510
537
  }
538
+ /** Moves and scales a sphere by a 4x4 matrix. */
511
539
  export function sphereTransform(out, sphere, m) {
512
540
  const radius = sphere[3];
513
541
  vec3TransformMat4(out, sphere, m);
@@ -515,6 +543,7 @@ export function sphereTransform(out, sphere, m) {
515
543
  return out;
516
544
  }
517
545
  // ---- frustum: six inward planes [nx, ny, nz, d] from a view-projection matrix
546
+ /** The six planes of the frustum a projection-view matrix sees. */
518
547
  export function frustumFromMatrix(out, m) {
519
548
  const rows = [0, 1, 2];
520
549
  let o = 0;
@@ -534,6 +563,7 @@ export function frustumFromMatrix(out, m) {
534
563
  }
535
564
  return out;
536
565
  }
566
+ /** Whether a sphere is at least partly inside a frustum. */
537
567
  export function frustumIntersectsSphere(frustum, sphere) {
538
568
  const x = sphere[0], y = sphere[1], z = sphere[2], negativeRadius = -sphere[3];
539
569
  for (let o = 0; o < 24; o += 4) {
@@ -542,6 +572,7 @@ export function frustumIntersectsSphere(frustum, sphere) {
542
572
  }
543
573
  return true;
544
574
  }
575
+ /** Whether a box is at least partly inside a frustum. */
545
576
  export function frustumIntersectsBox(frustum, box) {
546
577
  for (let o = 0; o < 24; o += 4) {
547
578
  const nx = frustum[o], ny = frustum[o + 1], nz = frustum[o + 2];
@@ -620,9 +651,11 @@ export function rayIntersectTriangle(out, origin, direction, p, a, b, c, cull) {
620
651
  return true;
621
652
  }
622
653
  // ---- color -------------------------------------------------------------------
654
+ /** Turns an sRGB color value into a linear one. */
623
655
  export function srgbToLinear(value) {
624
656
  return value <= 0.04045 ? value / 12.92 : Math.pow((value + 0.055) / 1.055, 2.4);
625
657
  }
658
+ /** Turns a linear color value into an sRGB one. */
626
659
  export function linearToSrgb(value) {
627
660
  return value <= 0.0031308 ? value * 12.92 : 1.055 * Math.pow(value, 1 / 2.4) - 0.055;
628
661
  }
@@ -633,8 +666,10 @@ export function colorFromHex(out, hex) {
633
666
  out[2] = srgbToLinear((hex & 255) / 255);
634
667
  return out;
635
668
  }
669
+ /** The value, kept between `min` and `max`. */
636
670
  export function clamp(value, min, max) {
637
671
  return value < min ? min : value > max ? max : value;
638
672
  }
673
+ /** Degrees times this are radians. */
639
674
  export const DEG_TO_RAD_3D = Math.PI / 180;
640
675
  //# sourceMappingURL=math3D.js.map
@@ -1,4 +1,5 @@
1
1
  import { Geometry3D } from './Geometry3D.js';
2
+ /** A box to make: its width, height and depth, and their segments. */
2
3
  export interface BoxGeometryOptions3D {
3
4
  readonly width?: number;
4
5
  readonly height?: number;
@@ -9,6 +10,7 @@ export interface BoxGeometryOptions3D {
9
10
  }
10
11
  /** Axis-aligned box centered on the origin with one material group per face (+X, -X, +Y, -Y, +Z, -Z). */
11
12
  export declare function createBoxGeometry3D(options?: BoxGeometryOptions3D): Geometry3D;
13
+ /** A plane to make: its width and height, and their segments. */
12
14
  export interface PlaneGeometryOptions3D {
13
15
  readonly width?: number;
14
16
  readonly height?: number;
@@ -17,6 +19,7 @@ export interface PlaneGeometryOptions3D {
17
19
  }
18
20
  /** Plane in the XY plane facing +Z. Rotate -90 degrees about X for a floor. */
19
21
  export declare function createPlaneGeometry3D(options?: PlaneGeometryOptions3D): Geometry3D;
22
+ /** A sphere to make: its radius and segments. */
20
23
  export interface SphereGeometryOptions3D {
21
24
  readonly radius?: number;
22
25
  readonly widthSegments?: number;
@@ -24,6 +27,7 @@ export interface SphereGeometryOptions3D {
24
27
  }
25
28
  /** UV sphere with poles on the Y axis. */
26
29
  export declare function createSphereGeometry3D(options?: SphereGeometryOptions3D): Geometry3D;
30
+ /** A cylinder to make: its top and bottom radius, height, segments, and whether its ends are open. */
27
31
  export interface CylinderGeometryOptions3D {
28
32
  readonly radiusTop?: number;
29
33
  readonly radiusBottom?: number;
@@ -34,11 +38,13 @@ export interface CylinderGeometryOptions3D {
34
38
  }
35
39
  /** Cylinder or truncated cone along Y. A zero radius at one end produces a cone. */
36
40
  export declare function createCylinderGeometry3D(options?: CylinderGeometryOptions3D): Geometry3D;
41
+ /** Makes a cone. */
37
42
  export declare function createConeGeometry3D(options?: {
38
43
  readonly radius?: number;
39
44
  readonly height?: number;
40
45
  readonly radialSegments?: number;
41
46
  }): Geometry3D;
47
+ /** A torus to make: its radius, tube and segments. */
42
48
  export interface TorusGeometryOptions3D {
43
49
  readonly radius?: number;
44
50
  readonly tube?: number;
@@ -47,6 +53,7 @@ export interface TorusGeometryOptions3D {
47
53
  }
48
54
  /** Torus around the Z axis. */
49
55
  export declare function createTorusGeometry3D(options?: TorusGeometryOptions3D): Geometry3D;
56
+ /** A capsule to make: its radius, height and segments. */
50
57
  export interface CapsuleGeometryOptions3D {
51
58
  readonly radius?: number;
52
59
  readonly height?: number;
@@ -146,6 +146,7 @@ export function createCylinderGeometry3D(options = {}) {
146
146
  }
147
147
  return builder.build();
148
148
  }
149
+ /** Makes a cone. */
149
150
  export function createConeGeometry3D(options = {}) {
150
151
  return createCylinderGeometry3D({
151
152
  radiusTop: 0,