@egret/engine 0.0.0-stage → 7.0.1-rc.3

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 (575) 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 +464 -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 +42 -0
  20. package/dist/animation/sequenceResetTypes.js +2 -0
  21. package/dist/animation/types.d.ts +69 -0
  22. package/dist/animation/types.js +2 -0
  23. package/dist/assetBundle.d.ts +52 -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 +15 -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 +43 -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 +233 -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 +29 -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 +109 -0
  46. package/dist/bitmapFontTypes.js +2 -0
  47. package/dist/bitmapResourceSlot.d.ts +25 -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 +411 -0
  57. package/dist/cameraTypes.d.ts +114 -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 +33 -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 +42 -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 +34 -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 +31 -0
  82. package/dist/gameClockTypes.js +2 -0
  83. package/dist/gameRun.d.ts +50 -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 +134 -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 +119 -0
  98. package/dist/hoverInputTypes.js +2 -0
  99. package/dist/index.d.ts +49 -0
  100. package/dist/index.js +20 -0
  101. package/dist/input.d.ts +6 -0
  102. package/dist/input.js +5 -0
  103. package/dist/inputActions.d.ts +81 -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 +64 -0
  116. package/dist/internal/uiFactoryState.js +157 -0
  117. package/dist/internal/uiRootState.d.ts +67 -0
  118. package/dist/internal/uiRootState.js +103 -0
  119. package/dist/keyboardInput.d.ts +12 -0
  120. package/dist/keyboardInput.js +578 -0
  121. package/dist/keyboardInputTypes.d.ts +81 -0
  122. package/dist/keyboardInputTypes.js +2 -0
  123. package/dist/kit.d.ts +14 -0
  124. package/dist/kit.js +9 -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 +16 -0
  132. package/dist/manifestResourceState.js +57 -0
  133. package/dist/manifestResourceTypes.d.ts +25 -0
  134. package/dist/manifestResourceTypes.js +2 -0
  135. package/dist/motion.d.ts +33 -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 +37 -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 +292 -0
  145. package/dist/particleTypes.d.ts +107 -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 +167 -0
  154. package/dist/physics2dTypes.js +2 -0
  155. package/dist/physics2dWorld.d.ts +4 -0
  156. package/dist/physics2dWorld.js +623 -0
  157. package/dist/pointerInput.d.ts +11 -0
  158. package/dist/pointerInput.js +299 -0
  159. package/dist/pointerInputTypes.d.ts +38 -0
  160. package/dist/pointerInputTypes.js +2 -0
  161. package/dist/random.d.ts +29 -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 +331 -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 +88 -0
  172. package/dist/rendering/prepareSharedDraws2D.js +652 -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 +18 -0
  178. package/dist/rendering/sharedColor2D.js +68 -0
  179. package/dist/rendering/sharedEffects2D.d.ts +23 -0
  180. package/dist/rendering/sharedEffects2D.js +118 -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 +95 -0
  188. package/dist/rendering/world3d/Animation3D.js +380 -0
  189. package/dist/rendering/world3d/AnimationTexture3D.d.ts +157 -0
  190. package/dist/rendering/world3d/AnimationTexture3D.js +601 -0
  191. package/dist/rendering/world3d/Batch3D.d.ts +71 -0
  192. package/dist/rendering/world3d/Batch3D.js +329 -0
  193. package/dist/rendering/world3d/Camera3D.d.ts +57 -0
  194. package/dist/rendering/world3d/Camera3D.js +129 -0
  195. package/dist/rendering/world3d/Character3D.d.ts +123 -0
  196. package/dist/rendering/world3d/Character3D.js +303 -0
  197. package/dist/rendering/world3d/Cloth3D.d.ts +115 -0
  198. package/dist/rendering/world3d/Cloth3D.js +498 -0
  199. package/dist/rendering/world3d/Compression3D.d.ts +21 -0
  200. package/dist/rendering/world3d/Compression3D.js +702 -0
  201. package/dist/rendering/world3d/Curves3D.d.ts +111 -0
  202. package/dist/rendering/world3d/Curves3D.js +455 -0
  203. package/dist/rendering/world3d/Decal3D.d.ts +41 -0
  204. package/dist/rendering/world3d/Decal3D.js +241 -0
  205. package/dist/rendering/world3d/Geometry3D.d.ts +85 -0
  206. package/dist/rendering/world3d/Geometry3D.js +326 -0
  207. package/dist/rendering/world3d/GeometryBuilder3D.d.ts +51 -0
  208. package/dist/rendering/world3d/GeometryBuilder3D.js +196 -0
  209. package/dist/rendering/world3d/Gizmo3D.d.ts +75 -0
  210. package/dist/rendering/world3d/Gizmo3D.js +512 -0
  211. package/dist/rendering/world3d/Gltf3D.d.ts +67 -0
  212. package/dist/rendering/world3d/Gltf3D.js +976 -0
  213. package/dist/rendering/world3d/GpuParticles3D.d.ts +107 -0
  214. package/dist/rendering/world3d/GpuParticles3D.js +400 -0
  215. package/dist/rendering/world3d/Hdr3D.d.ts +33 -0
  216. package/dist/rendering/world3d/Hdr3D.js +190 -0
  217. package/dist/rendering/world3d/Jelly3D.d.ts +75 -0
  218. package/dist/rendering/world3d/Jelly3D.js +266 -0
  219. package/dist/rendering/world3d/Ktx23D.d.ts +27 -0
  220. package/dist/rendering/world3d/Ktx23D.js +112 -0
  221. package/dist/rendering/world3d/Light3D.d.ts +75 -0
  222. package/dist/rendering/world3d/Light3D.js +93 -0
  223. package/dist/rendering/world3d/Material3D.d.ts +243 -0
  224. package/dist/rendering/world3d/Material3D.js +267 -0
  225. package/dist/rendering/world3d/Mesh3D.d.ts +108 -0
  226. package/dist/rendering/world3d/Mesh3D.js +323 -0
  227. package/dist/rendering/world3d/Meshopt3D.d.ts +12 -0
  228. package/dist/rendering/world3d/Meshopt3D.js +275 -0
  229. package/dist/rendering/world3d/Navigation3D.d.ts +173 -0
  230. package/dist/rendering/world3d/Navigation3D.js +971 -0
  231. package/dist/rendering/world3d/Object3D.d.ts +107 -0
  232. package/dist/rendering/world3d/Object3D.js +305 -0
  233. package/dist/rendering/world3d/Particles3D.d.ts +85 -0
  234. package/dist/rendering/world3d/Particles3D.js +274 -0
  235. package/dist/rendering/world3d/Physics3D.d.ts +416 -0
  236. package/dist/rendering/world3d/Physics3D.js +2835 -0
  237. package/dist/rendering/world3d/PhysicsHull3D.d.ts +35 -0
  238. package/dist/rendering/world3d/PhysicsHull3D.js +227 -0
  239. package/dist/rendering/world3d/PhysicsMesh3D.d.ts +39 -0
  240. package/dist/rendering/world3d/PhysicsMesh3D.js +338 -0
  241. package/dist/rendering/world3d/PhysicsQueries3D.d.ts +24 -0
  242. package/dist/rendering/world3d/PhysicsQueries3D.js +323 -0
  243. package/dist/rendering/world3d/PhysicsRemote3D.d.ts +174 -0
  244. package/dist/rendering/world3d/PhysicsRemote3D.js +534 -0
  245. package/dist/rendering/world3d/Ragdoll3D.d.ts +69 -0
  246. package/dist/rendering/world3d/Ragdoll3D.js +200 -0
  247. package/dist/rendering/world3d/Raycast3D.d.ts +37 -0
  248. package/dist/rendering/world3d/Raycast3D.js +246 -0
  249. package/dist/rendering/world3d/RenderList3D.d.ts +88 -0
  250. package/dist/rendering/world3d/RenderList3D.js +490 -0
  251. package/dist/rendering/world3d/Retarget3D.d.ts +20 -0
  252. package/dist/rendering/world3d/Retarget3D.js +185 -0
  253. package/dist/rendering/world3d/Serialize3D.d.ts +49 -0
  254. package/dist/rendering/world3d/Serialize3D.js +607 -0
  255. package/dist/rendering/world3d/StateMachine3D.d.ts +78 -0
  256. package/dist/rendering/world3d/StateMachine3D.js +277 -0
  257. package/dist/rendering/world3d/Terrain3D.d.ts +227 -0
  258. package/dist/rendering/world3d/Terrain3D.js +803 -0
  259. package/dist/rendering/world3d/Text3D.d.ts +90 -0
  260. package/dist/rendering/world3d/Text3D.js +558 -0
  261. package/dist/rendering/world3d/Texture3D.d.ts +133 -0
  262. package/dist/rendering/world3d/Texture3D.js +252 -0
  263. package/dist/rendering/world3d/Trail3D.d.ts +59 -0
  264. package/dist/rendering/world3d/Trail3D.js +193 -0
  265. package/dist/rendering/world3d/Vehicle3D.d.ts +97 -0
  266. package/dist/rendering/world3d/Vehicle3D.js +226 -0
  267. package/dist/rendering/world3d/VolumetricFog3D.d.ts +55 -0
  268. package/dist/rendering/world3d/VolumetricFog3D.js +229 -0
  269. package/dist/rendering/world3d/Water3D.d.ts +163 -0
  270. package/dist/rendering/world3d/Water3D.js +606 -0
  271. package/dist/rendering/world3d/core3D.d.ts +34 -0
  272. package/dist/rendering/world3d/core3D.js +99 -0
  273. package/dist/rendering/world3d/debug3D.d.ts +64 -0
  274. package/dist/rendering/world3d/debug3D.js +257 -0
  275. package/dist/rendering/world3d/decoders3D.d.ts +42 -0
  276. package/dist/rendering/world3d/decoders3D.js +133 -0
  277. package/dist/rendering/world3d/geometries3D.d.ts +99 -0
  278. package/dist/rendering/world3d/geometries3D.js +605 -0
  279. package/dist/rendering/world3d/helpers3D.d.ts +65 -0
  280. package/dist/rendering/world3d/helpers3D.js +177 -0
  281. package/dist/rendering/world3d/index.d.ts +91 -0
  282. package/dist/rendering/world3d/index.js +56 -0
  283. package/dist/rendering/world3d/math3D.d.ts +78 -0
  284. package/dist/rendering/world3d/math3D.js +640 -0
  285. package/dist/rendering/world3d/primitives3D.d.ts +60 -0
  286. package/dist/rendering/world3d/primitives3D.js +196 -0
  287. package/dist/resources.d.ts +8 -0
  288. package/dist/resources.js +6 -0
  289. package/dist/saveStore.d.ts +56 -0
  290. package/dist/saveStore.js +163 -0
  291. package/dist/semanticList.d.ts +122 -0
  292. package/dist/semanticList.js +174 -0
  293. package/dist/semanticTree.d.ts +10 -0
  294. package/dist/semanticTree.js +532 -0
  295. package/dist/semanticTypes.d.ts +167 -0
  296. package/dist/semanticTypes.js +2 -0
  297. package/dist/semantics.d.ts +6 -0
  298. package/dist/semantics.js +5 -0
  299. package/dist/sequencePlayback.d.ts +19 -0
  300. package/dist/sequencePlayback.js +391 -0
  301. package/dist/sequencePlaybackTypes.d.ts +21 -0
  302. package/dist/sequencePlaybackTypes.js +2 -0
  303. package/dist/sequenceTargetClaims.d.ts +10 -0
  304. package/dist/sequenceTargetClaims.js +31 -0
  305. package/dist/srgbBytes.d.ts +3 -0
  306. package/dist/srgbBytes.js +64 -0
  307. package/dist/startEngine.d.ts +5 -0
  308. package/dist/startEngine.js +31 -0
  309. package/dist/surfaceOwnership.d.ts +3 -0
  310. package/dist/surfaceOwnership.js +15 -0
  311. package/dist/text.d.ts +23 -0
  312. package/dist/text.js +4 -0
  313. package/dist/textField.d.ts +6 -0
  314. package/dist/textField.js +6 -0
  315. package/dist/tileMapDraw.d.ts +7 -0
  316. package/dist/tileMapDraw.js +310 -0
  317. package/dist/tiledImport.d.ts +9 -0
  318. package/dist/tiledImport.js +357 -0
  319. package/dist/tilemap.d.ts +5 -0
  320. package/dist/tilemap.js +5 -0
  321. package/dist/tilemapTypes.d.ts +169 -0
  322. package/dist/tilemapTypes.js +2 -0
  323. package/dist/tween.d.ts +15 -0
  324. package/dist/tween.js +329 -0
  325. package/dist/tweenTypes.d.ts +27 -0
  326. package/dist/tweenTypes.js +2 -0
  327. package/dist/ui/controlKeys.d.ts +109 -0
  328. package/dist/ui/controlKeys.js +249 -0
  329. package/dist/ui/controls.d.ts +52 -0
  330. package/dist/ui/controls.js +288 -0
  331. package/dist/ui/editing.d.ts +3 -0
  332. package/dist/ui/editing.js +3 -0
  333. package/dist/ui/index.d.ts +19 -0
  334. package/dist/ui/index.js +11 -0
  335. package/dist/ui/keyboardFocus.d.ts +32 -0
  336. package/dist/ui/keyboardFocus.js +146 -0
  337. package/dist/ui/layerTypes.d.ts +91 -0
  338. package/dist/ui/layerTypes.js +2 -0
  339. package/dist/ui/layers.d.ts +4 -0
  340. package/dist/ui/layers.js +586 -0
  341. package/dist/ui/leafContent.d.ts +21 -0
  342. package/dist/ui/leafContent.js +136 -0
  343. package/dist/ui/rangeControl.d.ts +50 -0
  344. package/dist/ui/rangeControl.js +167 -0
  345. package/dist/ui/scrollControl.d.ts +72 -0
  346. package/dist/ui/scrollControl.js +218 -0
  347. package/dist/ui/stateControls.d.ts +82 -0
  348. package/dist/ui/stateControls.js +328 -0
  349. package/dist/ui/textEditor.d.ts +53 -0
  350. package/dist/ui/textEditor.js +370 -0
  351. package/dist/ui/textEditorTypes.d.ts +78 -0
  352. package/dist/ui/textEditorTypes.js +2 -0
  353. package/dist/ui/textFieldControl.d.ts +96 -0
  354. package/dist/ui/textFieldControl.js +259 -0
  355. package/dist/ui/theme.d.ts +59 -0
  356. package/dist/ui/theme.js +165 -0
  357. package/dist/ui/types.d.ts +265 -0
  358. package/dist/ui/types.js +2 -0
  359. package/dist/ui/uiRoot.d.ts +4 -0
  360. package/dist/ui/uiRoot.js +1497 -0
  361. package/dist/ui/uiRootDisplay.d.ts +46 -0
  362. package/dist/ui/uiRootDisplay.js +148 -0
  363. package/dist/ui/uiRootModel.d.ts +112 -0
  364. package/dist/ui/uiRootModel.js +60 -0
  365. package/dist/ui/virtualList.d.ts +20 -0
  366. package/dist/ui/virtualList.js +105 -0
  367. package/dist/video.d.ts +4 -0
  368. package/dist/video.js +4 -0
  369. package/dist/videoPlayer.d.ts +4 -0
  370. package/dist/videoPlayer.js +215 -0
  371. package/dist/videoTypes.d.ts +74 -0
  372. package/dist/videoTypes.js +2 -0
  373. package/dist/web/BrowserAssetBundle.d.ts +39 -0
  374. package/dist/web/BrowserAssetBundle.js +136 -0
  375. package/dist/web/BrowserAudio.d.ts +41 -0
  376. package/dist/web/BrowserAudio.js +473 -0
  377. package/dist/web/BrowserFrameLoop.d.ts +65 -0
  378. package/dist/web/BrowserFrameLoop.js +125 -0
  379. package/dist/web/BrowserGame.d.ts +112 -0
  380. package/dist/web/BrowserGame.js +352 -0
  381. package/dist/web/BrowserGamepadInput.d.ts +35 -0
  382. package/dist/web/BrowserGamepadInput.js +134 -0
  383. package/dist/web/BrowserHoverInput.d.ts +24 -0
  384. package/dist/web/BrowserHoverInput.js +266 -0
  385. package/dist/web/BrowserImageTextures.d.ts +66 -0
  386. package/dist/web/BrowserImageTextures.js +169 -0
  387. package/dist/web/BrowserInputActions.d.ts +53 -0
  388. package/dist/web/BrowserInputActions.js +342 -0
  389. package/dist/web/BrowserKeyboardInput.d.ts +4 -0
  390. package/dist/web/BrowserKeyboardInput.js +223 -0
  391. package/dist/web/BrowserPlay.d.ts +289 -0
  392. package/dist/web/BrowserPlay.js +1301 -0
  393. package/dist/web/BrowserPointerInput.d.ts +4 -0
  394. package/dist/web/BrowserPointerInput.js +511 -0
  395. package/dist/web/BrowserSemantics.d.ts +34 -0
  396. package/dist/web/BrowserSemantics.js +418 -0
  397. package/dist/web/BrowserStatsPanel.d.ts +46 -0
  398. package/dist/web/BrowserStatsPanel.js +137 -0
  399. package/dist/web/BrowserStorage.d.ts +33 -0
  400. package/dist/web/BrowserStorage.js +132 -0
  401. package/dist/web/BrowserTextEditor.d.ts +49 -0
  402. package/dist/web/BrowserTextEditor.js +839 -0
  403. package/dist/web/BrowserTextInput.d.ts +83 -0
  404. package/dist/web/BrowserTextInput.js +524 -0
  405. package/dist/web/BrowserTextureProvider.d.ts +52 -0
  406. package/dist/web/BrowserTextureProvider.js +935 -0
  407. package/dist/web/BrowserVideo.d.ts +28 -0
  408. package/dist/web/BrowserVideo.js +211 -0
  409. package/dist/web/CanvasKitFontSetProvider.d.ts +29 -0
  410. package/dist/web/CanvasKitFontSetProvider.js +215 -0
  411. package/dist/web/CanvasKitParagraphProvider.d.ts +169 -0
  412. package/dist/web/CanvasKitParagraphProvider.js +691 -0
  413. package/dist/web/CanvasTextRasterProvider.d.ts +4 -0
  414. package/dist/web/CanvasTextRasterProvider.js +312 -0
  415. package/dist/web/ManifestByteSource.d.ts +147 -0
  416. package/dist/web/ManifestByteSource.js +974 -0
  417. package/dist/web/ManifestFontContentLoader.d.ts +12 -0
  418. package/dist/web/ManifestFontContentLoader.js +30 -0
  419. package/dist/web/MouseInput.d.ts +4 -0
  420. package/dist/web/MouseInput.js +218 -0
  421. package/dist/web/WebGL2Host.d.ts +5 -0
  422. package/dist/web/WebGL2Host.js +2672 -0
  423. package/dist/web/WebGPUHost.d.ts +87 -0
  424. package/dist/web/WebGPUHost.js +3349 -0
  425. package/dist/web/audio.d.ts +3 -0
  426. package/dist/web/audio.js +4 -0
  427. package/dist/web/canvasKitParagraphGeometry.d.ts +27 -0
  428. package/dist/web/canvasKitParagraphGeometry.js +83 -0
  429. package/dist/web/editing.d.ts +5 -0
  430. package/dist/web/editing.js +4 -0
  431. package/dist/web/editorFonts.d.ts +50 -0
  432. package/dist/web/editorFonts.js +297 -0
  433. package/dist/web/game.d.ts +5 -0
  434. package/dist/web/game.js +6 -0
  435. package/dist/web/gamepad.d.ts +3 -0
  436. package/dist/web/gamepad.js +4 -0
  437. package/dist/web/hover.d.ts +3 -0
  438. package/dist/web/hover.js +4 -0
  439. package/dist/web/image.d.ts +4 -0
  440. package/dist/web/image.js +4 -0
  441. package/dist/web/imageProjections2D.d.ts +14 -0
  442. package/dist/web/imageProjections2D.js +2 -0
  443. package/dist/web/input.d.ts +6 -0
  444. package/dist/web/input.js +4 -0
  445. package/dist/web/keyboard.d.ts +3 -0
  446. package/dist/web/keyboard.js +3 -0
  447. package/dist/web/kit.d.ts +10 -0
  448. package/dist/web/kit.js +7 -0
  449. package/dist/web/loop.d.ts +3 -0
  450. package/dist/web/loop.js +4 -0
  451. package/dist/web/paragraph.d.ts +6 -0
  452. package/dist/web/paragraph.js +4 -0
  453. package/dist/web/play.d.ts +5 -0
  454. package/dist/web/play.js +6 -0
  455. package/dist/web/playSfx.d.ts +36 -0
  456. package/dist/web/playSfx.js +112 -0
  457. package/dist/web/pointer.d.ts +3 -0
  458. package/dist/web/pointer.js +3 -0
  459. package/dist/web/prepareSharedSubmission2D.d.ts +27 -0
  460. package/dist/web/prepareSharedSubmission2D.js +57 -0
  461. package/dist/web/resources.d.ts +27 -0
  462. package/dist/web/resources.js +96 -0
  463. package/dist/web/semantics.d.ts +3 -0
  464. package/dist/web/semantics.js +4 -0
  465. package/dist/web/sharedDeviceSession.d.ts +64 -0
  466. package/dist/web/sharedDeviceSession.js +2 -0
  467. package/dist/web/sharedEffectShaders.d.ts +9 -0
  468. package/dist/web/sharedEffectShaders.js +165 -0
  469. package/dist/web/sharedFrameUpload.d.ts +25 -0
  470. package/dist/web/sharedFrameUpload.js +2 -0
  471. package/dist/web/sharedHostDeferred.d.ts +7 -0
  472. package/dist/web/sharedHostDeferred.js +12 -0
  473. package/dist/web/sharedRetentionLedger.d.ts +85 -0
  474. package/dist/web/sharedRetentionLedger.js +391 -0
  475. package/dist/web/sharedSubmissionStorage2D.d.ts +56 -0
  476. package/dist/web/sharedSubmissionStorage2D.js +73 -0
  477. package/dist/web/sharedWebGL2Arena.d.ts +40 -0
  478. package/dist/web/sharedWebGL2Arena.js +77 -0
  479. package/dist/web/sharedWebGL2Options.d.ts +30 -0
  480. package/dist/web/sharedWebGL2Options.js +96 -0
  481. package/dist/web/sharedWebGL2Shaders.d.ts +20 -0
  482. package/dist/web/sharedWebGL2Shaders.js +314 -0
  483. package/dist/web/sharedWebGPUOptions.d.ts +37 -0
  484. package/dist/web/sharedWebGPUOptions.js +126 -0
  485. package/dist/web/text.d.ts +3 -0
  486. package/dist/web/text.js +3 -0
  487. package/dist/web/textInput.d.ts +3 -0
  488. package/dist/web/textInput.js +3 -0
  489. package/dist/web/video.d.ts +3 -0
  490. package/dist/web/video.js +4 -0
  491. package/dist/web/webgl2.d.ts +7 -0
  492. package/dist/web/webgl2.js +4 -0
  493. package/dist/web/webgl2LayerState.d.ts +50 -0
  494. package/dist/web/webgl2LayerState.js +102 -0
  495. package/dist/web/webgl2Native.d.ts +70 -0
  496. package/dist/web/webgl2Native.js +568 -0
  497. package/dist/web/webgl2Types.d.ts +132 -0
  498. package/dist/web/webgl2Types.js +2 -0
  499. package/dist/web/webgpu.d.ts +6 -0
  500. package/dist/web/webgpu.js +2 -0
  501. package/dist/web/webgpuBindingCache.d.ts +26 -0
  502. package/dist/web/webgpuBindingCache.js +223 -0
  503. package/dist/web/webgpuBufferPool.d.ts +51 -0
  504. package/dist/web/webgpuBufferPool.js +58 -0
  505. package/dist/web/webgpuImageResidency.d.ts +53 -0
  506. package/dist/web/webgpuImageResidency.js +61 -0
  507. package/dist/web/webgpuLifetime.d.ts +45 -0
  508. package/dist/web/webgpuLifetime.js +64 -0
  509. package/dist/web/webgpuRetentionPool.d.ts +66 -0
  510. package/dist/web/webgpuRetentionPool.js +84 -0
  511. package/dist/web/webgpuSharedPass.d.ts +7 -0
  512. package/dist/web/webgpuSharedPass.js +211 -0
  513. package/dist/web/webgpuSharedResolvePass.d.ts +3 -0
  514. package/dist/web/webgpuSharedResolvePass.js +29 -0
  515. package/dist/web/world3d/Audio3D.d.ts +68 -0
  516. package/dist/web/world3d/Audio3D.js +212 -0
  517. package/dist/web/world3d/BrowserPlay3D.d.ts +182 -0
  518. package/dist/web/world3d/BrowserPlay3D.js +851 -0
  519. package/dist/web/world3d/FlyControls3D.d.ts +55 -0
  520. package/dist/web/world3d/FlyControls3D.js +160 -0
  521. package/dist/web/world3d/FollowControls3D.d.ts +28 -0
  522. package/dist/web/world3d/FollowControls3D.js +117 -0
  523. package/dist/web/world3d/OrbitControls3D.d.ts +55 -0
  524. package/dist/web/world3d/OrbitControls3D.js +187 -0
  525. package/dist/web/world3d/TransformControls3D.d.ts +34 -0
  526. package/dist/web/world3d/TransformControls3D.js +125 -0
  527. package/dist/web/world3d/WebGL2Renderer3D.d.ts +133 -0
  528. package/dist/web/world3d/WebGL2Renderer3D.js +1173 -0
  529. package/dist/web/world3d/WebGPURenderer3D.d.ts +110 -0
  530. package/dist/web/world3d/WebGPURenderer3D.js +1915 -0
  531. package/dist/web/world3d/World3DView.d.ts +51 -0
  532. package/dist/web/world3d/World3DView.js +77 -0
  533. package/dist/web/world3d/app3D.d.ts +136 -0
  534. package/dist/web/world3d/app3D.js +304 -0
  535. package/dist/web/world3d/assets3D.d.ts +38 -0
  536. package/dist/web/world3d/assets3D.js +112 -0
  537. package/dist/web/world3d/atmosphere3D.d.ts +47 -0
  538. package/dist/web/world3d/atmosphere3D.js +178 -0
  539. package/dist/web/world3d/frame3D.d.ts +142 -0
  540. package/dist/web/world3d/frame3D.js +388 -0
  541. package/dist/web/world3d/gpuResources3D.d.ts +98 -0
  542. package/dist/web/world3d/gpuResources3D.js +901 -0
  543. package/dist/web/world3d/host3D.d.ts +23 -0
  544. package/dist/web/world3d/host3D.js +61 -0
  545. package/dist/web/world3d/index.d.ts +38 -0
  546. package/dist/web/world3d/index.js +23 -0
  547. package/dist/web/world3d/loaders3D.d.ts +26 -0
  548. package/dist/web/world3d/loaders3D.js +138 -0
  549. package/dist/web/world3d/markers3D.d.ts +49 -0
  550. package/dist/web/world3d/markers3D.js +130 -0
  551. package/dist/web/world3d/materialWebGL23D.d.ts +34 -0
  552. package/dist/web/world3d/materialWebGL23D.js +218 -0
  553. package/dist/web/world3d/overlay3D.d.ts +28 -0
  554. package/dist/web/world3d/overlay3D.js +170 -0
  555. package/dist/web/world3d/post3D.d.ts +112 -0
  556. package/dist/web/world3d/post3D.js +459 -0
  557. package/dist/web/world3d/postWebGL23D.d.ts +24 -0
  558. package/dist/web/world3d/postWebGL23D.js +237 -0
  559. package/dist/web/world3d/postWebGPU3D.d.ts +23 -0
  560. package/dist/web/world3d/postWebGPU3D.js +255 -0
  561. package/dist/web/world3d/probe3D.d.ts +14 -0
  562. package/dist/web/world3d/probe3D.js +66 -0
  563. package/dist/web/world3d/shaders3D.d.ts +43 -0
  564. package/dist/web/world3d/shaders3D.js +851 -0
  565. package/dist/web/world3d/stats3D.d.ts +31 -0
  566. package/dist/web/world3d/stats3D.js +80 -0
  567. package/dist/web/world3d/webGL2FrameMetrics3D.d.ts +66 -0
  568. package/dist/web/world3d/webGL2FrameMetrics3D.js +185 -0
  569. package/dist/web/world3d/webgpu.d.ts +35 -0
  570. package/dist/web/world3d/webgpu.js +22 -0
  571. package/dist/web/world3d/webgpuPacking3D.d.ts +13 -0
  572. package/dist/web/world3d/webgpuPacking3D.js +85 -0
  573. package/dist/web/world3d/wgsl3D.d.ts +68 -0
  574. package/dist/web/world3d/wgsl3D.js +781 -0
  575. package/package.json +220 -4
