@egret/engine 0.0.0-stage → 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 (601) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +21 -0
  3. package/README.md +101 -2
  4. package/README.zh-CN.md +102 -0
  5. package/dist/Engine.d.ts +77 -0
  6. package/dist/Engine.js +469 -0
  7. package/dist/animation/index.d.ts +6 -0
  8. package/dist/animation/index.js +5 -0
  9. package/dist/animation/sequenceController.d.ts +22 -0
  10. package/dist/animation/sequenceController.js +618 -0
  11. package/dist/animation/sequenceCoordinator.d.ts +26 -0
  12. package/dist/animation/sequenceCoordinator.js +161 -0
  13. package/dist/animation/sequenceInput.d.ts +25 -0
  14. package/dist/animation/sequenceInput.js +108 -0
  15. package/dist/animation/sequenceMath.d.ts +35 -0
  16. package/dist/animation/sequenceMath.js +164 -0
  17. package/dist/animation/sequenceResetSlot.d.ts +7 -0
  18. package/dist/animation/sequenceResetSlot.js +367 -0
  19. package/dist/animation/sequenceResetTypes.d.ts +48 -0
  20. package/dist/animation/sequenceResetTypes.js +2 -0
  21. package/dist/animation/types.d.ts +75 -0
  22. package/dist/animation/types.js +2 -0
  23. package/dist/assetBundle.d.ts +54 -0
  24. package/dist/assetBundle.js +173 -0
  25. package/dist/assetGroup.d.ts +17 -0
  26. package/dist/assetGroup.js +332 -0
  27. package/dist/assetGroupTypes.d.ts +17 -0
  28. package/dist/assetGroupTypes.js +2 -0
  29. package/dist/audio.d.ts +4 -0
  30. package/dist/audio.js +4 -0
  31. package/dist/audioCues.d.ts +47 -0
  32. package/dist/audioCues.js +127 -0
  33. package/dist/audioMixer.d.ts +7 -0
  34. package/dist/audioMixer.js +785 -0
  35. package/dist/audioTypes.d.ts +246 -0
  36. package/dist/audioTypes.js +3 -0
  37. package/dist/bitmapBindingTicket.d.ts +24 -0
  38. package/dist/bitmapBindingTicket.js +215 -0
  39. package/dist/bitmapButton.d.ts +4 -0
  40. package/dist/bitmapButton.js +407 -0
  41. package/dist/bitmapButtonTypes.d.ts +31 -0
  42. package/dist/bitmapButtonTypes.js +2 -0
  43. package/dist/bitmapFontParse.d.ts +10 -0
  44. package/dist/bitmapFontParse.js +246 -0
  45. package/dist/bitmapFontTypes.d.ts +112 -0
  46. package/dist/bitmapFontTypes.js +2 -0
  47. package/dist/bitmapResourceSlot.d.ts +26 -0
  48. package/dist/bitmapResourceSlot.js +340 -0
  49. package/dist/bitmapText.d.ts +6 -0
  50. package/dist/bitmapText.js +320 -0
  51. package/dist/bitmapfont.d.ts +5 -0
  52. package/dist/bitmapfont.js +5 -0
  53. package/dist/camera.d.ts +4 -0
  54. package/dist/camera.js +4 -0
  55. package/dist/camera2d.d.ts +7 -0
  56. package/dist/camera2d.js +419 -0
  57. package/dist/cameraTypes.d.ts +126 -0
  58. package/dist/cameraTypes.js +2 -0
  59. package/dist/closeHost.d.ts +4 -0
  60. package/dist/closeHost.js +66 -0
  61. package/dist/contentArtifacts.d.ts +12 -0
  62. package/dist/contentArtifacts.js +153 -0
  63. package/dist/contentAtlasPages.d.ts +13 -0
  64. package/dist/contentAtlasPages.js +117 -0
  65. package/dist/contentLoader.d.ts +6 -0
  66. package/dist/contentLoader.js +327 -0
  67. package/dist/contentTypes.d.ts +35 -0
  68. package/dist/contentTypes.js +2 -0
  69. package/dist/createEngine.d.ts +7 -0
  70. package/dist/createEngine.js +25 -0
  71. package/dist/createEngineForProfile.d.ts +5 -0
  72. package/dist/createEngineForProfile.js +45 -0
  73. package/dist/displaySubtreeTicket.d.ts +25 -0
  74. package/dist/displaySubtreeTicket.js +76 -0
  75. package/dist/fontContentLoader.d.ts +6 -0
  76. package/dist/fontContentLoader.js +298 -0
  77. package/dist/fontContentTypes.d.ts +39 -0
  78. package/dist/fontContentTypes.js +2 -0
  79. package/dist/gameClock.d.ts +24 -0
  80. package/dist/gameClock.js +246 -0
  81. package/dist/gameClockTypes.d.ts +37 -0
  82. package/dist/gameClockTypes.js +2 -0
  83. package/dist/gameRun.d.ts +53 -0
  84. package/dist/gameRun.js +97 -0
  85. package/dist/gamepad.d.ts +5 -0
  86. package/dist/gamepad.js +5 -0
  87. package/dist/gamepadInput.d.ts +4 -0
  88. package/dist/gamepadInput.js +281 -0
  89. package/dist/gamepadKeys.d.ts +4 -0
  90. package/dist/gamepadKeys.js +205 -0
  91. package/dist/gamepadTypes.d.ts +142 -0
  92. package/dist/gamepadTypes.js +3 -0
  93. package/dist/hover.d.ts +4 -0
  94. package/dist/hover.js +4 -0
  95. package/dist/hoverInput.d.ts +8 -0
  96. package/dist/hoverInput.js +503 -0
  97. package/dist/hoverInputTypes.d.ts +129 -0
  98. package/dist/hoverInputTypes.js +2 -0
  99. package/dist/index.d.ts +52 -0
  100. package/dist/index.js +21 -0
  101. package/dist/input.d.ts +6 -0
  102. package/dist/input.js +5 -0
  103. package/dist/inputActions.d.ts +86 -0
  104. package/dist/inputActions.js +330 -0
  105. package/dist/internal/contentFactoryState.d.ts +19 -0
  106. package/dist/internal/contentFactoryState.js +42 -0
  107. package/dist/internal/mouseInputFactoryState.d.ts +57 -0
  108. package/dist/internal/mouseInputFactoryState.js +125 -0
  109. package/dist/internal/sequenceControllerFactoryState.d.ts +42 -0
  110. package/dist/internal/sequenceControllerFactoryState.js +98 -0
  111. package/dist/internal/textFieldFactoryState.d.ts +11 -0
  112. package/dist/internal/textFieldFactoryState.js +32 -0
  113. package/dist/internal/texturedFrameState.d.ts +4 -0
  114. package/dist/internal/texturedFrameState.js +12 -0
  115. package/dist/internal/uiFactoryState.d.ts +68 -0
  116. package/dist/internal/uiFactoryState.js +173 -0
  117. package/dist/internal/uiRootState.d.ts +67 -0
  118. package/dist/internal/uiRootState.js +103 -0
  119. package/dist/keyboardInput.d.ts +13 -0
  120. package/dist/keyboardInput.js +579 -0
  121. package/dist/keyboardInputTypes.d.ts +93 -0
  122. package/dist/keyboardInputTypes.js +2 -0
  123. package/dist/kit.d.ts +16 -0
  124. package/dist/kit.js +10 -0
  125. package/dist/layout.d.ts +5 -0
  126. package/dist/layout.js +132 -0
  127. package/dist/layoutTypes.d.ts +28 -0
  128. package/dist/layoutTypes.js +2 -0
  129. package/dist/manifestAssetGroup.d.ts +10 -0
  130. package/dist/manifestAssetGroup.js +477 -0
  131. package/dist/manifestResourceState.d.ts +17 -0
  132. package/dist/manifestResourceState.js +58 -0
  133. package/dist/manifestResourceTypes.d.ts +26 -0
  134. package/dist/manifestResourceTypes.js +2 -0
  135. package/dist/motion.d.ts +35 -0
  136. package/dist/motion.js +206 -0
  137. package/dist/mouseInput.d.ts +102 -0
  138. package/dist/mouseInput.js +562 -0
  139. package/dist/mouseInputTypes.d.ts +41 -0
  140. package/dist/mouseInputTypes.js +2 -0
  141. package/dist/paragraph.d.ts +8 -0
  142. package/dist/paragraph.js +7 -0
  143. package/dist/particleEmitter.d.ts +4 -0
  144. package/dist/particleEmitter.js +300 -0
  145. package/dist/particleTypes.d.ts +115 -0
  146. package/dist/particleTypes.js +2 -0
  147. package/dist/particles.d.ts +4 -0
  148. package/dist/particles.js +4 -0
  149. package/dist/physics2d.d.ts +4 -0
  150. package/dist/physics2d.js +4 -0
  151. package/dist/physics2dGeometry.d.ts +39 -0
  152. package/dist/physics2dGeometry.js +230 -0
  153. package/dist/physics2dTypes.d.ts +221 -0
  154. package/dist/physics2dTypes.js +2 -0
  155. package/dist/physics2dWorld.d.ts +4 -0
  156. package/dist/physics2dWorld.js +823 -0
  157. package/dist/pointerInput.d.ts +12 -0
  158. package/dist/pointerInput.js +300 -0
  159. package/dist/pointerInputTypes.d.ts +41 -0
  160. package/dist/pointerInputTypes.js +2 -0
  161. package/dist/random.d.ts +30 -0
  162. package/dist/random.js +131 -0
  163. package/dist/rendering/ownedPreparationFailure2D.d.ts +5 -0
  164. package/dist/rendering/ownedPreparationFailure2D.js +33 -0
  165. package/dist/rendering/packSharedDraws2D.d.ts +50 -0
  166. package/dist/rendering/packSharedDraws2D.js +379 -0
  167. package/dist/rendering/packedOrientation.d.ts +4 -0
  168. package/dist/rendering/packedOrientation.js +7 -0
  169. package/dist/rendering/prepareRectangles2D.d.ts +92 -0
  170. package/dist/rendering/prepareRectangles2D.js +481 -0
  171. package/dist/rendering/prepareSharedDraws2D.d.ts +90 -0
  172. package/dist/rendering/prepareSharedDraws2D.js +663 -0
  173. package/dist/rendering/preparedBatches2D.d.ts +17 -0
  174. package/dist/rendering/preparedBatches2D.js +30 -0
  175. package/dist/rendering/preparedSharedBatches2D.d.ts +44 -0
  176. package/dist/rendering/preparedSharedBatches2D.js +247 -0
  177. package/dist/rendering/sharedColor2D.d.ts +52 -0
  178. package/dist/rendering/sharedColor2D.js +191 -0
  179. package/dist/rendering/sharedEffects2D.d.ts +23 -0
  180. package/dist/rendering/sharedEffects2D.js +126 -0
  181. package/dist/rendering/sharedPreparationRetention2D.d.ts +120 -0
  182. package/dist/rendering/sharedPreparationRetention2D.js +357 -0
  183. package/dist/rendering/srgbBytes.d.ts +3 -0
  184. package/dist/rendering/srgbBytes.js +64 -0
  185. package/dist/rendering/texturedPreparationBudget2D.d.ts +31 -0
  186. package/dist/rendering/texturedPreparationBudget2D.js +81 -0
  187. package/dist/rendering/world3d/Animation3D.d.ts +104 -0
  188. package/dist/rendering/world3d/Animation3D.js +384 -0
  189. package/dist/rendering/world3d/AnimationTexture3D.d.ts +163 -0
  190. package/dist/rendering/world3d/AnimationTexture3D.js +603 -0
  191. package/dist/rendering/world3d/Batch3D.d.ts +75 -0
  192. package/dist/rendering/world3d/Batch3D.js +332 -0
  193. package/dist/rendering/world3d/Camera3D.d.ts +62 -0
  194. package/dist/rendering/world3d/Camera3D.js +132 -0
  195. package/dist/rendering/world3d/Character3D.d.ts +127 -0
  196. package/dist/rendering/world3d/Character3D.js +305 -0
  197. package/dist/rendering/world3d/Cloth3D.d.ts +130 -0
  198. package/dist/rendering/world3d/Cloth3D.js +503 -0
  199. package/dist/rendering/world3d/Compression3D.d.ts +22 -0
  200. package/dist/rendering/world3d/Compression3D.js +703 -0
  201. package/dist/rendering/world3d/Curves3D.d.ts +119 -0
  202. package/dist/rendering/world3d/Curves3D.js +460 -0
  203. package/dist/rendering/world3d/Decal3D.d.ts +43 -0
  204. package/dist/rendering/world3d/Decal3D.js +242 -0
  205. package/dist/rendering/world3d/Export3D.d.ts +13 -0
  206. package/dist/rendering/world3d/Export3D.js +263 -0
  207. package/dist/rendering/world3d/Geometry3D.d.ts +95 -0
  208. package/dist/rendering/world3d/Geometry3D.js +335 -0
  209. package/dist/rendering/world3d/GeometryBuilder3D.d.ts +53 -0
  210. package/dist/rendering/world3d/GeometryBuilder3D.js +196 -0
  211. package/dist/rendering/world3d/Gizmo3D.d.ts +80 -0
  212. package/dist/rendering/world3d/Gizmo3D.js +514 -0
  213. package/dist/rendering/world3d/Gltf3D.d.ts +73 -0
  214. package/dist/rendering/world3d/Gltf3D.js +996 -0
  215. package/dist/rendering/world3d/GpuParticles3D.d.ts +109 -0
  216. package/dist/rendering/world3d/GpuParticles3D.js +401 -0
  217. package/dist/rendering/world3d/Hdr3D.d.ts +35 -0
  218. package/dist/rendering/world3d/Hdr3D.js +191 -0
  219. package/dist/rendering/world3d/Jelly3D.d.ts +77 -0
  220. package/dist/rendering/world3d/Jelly3D.js +267 -0
  221. package/dist/rendering/world3d/Ktx23D.d.ts +30 -0
  222. package/dist/rendering/world3d/Ktx23D.js +112 -0
  223. package/dist/rendering/world3d/Light3D.d.ts +84 -0
  224. package/dist/rendering/world3d/Light3D.js +97 -0
  225. package/dist/rendering/world3d/Material3D.d.ts +253 -0
  226. package/dist/rendering/world3d/Material3D.js +269 -0
  227. package/dist/rendering/world3d/Mesh3D.d.ts +112 -0
  228. package/dist/rendering/world3d/Mesh3D.js +337 -0
  229. package/dist/rendering/world3d/Meshopt3D.d.ts +15 -0
  230. package/dist/rendering/world3d/Meshopt3D.js +276 -0
  231. package/dist/rendering/world3d/Navigation3D.d.ts +213 -0
  232. package/dist/rendering/world3d/Navigation3D.js +1043 -0
  233. package/dist/rendering/world3d/Object3D.d.ts +118 -0
  234. package/dist/rendering/world3d/Object3D.js +315 -0
  235. package/dist/rendering/world3d/Particles3D.d.ts +90 -0
  236. package/dist/rendering/world3d/Particles3D.js +277 -0
  237. package/dist/rendering/world3d/Physics3D.d.ts +430 -0
  238. package/dist/rendering/world3d/Physics3D.js +2840 -0
  239. package/dist/rendering/world3d/PhysicsHull3D.d.ts +37 -0
  240. package/dist/rendering/world3d/PhysicsHull3D.js +229 -0
  241. package/dist/rendering/world3d/PhysicsMesh3D.d.ts +41 -0
  242. package/dist/rendering/world3d/PhysicsMesh3D.js +340 -0
  243. package/dist/rendering/world3d/PhysicsQueries3D.d.ts +24 -0
  244. package/dist/rendering/world3d/PhysicsQueries3D.js +323 -0
  245. package/dist/rendering/world3d/PhysicsRemote3D.d.ts +179 -0
  246. package/dist/rendering/world3d/PhysicsRemote3D.js +536 -0
  247. package/dist/rendering/world3d/Ragdoll3D.d.ts +74 -0
  248. package/dist/rendering/world3d/Ragdoll3D.js +202 -0
  249. package/dist/rendering/world3d/Raycast3D.d.ts +40 -0
  250. package/dist/rendering/world3d/Raycast3D.js +247 -0
  251. package/dist/rendering/world3d/RenderList3D.d.ts +91 -0
  252. package/dist/rendering/world3d/RenderList3D.js +502 -0
  253. package/dist/rendering/world3d/Retarget3D.d.ts +21 -0
  254. package/dist/rendering/world3d/Retarget3D.js +185 -0
  255. package/dist/rendering/world3d/Rig3D.d.ts +57 -0
  256. package/dist/rendering/world3d/Rig3D.js +219 -0
  257. package/dist/rendering/world3d/Sdf3D.d.ts +181 -0
  258. package/dist/rendering/world3d/Sdf3D.js +1136 -0
  259. package/dist/rendering/world3d/SdfLod3D.d.ts +17 -0
  260. package/dist/rendering/world3d/SdfLod3D.js +56 -0
  261. package/dist/rendering/world3d/Serialize3D.d.ts +66 -0
  262. package/dist/rendering/world3d/Serialize3D.js +629 -0
  263. package/dist/rendering/world3d/Simplify3D.d.ts +29 -0
  264. package/dist/rendering/world3d/Simplify3D.js +426 -0
  265. package/dist/rendering/world3d/StateMachine3D.d.ts +87 -0
  266. package/dist/rendering/world3d/StateMachine3D.js +280 -0
  267. package/dist/rendering/world3d/SurfaceMaterial3D.d.ts +26 -0
  268. package/dist/rendering/world3d/SurfaceMaterial3D.js +138 -0
  269. package/dist/rendering/world3d/Terrain3D.d.ts +248 -0
  270. package/dist/rendering/world3d/Terrain3D.js +827 -0
  271. package/dist/rendering/world3d/Text3D.d.ts +95 -0
  272. package/dist/rendering/world3d/Text3D.js +560 -0
  273. package/dist/rendering/world3d/Texture3D.d.ts +148 -0
  274. package/dist/rendering/world3d/Texture3D.js +270 -0
  275. package/dist/rendering/world3d/Trail3D.d.ts +62 -0
  276. package/dist/rendering/world3d/Trail3D.js +195 -0
  277. package/dist/rendering/world3d/Vehicle3D.d.ts +102 -0
  278. package/dist/rendering/world3d/Vehicle3D.js +228 -0
  279. package/dist/rendering/world3d/VolumetricFog3D.d.ts +57 -0
  280. package/dist/rendering/world3d/VolumetricFog3D.js +230 -0
  281. package/dist/rendering/world3d/Water3D.d.ts +165 -0
  282. package/dist/rendering/world3d/Water3D.js +607 -0
  283. package/dist/rendering/world3d/core3D.d.ts +36 -0
  284. package/dist/rendering/world3d/core3D.js +99 -0
  285. package/dist/rendering/world3d/debug3D.d.ts +69 -0
  286. package/dist/rendering/world3d/debug3D.js +262 -0
  287. package/dist/rendering/world3d/decoders3D.d.ts +42 -0
  288. package/dist/rendering/world3d/decoders3D.js +133 -0
  289. package/dist/rendering/world3d/geometries3D.d.ts +111 -0
  290. package/dist/rendering/world3d/geometries3D.js +610 -0
  291. package/dist/rendering/world3d/helpers3D.d.ts +67 -0
  292. package/dist/rendering/world3d/helpers3D.js +178 -0
  293. package/dist/rendering/world3d/index.d.ts +103 -0
  294. package/dist/rendering/world3d/index.js +62 -0
  295. package/dist/rendering/world3d/math3D.d.ts +114 -0
  296. package/dist/rendering/world3d/math3D.js +675 -0
  297. package/dist/rendering/world3d/primitives3D.d.ts +67 -0
  298. package/dist/rendering/world3d/primitives3D.js +197 -0
  299. package/dist/resources.d.ts +8 -0
  300. package/dist/resources.js +6 -0
  301. package/dist/saveStore.d.ts +71 -0
  302. package/dist/saveStore.js +182 -0
  303. package/dist/semanticList.d.ts +126 -0
  304. package/dist/semanticList.js +175 -0
  305. package/dist/semanticTree.d.ts +10 -0
  306. package/dist/semanticTree.js +539 -0
  307. package/dist/semanticTypes.d.ts +175 -0
  308. package/dist/semanticTypes.js +2 -0
  309. package/dist/semantics.d.ts +6 -0
  310. package/dist/semantics.js +5 -0
  311. package/dist/sequencePlayback.d.ts +19 -0
  312. package/dist/sequencePlayback.js +391 -0
  313. package/dist/sequencePlaybackTypes.d.ts +24 -0
  314. package/dist/sequencePlaybackTypes.js +2 -0
  315. package/dist/sequenceTargetClaims.d.ts +10 -0
  316. package/dist/sequenceTargetClaims.js +31 -0
  317. package/dist/srgbBytes.d.ts +3 -0
  318. package/dist/srgbBytes.js +64 -0
  319. package/dist/startEngine.d.ts +5 -0
  320. package/dist/startEngine.js +31 -0
  321. package/dist/surfaceOwnership.d.ts +3 -0
  322. package/dist/surfaceOwnership.js +15 -0
  323. package/dist/text.d.ts +24 -0
  324. package/dist/text.js +4 -0
  325. package/dist/textField.d.ts +6 -0
  326. package/dist/textField.js +6 -0
  327. package/dist/textTable.d.ts +41 -0
  328. package/dist/textTable.js +114 -0
  329. package/dist/tileMapDraw.d.ts +7 -0
  330. package/dist/tileMapDraw.js +310 -0
  331. package/dist/tiledImport.d.ts +9 -0
  332. package/dist/tiledImport.js +357 -0
  333. package/dist/tilemap.d.ts +5 -0
  334. package/dist/tilemap.js +5 -0
  335. package/dist/tilemapTypes.d.ts +182 -0
  336. package/dist/tilemapTypes.js +2 -0
  337. package/dist/timer.d.ts +34 -0
  338. package/dist/timer.js +119 -0
  339. package/dist/tween.d.ts +15 -0
  340. package/dist/tween.js +329 -0
  341. package/dist/tweenTypes.d.ts +31 -0
  342. package/dist/tweenTypes.js +2 -0
  343. package/dist/ui/controlKeys.d.ts +113 -0
  344. package/dist/ui/controlKeys.js +250 -0
  345. package/dist/ui/controls.d.ts +58 -0
  346. package/dist/ui/controls.js +290 -0
  347. package/dist/ui/editing.d.ts +3 -0
  348. package/dist/ui/editing.js +3 -0
  349. package/dist/ui/index.d.ts +19 -0
  350. package/dist/ui/index.js +11 -0
  351. package/dist/ui/keyboardFocus.d.ts +32 -0
  352. package/dist/ui/keyboardFocus.js +146 -0
  353. package/dist/ui/layerTypes.d.ts +98 -0
  354. package/dist/ui/layerTypes.js +2 -0
  355. package/dist/ui/layers.d.ts +4 -0
  356. package/dist/ui/layers.js +586 -0
  357. package/dist/ui/leafContent.d.ts +21 -0
  358. package/dist/ui/leafContent.js +136 -0
  359. package/dist/ui/rangeControl.d.ts +53 -0
  360. package/dist/ui/rangeControl.js +168 -0
  361. package/dist/ui/scrollControl.d.ts +84 -0
  362. package/dist/ui/scrollControl.js +222 -0
  363. package/dist/ui/stateControls.d.ts +90 -0
  364. package/dist/ui/stateControls.js +331 -0
  365. package/dist/ui/textEditor.d.ts +54 -0
  366. package/dist/ui/textEditor.js +371 -0
  367. package/dist/ui/textEditorTypes.d.ts +85 -0
  368. package/dist/ui/textEditorTypes.js +2 -0
  369. package/dist/ui/textFieldControl.d.ts +100 -0
  370. package/dist/ui/textFieldControl.js +260 -0
  371. package/dist/ui/theme.d.ts +64 -0
  372. package/dist/ui/theme.js +166 -0
  373. package/dist/ui/types.d.ts +285 -0
  374. package/dist/ui/types.js +2 -0
  375. package/dist/ui/uiRoot.d.ts +4 -0
  376. package/dist/ui/uiRoot.js +1526 -0
  377. package/dist/ui/uiRootDisplay.d.ts +46 -0
  378. package/dist/ui/uiRootDisplay.js +148 -0
  379. package/dist/ui/uiRootModel.d.ts +114 -0
  380. package/dist/ui/uiRootModel.js +66 -0
  381. package/dist/ui/virtualList.d.ts +20 -0
  382. package/dist/ui/virtualList.js +105 -0
  383. package/dist/video.d.ts +4 -0
  384. package/dist/video.js +4 -0
  385. package/dist/videoPlayer.d.ts +4 -0
  386. package/dist/videoPlayer.js +215 -0
  387. package/dist/videoTypes.d.ts +77 -0
  388. package/dist/videoTypes.js +2 -0
  389. package/dist/web/BrowserAssetBundle.d.ts +41 -0
  390. package/dist/web/BrowserAssetBundle.js +136 -0
  391. package/dist/web/BrowserAudio.d.ts +74 -0
  392. package/dist/web/BrowserAudio.js +503 -0
  393. package/dist/web/BrowserFrameLoop.d.ts +69 -0
  394. package/dist/web/BrowserFrameLoop.js +125 -0
  395. package/dist/web/BrowserGame.d.ts +174 -0
  396. package/dist/web/BrowserGame.js +473 -0
  397. package/dist/web/BrowserGamepadInput.d.ts +38 -0
  398. package/dist/web/BrowserGamepadInput.js +134 -0
  399. package/dist/web/BrowserHoverInput.d.ts +25 -0
  400. package/dist/web/BrowserHoverInput.js +266 -0
  401. package/dist/web/BrowserImageTextures.d.ts +72 -0
  402. package/dist/web/BrowserImageTextures.js +169 -0
  403. package/dist/web/BrowserInputActions.d.ts +63 -0
  404. package/dist/web/BrowserInputActions.js +345 -0
  405. package/dist/web/BrowserKeyboardInput.d.ts +4 -0
  406. package/dist/web/BrowserKeyboardInput.js +223 -0
  407. package/dist/web/BrowserPlay.d.ts +417 -0
  408. package/dist/web/BrowserPlay.js +1648 -0
  409. package/dist/web/BrowserPointerInput.d.ts +4 -0
  410. package/dist/web/BrowserPointerInput.js +511 -0
  411. package/dist/web/BrowserPreferences.d.ts +10 -0
  412. package/dist/web/BrowserPreferences.js +39 -0
  413. package/dist/web/BrowserSemantics.d.ts +36 -0
  414. package/dist/web/BrowserSemantics.js +418 -0
  415. package/dist/web/BrowserStatsPanel.d.ts +56 -0
  416. package/dist/web/BrowserStatsPanel.js +143 -0
  417. package/dist/web/BrowserStorage.d.ts +35 -0
  418. package/dist/web/BrowserStorage.js +132 -0
  419. package/dist/web/BrowserTextEditor.d.ts +52 -0
  420. package/dist/web/BrowserTextEditor.js +839 -0
  421. package/dist/web/BrowserTextInput.d.ts +89 -0
  422. package/dist/web/BrowserTextInput.js +524 -0
  423. package/dist/web/BrowserTextureProvider.d.ts +58 -0
  424. package/dist/web/BrowserTextureProvider.js +935 -0
  425. package/dist/web/BrowserVideo.d.ts +40 -0
  426. package/dist/web/BrowserVideo.js +237 -0
  427. package/dist/web/CanvasKitFontSetProvider.d.ts +32 -0
  428. package/dist/web/CanvasKitFontSetProvider.js +215 -0
  429. package/dist/web/CanvasKitParagraphProvider.d.ts +173 -0
  430. package/dist/web/CanvasKitParagraphProvider.js +692 -0
  431. package/dist/web/CanvasTextRasterProvider.d.ts +4 -0
  432. package/dist/web/CanvasTextRasterProvider.js +312 -0
  433. package/dist/web/ManifestByteSource.d.ts +151 -0
  434. package/dist/web/ManifestByteSource.js +975 -0
  435. package/dist/web/ManifestFontContentLoader.d.ts +13 -0
  436. package/dist/web/ManifestFontContentLoader.js +30 -0
  437. package/dist/web/MouseInput.d.ts +4 -0
  438. package/dist/web/MouseInput.js +218 -0
  439. package/dist/web/WebGL2Host.d.ts +5 -0
  440. package/dist/web/WebGL2Host.js +2711 -0
  441. package/dist/web/WebGPUHost.d.ts +100 -0
  442. package/dist/web/WebGPUHost.js +3430 -0
  443. package/dist/web/audio.d.ts +3 -0
  444. package/dist/web/audio.js +4 -0
  445. package/dist/web/canvasKitParagraphGeometry.d.ts +27 -0
  446. package/dist/web/canvasKitParagraphGeometry.js +83 -0
  447. package/dist/web/editing.d.ts +5 -0
  448. package/dist/web/editing.js +4 -0
  449. package/dist/web/editorFonts.d.ts +54 -0
  450. package/dist/web/editorFonts.js +297 -0
  451. package/dist/web/game.d.ts +5 -0
  452. package/dist/web/game.js +6 -0
  453. package/dist/web/gamepad.d.ts +3 -0
  454. package/dist/web/gamepad.js +4 -0
  455. package/dist/web/hover.d.ts +3 -0
  456. package/dist/web/hover.js +4 -0
  457. package/dist/web/image.d.ts +4 -0
  458. package/dist/web/image.js +4 -0
  459. package/dist/web/imageProjections2D.d.ts +16 -0
  460. package/dist/web/imageProjections2D.js +2 -0
  461. package/dist/web/input.d.ts +6 -0
  462. package/dist/web/input.js +4 -0
  463. package/dist/web/keyboard.d.ts +3 -0
  464. package/dist/web/keyboard.js +3 -0
  465. package/dist/web/kit.d.ts +11 -0
  466. package/dist/web/kit.js +8 -0
  467. package/dist/web/loop.d.ts +3 -0
  468. package/dist/web/loop.js +4 -0
  469. package/dist/web/paragraph.d.ts +6 -0
  470. package/dist/web/paragraph.js +4 -0
  471. package/dist/web/play.d.ts +10 -0
  472. package/dist/web/play.js +9 -0
  473. package/dist/web/playMusic.d.ts +33 -0
  474. package/dist/web/playMusic.js +194 -0
  475. package/dist/web/playSfx.d.ts +36 -0
  476. package/dist/web/playSfx.js +112 -0
  477. package/dist/web/playTouch.d.ts +45 -0
  478. package/dist/web/playTouch.js +141 -0
  479. package/dist/web/playWidgets.d.ts +71 -0
  480. package/dist/web/playWidgets.js +431 -0
  481. package/dist/web/pointer.d.ts +3 -0
  482. package/dist/web/pointer.js +3 -0
  483. package/dist/web/prepareSharedSubmission2D.d.ts +27 -0
  484. package/dist/web/prepareSharedSubmission2D.js +63 -0
  485. package/dist/web/resources.d.ts +29 -0
  486. package/dist/web/resources.js +96 -0
  487. package/dist/web/semantics.d.ts +3 -0
  488. package/dist/web/semantics.js +4 -0
  489. package/dist/web/sharedDeviceSession.d.ts +64 -0
  490. package/dist/web/sharedDeviceSession.js +2 -0
  491. package/dist/web/sharedEffectShaders.d.ts +13 -0
  492. package/dist/web/sharedEffectShaders.js +181 -0
  493. package/dist/web/sharedFrameUpload.d.ts +25 -0
  494. package/dist/web/sharedFrameUpload.js +2 -0
  495. package/dist/web/sharedHostDeferred.d.ts +7 -0
  496. package/dist/web/sharedHostDeferred.js +12 -0
  497. package/dist/web/sharedRetentionLedger.d.ts +85 -0
  498. package/dist/web/sharedRetentionLedger.js +391 -0
  499. package/dist/web/sharedSubmissionStorage2D.d.ts +56 -0
  500. package/dist/web/sharedSubmissionStorage2D.js +73 -0
  501. package/dist/web/sharedWebGL2Arena.d.ts +40 -0
  502. package/dist/web/sharedWebGL2Arena.js +77 -0
  503. package/dist/web/sharedWebGL2Options.d.ts +33 -0
  504. package/dist/web/sharedWebGL2Options.js +102 -0
  505. package/dist/web/sharedWebGL2Shaders.d.ts +33 -0
  506. package/dist/web/sharedWebGL2Shaders.js +408 -0
  507. package/dist/web/sharedWebGPUOptions.d.ts +41 -0
  508. package/dist/web/sharedWebGPUOptions.js +130 -0
  509. package/dist/web/text.d.ts +3 -0
  510. package/dist/web/text.js +3 -0
  511. package/dist/web/textInput.d.ts +3 -0
  512. package/dist/web/textInput.js +3 -0
  513. package/dist/web/video.d.ts +3 -0
  514. package/dist/web/video.js +4 -0
  515. package/dist/web/webgl2.d.ts +7 -0
  516. package/dist/web/webgl2.js +4 -0
  517. package/dist/web/webgl2LayerState.d.ts +50 -0
  518. package/dist/web/webgl2LayerState.js +102 -0
  519. package/dist/web/webgl2Native.d.ts +72 -0
  520. package/dist/web/webgl2Native.js +572 -0
  521. package/dist/web/webgl2Types.d.ts +150 -0
  522. package/dist/web/webgl2Types.js +2 -0
  523. package/dist/web/webgpu.d.ts +6 -0
  524. package/dist/web/webgpu.js +2 -0
  525. package/dist/web/webgpuBindingCache.d.ts +26 -0
  526. package/dist/web/webgpuBindingCache.js +223 -0
  527. package/dist/web/webgpuBufferPool.d.ts +51 -0
  528. package/dist/web/webgpuBufferPool.js +58 -0
  529. package/dist/web/webgpuImageResidency.d.ts +56 -0
  530. package/dist/web/webgpuImageResidency.js +65 -0
  531. package/dist/web/webgpuLifetime.d.ts +45 -0
  532. package/dist/web/webgpuLifetime.js +64 -0
  533. package/dist/web/webgpuRetentionPool.d.ts +66 -0
  534. package/dist/web/webgpuRetentionPool.js +85 -0
  535. package/dist/web/webgpuSharedPass.d.ts +7 -0
  536. package/dist/web/webgpuSharedPass.js +293 -0
  537. package/dist/web/webgpuSharedResolvePass.d.ts +3 -0
  538. package/dist/web/webgpuSharedResolvePass.js +34 -0
  539. package/dist/web/world3d/Audio3D.d.ts +85 -0
  540. package/dist/web/world3d/Audio3D.js +271 -0
  541. package/dist/web/world3d/BrowserPlay3D.d.ts +295 -0
  542. package/dist/web/world3d/BrowserPlay3D.js +1256 -0
  543. package/dist/web/world3d/FlyControls3D.d.ts +59 -0
  544. package/dist/web/world3d/FlyControls3D.js +162 -0
  545. package/dist/web/world3d/FollowControls3D.d.ts +31 -0
  546. package/dist/web/world3d/FollowControls3D.js +119 -0
  547. package/dist/web/world3d/OrbitControls3D.d.ts +58 -0
  548. package/dist/web/world3d/OrbitControls3D.js +189 -0
  549. package/dist/web/world3d/TransformControls3D.d.ts +37 -0
  550. package/dist/web/world3d/TransformControls3D.js +128 -0
  551. package/dist/web/world3d/WebGL2Renderer3D.d.ts +136 -0
  552. package/dist/web/world3d/WebGL2Renderer3D.js +1175 -0
  553. package/dist/web/world3d/WebGPURenderer3D.d.ts +112 -0
  554. package/dist/web/world3d/WebGPURenderer3D.js +1916 -0
  555. package/dist/web/world3d/World3DView.d.ts +54 -0
  556. package/dist/web/world3d/World3DView.js +79 -0
  557. package/dist/web/world3d/app3D.d.ts +143 -0
  558. package/dist/web/world3d/app3D.js +305 -0
  559. package/dist/web/world3d/assets3D.d.ts +39 -0
  560. package/dist/web/world3d/assets3D.js +112 -0
  561. package/dist/web/world3d/atmosphere3D.d.ts +56 -0
  562. package/dist/web/world3d/atmosphere3D.js +193 -0
  563. package/dist/web/world3d/canvasFont3D.d.ts +21 -0
  564. package/dist/web/world3d/canvasFont3D.js +165 -0
  565. package/dist/web/world3d/frame3D.d.ts +144 -0
  566. package/dist/web/world3d/frame3D.js +388 -0
  567. package/dist/web/world3d/gpuResources3D.d.ts +98 -0
  568. package/dist/web/world3d/gpuResources3D.js +901 -0
  569. package/dist/web/world3d/host3D.d.ts +24 -0
  570. package/dist/web/world3d/host3D.js +61 -0
  571. package/dist/web/world3d/index.d.ts +40 -0
  572. package/dist/web/world3d/index.js +24 -0
  573. package/dist/web/world3d/loaders3D.d.ts +27 -0
  574. package/dist/web/world3d/loaders3D.js +138 -0
  575. package/dist/web/world3d/markers3D.d.ts +53 -0
  576. package/dist/web/world3d/markers3D.js +130 -0
  577. package/dist/web/world3d/materialWebGL23D.d.ts +34 -0
  578. package/dist/web/world3d/materialWebGL23D.js +218 -0
  579. package/dist/web/world3d/overlay3D.d.ts +47 -0
  580. package/dist/web/world3d/overlay3D.js +187 -0
  581. package/dist/web/world3d/post3D.d.ts +116 -0
  582. package/dist/web/world3d/post3D.js +462 -0
  583. package/dist/web/world3d/postWebGL23D.d.ts +24 -0
  584. package/dist/web/world3d/postWebGL23D.js +237 -0
  585. package/dist/web/world3d/postWebGPU3D.d.ts +23 -0
  586. package/dist/web/world3d/postWebGPU3D.js +255 -0
  587. package/dist/web/world3d/probe3D.d.ts +15 -0
  588. package/dist/web/world3d/probe3D.js +66 -0
  589. package/dist/web/world3d/shaders3D.d.ts +43 -0
  590. package/dist/web/world3d/shaders3D.js +851 -0
  591. package/dist/web/world3d/stats3D.d.ts +34 -0
  592. package/dist/web/world3d/stats3D.js +81 -0
  593. package/dist/web/world3d/webGL2FrameMetrics3D.d.ts +71 -0
  594. package/dist/web/world3d/webGL2FrameMetrics3D.js +185 -0
  595. package/dist/web/world3d/webgpu.d.ts +37 -0
  596. package/dist/web/world3d/webgpu.js +23 -0
  597. package/dist/web/world3d/webgpuPacking3D.d.ts +13 -0
  598. package/dist/web/world3d/webgpuPacking3D.js +85 -0
  599. package/dist/web/world3d/wgsl3D.d.ts +68 -0
  600. package/dist/web/world3d/wgsl3D.js +781 -0
  601. package/package.json +220 -4
