@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
@@ -8,6 +8,33 @@ export function decodeSharedSRGB(value) {
8
8
  export function decodeSharedSRGBByte(code) {
9
9
  return decodeSRGBByte(code);
10
10
  }
11
+ /** The recipe and target a frame records for each blend space. */
12
+ export const SHARED_BLEND_RECIPES_2D = Object.freeze({
13
+ linear: Object.freeze({
14
+ colorRecipe: 'egret.linear-srgb-pma/1',
15
+ targetRepresentation: 'egret.srgb-pma8-target/1'
16
+ }),
17
+ srgb: Object.freeze({
18
+ colorRecipe: 'egret.srgb-pma/1',
19
+ targetRepresentation: 'egret.encoded-srgb-pma8-target/1'
20
+ })
21
+ });
22
+ /** The blend space of a frame whose recipe and target agree, or undefined. */
23
+ export function sharedBlendSpace2D(frame) {
24
+ for (const space of ['linear', 'srgb']) {
25
+ const recipe = SHARED_BLEND_RECIPES_2D[space];
26
+ if (frame.colorRecipe === recipe.colorRecipe && frame.targetRepresentation === recipe.targetRepresentation)
27
+ return space;
28
+ }
29
+ return undefined;
30
+ }
31
+ /**
32
+ * The 0-to-1 value a target of the blend space holds for a channel byte of a colour: its linear light, or the
33
+ * byte as it is written in a target that mixes the codes.
34
+ */
35
+ export function sharedTargetChannel2D(space, code) {
36
+ return space === 'srgb' ? (code & 255) / 255 : decodeSRGBByte(code);
37
+ }
11
38
  export function encodeSharedSRGB(value) {
12
39
  return value <= 0.0031308 ? 12.92 * value : 1.055 * value ** (1 / 2.4) - 0.055;
13
40
  }
@@ -24,6 +51,65 @@ for (let alpha = 0; alpha < 256; alpha++) {
24
51
  for (let code = 0; code < 256; code++)
25
52
  premultipliedSrgb[(alpha << 8) | code] = Math.min(cap, Math.floor(255 * encodeSharedSRGB(a * decodeSharedSRGB(code / 255)) + 0.5));
26
53
  }
54
+ /**
55
+ * How many levels a page of this size has when it carries its smaller copies: the page itself, then each copy
56
+ * half as large, rounded down and never below one texel, down to one texel.
57
+ */
58
+ export function sharedPageLevels2D(width, height) {
59
+ return 1 + Math.floor(Math.log2(Math.max(width, height)));
60
+ }
61
+ /** The size of each level of a page, and where its bytes start in the page's bytes. */
62
+ export function sharedPageLevelLayout2D(width, height, levels) {
63
+ const layout = [];
64
+ let offset = 0;
65
+ for (let level = 0; level < levels; level++) {
66
+ const w = Math.max(1, width >> level), h = Math.max(1, height >> level);
67
+ layout.push({ width: w, height: h, offset });
68
+ offset += 4 * w * h;
69
+ }
70
+ return layout;
71
+ }
72
+ /** The bytes of a page with `levels` levels: the page's own, then those of each smaller copy after it. */
73
+ export function sharedPageChainBytes2D(width, height, levels) {
74
+ const layout = sharedPageLevelLayout2D(width, height, levels), last = layout[layout.length - 1];
75
+ return last.offset + 4 * last.width * last.height;
76
+ }
77
+ const encodedCode = (value, alpha) => Math.min(caps[alpha], Math.floor(255 * encodeSharedSRGB(value) + 0.5));
78
+ /**
79
+ * Writes each smaller level from the one before it. A texel of a level is the mean of the two by two texels of
80
+ * the level above it that it covers, in linear light with alpha premultiplied, then encoded as the page is.
81
+ * A level above that is one texel wide or high gives that texel twice. An odd last row or column of a level
82
+ * is left out of the next, as a GPU leaves it out when it makes the levels itself.
83
+ */
84
+ function fillSharedLevels2D(chain, width, height, levels) {
85
+ const layout = sharedPageLevelLayout2D(width, height, levels);
86
+ for (let level = 1; level < levels; level++) {
87
+ const above = layout[level - 1], here = layout[level];
88
+ for (let y = 0; y < here.height; y++) {
89
+ const y0 = Math.min(2 * y, above.height - 1), y1 = Math.min(2 * y + 1, above.height - 1);
90
+ for (let x = 0; x < here.width; x++) {
91
+ const x0 = Math.min(2 * x, above.width - 1), x1 = Math.min(2 * x + 1, above.width - 1);
92
+ const taps = [
93
+ above.offset + 4 * (y0 * above.width + x0),
94
+ above.offset + 4 * (y0 * above.width + x1),
95
+ above.offset + 4 * (y1 * above.width + x0),
96
+ above.offset + 4 * (y1 * above.width + x1)
97
+ ];
98
+ let alpha = 0;
99
+ for (const tap of taps)
100
+ alpha += chain[tap + 3];
101
+ const a = Math.floor(alpha / 4 + 0.5), out = here.offset + 4 * (y * here.width + x);
102
+ for (let channel = 0; channel < 3; channel++) {
103
+ let sum = 0;
104
+ for (const tap of taps)
105
+ sum += decodeSRGBByte(chain[tap + channel]);
106
+ chain[out + channel] = encodedCode(sum / 4, a);
107
+ }
108
+ chain[out + 3] = a;
109
+ }
110
+ }
111
+ }
112
+ }
27
113
  function sampleCopy(diagnostics) {
28
114
  diagnostics.highCanonicalBytes = Math.max(diagnostics.highCanonicalBytes, diagnostics.canonicalBytes);
29
115
  diagnostics.highScratchBytes = Math.max(diagnostics.highScratchBytes, diagnostics.scratchBytes);
@@ -32,8 +118,28 @@ function sampleCopy(diagnostics) {
32
118
  diagnostics.saturated = true;
33
119
  diagnostics.highTemporaryBytes = Math.max(diagnostics.highTemporaryBytes, excess ? Number.MAX_SAFE_INTEGER : diagnostics.canonicalBytes + diagnostics.scratchBytes);
34
120
  }
121
+ function writePremultipliedPixel(source, output, offset, alpha) {
122
+ const row = alpha << 8;
123
+ output[offset] = premultipliedSrgb[row | source[offset]];
124
+ output[offset + 1] = premultipliedSrgb[row | source[offset + 1]];
125
+ output[offset + 2] = premultipliedSrgb[row | source[offset + 2]];
126
+ output[offset + 3] = alpha;
127
+ }
128
+ // Four separated neighboring pairs select a loop. Every pixel in the chosen loop still uses its own alpha.
129
+ function hasEndpointRuns(source, start, end) {
130
+ if (end - start < 32)
131
+ return false;
132
+ const stride = Math.floor((end - start) / 16) * 4;
133
+ for (let sample = 0; sample < 4; sample++) {
134
+ const offset = start + sample * stride + 3;
135
+ const alpha = source[offset];
136
+ if ((alpha !== 0 && alpha !== 255) || source[offset + 4] !== alpha)
137
+ return false;
138
+ }
139
+ return true;
140
+ }
35
141
  /** One actual source copy and one tight canonical output; callers reserve that peak first. */
36
- export function copySharedPagePixels(image, diagnostics) {
142
+ export function copySharedPagePixels(image, diagnostics, levels = 1) {
37
143
  let source, output;
38
144
  try {
39
145
  source = copyImageData2DPixels(image);
@@ -41,18 +147,35 @@ export function copySharedPagePixels(image, diagnostics) {
41
147
  diagnostics.scratchBytes += source.byteLength;
42
148
  sampleCopy(diagnostics);
43
149
  }
44
- output = new Uint8Array(source.byteLength);
150
+ output = new Uint8Array(levels === 1 ? source.byteLength : sharedPageChainBytes2D(image.width, image.height, levels));
45
151
  if (diagnostics) {
46
152
  diagnostics.canonicalBytes += output.byteLength;
47
153
  sampleCopy(diagnostics);
48
154
  }
49
- for (let offset = 0; offset < source.length; offset += 4) {
50
- const alpha = source[offset + 3], row = alpha << 8;
51
- output[offset] = premultipliedSrgb[row | source[offset]];
52
- output[offset + 1] = premultipliedSrgb[row | source[offset + 1]];
53
- output[offset + 2] = premultipliedSrgb[row | source[offset + 2]];
54
- output[offset + 3] = alpha;
155
+ const sourceWords = new Uint32Array(source.buffer, source.byteOffset, source.length / 4);
156
+ const outputWords = new Uint32Array(output.buffer, output.byteOffset, sourceWords.length);
157
+ const blockBytes = 1024 * 4;
158
+ for (let start = 0; start < source.length; start += blockBytes) {
159
+ const end = Math.min(start + blockBytes, source.length);
160
+ if (!hasEndpointRuns(source, start, end)) {
161
+ for (let offset = start; offset < end; offset += 4) {
162
+ writePremultipliedPixel(source, output, offset, source[offset + 3]);
163
+ }
164
+ continue;
165
+ }
166
+ for (let offset = start; offset < end; offset += 4) {
167
+ const alpha = source[offset + 3];
168
+ // Transparent black is already zero. Whole-word copying preserves byte order on either endianness.
169
+ if (alpha === 0)
170
+ continue;
171
+ if (alpha === 255)
172
+ outputWords[offset / 4] = sourceWords[offset / 4];
173
+ else
174
+ writePremultipliedPixel(source, output, offset, alpha);
175
+ }
55
176
  }
177
+ if (levels > 1)
178
+ fillSharedLevels2D(output, image.width, image.height, levels);
56
179
  return output;
57
180
  }
58
181
  catch (cause) {
@@ -1,8 +1,8 @@
1
1
  import { decodeSRGBByte } from './srgbBytes.js';
2
2
  /** The bytes of one group's uniform: 36 vectors of four floats. */
3
3
  export const EFFECT_UNIFORM_BYTES = 576;
4
- function fail() {
5
- throw new RangeError('Shared effect limits or geometry are unsupported');
4
+ function fail(detail) {
5
+ throw new RangeError('Shared effect limits or geometry are unsupported' + (detail === undefined ? '' : ': ' + detail));
6
6
  }
7
7
  function inverse(m, rect, ratio) {
8
8
  const det = m.a * m.d - m.b * m.c;
@@ -31,6 +31,8 @@ function inverse(m, rect, ratio) {
31
31
  export function prepareEffects2D(frame, ratio, enabled) {
32
32
  const groups = [], stack = [];
33
33
  let depth = 0;
34
+ // A frame that mixes stored codes holds a glow's colour as its codes; one that mixes light, as linear light.
35
+ const channel = frame.colorRecipe === 'egret.srgb-pma/1' ? (code) => (code & 255) / 255 : decodeSRGBByte;
34
36
  for (const command of frame.commands) {
35
37
  if (command.kind !== 'barrier') {
36
38
  if (stack.length && frame.materials[command.materialIndex]?.blend === 'add-preserve')
@@ -38,8 +40,14 @@ export function prepareEffects2D(frame, ratio, enabled) {
38
40
  continue;
39
41
  }
40
42
  if (command.reason === 'effect-enter') {
41
- if (!enabled || !command.effect || groups.length >= 8 || stack.length >= 4)
43
+ if (!enabled)
44
+ fail('effects are off: make the Host with `effects: true`');
45
+ if (!command.effect)
42
46
  fail();
47
+ if (groups.length >= 8)
48
+ fail('more than 8 effect groups in one frame');
49
+ if (stack.length >= 4)
50
+ fail('effect groups nested more than 4 deep');
43
51
  const e = command.effect, radius = Math.min(16, Math.ceil(e.blurRadius * ratio));
44
52
  if (!Number.isInteger(radius) || radius < 0 || radius > 16 || e.clips.length > 8)
45
53
  fail();
@@ -47,8 +55,8 @@ export function prepareEffects2D(frame, ratio, enabled) {
47
55
  uniform[0] = radius;
48
56
  uniform[2] = e.clips.length;
49
57
  let spread = 0;
50
- // Vector 28: whether there is a colour matrix, the kind of spread, its radius and its strength; 29: its colour in linear
51
- // light and its alpha; 30: its offset in backing pixels, inner and knockout; 31-35: the matrix, by rows, and its offsets.
58
+ // Vector 28: whether there is a colour matrix, the kind of spread, its radius and its strength; 29: its colour as the
59
+ // target holds it (linear light, or the code in an sRGB blend space) and its alpha; 30: its offset in backing pixels, inner and knockout; 31-35: the matrix, by rows, and its offsets.
52
60
  if (e.colorMatrix !== undefined) {
53
61
  if (e.colorMatrix.length !== 20 || e.colorMatrix.some(v => !Number.isFinite(v)))
54
62
  fail();
@@ -70,9 +78,9 @@ export function prepareEffects2D(frame, ratio, enabled) {
70
78
  uniform[113] = g.kind === 'outline' ? 2 : 1;
71
79
  uniform[114] = spread;
72
80
  uniform[115] = g.strength;
73
- uniform[116] = decodeSRGBByte(g.color >> 16);
74
- uniform[117] = decodeSRGBByte(g.color >> 8);
75
- uniform[118] = decodeSRGBByte(g.color);
81
+ uniform[116] = channel(g.color >> 16);
82
+ uniform[117] = channel(g.color >> 8);
83
+ uniform[118] = channel(g.color);
76
84
  uniform[119] = g.alpha;
77
85
  uniform[120] = Math.round(g.offsetX * ratio);
78
86
  uniform[121] = Math.round(g.offsetY * ratio);
@@ -1,12 +1,17 @@
1
1
  import type { Object3D } from './Object3D.js';
2
+ /** What an animation track moves: a node's position, rotation, scale, or morph weights. */
2
3
  export type AnimationPath3D = 'position' | 'quaternion' | 'scale' | 'weights';
4
+ /** How a track goes between its keys: it steps, moves in a line, or follows a cubic spline. */
3
5
  export type AnimationInterpolation3D = 'step' | 'linear' | 'cubic';
6
+ /** How an action plays its clip: over and over, once, or back and forth. */
4
7
  export type AnimationLoop3D = 'repeat' | 'once' | 'pingpong';
8
+ /** The most tracks, keys and actions animations hold. */
5
9
  export declare const ANIMATION3D_LIMITS: Readonly<{
6
10
  readonly maxTracks: 4096;
7
11
  readonly maxKeys: 1048576;
8
12
  readonly maxActions: 256;
9
13
  }>;
14
+ /** A track to make: the node it moves by name, what it moves, its key times and values, and its interpolation. */
10
15
  export interface AnimationTrackInput3D {
11
16
  /** Name of the animated node, resolved under the mixer root. */
12
17
  readonly targetName: string;
@@ -20,6 +25,7 @@ export interface AnimationTrackInput3D {
20
25
  readonly values: ArrayLike<number>;
21
26
  readonly interpolation?: AnimationInterpolation3D;
22
27
  }
28
+ /** One track of a clip: the node it moves, what it moves, its keys and its interpolation. */
23
29
  export interface AnimationTrack3D {
24
30
  readonly targetName: string;
25
31
  readonly path: AnimationPath3D;
@@ -29,12 +35,14 @@ export interface AnimationTrack3D {
29
35
  /** Components per key: 3, 4, or the morph target count. */
30
36
  readonly size: number;
31
37
  }
38
+ /** A named animation: its tracks and its length in seconds. */
32
39
  export declare class AnimationClip3D {
33
40
  readonly name: string;
34
41
  readonly tracks: readonly AnimationTrack3D[];
35
42
  readonly duration: number;
36
43
  constructor(name: string, tracks: readonly AnimationTrackInput3D[], duration?: number);
37
44
  }
45
+ /** Makes a clip from its name and tracks; malformed tracks are refused. */
38
46
  export declare function createAnimationClip3D(input: {
39
47
  readonly name?: string;
40
48
  readonly tracks: readonly AnimationTrackInput3D[];
@@ -44,6 +52,7 @@ export declare function createAnimationClip3D(input: {
44
52
  export declare function sampleAnimationTrack3D(track: AnimationTrack3D, time: number, out: Float32Array, hint: {
45
53
  index: number;
46
54
  }): void;
55
+ /** One clip playing on a mixer: play, stop and reset it, fade it in or out, or cross-fade to another. */
47
56
  export declare class AnimationAction3D {
48
57
  #private;
49
58
  readonly clip: AnimationClip3D;
@@ -5,7 +5,9 @@
5
5
  import { World3DError, requireCount3D, requireFinite3D } from './core3D.js';
6
6
  import { quatNormalize, quatSlerp } from './math3D.js';
7
7
  import { Mesh3D } from './Mesh3D.js';
8
+ /** The most tracks, keys and actions animations hold. */
8
9
  export const ANIMATION3D_LIMITS = Object.freeze({ maxTracks: 4096, maxKeys: 1048576, maxActions: 256 });
10
+ /** A named animation: its tracks and its length in seconds. */
9
11
  export class AnimationClip3D {
10
12
  name;
11
13
  tracks;
@@ -43,6 +45,7 @@ export class AnimationClip3D {
43
45
  this.duration = duration === undefined ? end : requireFinite3D(duration, 'clip duration');
44
46
  }
45
47
  }
48
+ /** Makes a clip from its name and tracks; malformed tracks are refused. */
46
49
  export function createAnimationClip3D(input) {
47
50
  return new AnimationClip3D(input.name ?? '', input.tracks, input.duration);
48
51
  }
@@ -175,6 +178,7 @@ class PropertyMix {
175
178
  this.target.markTransformDirty();
176
179
  }
177
180
  }
181
+ /** One clip playing on a mixer: play, stop and reset it, fade it in or out, or cross-fade to another. */
178
182
  export class AnimationAction3D {
179
183
  clip;
180
184
  /** Blend weight before fading is applied. */
@@ -5,11 +5,13 @@ import type { Material3D } from './Material3D.js';
5
5
  import type { Camera3D } from './Camera3D.js';
6
6
  import { InstancedMesh3D, type Mesh3D } from './Mesh3D.js';
7
7
  import type { Object3D } from './Object3D.js';
8
+ /** The most bone matrices, clips and frames a second an animation texture holds. */
8
9
  export declare const ANIMATION_TEXTURE3D_LIMITS: Readonly<{
9
10
  readonly maxMatrices: 2097152;
10
11
  readonly maxClips: 256;
11
12
  readonly maxFps: 240;
12
13
  }>;
14
+ /** One clip baked into an animation texture: its name, first frame, frame count and length. */
13
15
  export interface BakedClip3D {
14
16
  readonly name: string;
15
17
  /** First frame of the clip in the table. */
@@ -47,6 +49,7 @@ export declare class AnimationTexture3D extends Resource3D {
47
49
  */
48
50
  framesAt(clip: number, time: number, loop: boolean, out: Float32Array | number[], offset?: number): void;
49
51
  }
52
+ /** How many frames a second clips are baked at. */
50
53
  export interface BakeAnimationOptions3D {
51
54
  /** Poses stored per second of each clip. Default 30. */
52
55
  readonly fps?: number;
@@ -59,6 +62,7 @@ export interface BakeAnimationOptions3D {
59
62
  * morph targets where a clip animates them.
60
63
  */
61
64
  export declare function bakeAnimationTexture3D(root: Object3D, mesh: Mesh3D, clips: readonly AnimationClip3D[], options?: BakeAnimationOptions3D): AnimationTexture3D;
65
+ /** How an instance plays a baked clip: from when, how fast, whether it loops and how long it fades. */
62
66
  export interface InstanceClipOptions3D {
63
67
  /** Where in the clip to start, in seconds. Default 0. */
64
68
  readonly time?: number;
@@ -69,6 +73,7 @@ export interface InstanceClipOptions3D {
69
73
  /** Seconds to cross-fade from the clip the instance is playing now, which keeps running while it fades. Default 0. */
70
74
  readonly fade?: number;
71
75
  }
76
+ /** How an instance blends two baked clips: from when, how fast, whether they loop and stay in step. */
72
77
  export interface InstanceBlendOptions3D {
73
78
  readonly time?: number;
74
79
  readonly speed?: number;
@@ -153,5 +158,6 @@ export declare class SkinnedInstancedMesh3D extends InstancedMesh3D {
153
158
  }
154
159
  /** A baked skin can extend beyond the available sphere, including when a bone scales in place. */
155
160
  export declare function worldRenderSphere3D(mesh: Mesh3D): Float32Array | undefined;
161
+ /** Makes many skinned instances of one mesh, each playing baked clips from an animation texture. */
156
162
  export declare function createSkinnedInstancedMesh3D(geometry: Geometry3D, material: Material3D | Material3D[], animations: AnimationTexture3D, capacity: number, instanceColorSize?: 3 | 4): SkinnedInstancedMesh3D;
157
163
  //# sourceMappingURL=AnimationTexture3D.d.ts.map
@@ -16,6 +16,7 @@ function affineScaleBound(m, o) {
16
16
  const columns = Math.max(a + d + g, b + e + h, c + f + i);
17
17
  return Math.sqrt(rows) * Math.sqrt(columns);
18
18
  }
19
+ /** The most bone matrices, clips and frames a second an animation texture holds. */
19
20
  export const ANIMATION_TEXTURE3D_LIMITS = Object.freeze({ maxMatrices: 2097152, maxClips: 256, maxFps: 240 });
20
21
  /**
21
22
  * Bone matrices of one skinned mesh for every frame of a set of clips. The
@@ -595,6 +596,7 @@ export class SkinnedInstancedMesh3D extends InstancedMesh3D {
595
596
  export function worldRenderSphere3D(mesh) {
596
597
  return mesh instanceof SkinnedInstancedMesh3D ? undefined : mesh.worldBoundingSphere;
597
598
  }
599
+ /** Makes many skinned instances of one mesh, each playing baked clips from an animation texture. */
598
600
  export function createSkinnedInstancedMesh3D(geometry, material, animations, capacity, instanceColorSize = 3) {
599
601
  return new SkinnedInstancedMesh3D(geometry, material, animations, capacity, instanceColorSize);
600
602
  }
@@ -3,6 +3,7 @@ import { Geometry3D } from './Geometry3D.js';
3
3
  import { Material3D } from './Material3D.js';
4
4
  import type { ColorInput3D } from './Material3D.js';
5
5
  import { Mesh3D } from './Mesh3D.js';
6
+ /** The most items, vertices and line points a batch holds. */
6
7
  export declare const BATCH3D_LIMITS: Readonly<{
7
8
  readonly maxItems: 65536;
8
9
  readonly maxVertices: 4194304;
@@ -37,6 +38,7 @@ export declare class BatchedMesh3D extends Mesh3D {
37
38
  /** Release the combined geometry. The material stays with its owner. */
38
39
  dispose(): void;
39
40
  }
41
+ /** A thick line to make: its width, whether that width is in screen pixels, its color and whether it closes. */
40
42
  export interface FatLineOptions3D {
41
43
  /** Width in world units, or in pixels when `screenSpace` is set. */
42
44
  readonly width?: number;
@@ -66,6 +68,8 @@ export declare class FatLine3D extends Mesh3D {
66
68
  /** Release the line's own geometry and material. */
67
69
  dispose(): void;
68
70
  }
71
+ /** Makes a mesh that draws many geometries with one material in one draw. */
69
72
  export declare function createBatchedMesh3D(material: Material3D): BatchedMesh3D;
73
+ /** Makes a line of a given thickness through points. */
70
74
  export declare function createFatLine3D(points: ArrayLike<number> | readonly ArrayLike<number>[], options?: FatLineOptions3D): FatLine3D;
71
75
  //# sourceMappingURL=Batch3D.d.ts.map
@@ -3,6 +3,7 @@ import { Attribute3D, Geometry3D } from './Geometry3D.js';
3
3
  import { Material3D } from './Material3D.js';
4
4
  import { mat3NormalFromMat4, mat4Identity } from './math3D.js';
5
5
  import { Mesh3D } from './Mesh3D.js';
6
+ /** The most items, vertices and line points a batch holds. */
6
7
  export const BATCH3D_LIMITS = Object.freeze({ maxItems: 65536, maxVertices: 4194304, maxLinePoints: 65536 });
7
8
  const IDENTITY = mat4Identity(new Float32Array(16));
8
9
  /**
@@ -320,9 +321,11 @@ export class FatLine3D extends Mesh3D {
320
321
  this.material.dispose();
321
322
  }
322
323
  }
324
+ /** Makes a mesh that draws many geometries with one material in one draw. */
323
325
  export function createBatchedMesh3D(material) {
324
326
  return new BatchedMesh3D(material);
325
327
  }
328
+ /** Makes a line of a given thickness through points. */
326
329
  export function createFatLine3D(points, options = {}) {
327
330
  return new FatLine3D(points, options);
328
331
  }
@@ -1,4 +1,5 @@
1
1
  import { Object3D } from './Object3D.js';
2
+ /** A perspective camera to make: its vertical field of view, aspect ratio and near and far planes. */
2
3
  export interface PerspectiveCameraOptions3D {
3
4
  /** Vertical field of view in degrees. */
4
5
  readonly fov?: number;
@@ -6,6 +7,7 @@ export interface PerspectiveCameraOptions3D {
6
7
  readonly near?: number;
7
8
  readonly far?: number;
8
9
  }
10
+ /** An orthographic camera to make: the height it sees, its aspect ratio and near and far planes. */
9
11
  export interface OrthographicCameraOptions3D {
10
12
  /** Visible world height; width follows from the aspect ratio. */
11
13
  readonly height?: number;
@@ -13,6 +15,7 @@ export interface OrthographicCameraOptions3D {
13
15
  readonly near?: number;
14
16
  readonly far?: number;
15
17
  }
18
+ /** A camera: its projection, and calls that turn screen points into rays and world points into screen points. */
16
19
  export declare class Camera3D extends Object3D {
17
20
  #private;
18
21
  readonly projectionKind: 'perspective' | 'orthographic';
@@ -52,6 +55,8 @@ export declare class Camera3D extends Object3D {
52
55
  clone(recursive?: boolean): this;
53
56
  protected copyFrom(source: this): void;
54
57
  }
58
+ /** Makes a perspective camera. */
55
59
  export declare function createPerspectiveCamera3D(options?: PerspectiveCameraOptions3D): Camera3D;
60
+ /** Makes an orthographic camera. */
56
61
  export declare function createOrthographicCamera3D(options?: OrthographicCameraOptions3D): Camera3D;
57
62
  //# sourceMappingURL=Camera3D.d.ts.map
@@ -4,6 +4,7 @@
4
4
  import { World3DError, requireFinite3D, requirePositive3D } from './core3D.js';
5
5
  import { frustumFromMatrix, mat4Invert, mat4Multiply, mat4Orthographic, mat4Perspective, vec3Normalize, vec3Sub, vec3TransformMat4 } from './math3D.js';
6
6
  import { Object3D } from './Object3D.js';
7
+ /** A camera: its projection, and calls that turn screen points into rays and world points into screen points. */
7
8
  export class Camera3D extends Object3D {
8
9
  projectionKind;
9
10
  fov = 50;
@@ -108,6 +109,7 @@ export class Camera3D extends Object3D {
108
109
  this.customProjection = source.customProjection === undefined ? undefined : Array.from(source.customProjection);
109
110
  }
110
111
  }
112
+ /** Makes a perspective camera. */
111
113
  export function createPerspectiveCamera3D(options = {}) {
112
114
  const camera = new Camera3D('perspective');
113
115
  camera.fov = options.fov ?? 50;
@@ -117,6 +119,7 @@ export function createPerspectiveCamera3D(options = {}) {
117
119
  camera.updateProjectionMatrix();
118
120
  return camera;
119
121
  }
122
+ /** Makes an orthographic camera. */
120
123
  export function createOrthographicCamera3D(options = {}) {
121
124
  const camera = new Camera3D('orthographic');
122
125
  camera.orthographicHeight = options.height ?? 10;
@@ -2,6 +2,7 @@ import type { Camera3D } from './Camera3D.js';
2
2
  import type { Object3D } from './Object3D.js';
3
3
  import { CharacterController3D } from './Physics3D.js';
4
4
  import type { CharacterControllerOptions3D, PhysicsWorld3D, RigidBody3D } from './Physics3D.js';
5
+ /** How a character moves: its jump and gravity, the steps it climbs, its acceleration and air control, and its grace time to jump. */
5
6
  export interface CharacterMotorOptions3D extends CharacterControllerOptions3D {
6
7
  /** Upward speed given by a jump, in units per second. Defaults to 5. */
7
8
  readonly jumpSpeed?: number;
@@ -63,6 +64,7 @@ export declare class CharacterMotor3D {
63
64
  */
64
65
  update(deltaSeconds: number, wishX: number, wishZ: number, jump?: boolean): void;
65
66
  }
67
+ /** How a follow camera keeps behind its target: its distance and height, its angles, and what it keeps clear of. */
66
68
  export interface FollowCameraOptions3D {
67
69
  /** Distance kept behind the target when nothing is in the way. Defaults to 6. */
68
70
  readonly distance?: number;
@@ -118,6 +120,8 @@ export declare class FollowCamera3D {
118
120
  /** Place the camera for the current target, angles and distance. */
119
121
  update(deltaSeconds?: number): void;
120
122
  }
123
+ /** Makes a character motor that walks, jumps and climbs steps in a physics world. */
121
124
  export declare function createCharacterMotor3D(world: PhysicsWorld3D, options?: CharacterMotorOptions3D): CharacterMotor3D;
125
+ /** Makes a camera that follows a target and keeps out of walls. */
122
126
  export declare function createFollowCamera3D(camera: Camera3D, target: Object3D | ArrayLike<number>, options?: FollowCameraOptions3D): FollowCamera3D;
123
127
  //# sourceMappingURL=Character3D.d.ts.map
@@ -294,9 +294,11 @@ export class FollowCamera3D {
294
294
  camera.lookAt(pivot[0], pivot[1], pivot[2]);
295
295
  }
296
296
  }
297
+ /** Makes a character motor that walks, jumps and climbs steps in a physics world. */
297
298
  export function createCharacterMotor3D(world, options = {}) {
298
299
  return new CharacterMotor3D(world, options);
299
300
  }
301
+ /** Makes a camera that follows a target and keeps out of walls. */
300
302
  export function createFollowCamera3D(camera, target, options = {}) {
301
303
  return new FollowCamera3D(camera, target, options);
302
304
  }
@@ -1,10 +1,12 @@
1
1
  import type { Material3D } from './Material3D.js';
2
2
  import { Mesh3D } from './Mesh3D.js';
3
3
  import type { RigidBody3D } from './Physics3D.js';
4
+ /** The most points and colliders cloth and ropes hold. */
4
5
  export declare const CLOTH3D_LIMITS: Readonly<{
5
6
  readonly maxPoints: 16384;
6
7
  readonly maxColliders: 32;
7
8
  }>;
9
+ /** How a strand of points behaves: its gravity, damping, iterations, thickness, and what it collides with. */
8
10
  export interface StrandOptions3D {
9
11
  /** Pull on every point, as an acceleration. Defaults to 9.81 downward. */
10
12
  readonly gravity?: readonly [number, number, number];
@@ -44,7 +46,9 @@ declare class Strands3D {
44
46
  setPoint(index: number, x: number, y: number, z: number): void;
45
47
  /**
46
48
  * Hold a point where it is now. With a body, the point keeps its place on
47
- * that body and follows it as the body moves and turns.
49
+ * that body and follows it as the body moves and turns. The pin is one-way:
50
+ * the cloth or rope follows the body and never pulls on it, so a tarp on a
51
+ * truck does not slow the truck.
48
52
  */
49
53
  pinPoint(index: number, body?: RigidBody3D): void;
50
54
  unpinPoint(index: number): void;
@@ -53,12 +57,17 @@ declare class Strands3D {
53
57
  protected advance(deltaSeconds: number): void;
54
58
  private collide;
55
59
  }
60
+ /** A rope to make: from where to where, in how many segments, how slack, and which ends are pinned. */
56
61
  export interface RopeOptions3D extends StrandOptions3D {
57
62
  readonly start: readonly [number, number, number];
58
63
  readonly end: readonly [number, number, number];
59
64
  /** Number of links. Defaults to 16. */
60
65
  readonly segments?: number;
61
- /** Extra length as a share of the straight distance, so the rope hangs in a curve. Defaults to 0. */
66
+ /**
67
+ * Extra length as a share of the straight distance between its ends, so the rope hangs in a curve: 0 is taut, 0.01
68
+ * barely sags, 0.1 is a tenth longer, 0.33 hangs loose. It is not a multiple of the length: 1 is a rope twice as long
69
+ * as the gap, which folds on itself. Defaults to 0.
70
+ */
62
71
  readonly slack?: number;
63
72
  /** Hold the first or the last point in place, or on a body. Both ends are free unless pinned. */
64
73
  readonly pinStart?: boolean | RigidBody3D;
@@ -80,13 +89,17 @@ export declare class Rope3D extends Strands3D {
80
89
  update(deltaSeconds: number): void;
81
90
  private rebuild;
82
91
  }
92
+ /** A cloth to make: its columns and rows, where it starts and which way it spreads, and how stiff it is. */
83
93
  export interface ClothOptions3D extends StrandOptions3D {
84
94
  /** Number of points across and down; at least two each. */
85
95
  readonly columns: number;
86
96
  readonly rows: number;
87
97
  /** World position of the first point of the first row. */
88
98
  readonly origin: readonly [number, number, number];
89
- /** Vectors along a full row and down a full column. */
99
+ /**
100
+ * Vectors along a whole row and down a whole column: the width and the height of the sheet, not the gap between two
101
+ * points. A tarp 3 wide and 2 deep is `right: [3, 0, 0]`, `down: [0, -2, 0]`, whatever its columns and rows.
102
+ */
90
103
  readonly right: readonly [number, number, number];
91
104
  readonly down: readonly [number, number, number];
92
105
  /** Add links that skip a point, which makes the cloth resist folding. Defaults to true. */
@@ -109,7 +122,9 @@ export declare class Cloth3D extends Strands3D {
109
122
  update(deltaSeconds: number): void;
110
123
  private rebuild;
111
124
  }
125
+ /** Makes a rope of points that hangs and swings. */
112
126
  export declare function createRope3D(options: RopeOptions3D): Rope3D;
127
+ /** Makes a sheet of cloth that hangs, folds and blows. */
113
128
  export declare function createCloth3D(options: ClothOptions3D): Cloth3D;
114
129
  export {};
115
130
  //# sourceMappingURL=Cloth3D.d.ts.map
@@ -7,6 +7,7 @@
7
7
  import { World3DError, requireCount3D, requireFinite3D, requirePositive3D } from './core3D.js';
8
8
  import { Attribute3D, Geometry3D } from './Geometry3D.js';
9
9
  import { Mesh3D } from './Mesh3D.js';
10
+ /** The most points and colliders cloth and ropes hold. */
10
11
  export const CLOTH3D_LIMITS = Object.freeze({ maxPoints: 16384, maxColliders: 32 });
11
12
  /** Points and links shared by ropes and cloth. */
12
13
  class Strands3D {
@@ -89,7 +90,9 @@ class Strands3D {
89
90
  }
90
91
  /**
91
92
  * Hold a point where it is now. With a body, the point keeps its place on
92
- * that body and follows it as the body moves and turns.
93
+ * that body and follows it as the body moves and turns. The pin is one-way:
94
+ * the cloth or rope follows the body and never pulls on it, so a tarp on a
95
+ * truck does not slow the truck.
93
96
  */
94
97
  pinPoint(index, body) {
95
98
  this.check(index);
@@ -489,9 +492,11 @@ export class Cloth3D extends Strands3D {
489
492
  mesh.geometry.invalidateBounds();
490
493
  }
491
494
  }
495
+ /** Makes a rope of points that hangs and swings. */
492
496
  export function createRope3D(options) {
493
497
  return new Rope3D(options);
494
498
  }
499
+ /** Makes a sheet of cloth that hangs, folds and blows. */
495
500
  export function createCloth3D(options) {
496
501
  return new Cloth3D(options);
497
502
  }
@@ -1,3 +1,4 @@
1
+ /** The most bytes a decompression gives. */
1
2
  export declare const COMPRESSION3D_LIMITS: Readonly<{
2
3
  readonly maxOutputBytes: 536870912;
3
4
  }>;
@@ -5,6 +5,7 @@
5
5
  // on whole buffers. Zstandard dictionaries are not supported, and checksums
6
6
  // are skipped rather than verified.
7
7
  import { World3DError } from './core3D.js';
8
+ /** The most bytes a decompression gives. */
8
9
  export const COMPRESSION3D_LIMITS = Object.freeze({ maxOutputBytes: 536870912 });
9
10
  const bad = (detail) => new World3DError('WORLD3D_INPUT_INVALID', 'compressed data: ' + detail);
10
11
  const tooBig = () => new World3DError('WORLD3D_BUDGET', 'decompressed size');