@@ -0,0 +1,357 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import { EgretError } from '@egret/runtime';
3
+ const MAX_CELLS = 1 << 24, MAX_LAYERS = 256, MAX_TILESETS = 256, MAX_OBJECTS = 100_000, MAX_SIDE = 1 << 16;
4
+ /** The top three bits of a global id say how the tile is turned; the rest is the id. */
5
+ export const TILE_FLIP_MASK = 0xe0000000;
6
+ const record = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
7
+ const fail = (code, where) => {
8
+ throw new EgretError(code, { cause: new Error(where) });
9
+ };
10
+ function whole(value, least, most, where) {
11
+ if (!Number.isSafeInteger(value) || value < least || value > most)
12
+ fail('TILEMAP_DATA_INVALID', where);
13
+ return value;
14
+ }
15
+ function number(value, where, otherwise) {
16
+ if (value === undefined && otherwise !== undefined)
17
+ return otherwise;
18
+ if (typeof value !== 'number' || !Number.isFinite(value))
19
+ fail('TILEMAP_DATA_INVALID', where);
20
+ return value;
21
+ }
22
+ function text(value, where, otherwise) {
23
+ if (value === undefined && otherwise !== undefined)
24
+ return otherwise;
25
+ if (typeof value !== 'string')
26
+ fail('TILEMAP_DATA_INVALID', where);
27
+ return value;
28
+ }
29
+ function flag(value, where, otherwise) {
30
+ if (value === undefined)
31
+ return otherwise;
32
+ if (typeof value !== 'boolean')
33
+ fail('TILEMAP_DATA_INVALID', where);
34
+ return value;
35
+ }
36
+ /** `#RRGGBB` or `#AARRGGBB`, as Tiled writes it; the colour without its alpha. */
37
+ function colour(value, where) {
38
+ if (value === undefined)
39
+ return undefined;
40
+ const found = typeof value === 'string' ? /^#(?:[0-9a-fA-F]{2})?([0-9a-fA-F]{6})$/.exec(value) : null;
41
+ if (found === null)
42
+ return fail('TILEMAP_DATA_INVALID', where);
43
+ return parseInt(found[1], 16);
44
+ }
45
+ function properties(value, where) {
46
+ if (value === undefined)
47
+ return Object.freeze({});
48
+ if (!Array.isArray(value))
49
+ return fail('TILEMAP_DATA_INVALID', where);
50
+ const out = {};
51
+ for (const entry of value) {
52
+ if (!record(entry))
53
+ fail('TILEMAP_DATA_INVALID', where);
54
+ const name = text(entry['name'], where + '.name'), raw = entry['value'];
55
+ if (Object.hasOwn(out, name))
56
+ fail('TILEMAP_DATA_INVALID', where + ': ' + name + ' twice');
57
+ // A property of a class or an object reference is kept as what it can be read as; a class is not followed.
58
+ if (typeof raw === 'string' || typeof raw === 'boolean' || (typeof raw === 'number' && Number.isFinite(raw)))
59
+ out[name] = raw;
60
+ else if (raw === null || raw === undefined)
61
+ out[name] = '';
62
+ else if (record(raw))
63
+ out[name] = JSON.stringify(raw);
64
+ else
65
+ fail('TILEMAP_DATA_INVALID', where + ': ' + name);
66
+ }
67
+ return Object.freeze(out);
68
+ }
69
+ const ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
70
+ /** Base64 without the host: the core has no `atob` of its own to lean on. */
71
+ function base64(value, where) {
72
+ const clean = value.replace(/\s+/g, '');
73
+ if (clean.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(clean))
74
+ fail('TILEMAP_DATA_INVALID', where);
75
+ const padding = clean.endsWith('==') ? 2 : clean.endsWith('=') ? 1 : 0, out = new Uint8Array((clean.length / 4) * 3 - padding);
76
+ let at = 0;
77
+ for (let i = 0; i < clean.length; i += 4) {
78
+ const n = (ALPHABET.indexOf(clean[i]) << 18) |
79
+ (ALPHABET.indexOf(clean[i + 1]) << 12) |
80
+ (Math.max(0, ALPHABET.indexOf(clean[i + 2])) << 6) |
81
+ Math.max(0, ALPHABET.indexOf(clean[i + 3]));
82
+ for (const shift of [16, 8, 0])
83
+ if (at < out.length)
84
+ out[at++] = (n >>> shift) & 255;
85
+ }
86
+ return out;
87
+ }
88
+ /** The cells of a layer or a chunk, from an array of numbers or base64 of little-endian 32-bit words. */
89
+ function cells(raw, count, encoding, compression, where) {
90
+ if (compression !== undefined && compression !== '')
91
+ return fail('TILEMAP_COMPRESSION_UNSUPPORTED', where);
92
+ const out = new Uint32Array(count);
93
+ if (encoding === 'base64') {
94
+ const bytes = base64(text(raw, where), where);
95
+ if (bytes.length !== count * 4)
96
+ fail('TILEMAP_DATA_INVALID', where + ': length');
97
+ for (let i = 0; i < count; i++)
98
+ out[i] = (bytes[i * 4] | (bytes[i * 4 + 1] << 8) | (bytes[i * 4 + 2] << 16) | (bytes[i * 4 + 3] << 24)) >>> 0;
99
+ return out;
100
+ }
101
+ if (encoding !== undefined && encoding !== 'csv')
102
+ return fail('TILEMAP_DATA_INVALID', where + ': encoding');
103
+ if (!Array.isArray(raw) || raw.length !== count)
104
+ return fail('TILEMAP_DATA_INVALID', where + ': length');
105
+ for (let i = 0; i < count; i++)
106
+ out[i] = whole(raw[i], 0, 0xffffffff, where);
107
+ return out;
108
+ }
109
+ function tileset(raw, where, external) {
110
+ if (!record(raw))
111
+ return fail('TILEMAP_DATA_INVALID', where);
112
+ const firstGid = whole(raw['firstgid'], 1, 0x1fffffff, where + '.firstgid');
113
+ let set = raw;
114
+ if (raw['source'] !== undefined) {
115
+ const source = text(raw['source'], where + '.source'), found = Object.hasOwn(external, source) ? external[source] : undefined;
116
+ if (!record(found))
117
+ return fail('TILEMAP_TILESET_MISSING', source);
118
+ set = found;
119
+ }
120
+ if (set['image'] === undefined)
121
+ return fail('TILEMAP_TILESET_UNSUPPORTED', where + ': a set of separate images');
122
+ const tileWidth = whole(set['tilewidth'], 1, 4096, where + '.tilewidth'), tileHeight = whole(set['tileheight'], 1, 4096, where + '.tileheight');
123
+ const spacing = whole(set['spacing'] ?? 0, 0, 4096, where + '.spacing'), margin = whole(set['margin'] ?? 0, 0, 4096, where + '.margin');
124
+ const imageWidth = whole(set['imagewidth'], 1, 16384, where + '.imagewidth'), imageHeight = whole(set['imageheight'], 1, 16384, where + '.imageheight');
125
+ const columns = whole(set['columns'], 1, 16384, where + '.columns'), tileCount = whole(set['tilecount'], 1, MAX_CELLS, where + '.tilecount');
126
+ // Every tile the set says it has lies inside its image.
127
+ const rows = Math.ceil(tileCount / columns);
128
+ if (margin * 2 + columns * tileWidth + (columns - 1) * spacing > imageWidth ||
129
+ margin * 2 + rows * tileHeight + (rows - 1) * spacing > imageHeight)
130
+ fail('TILEMAP_DATA_INVALID', where + ': the tiles do not fit the image');
131
+ const tiles = new Map();
132
+ if (set['tiles'] !== undefined) {
133
+ if (!Array.isArray(set['tiles']))
134
+ fail('TILEMAP_DATA_INVALID', where + '.tiles');
135
+ for (const tile of set['tiles']) {
136
+ if (!record(tile))
137
+ fail('TILEMAP_DATA_INVALID', where + '.tiles');
138
+ const t = tile, id = whole(t['id'], 0, tileCount - 1, where + '.tiles.id');
139
+ let animation;
140
+ if (t['animation'] !== undefined) {
141
+ if (!Array.isArray(t['animation']) || t['animation'].length === 0)
142
+ fail('TILEMAP_DATA_INVALID', where + '.animation');
143
+ animation = t['animation'].map(frame => {
144
+ if (!record(frame))
145
+ return fail('TILEMAP_DATA_INVALID', where + '.animation');
146
+ return Object.freeze({
147
+ tileId: whole(frame['tileid'], 0, tileCount - 1, where + '.animation.tileid'),
148
+ duration: whole(frame['duration'], 1, 3_600_000, where + '.animation.duration')
149
+ });
150
+ });
151
+ }
152
+ const type = t['type'] ?? t['class'];
153
+ tiles.set(id, Object.freeze({
154
+ properties: properties(t['properties'], where + '.tiles.properties'),
155
+ ...(animation === undefined ? {} : { animation: Object.freeze(animation) }),
156
+ ...(typeof type === 'string' && type !== '' ? { type } : {})
157
+ }));
158
+ }
159
+ }
160
+ return Object.freeze({
161
+ name: text(set['name'], where + '.name'),
162
+ firstGid,
163
+ tileWidth,
164
+ tileHeight,
165
+ columns,
166
+ tileCount,
167
+ spacing,
168
+ margin,
169
+ image: text(set['image'], where + '.image'),
170
+ imageWidth,
171
+ imageHeight,
172
+ properties: properties(set['properties'], where + '.properties'),
173
+ tiles
174
+ });
175
+ }
176
+ function object(raw, where) {
177
+ if (!record(raw))
178
+ return fail('TILEMAP_DATA_INVALID', where);
179
+ const shape = raw['point'] === true
180
+ ? 'point'
181
+ : raw['ellipse'] === true
182
+ ? 'ellipse'
183
+ : Array.isArray(raw['polygon'])
184
+ ? 'polygon'
185
+ : Array.isArray(raw['polyline'])
186
+ ? 'polyline'
187
+ : record(raw['text'])
188
+ ? 'text'
189
+ : 'rectangle';
190
+ const pointsRaw = shape === 'polygon' ? raw['polygon'] : shape === 'polyline' ? raw['polyline'] : undefined;
191
+ const points = pointsRaw === undefined
192
+ ? undefined
193
+ : Object.freeze(pointsRaw.map(point => {
194
+ if (!record(point))
195
+ return fail('TILEMAP_DATA_INVALID', where + '.points');
196
+ return Object.freeze({ x: number(point['x'], where + '.x'), y: number(point['y'], where + '.y') });
197
+ }));
198
+ const type = raw['type'] ?? raw['class'] ?? '';
199
+ return Object.freeze({
200
+ id: whole(raw['id'], 0, Number.MAX_SAFE_INTEGER, where + '.id'),
201
+ name: text(raw['name'], where + '.name', ''),
202
+ type: text(type, where + '.type'),
203
+ x: number(raw['x'], where + '.x'),
204
+ y: number(raw['y'], where + '.y'),
205
+ width: number(raw['width'], where + '.width', 0),
206
+ height: number(raw['height'], where + '.height', 0),
207
+ rotation: number(raw['rotation'], where + '.rotation', 0),
208
+ visible: flag(raw['visible'], where + '.visible', true),
209
+ ...(raw['gid'] === undefined ? {} : { gid: whole(raw['gid'], 1, 0xffffffff, where + '.gid') }),
210
+ shape,
211
+ ...(points === undefined ? {} : { points }),
212
+ ...(shape === 'text' ? { text: text(raw['text']['text'], where + '.text', '') } : {}),
213
+ properties: properties(raw['properties'], where + '.properties')
214
+ });
215
+ }
216
+ /**
217
+ * Reads a map saved by Tiled as JSON (`.tmj`, or `.json`), orthogonal, with tile layers as arrays or as
218
+ * base64 without compression, finite or infinite, object layers and groups. What it cannot read it refuses.
219
+ */
220
+ export function importTiledMap(json, options = {}) {
221
+ if (!record(options) || (options.tilesets !== undefined && !record(options.tilesets)))
222
+ throw new EgretError('TILEMAP_OPTIONS_INVALID');
223
+ if (!record(json) || (json['type'] !== undefined && json['type'] !== 'map'))
224
+ return fail('TILEMAP_DATA_INVALID', 'map');
225
+ if (json['orientation'] !== 'orthogonal')
226
+ return fail('TILEMAP_ORIENTATION_UNSUPPORTED', String(json['orientation']));
227
+ const infinite = flag(json['infinite'], 'infinite', false);
228
+ const width = whole(json['width'], infinite ? 0 : 1, MAX_SIDE, 'width'), height = whole(json['height'], infinite ? 0 : 1, MAX_SIDE, 'height');
229
+ const tileWidth = whole(json['tilewidth'], 1, 4096, 'tilewidth'), tileHeight = whole(json['tileheight'], 1, 4096, 'tileheight');
230
+ if (!Array.isArray(json['tilesets']) || json['tilesets'].length > MAX_TILESETS)
231
+ return fail('TILEMAP_DATA_INVALID', 'tilesets');
232
+ const tilesets = json['tilesets']
233
+ .map((set, index) => tileset(set, 'tilesets.' + index, (options.tilesets ?? {})))
234
+ .sort((a, b) => a.firstGid - b.firstGid);
235
+ for (let i = 1; i < tilesets.length; i++)
236
+ if (tilesets[i].firstGid < tilesets[i - 1].firstGid + tilesets[i - 1].tileCount)
237
+ fail('TILEMAP_DATA_INVALID', 'tilesets overlap');
238
+ const layers = [];
239
+ let objectCount = 0;
240
+ function walk(list, prefix, ox, oy, opacity, visible, px, py, depth) {
241
+ if (!Array.isArray(list) || depth > 32)
242
+ return fail('TILEMAP_DATA_INVALID', prefix + 'layers');
243
+ for (const raw of list) {
244
+ if (!record(raw))
245
+ fail('TILEMAP_DATA_INVALID', prefix + 'layer');
246
+ const layer = raw, name = prefix + text(layer['name'], 'layer.name', ''), where = 'layer ' + name;
247
+ const x = ox + number(layer['offsetx'], where, 0), y = oy + number(layer['offsety'], where, 0);
248
+ const alpha = opacity * number(layer['opacity'], where, 1), shown = visible && flag(layer['visible'], where, true);
249
+ const parallaxX = px * number(layer['parallaxx'], where, 1), parallaxY = py * number(layer['parallaxy'], where, 1);
250
+ if (alpha < 0 || alpha > 1)
251
+ fail('TILEMAP_DATA_INVALID', where + ': opacity');
252
+ if (layers.length >= MAX_LAYERS)
253
+ fail('TILEMAP_DATA_INVALID', 'too many layers');
254
+ if (layer['type'] === 'group') {
255
+ walk(layer['layers'], name + '/', x, y, alpha, shown, parallaxX, parallaxY, depth + 1);
256
+ continue;
257
+ }
258
+ const common = {
259
+ name,
260
+ offsetX: x,
261
+ offsetY: y,
262
+ opacity: alpha,
263
+ visible: shown,
264
+ properties: properties(layer['properties'], where)
265
+ };
266
+ if (layer['type'] === 'tilelayer') {
267
+ let data, w, h, startX = 0, startY = 0;
268
+ if (layer['chunks'] !== undefined) {
269
+ // An infinite layer: the chunks are laid into one grid that holds them all.
270
+ if (!Array.isArray(layer['chunks']))
271
+ fail('TILEMAP_DATA_INVALID', where + ': chunks');
272
+ const chunks = layer['chunks'].map((chunk, index) => {
273
+ if (!record(chunk))
274
+ return fail('TILEMAP_DATA_INVALID', where + ': chunk');
275
+ const cw = whole(chunk['width'], 1, MAX_SIDE, where), ch = whole(chunk['height'], 1, MAX_SIDE, where);
276
+ return {
277
+ x: whole(chunk['x'], -MAX_SIDE, MAX_SIDE, where),
278
+ y: whole(chunk['y'], -MAX_SIDE, MAX_SIDE, where),
279
+ width: cw,
280
+ height: ch,
281
+ data: cells(chunk['data'], cw * ch, layer['encoding'], layer['compression'], where + ': chunk ' + index)
282
+ };
283
+ });
284
+ if (chunks.length === 0) {
285
+ w = 0;
286
+ h = 0;
287
+ data = new Uint32Array(0);
288
+ }
289
+ else {
290
+ startX = Math.min(...chunks.map(c => c.x));
291
+ startY = Math.min(...chunks.map(c => c.y));
292
+ w = Math.max(...chunks.map(c => c.x + c.width)) - startX;
293
+ h = Math.max(...chunks.map(c => c.y + c.height)) - startY;
294
+ if (w * h > MAX_CELLS)
295
+ fail('TILEMAP_DATA_INVALID', where + ': too many cells');
296
+ data = new Uint32Array(w * h);
297
+ for (const chunk of chunks)
298
+ for (let row = 0; row < chunk.height; row++)
299
+ data.set(chunk.data.subarray(row * chunk.width, (row + 1) * chunk.width), (chunk.y - startY + row) * w + chunk.x - startX);
300
+ }
301
+ }
302
+ else {
303
+ w = whole(layer['width'], 1, MAX_SIDE, where);
304
+ h = whole(layer['height'], 1, MAX_SIDE, where);
305
+ if (w * h > MAX_CELLS)
306
+ fail('TILEMAP_DATA_INVALID', where + ': too many cells');
307
+ data = cells(layer['data'], w * h, layer['encoding'], layer['compression'], where);
308
+ }
309
+ // Every id is one of a tileset, or none.
310
+ for (const gid of data) {
311
+ const id = (gid & ~TILE_FLIP_MASK) >>> 0;
312
+ if (id !== 0 && !tilesets.some(set => id >= set.firstGid && id < set.firstGid + set.tileCount))
313
+ fail('TILEMAP_DATA_INVALID', where + ': tile ' + id + ' of no tileset');
314
+ }
315
+ layers.push(Object.freeze({
316
+ type: 'tile',
317
+ ...common,
318
+ width: w,
319
+ height: h,
320
+ startX,
321
+ startY,
322
+ parallaxX,
323
+ parallaxY,
324
+ data
325
+ }));
326
+ }
327
+ else if (layer['type'] === 'objectgroup') {
328
+ if (!Array.isArray(layer['objects']))
329
+ fail('TILEMAP_DATA_INVALID', where + ': objects');
330
+ objectCount += layer['objects'].length;
331
+ if (objectCount > MAX_OBJECTS)
332
+ fail('TILEMAP_DATA_INVALID', 'too many objects');
333
+ layers.push(Object.freeze({
334
+ type: 'object',
335
+ ...common,
336
+ objects: Object.freeze(layer['objects'].map((o, i) => object(o, where + ': object ' + i)))
337
+ }));
338
+ }
339
+ else
340
+ fail('TILEMAP_LAYER_UNSUPPORTED', where + ': ' + String(layer['type']));
341
+ }
342
+ }
343
+ walk(json['layers'], '', 0, 0, 1, true, 1, 1, 0);
344
+ return Object.freeze({
345
+ orientation: 'orthogonal',
346
+ width,
347
+ height,
348
+ tileWidth,
349
+ tileHeight,
350
+ infinite,
351
+ backgroundColor: colour(json['backgroundcolor'], 'backgroundcolor'),
352
+ properties: properties(json['properties'], 'properties'),
353
+ tilesets: Object.freeze(tilesets),
354
+ layers: Object.freeze(layers)
355
+ });
356
+ }
357
+ //# sourceMappingURL=tiledImport.js.map
@@ -0,0 +1,5 @@
1
+ /** Optional tile maps: Tiled maps read into plain data, and drawn in chunks of meshes. */
2
+ export { importTiledMap, TILE_FLIP_MASK } from './tiledImport.js';
3
+ export { createTileMap } from './tileMapDraw.js';
4
+ export type { ObjectLayerData, TileAnimationFrame, TiledImportOptions, TileInfo, TileLayerData, TileMap, TileMapChunk, TileMapData, TileMapLayer, TileMapLayerData, TileMapObject, TileMapOptions, TileMapProperties, TileMapPropertyValue, TileSetData } from './tilemapTypes.js';
5
+ //# sourceMappingURL=tilemap.d.ts.map
@@ -0,0 +1,5 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /** Optional tile maps: Tiled maps read into plain data, and drawn in chunks of meshes. */
3
+ export { importTiledMap, TILE_FLIP_MASK } from './tiledImport.js';
4
+ export { createTileMap } from './tileMapDraw.js';
5
+ //# sourceMappingURL=tilemap.js.map
@@ -0,0 +1,169 @@
1
+ import type { AssetLease, DisplayObjectContainer, Mesh2D, Texture } from '@egret/runtime';
2
+ import type { TexturedGeometry2D } from '@egret/contracts';
3
+ export type TileMapPropertyValue = string | number | boolean;
4
+ export type TileMapProperties = Readonly<Record<string, TileMapPropertyValue>>;
5
+ export interface TileAnimationFrame {
6
+ readonly tileId: number;
7
+ readonly duration: number;
8
+ }
9
+ export interface TileSetData {
10
+ readonly name: string;
11
+ /** The global id of the first tile of the set. */
12
+ readonly firstGid: number;
13
+ readonly tileWidth: number;
14
+ readonly tileHeight: number;
15
+ readonly columns: number;
16
+ readonly tileCount: number;
17
+ readonly spacing: number;
18
+ readonly margin: number;
19
+ /** Where the image is, as the map says it; the game loads it. */
20
+ readonly image: string;
21
+ readonly imageWidth: number;
22
+ readonly imageHeight: number;
23
+ readonly properties: TileMapProperties;
24
+ /** What a tile of the set says of itself, by its id in the set. */
25
+ readonly tiles: ReadonlyMap<number, {
26
+ readonly properties: TileMapProperties;
27
+ readonly animation?: readonly TileAnimationFrame[];
28
+ readonly type?: string;
29
+ }>;
30
+ }
31
+ export interface TileLayerData {
32
+ readonly type: 'tile';
33
+ readonly name: string;
34
+ /** Cells across and down. An infinite map is cut to the cells it has, starting at `startX`, `startY`. */
35
+ readonly width: number;
36
+ readonly height: number;
37
+ readonly startX: number;
38
+ readonly startY: number;
39
+ readonly offsetX: number;
40
+ readonly offsetY: number;
41
+ readonly opacity: number;
42
+ readonly visible: boolean;
43
+ readonly parallaxX: number;
44
+ readonly parallaxY: number;
45
+ readonly properties: TileMapProperties;
46
+ /** A global id with its flip flags in the top three bits, row by row. 0 is no tile. */
47
+ readonly data: Uint32Array;
48
+ }
49
+ export interface TileMapObject {
50
+ readonly id: number;
51
+ readonly name: string;
52
+ readonly type: string;
53
+ readonly x: number;
54
+ readonly y: number;
55
+ readonly width: number;
56
+ readonly height: number;
57
+ readonly rotation: number;
58
+ readonly visible: boolean;
59
+ /** A tile drawn as the object, with its flip flags. */
60
+ readonly gid?: number;
61
+ readonly shape: 'rectangle' | 'ellipse' | 'point' | 'polygon' | 'polyline' | 'text';
62
+ readonly points?: readonly {
63
+ readonly x: number;
64
+ readonly y: number;
65
+ }[];
66
+ readonly text?: string;
67
+ readonly properties: TileMapProperties;
68
+ }
69
+ export interface ObjectLayerData {
70
+ readonly type: 'object';
71
+ readonly name: string;
72
+ readonly offsetX: number;
73
+ readonly offsetY: number;
74
+ readonly opacity: number;
75
+ readonly visible: boolean;
76
+ readonly properties: TileMapProperties;
77
+ readonly objects: readonly TileMapObject[];
78
+ }
79
+ export type TileMapLayerData = TileLayerData | ObjectLayerData;
80
+ /** A map as plain, frozen data: what a tile map is made from. */
81
+ export interface TileMapData {
82
+ readonly orientation: 'orthogonal';
83
+ /** Cells across and down, and the size of one. */
84
+ readonly width: number;
85
+ readonly height: number;
86
+ readonly tileWidth: number;
87
+ readonly tileHeight: number;
88
+ readonly infinite: boolean;
89
+ readonly backgroundColor: number | undefined;
90
+ readonly properties: TileMapProperties;
91
+ readonly tilesets: readonly TileSetData[];
92
+ /** Back to front. Layers inside groups are given with the names of their groups before theirs, `group/layer`. */
93
+ readonly layers: readonly TileMapLayerData[];
94
+ }
95
+ export interface TiledImportOptions {
96
+ /** Tilesets kept in files of their own, by the `source` the map names, as the JSON Tiled writes for them. */
97
+ readonly tilesets?: Readonly<Record<string, unknown>>;
98
+ }
99
+ export interface TileInfo {
100
+ /** The global id, without flip flags. */
101
+ readonly gid: number;
102
+ readonly tileset: TileSetData;
103
+ /** The id inside its set. */
104
+ readonly id: number;
105
+ readonly flippedHorizontally: boolean;
106
+ readonly flippedVertically: boolean;
107
+ readonly flippedDiagonally: boolean;
108
+ readonly properties: TileMapProperties;
109
+ }
110
+ export interface TileMapChunk {
111
+ /** The first cell of the chunk. */
112
+ readonly column: number;
113
+ readonly row: number;
114
+ readonly visible: boolean;
115
+ /** One mesh for each tileset the chunk draws from. */
116
+ readonly meshes: readonly {
117
+ readonly tileset: string;
118
+ readonly mesh: Mesh2D;
119
+ readonly geometry: TexturedGeometry2D;
120
+ readonly tiles: number;
121
+ }[];
122
+ }
123
+ export interface TileMapLayer {
124
+ readonly name: string;
125
+ readonly data: TileLayerData;
126
+ readonly display: DisplayObjectContainer;
127
+ readonly chunks: readonly TileMapChunk[];
128
+ }
129
+ export interface TileMapOptions {
130
+ readonly map: TileMapData;
131
+ /** The image of each tileset that is drawn, by its name. A set without one cannot be drawn. */
132
+ readonly textures: Readonly<Record<string, AssetLease<Texture>>>;
133
+ /** Cells across and down in one chunk, 4 to 128. Defaults to 32. */
134
+ readonly chunkSize?: number;
135
+ }
136
+ /** A map drawn: one container for each tile layer, cut into chunks of meshes that can be left out when they cannot be seen. */
137
+ export interface TileMap {
138
+ readonly state: 'active' | 'closed';
139
+ readonly data: TileMapData;
140
+ /** Holds the layers back to front. Put it in the world. */
141
+ readonly display: DisplayObjectContainer;
142
+ readonly layers: readonly TileMapLayer[];
143
+ layer(name: string): TileMapLayer;
144
+ /** The tile at a cell of a layer, or undefined for none or a cell outside it. */
145
+ tileAt(layer: string, column: number, row: number): TileInfo | undefined;
146
+ /** Puts a tile, with its flip flags, at a cell, or takes it away with 0. Its chunk is drawn again. */
147
+ setTile(layer: string, column: number, row: number, gid: number): void;
148
+ /** What a tile says of itself, by global id. */
149
+ propertiesOf(gid: number): TileMapProperties;
150
+ /** The cell under a point of the map, and the top left corner of a cell. */
151
+ cellAt(x: number, y: number): {
152
+ readonly column: number;
153
+ readonly row: number;
154
+ };
155
+ cellOrigin(column: number, row: number): {
156
+ readonly x: number;
157
+ readonly y: number;
158
+ };
159
+ /** Shows only the chunks that meet a rectangle of the map. Returns how many chunks show. */
160
+ cull(view: {
161
+ readonly x: number;
162
+ readonly y: number;
163
+ readonly width: number;
164
+ readonly height: number;
165
+ }): number;
166
+ /** Takes the meshes off the display and lets go of them. A scope can own a tile map through this. */
167
+ dispose(): void;
168
+ }
169
+ //# sourceMappingURL=tilemapTypes.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tilemapTypes.js.map
@@ -0,0 +1,15 @@
1
+ import { Scope } from '@egret/runtime';
2
+ import type { GameClock } from './gameClockTypes.js';
3
+ import type { Tween } from './tweenTypes.js';
4
+ export interface TweenContext {
5
+ assertOpen(): void;
6
+ isEngineScope(scope: unknown): scope is Scope;
7
+ readonly clock: GameClock;
8
+ }
9
+ export interface TweenOwner {
10
+ create(scope: unknown, options: unknown): Tween;
11
+ close(): void;
12
+ }
13
+ /** Private Engine assembly; live records alone belong to the owner inventory. */
14
+ export declare function createTweenOwner(context: TweenContext): TweenOwner;
15
+ //# sourceMappingURL=tween.d.ts.map