@@ -0,0 +1,85 @@
1
+ import type { Disposable } from '@egret/contracts';
2
+ import { Object3D } from '../../rendering/world3d/Object3D.js';
3
+ /** An audio listener to make: its audio context and volume. */
4
+ export interface AudioListenerOptions3D {
5
+ /** Reuse an existing context; otherwise one is created. */
6
+ readonly context?: AudioContext;
7
+ readonly volume?: number;
8
+ }
9
+ /** Ears of the scene. Attach it to the camera (or pass the camera to update()). */
10
+ export declare class AudioListener3D extends Object3D implements Disposable {
11
+ #private;
12
+ readonly context: AudioContext;
13
+ /** Everything this listener hears passes through this gain. */
14
+ readonly output: GainNode;
15
+ constructor(options?: AudioListenerOptions3D);
16
+ get volume(): number;
17
+ set volume(value: number);
18
+ /** Browsers start audio suspended until a user gesture; call this from one. */
19
+ resume(): Promise<void>;
20
+ /** Fetch and decode a sound file into a buffer that any number of sources can share. */
21
+ load(url: string, signal?: AbortSignal): Promise<AudioBuffer>;
22
+ /**
23
+ * A buffer of samples made in code, for a sound synthesized rather than loaded: one array per channel, or one array
24
+ * for mono, each value from -1 to 1, at `sampleRate` samples a second (default: the context's). Share it between
25
+ * sources as a loaded buffer.
26
+ */
27
+ bufferFrom(samples: ArrayLike<number> | readonly ArrayLike<number>[], sampleRate?: number): AudioBuffer;
28
+ /** @internal */ register(source: PositionalAudio3D): void;
29
+ /** @internal */ unregister(source: PositionalAudio3D): void;
30
+ /** Copy this node's world pose to the audio listener and every source's to its panner. */
31
+ update(): void;
32
+ dispose(): void;
33
+ }
34
+ /** A positional sound to make: its buffer and volume, how it fades with distance, its cone, rate, and whether it is spatial. */
35
+ export interface PositionalAudioOptions3D {
36
+ readonly buffer?: AudioBuffer;
37
+ readonly loop?: boolean;
38
+ readonly volume?: number;
39
+ /** Distance at which the volume starts to fall. */
40
+ readonly refDistance?: number;
41
+ /** Distance beyond which the volume no longer falls ('linear': reaches zero). */
42
+ readonly maxDistance?: number;
43
+ readonly rolloffFactor?: number;
44
+ readonly distanceModel?: DistanceModelType;
45
+ /** Cone, in degrees, for directional sources pointing along the node's -Z axis. */
46
+ readonly coneInnerAngle?: number;
47
+ readonly coneOuterAngle?: number;
48
+ readonly coneOuterGain?: number;
49
+ readonly playbackRate?: number;
50
+ /** false plays without spatialization, for music and interface sounds. */
51
+ readonly spatial?: boolean;
52
+ }
53
+ /** A sound placed in the scene. Each play() starts a fresh voice; several may overlap. */
54
+ export declare class PositionalAudio3D extends Object3D implements Disposable {
55
+ #private;
56
+ readonly listener: AudioListener3D;
57
+ readonly gain: GainNode;
58
+ readonly panner: PannerNode | undefined;
59
+ buffer: AudioBuffer | undefined;
60
+ loop: boolean;
61
+ constructor(listener: AudioListener3D, options?: PositionalAudioOptions3D);
62
+ get volume(): number;
63
+ set volume(value: number);
64
+ get isPlaying(): boolean;
65
+ /** The speed and pitch of the voices: set, it changes the voices playing now as well as those to come. */
66
+ get playbackRate(): number;
67
+ set playbackRate(value: number);
68
+ /**
69
+ * Changes the speed and pitch of every voice, playing or to come, gliding over `rampSeconds` (default 0, at once): an
70
+ * engine's note following its speed.
71
+ */
72
+ setPlaybackRate(rate: number, rampSeconds?: number): void;
73
+ /** Start a voice after `delaySeconds`, from `offsetSeconds` into the buffer. */
74
+ play(delaySeconds?: number, offsetSeconds?: number): AudioBufferSourceNode;
75
+ /** Stop every voice of this source. */
76
+ stop(): void;
77
+ /** @internal Copy the node's world pose to the panner. */
78
+ updatePanner(): void;
79
+ dispose(): void;
80
+ }
81
+ /** Makes the listener 3D sounds are heard by, usually on the camera. */
82
+ export declare function createAudioListener3D(options?: AudioListenerOptions3D): AudioListener3D;
83
+ /** Makes a sound that plays from a place in the scene. */
84
+ export declare function createPositionalAudio3D(listener: AudioListener3D, options?: PositionalAudioOptions3D): PositionalAudio3D;
85
+ //# sourceMappingURL=Audio3D.d.ts.map
@@ -0,0 +1,271 @@
1
+ import { World3DError } from '../../rendering/world3d/core3D.js';
2
+ import { Object3D } from '../../rendering/world3d/Object3D.js';
3
+ /** Ears of the scene. Attach it to the camera (or pass the camera to update()). */
4
+ export class AudioListener3D extends Object3D {
5
+ context;
6
+ /** Everything this listener hears passes through this gain. */
7
+ output;
8
+ #ownsContext;
9
+ #sources = new Set();
10
+ #disposed = false;
11
+ constructor(options = {}) {
12
+ super();
13
+ const Context = globalThis.AudioContext;
14
+ if (!options.context && typeof Context !== 'function')
15
+ throw new World3DError('WORLD3D_CONTEXT_UNAVAILABLE', 'Web Audio');
16
+ this.context = options.context ?? new Context();
17
+ this.#ownsContext = !options.context;
18
+ this.output = this.context.createGain();
19
+ this.output.gain.value = options.volume ?? 1;
20
+ this.output.connect(this.context.destination);
21
+ }
22
+ get volume() {
23
+ return this.output.gain.value;
24
+ }
25
+ set volume(value) {
26
+ this.output.gain.value = Math.max(0, value);
27
+ }
28
+ /** Browsers start audio suspended until a user gesture; call this from one. */
29
+ resume() {
30
+ return this.context.state === 'suspended' ? this.context.resume() : Promise.resolve();
31
+ }
32
+ /** Fetch and decode a sound file into a buffer that any number of sources can share. */
33
+ async load(url, signal) {
34
+ let response;
35
+ try {
36
+ response = await fetch(url, signal ? { signal } : {});
37
+ }
38
+ catch (cause) {
39
+ throw new World3DError('WORLD3D_RESOURCE_FAILED', url, cause);
40
+ }
41
+ if (!response.ok)
42
+ throw new World3DError('WORLD3D_RESOURCE_FAILED', url + ' (HTTP ' + response.status + ')');
43
+ try {
44
+ return await this.context.decodeAudioData(await response.arrayBuffer());
45
+ }
46
+ catch (cause) {
47
+ throw new World3DError('WORLD3D_RESOURCE_FAILED', 'audio decode: ' + url, cause);
48
+ }
49
+ }
50
+ /**
51
+ * A buffer of samples made in code, for a sound synthesized rather than loaded: one array per channel, or one array
52
+ * for mono, each value from -1 to 1, at `sampleRate` samples a second (default: the context's). Share it between
53
+ * sources as a loaded buffer.
54
+ */
55
+ bufferFrom(samples, sampleRate = this.context.sampleRate) {
56
+ if (this.#disposed)
57
+ throw new World3DError('WORLD3D_DISPOSED', 'audio');
58
+ const channels = Array.isArray(samples) && typeof samples[0] === 'object'
59
+ ? samples
60
+ : [samples];
61
+ const length = channels[0]?.length ?? 0;
62
+ if (channels.length < 1 ||
63
+ channels.length > 32 ||
64
+ length < 1 ||
65
+ !channels.every(channel => channel !== null && typeof channel === 'object' && channel.length === length) ||
66
+ !(sampleRate >= 3000 && sampleRate <= 768000))
67
+ throw new World3DError('WORLD3D_INPUT_INVALID', 'audio samples');
68
+ const buffer = this.context.createBuffer(channels.length, length, sampleRate);
69
+ channels.forEach((channel, index) => {
70
+ const target = buffer.getChannelData(index);
71
+ for (let i = 0; i < length; i++)
72
+ target[i] = Math.max(-1, Math.min(1, Number(channel[i]) || 0));
73
+ });
74
+ return buffer;
75
+ }
76
+ /** @internal */ register(source) {
77
+ this.#sources.add(source);
78
+ }
79
+ /** @internal */ unregister(source) {
80
+ this.#sources.delete(source);
81
+ }
82
+ /** Copy this node's world pose to the audio listener and every source's to its panner. */
83
+ update() {
84
+ if (this.#disposed)
85
+ return;
86
+ this.updateWorldMatrices();
87
+ const m = this.matrixWorld, listener = this.context.listener, time = this.context.currentTime;
88
+ const fx = -m[8], fy = -m[9], fz = -m[10], ux = m[4], uy = m[5], uz = m[6];
89
+ if (listener.positionX) {
90
+ listener.positionX.setValueAtTime(m[12], time);
91
+ listener.positionY.setValueAtTime(m[13], time);
92
+ listener.positionZ.setValueAtTime(m[14], time);
93
+ listener.forwardX.setValueAtTime(fx, time);
94
+ listener.forwardY.setValueAtTime(fy, time);
95
+ listener.forwardZ.setValueAtTime(fz, time);
96
+ listener.upX.setValueAtTime(ux, time);
97
+ listener.upY.setValueAtTime(uy, time);
98
+ listener.upZ.setValueAtTime(uz, time);
99
+ }
100
+ else {
101
+ // Older engines only have the setter methods.
102
+ const legacy = listener;
103
+ legacy.setPosition(m[12], m[13], m[14]);
104
+ legacy.setOrientation(fx, fy, fz, ux, uy, uz);
105
+ }
106
+ for (const source of this.#sources)
107
+ source.updatePanner();
108
+ }
109
+ dispose() {
110
+ if (this.#disposed)
111
+ return;
112
+ this.#disposed = true;
113
+ for (const source of [...this.#sources])
114
+ source.dispose();
115
+ this.output.disconnect();
116
+ if (this.#ownsContext)
117
+ void this.context.close().catch(() => undefined);
118
+ }
119
+ }
120
+ /** A sound placed in the scene. Each play() starts a fresh voice; several may overlap. */
121
+ export class PositionalAudio3D extends Object3D {
122
+ listener;
123
+ gain;
124
+ panner;
125
+ buffer;
126
+ loop;
127
+ #playbackRate;
128
+ #voices = new Set();
129
+ #disposed = false;
130
+ constructor(listener, options = {}) {
131
+ super();
132
+ if (!(listener instanceof AudioListener3D))
133
+ throw new World3DError('WORLD3D_INPUT_INVALID', 'listener');
134
+ this.listener = listener;
135
+ const context = listener.context;
136
+ this.buffer = options.buffer;
137
+ this.loop = options.loop ?? false;
138
+ this.#playbackRate = options.playbackRate ?? 1;
139
+ this.gain = context.createGain();
140
+ this.gain.gain.value = options.volume ?? 1;
141
+ if (options.spatial ?? true) {
142
+ const panner = (this.panner = context.createPanner());
143
+ panner.panningModel = 'HRTF';
144
+ panner.distanceModel = options.distanceModel ?? 'inverse';
145
+ panner.refDistance = options.refDistance ?? 1;
146
+ panner.maxDistance = options.maxDistance ?? 10000;
147
+ panner.rolloffFactor = options.rolloffFactor ?? 1;
148
+ panner.coneInnerAngle = options.coneInnerAngle ?? 360;
149
+ panner.coneOuterAngle = options.coneOuterAngle ?? 360;
150
+ panner.coneOuterGain = options.coneOuterGain ?? 0;
151
+ this.gain.connect(panner);
152
+ panner.connect(listener.output);
153
+ }
154
+ else
155
+ this.gain.connect(listener.output);
156
+ listener.register(this);
157
+ }
158
+ get volume() {
159
+ return this.gain.gain.value;
160
+ }
161
+ set volume(value) {
162
+ this.gain.gain.value = Math.max(0, value);
163
+ }
164
+ get isPlaying() {
165
+ return this.#voices.size > 0;
166
+ }
167
+ /** The speed and pitch of the voices: set, it changes the voices playing now as well as those to come. */
168
+ get playbackRate() {
169
+ return this.#playbackRate;
170
+ }
171
+ set playbackRate(value) {
172
+ this.setPlaybackRate(value);
173
+ }
174
+ /**
175
+ * Changes the speed and pitch of every voice, playing or to come, gliding over `rampSeconds` (default 0, at once): an
176
+ * engine's note following its speed.
177
+ */
178
+ setPlaybackRate(rate, rampSeconds = 0) {
179
+ if (!(typeof rate === 'number' && rate > 0 && rate <= 16))
180
+ throw new World3DError('WORLD3D_INPUT_INVALID', 'playbackRate');
181
+ if (!(typeof rampSeconds === 'number' && rampSeconds >= 0 && Number.isFinite(rampSeconds)))
182
+ throw new World3DError('WORLD3D_INPUT_INVALID', 'rampSeconds');
183
+ this.#playbackRate = rate;
184
+ const now = this.listener.context.currentTime;
185
+ for (const voice of this.#voices) {
186
+ const param = voice.playbackRate;
187
+ if (rampSeconds === 0) {
188
+ param.cancelScheduledValues?.(now);
189
+ param.setValueAtTime(rate, now);
190
+ }
191
+ else {
192
+ param.cancelScheduledValues?.(now);
193
+ param.setValueAtTime(param.value, now);
194
+ param.linearRampToValueAtTime(rate, now + rampSeconds);
195
+ }
196
+ }
197
+ }
198
+ /** Start a voice after `delaySeconds`, from `offsetSeconds` into the buffer. */
199
+ play(delaySeconds = 0, offsetSeconds = 0) {
200
+ if (this.#disposed)
201
+ throw new World3DError('WORLD3D_DISPOSED', 'audio');
202
+ if (!this.buffer)
203
+ throw new World3DError('WORLD3D_INPUT_INVALID', 'audio buffer');
204
+ const context = this.listener.context, voice = context.createBufferSource();
205
+ voice.buffer = this.buffer;
206
+ voice.loop = this.loop;
207
+ voice.playbackRate.value = this.#playbackRate;
208
+ voice.connect(this.gain);
209
+ voice.onended = () => {
210
+ voice.disconnect();
211
+ this.#voices.delete(voice);
212
+ };
213
+ this.#voices.add(voice);
214
+ this.updatePanner();
215
+ voice.start(context.currentTime + Math.max(0, delaySeconds), Math.max(0, offsetSeconds));
216
+ return voice;
217
+ }
218
+ /** Stop every voice of this source. */
219
+ stop() {
220
+ for (const voice of this.#voices) {
221
+ voice.onended = null;
222
+ try {
223
+ voice.stop();
224
+ }
225
+ catch {
226
+ /* not started yet */
227
+ }
228
+ voice.disconnect();
229
+ }
230
+ this.#voices.clear();
231
+ }
232
+ /** @internal Copy the node's world pose to the panner. */
233
+ updatePanner() {
234
+ const panner = this.panner;
235
+ if (!panner || this.#disposed)
236
+ return;
237
+ this.updateWorldMatrices();
238
+ const m = this.matrixWorld, time = this.listener.context.currentTime;
239
+ if (panner.positionX) {
240
+ panner.positionX.setValueAtTime(m[12], time);
241
+ panner.positionY.setValueAtTime(m[13], time);
242
+ panner.positionZ.setValueAtTime(m[14], time);
243
+ panner.orientationX.setValueAtTime(-m[8], time);
244
+ panner.orientationY.setValueAtTime(-m[9], time);
245
+ panner.orientationZ.setValueAtTime(-m[10], time);
246
+ }
247
+ else {
248
+ const legacy = panner;
249
+ legacy.setPosition(m[12], m[13], m[14]);
250
+ legacy.setOrientation(-m[8], -m[9], -m[10]);
251
+ }
252
+ }
253
+ dispose() {
254
+ if (this.#disposed)
255
+ return;
256
+ this.stop();
257
+ this.#disposed = true;
258
+ this.gain.disconnect();
259
+ this.panner?.disconnect();
260
+ this.listener.unregister(this);
261
+ }
262
+ }
263
+ /** Makes the listener 3D sounds are heard by, usually on the camera. */
264
+ export function createAudioListener3D(options = {}) {
265
+ return new AudioListener3D(options);
266
+ }
267
+ /** Makes a sound that plays from a place in the scene. */
268
+ export function createPositionalAudio3D(listener, options = {}) {
269
+ return new PositionalAudio3D(listener, options);
270
+ }
271
+ //# sourceMappingURL=Audio3D.js.map
@@ -0,0 +1,295 @@
1
+ import type { DisplayObject } from '@egret/runtime';
2
+ import { play } from '../play.js';
3
+ import type { PlayGame, PlayOptions } from '../play.js';
4
+ import { Object3D, Scene3D } from '../../rendering/world3d/Object3D.js';
5
+ import type { Geometry3D } from '../../rendering/world3d/Geometry3D.js';
6
+ import type { Camera3D } from '../../rendering/world3d/Camera3D.js';
7
+ import type { Light3D } from '../../rendering/world3d/Light3D.js';
8
+ import type { World3DApp } from './app3D.js';
9
+ /** Where a thing is made. What is left out is 0. */
10
+ export interface PlayPlace3D {
11
+ readonly x?: number;
12
+ readonly y?: number;
13
+ readonly z?: number;
14
+ }
15
+ /**
16
+ * A thing of the world: a box, a ball, a cylinder or a cone. It is placed, turned and sized by plain numbers, which
17
+ * can be set at any time and tweened, and it takes properties of the game's own.
18
+ */
19
+ export declare class PlayThing3D {
20
+ #private;
21
+ /** What the thing is drawn with: its own mesh, or the model given to `game.add`. */
22
+ readonly node: Object3D;
23
+ /** Half its width, height and depth as made, before its scale. */
24
+ readonly halfX: number;
25
+ readonly halfY: number;
26
+ readonly halfZ: number;
27
+ /**
28
+ * Where the middle of its box is from its place, before its scale: 0 for what `play3d` makes, and for a model
29
+ * whatever its geometry says, as for a figure that stands on its place.
30
+ */
31
+ readonly middleX: number;
32
+ readonly middleY: number;
33
+ readonly middleZ: number;
34
+ [own: string]: unknown;
35
+ /**
36
+ * A thing of its own geometry and colour, or one of a model made elsewhere: then `half` and `middle` are its box,
37
+ * and its colour is the model's own. Geometry passed directly is owned and released when the thing leaves;
38
+ * an Object3D and its geometry and materials stay owned by their caller.
39
+ */
40
+ constructor(shape: Geometry3D | Object3D, color: number, half: readonly [number, number, number], middle?: readonly [number, number, number]);
41
+ get x(): number;
42
+ set x(value: number);
43
+ /** Up. */
44
+ get y(): number;
45
+ set y(value: number);
46
+ /** Towards the camera as the game starts; away from it is less. */
47
+ get z(): number;
48
+ set z(value: number);
49
+ /** Turns about its own axes, in degrees. */
50
+ get rotationX(): number;
51
+ set rotationX(value: number);
52
+ get rotationY(): number;
53
+ set rotationY(value: number);
54
+ get rotationZ(): number;
55
+ set rotationZ(value: number);
56
+ /** Its size as a share of the size it was made with; setting it sets all three of the ones below. */
57
+ get scale(): number;
58
+ set scale(value: number);
59
+ get scaleX(): number;
60
+ set scaleX(value: number);
61
+ get scaleY(): number;
62
+ set scaleY(value: number);
63
+ get scaleZ(): number;
64
+ set scaleZ(value: number);
65
+ get visible(): boolean;
66
+ set visible(value: boolean);
67
+ /** Its colour, `0xRRGGBB`. What is not a colour is not taken; a model keeps the colours it has. */
68
+ get color(): number;
69
+ set color(value: number);
70
+ /**
71
+ * How much it shines with its own colour, lit or not: 0 (the default) not at all, 1 as bright as its colour,
72
+ * more for a lamp or a screen. A thing that glows is not hidden by fog. A model keeps the materials it has.
73
+ */
74
+ get glow(): number;
75
+ set glow(value: number);
76
+ /**
77
+ * How much of it is seen, 0 to 1: 1 (the default) is solid, less lets what is behind it show through, as glass, a
78
+ * ghost or, with `glow`, a beam of light, whose light is added to what is behind it. A see-through thing casts no
79
+ * shadow. A model keeps the materials it has.
80
+ */
81
+ get opacity(): number;
82
+ set opacity(value: number);
83
+ /** Whether `game.remove` has taken it out of the world. Setting it afterwards does nothing that is seen. */
84
+ get removed(): boolean;
85
+ /** Used by game removal and teardown; only resources made for this thing are retired. */
86
+ leave(): void;
87
+ }
88
+ /**
89
+ * A lamp: light from a point of the world that fades out by `range`. It is placed and changed by plain numbers, and
90
+ * `game.remove` puts it out. Up to eight are lit fully; more are lit by a coarser way.
91
+ */
92
+ export declare class PlayLamp3D {
93
+ #private;
94
+ readonly node: Light3D;
95
+ constructor(color: number, intensity: number, range: number);
96
+ get x(): number;
97
+ set x(value: number);
98
+ get y(): number;
99
+ set y(value: number);
100
+ get z(): number;
101
+ set z(value: number);
102
+ get color(): number;
103
+ set color(value: number);
104
+ /** How bright it is; 0 is dark. */
105
+ get intensity(): number;
106
+ set intensity(value: number);
107
+ /** How far it reaches before it has faded out, in units of the world. */
108
+ get range(): number;
109
+ set range(value: number);
110
+ get visible(): boolean;
111
+ set visible(value: boolean);
112
+ get removed(): boolean;
113
+ leave(): void;
114
+ }
115
+ /** A lamp to light: how bright, and how far it reaches. */
116
+ export interface PlayLampOptions3D {
117
+ /** How bright it is: 4 unless given. */
118
+ readonly intensity?: number;
119
+ /** How far it reaches: 8 unless given. */
120
+ readonly range?: number;
121
+ }
122
+ /** What falls from the sky: snow, rain, or nothing. */
123
+ export type PlayWeather3D = 'snow' | 'rain' | 'none';
124
+ /** Weather to show: how much rain or snow. */
125
+ export interface PlayWeatherOptions3D {
126
+ /** How much falls: 1 unless given, from 0 to 3. */
127
+ readonly amount?: number;
128
+ }
129
+ /** The camera: where it is and what it looks at, by plain numbers. */
130
+ export interface PlayCamera3D {
131
+ x: number;
132
+ y: number;
133
+ z: number;
134
+ /** The angle it sees from top to bottom, in degrees. */
135
+ fov: number;
136
+ /** Turns it to look at a point. It goes on looking there as it moves. */
137
+ lookAt(x: number, y: number, z: number): void;
138
+ readonly node: Camera3D;
139
+ }
140
+ /** How the camera follows: where it sits behind, how smoothly, and whether it turns with the target. */
141
+ export interface PlayFollow3D {
142
+ /** Where the camera stays from the thing: 0, 4 and 8 unless given, which is above and behind. */
143
+ readonly x?: number;
144
+ readonly y?: number;
145
+ readonly z?: number;
146
+ /** How quickly it catches up: 6 unless given; 0 keeps it exactly there. */
147
+ readonly smooth?: number;
148
+ /**
149
+ * Turns the place of the camera with the thing's `rotationY`, so that it stays behind a car or a figure that turns:
150
+ * `{ y: 3, z: 7, turn: true }` is above and behind whichever way the thing faces. False unless given.
151
+ */
152
+ readonly turn?: boolean;
153
+ /**
154
+ * How far above the thing the camera looks: 0 unless given. A tall tower or a sky the thing moves under is framed by
155
+ * looking higher; the camera keeps its place.
156
+ */
157
+ readonly lookY?: number;
158
+ }
159
+ /** A burst of particles: its color and count, how fast and how long they fly, their size and gravity. */
160
+ export interface PlayBurst3D {
161
+ readonly color?: number;
162
+ readonly count?: number;
163
+ readonly speed?: number;
164
+ readonly life?: number;
165
+ readonly size?: number;
166
+ readonly gravity?: number;
167
+ }
168
+ type Body = PlayThing3D | DisplayObject;
169
+ /** What `play3d` gives: everything `play` gives for the interface and the game's time, and a world of things. */
170
+ export type PlayLookName3D = 'day' | 'dusk' | 'night' | 'fog' | 'snow';
171
+ /** How a 3D play game looks: its background and sky, its ground, its light and sun, and its fog. */
172
+ export interface PlayLook3D {
173
+ /** What is behind everything, and the colour of the fog. */
174
+ readonly background?: number;
175
+ /** The colour of the light from above. */
176
+ readonly sky?: number;
177
+ /** The colour of the light from below. */
178
+ readonly ground?: number;
179
+ /** How strong the light from above and below is, 0 to 16: 0.22 at night, 0.9 by day. */
180
+ readonly light?: number;
181
+ /** The colour of the sun. */
182
+ readonly sun?: number;
183
+ /** How strong the sun is, 0 to 16: 0.35 at night, 2.4 by day. */
184
+ readonly sunIntensity?: number;
185
+ /** The side the sun shines from, as `[x, y, z]`; y up. */
186
+ readonly sunFrom?: readonly [number, number, number];
187
+ /** How thick the air is: 0 is clear, 0.02 a haze, 0.06 a fog. */
188
+ readonly fog?: number;
189
+ }
190
+ /** The looks every game is given, by name. */
191
+ export declare const PLAY_LOOKS_3D: Readonly<Record<PlayLookName3D, Required<PlayLook3D>>>;
192
+ /** Everything a small 3D game is given: its scene and camera, its input, and calls that make, move and light things. */
193
+ export interface Play3DGame extends Omit<PlayGame, 'remove' | 'near' | 'overlaps' | 'hits' | 'hitsAll' | 'pushOut' | 'burst' | 'shake' | 'onTap'> {
194
+ readonly scene: Scene3D;
195
+ readonly camera: PlayCamera3D;
196
+ /** The light of the day. It keeps its direction and stays over what the camera looks at. */
197
+ readonly sun: Light3D;
198
+ /** The World3D app under the game, for what this does not cover. */
199
+ readonly app: World3DApp;
200
+ /**
201
+ * The light and air of the world: `'day'`, `'dusk'`, `'night'`, `'fog'` or `'snow'`, or the parts of one to change:
202
+ * `{ background, sky, ground, light, sun, sunIntensity, sunFrom, fog }`, colours as `0xRRGGBB`, `sunFrom` the side
203
+ * the sun shines from as `[x, y, z]`, and `fog` its thickness, 0 for none. A restart keeps it.
204
+ */
205
+ look(look: PlayLookName3D | PlayLook3D): void;
206
+ /** A box of this width, height and depth, its middle at the place given. */
207
+ box(width: number, height: number, depth: number, color: number, at?: PlayPlace3D): PlayThing3D;
208
+ /** A ball. */
209
+ sphere(radius: number, color: number, at?: PlayPlace3D): PlayThing3D;
210
+ /** A cylinder standing on its end. */
211
+ cylinder(radius: number, height: number, color: number, at?: PlayPlace3D): PlayThing3D;
212
+ /** A cone standing on its base. */
213
+ cone(radius: number, height: number, color: number, at?: PlayPlace3D): PlayThing3D;
214
+ /** A square floor of this size whose top is at the height given, 0 unless said. */
215
+ ground(size: number, color: number, y?: number): PlayThing3D;
216
+ /**
217
+ * Makes a model of your own a thing of the world: a mesh of your geometry, a group, or what `loadGltf3D` gave.
218
+ * Its box for the tests is worked out from its geometry; it keeps its own materials.
219
+ */
220
+ add(model: Object3D, at?: PlayPlace3D): PlayThing3D;
221
+ /**
222
+ * Calls the function when the thing is tapped or clicked, by a ray from the camera through the pointer; the
223
+ * nearest thing hit gets it. A sprite of the interface is given to `onTap` of `play` as before.
224
+ */
225
+ onTap(target: PlayThing3D | DisplayObject, callback: () => unknown): void;
226
+ /** Takes a thing or a lamp out of the world, or a sprite off the interface. */
227
+ remove(body: Body | PlayLamp3D): void;
228
+ /** Whether the middles of two things are within a distance: the sum of their radii unless given. */
229
+ near(a: Body, b: Body, distance?: number): boolean;
230
+ /** Whether two things overlap, taken as upright boxes. */
231
+ overlaps(a: Body, b: Body, shrink?: number): boolean;
232
+ hits<T extends Body>(a: Body, others: readonly T[], shrink?: number): T | undefined;
233
+ hitsAll<T extends Body>(a: Body, others: readonly T[], shrink?: number): T[];
234
+ /**
235
+ * How far to move thing `a` so it no longer overlaps thing `b`, by the shortest way out: one of x, y and z is not
236
+ * 0. Undefined when they do not overlap. A `y` above 0 means `a` stands on `b`.
237
+ */
238
+ pushOut(a: PlayThing3D, b: PlayThing3D): {
239
+ x: number;
240
+ y: number;
241
+ z: number;
242
+ } | undefined;
243
+ /** Keeps the camera by a thing and looking at it; without a thing, lets the camera be. */
244
+ follow(thing?: PlayThing3D, where?: PlayFollow3D): void;
245
+ /** Shakes the camera by up to this many units of the world. */
246
+ shake(amount?: number, seconds?: number): void;
247
+ /** Throws small pieces out from a point of the world. */
248
+ burst(x: number, y: number, z: number, options?: PlayBurst3D): void;
249
+ /**
250
+ * Makes things one: a group that is placed, turned, scaled, tweened and tested as one thing, with the things in
251
+ * it where they are within it. Their places are now from the group's place, which is `at`, 0 unless given. Test
252
+ * the group, not its parts, for overlaps; removing the group removes its parts.
253
+ */
254
+ group(parts: readonly PlayThing3D[], at?: PlayPlace3D): PlayThing3D;
255
+ /** A lamp at a place: light of a colour that fades out by its range. */
256
+ lamp(color: number, at?: PlayPlace3D, options?: PlayLampOptions3D): PlayLamp3D;
257
+ /**
258
+ * Snow or rain falling around what the camera looks at, or `'none'` to stop it. `{ amount }` is how much, 1
259
+ * unless given. A restart keeps it.
260
+ */
261
+ weather(kind: PlayWeather3D, options?: PlayWeatherOptions3D): void;
262
+ }
263
+ /** A small 3D game to start: its setup and update, and the options of a 2D play game. */
264
+ export interface Play3DOptions extends Omit<PlayOptions, 'setup' | 'update' | 'canvas'> {
265
+ readonly setup?: (game: Play3DGame) => void | Promise<void>;
266
+ readonly update?: (seconds: number, game: Play3DGame) => void;
267
+ }
268
+ /** How far two things overlap on each axis; all three are above 0 when they overlap. */
269
+ export declare function overlap3D(a: PlayThing3D, b: PlayThing3D, shrink?: number): [number, number, number];
270
+ /**
271
+ * The box of a model, in its own units and about its own place: half its size and where its middle is. Every mesh
272
+ * under it counts, placed as it is under it; the model's own place, turn and scale do not.
273
+ */
274
+ export declare function modelBox3D(model: Object3D): {
275
+ half: [number, number, number];
276
+ middle: [number, number, number];
277
+ };
278
+ /** The move that takes `a` out of `b` by the shortest way, or undefined when they are apart. */
279
+ export declare function pushOut3D(a: PlayThing3D, b: PlayThing3D): {
280
+ x: number;
281
+ y: number;
282
+ z: number;
283
+ } | undefined;
284
+ interface Play3DSurface {
285
+ readonly ready?: Promise<World3DApp>;
286
+ show?(scene: Scene3D, camera: Camera3D): void;
287
+ unplace?(): void;
288
+ remove?(): void;
289
+ }
290
+ /** Starts a 3D game in the page. See the guide `play3d.md`. */
291
+ export declare function play3d(options: Play3DOptions): Promise<Play3DGame>;
292
+ /** Internal host entry. The flat session owns input and UI; the surface presents the original scene. */
293
+ export declare function createPlay3DSession(options: Play3DOptions, startFlat: typeof play, attach: (given: PlayGame, options: Play3DOptions) => Play3DSurface): Promise<Play3DGame>;
294
+ export {};
295
+ //# sourceMappingURL=BrowserPlay3D.d.ts.map