@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.
- package/LICENSE +201 -0
- package/NOTICE +21 -0
- package/README.md +101 -2
- package/README.zh-CN.md +102 -0
- package/dist/Engine.d.ts +77 -0
- package/dist/Engine.js +469 -0
- package/dist/animation/index.d.ts +6 -0
- package/dist/animation/index.js +5 -0
- package/dist/animation/sequenceController.d.ts +22 -0
- package/dist/animation/sequenceController.js +618 -0
- package/dist/animation/sequenceCoordinator.d.ts +26 -0
- package/dist/animation/sequenceCoordinator.js +161 -0
- package/dist/animation/sequenceInput.d.ts +25 -0
- package/dist/animation/sequenceInput.js +108 -0
- package/dist/animation/sequenceMath.d.ts +35 -0
- package/dist/animation/sequenceMath.js +164 -0
- package/dist/animation/sequenceResetSlot.d.ts +7 -0
- package/dist/animation/sequenceResetSlot.js +367 -0
- package/dist/animation/sequenceResetTypes.d.ts +48 -0
- package/dist/animation/sequenceResetTypes.js +2 -0
- package/dist/animation/types.d.ts +75 -0
- package/dist/animation/types.js +2 -0
- package/dist/assetBundle.d.ts +54 -0
- package/dist/assetBundle.js +173 -0
- package/dist/assetGroup.d.ts +17 -0
- package/dist/assetGroup.js +332 -0
- package/dist/assetGroupTypes.d.ts +17 -0
- package/dist/assetGroupTypes.js +2 -0
- package/dist/audio.d.ts +4 -0
- package/dist/audio.js +4 -0
- package/dist/audioCues.d.ts +47 -0
- package/dist/audioCues.js +127 -0
- package/dist/audioMixer.d.ts +7 -0
- package/dist/audioMixer.js +785 -0
- package/dist/audioTypes.d.ts +246 -0
- package/dist/audioTypes.js +3 -0
- package/dist/bitmapBindingTicket.d.ts +24 -0
- package/dist/bitmapBindingTicket.js +215 -0
- package/dist/bitmapButton.d.ts +4 -0
- package/dist/bitmapButton.js +407 -0
- package/dist/bitmapButtonTypes.d.ts +31 -0
- package/dist/bitmapButtonTypes.js +2 -0
- package/dist/bitmapFontParse.d.ts +10 -0
- package/dist/bitmapFontParse.js +246 -0
- package/dist/bitmapFontTypes.d.ts +112 -0
- package/dist/bitmapFontTypes.js +2 -0
- package/dist/bitmapResourceSlot.d.ts +26 -0
- package/dist/bitmapResourceSlot.js +340 -0
- package/dist/bitmapText.d.ts +6 -0
- package/dist/bitmapText.js +320 -0
- package/dist/bitmapfont.d.ts +5 -0
- package/dist/bitmapfont.js +5 -0
- package/dist/camera.d.ts +4 -0
- package/dist/camera.js +4 -0
- package/dist/camera2d.d.ts +7 -0
- package/dist/camera2d.js +419 -0
- package/dist/cameraTypes.d.ts +126 -0
- package/dist/cameraTypes.js +2 -0
- package/dist/closeHost.d.ts +4 -0
- package/dist/closeHost.js +66 -0
- package/dist/contentArtifacts.d.ts +12 -0
- package/dist/contentArtifacts.js +153 -0
- package/dist/contentAtlasPages.d.ts +13 -0
- package/dist/contentAtlasPages.js +117 -0
- package/dist/contentLoader.d.ts +6 -0
- package/dist/contentLoader.js +327 -0
- package/dist/contentTypes.d.ts +35 -0
- package/dist/contentTypes.js +2 -0
- package/dist/createEngine.d.ts +7 -0
- package/dist/createEngine.js +25 -0
- package/dist/createEngineForProfile.d.ts +5 -0
- package/dist/createEngineForProfile.js +45 -0
- package/dist/displaySubtreeTicket.d.ts +25 -0
- package/dist/displaySubtreeTicket.js +76 -0
- package/dist/fontContentLoader.d.ts +6 -0
- package/dist/fontContentLoader.js +298 -0
- package/dist/fontContentTypes.d.ts +39 -0
- package/dist/fontContentTypes.js +2 -0
- package/dist/gameClock.d.ts +24 -0
- package/dist/gameClock.js +246 -0
- package/dist/gameClockTypes.d.ts +37 -0
- package/dist/gameClockTypes.js +2 -0
- package/dist/gameRun.d.ts +53 -0
- package/dist/gameRun.js +97 -0
- package/dist/gamepad.d.ts +5 -0
- package/dist/gamepad.js +5 -0
- package/dist/gamepadInput.d.ts +4 -0
- package/dist/gamepadInput.js +281 -0
- package/dist/gamepadKeys.d.ts +4 -0
- package/dist/gamepadKeys.js +205 -0
- package/dist/gamepadTypes.d.ts +142 -0
- package/dist/gamepadTypes.js +3 -0
- package/dist/hover.d.ts +4 -0
- package/dist/hover.js +4 -0
- package/dist/hoverInput.d.ts +8 -0
- package/dist/hoverInput.js +503 -0
- package/dist/hoverInputTypes.d.ts +129 -0
- package/dist/hoverInputTypes.js +2 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.js +21 -0
- package/dist/input.d.ts +6 -0
- package/dist/input.js +5 -0
- package/dist/inputActions.d.ts +86 -0
- package/dist/inputActions.js +330 -0
- package/dist/internal/contentFactoryState.d.ts +19 -0
- package/dist/internal/contentFactoryState.js +42 -0
- package/dist/internal/mouseInputFactoryState.d.ts +57 -0
- package/dist/internal/mouseInputFactoryState.js +125 -0
- package/dist/internal/sequenceControllerFactoryState.d.ts +42 -0
- package/dist/internal/sequenceControllerFactoryState.js +98 -0
- package/dist/internal/textFieldFactoryState.d.ts +11 -0
- package/dist/internal/textFieldFactoryState.js +32 -0
- package/dist/internal/texturedFrameState.d.ts +4 -0
- package/dist/internal/texturedFrameState.js +12 -0
- package/dist/internal/uiFactoryState.d.ts +68 -0
- package/dist/internal/uiFactoryState.js +173 -0
- package/dist/internal/uiRootState.d.ts +67 -0
- package/dist/internal/uiRootState.js +103 -0
- package/dist/keyboardInput.d.ts +13 -0
- package/dist/keyboardInput.js +579 -0
- package/dist/keyboardInputTypes.d.ts +93 -0
- package/dist/keyboardInputTypes.js +2 -0
- package/dist/kit.d.ts +16 -0
- package/dist/kit.js +10 -0
- package/dist/layout.d.ts +5 -0
- package/dist/layout.js +132 -0
- package/dist/layoutTypes.d.ts +28 -0
- package/dist/layoutTypes.js +2 -0
- package/dist/manifestAssetGroup.d.ts +10 -0
- package/dist/manifestAssetGroup.js +477 -0
- package/dist/manifestResourceState.d.ts +17 -0
- package/dist/manifestResourceState.js +58 -0
- package/dist/manifestResourceTypes.d.ts +26 -0
- package/dist/manifestResourceTypes.js +2 -0
- package/dist/motion.d.ts +35 -0
- package/dist/motion.js +206 -0
- package/dist/mouseInput.d.ts +102 -0
- package/dist/mouseInput.js +562 -0
- package/dist/mouseInputTypes.d.ts +41 -0
- package/dist/mouseInputTypes.js +2 -0
- package/dist/paragraph.d.ts +8 -0
- package/dist/paragraph.js +7 -0
- package/dist/particleEmitter.d.ts +4 -0
- package/dist/particleEmitter.js +300 -0
- package/dist/particleTypes.d.ts +115 -0
- package/dist/particleTypes.js +2 -0
- package/dist/particles.d.ts +4 -0
- package/dist/particles.js +4 -0
- package/dist/physics2d.d.ts +4 -0
- package/dist/physics2d.js +4 -0
- package/dist/physics2dGeometry.d.ts +39 -0
- package/dist/physics2dGeometry.js +230 -0
- package/dist/physics2dTypes.d.ts +221 -0
- package/dist/physics2dTypes.js +2 -0
- package/dist/physics2dWorld.d.ts +4 -0
- package/dist/physics2dWorld.js +823 -0
- package/dist/pointerInput.d.ts +12 -0
- package/dist/pointerInput.js +300 -0
- package/dist/pointerInputTypes.d.ts +41 -0
- package/dist/pointerInputTypes.js +2 -0
- package/dist/random.d.ts +30 -0
- package/dist/random.js +131 -0
- package/dist/rendering/ownedPreparationFailure2D.d.ts +5 -0
- package/dist/rendering/ownedPreparationFailure2D.js +33 -0
- package/dist/rendering/packSharedDraws2D.d.ts +50 -0
- package/dist/rendering/packSharedDraws2D.js +379 -0
- package/dist/rendering/packedOrientation.d.ts +4 -0
- package/dist/rendering/packedOrientation.js +7 -0
- package/dist/rendering/prepareRectangles2D.d.ts +92 -0
- package/dist/rendering/prepareRectangles2D.js +481 -0
- package/dist/rendering/prepareSharedDraws2D.d.ts +90 -0
- package/dist/rendering/prepareSharedDraws2D.js +663 -0
- package/dist/rendering/preparedBatches2D.d.ts +17 -0
- package/dist/rendering/preparedBatches2D.js +30 -0
- package/dist/rendering/preparedSharedBatches2D.d.ts +44 -0
- package/dist/rendering/preparedSharedBatches2D.js +247 -0
- package/dist/rendering/sharedColor2D.d.ts +52 -0
- package/dist/rendering/sharedColor2D.js +191 -0
- package/dist/rendering/sharedEffects2D.d.ts +23 -0
- package/dist/rendering/sharedEffects2D.js +126 -0
- package/dist/rendering/sharedPreparationRetention2D.d.ts +120 -0
- package/dist/rendering/sharedPreparationRetention2D.js +357 -0
- package/dist/rendering/srgbBytes.d.ts +3 -0
- package/dist/rendering/srgbBytes.js +64 -0
- package/dist/rendering/texturedPreparationBudget2D.d.ts +31 -0
- package/dist/rendering/texturedPreparationBudget2D.js +81 -0
- package/dist/rendering/world3d/Animation3D.d.ts +104 -0
- package/dist/rendering/world3d/Animation3D.js +384 -0
- package/dist/rendering/world3d/AnimationTexture3D.d.ts +163 -0
- package/dist/rendering/world3d/AnimationTexture3D.js +603 -0
- package/dist/rendering/world3d/Batch3D.d.ts +75 -0
- package/dist/rendering/world3d/Batch3D.js +332 -0
- package/dist/rendering/world3d/Camera3D.d.ts +62 -0
- package/dist/rendering/world3d/Camera3D.js +132 -0
- package/dist/rendering/world3d/Character3D.d.ts +127 -0
- package/dist/rendering/world3d/Character3D.js +305 -0
- package/dist/rendering/world3d/Cloth3D.d.ts +130 -0
- package/dist/rendering/world3d/Cloth3D.js +503 -0
- package/dist/rendering/world3d/Compression3D.d.ts +22 -0
- package/dist/rendering/world3d/Compression3D.js +703 -0
- package/dist/rendering/world3d/Curves3D.d.ts +119 -0
- package/dist/rendering/world3d/Curves3D.js +460 -0
- package/dist/rendering/world3d/Decal3D.d.ts +43 -0
- package/dist/rendering/world3d/Decal3D.js +242 -0
- package/dist/rendering/world3d/Export3D.d.ts +13 -0
- package/dist/rendering/world3d/Export3D.js +263 -0
- package/dist/rendering/world3d/Geometry3D.d.ts +95 -0
- package/dist/rendering/world3d/Geometry3D.js +335 -0
- package/dist/rendering/world3d/GeometryBuilder3D.d.ts +53 -0
- package/dist/rendering/world3d/GeometryBuilder3D.js +196 -0
- package/dist/rendering/world3d/Gizmo3D.d.ts +80 -0
- package/dist/rendering/world3d/Gizmo3D.js +514 -0
- package/dist/rendering/world3d/Gltf3D.d.ts +73 -0
- package/dist/rendering/world3d/Gltf3D.js +996 -0
- package/dist/rendering/world3d/GpuParticles3D.d.ts +109 -0
- package/dist/rendering/world3d/GpuParticles3D.js +401 -0
- package/dist/rendering/world3d/Hdr3D.d.ts +35 -0
- package/dist/rendering/world3d/Hdr3D.js +191 -0
- package/dist/rendering/world3d/Jelly3D.d.ts +77 -0
- package/dist/rendering/world3d/Jelly3D.js +267 -0
- package/dist/rendering/world3d/Ktx23D.d.ts +30 -0
- package/dist/rendering/world3d/Ktx23D.js +112 -0
- package/dist/rendering/world3d/Light3D.d.ts +84 -0
- package/dist/rendering/world3d/Light3D.js +97 -0
- package/dist/rendering/world3d/Material3D.d.ts +253 -0
- package/dist/rendering/world3d/Material3D.js +269 -0
- package/dist/rendering/world3d/Mesh3D.d.ts +112 -0
- package/dist/rendering/world3d/Mesh3D.js +337 -0
- package/dist/rendering/world3d/Meshopt3D.d.ts +15 -0
- package/dist/rendering/world3d/Meshopt3D.js +276 -0
- package/dist/rendering/world3d/Navigation3D.d.ts +213 -0
- package/dist/rendering/world3d/Navigation3D.js +1043 -0
- package/dist/rendering/world3d/Object3D.d.ts +118 -0
- package/dist/rendering/world3d/Object3D.js +315 -0
- package/dist/rendering/world3d/Particles3D.d.ts +90 -0
- package/dist/rendering/world3d/Particles3D.js +277 -0
- package/dist/rendering/world3d/Physics3D.d.ts +430 -0
- package/dist/rendering/world3d/Physics3D.js +2840 -0
- package/dist/rendering/world3d/PhysicsHull3D.d.ts +37 -0
- package/dist/rendering/world3d/PhysicsHull3D.js +229 -0
- package/dist/rendering/world3d/PhysicsMesh3D.d.ts +41 -0
- package/dist/rendering/world3d/PhysicsMesh3D.js +340 -0
- package/dist/rendering/world3d/PhysicsQueries3D.d.ts +24 -0
- package/dist/rendering/world3d/PhysicsQueries3D.js +323 -0
- package/dist/rendering/world3d/PhysicsRemote3D.d.ts +179 -0
- package/dist/rendering/world3d/PhysicsRemote3D.js +536 -0
- package/dist/rendering/world3d/Ragdoll3D.d.ts +74 -0
- package/dist/rendering/world3d/Ragdoll3D.js +202 -0
- package/dist/rendering/world3d/Raycast3D.d.ts +40 -0
- package/dist/rendering/world3d/Raycast3D.js +247 -0
- package/dist/rendering/world3d/RenderList3D.d.ts +91 -0
- package/dist/rendering/world3d/RenderList3D.js +502 -0
- package/dist/rendering/world3d/Retarget3D.d.ts +21 -0
- package/dist/rendering/world3d/Retarget3D.js +185 -0
- package/dist/rendering/world3d/Rig3D.d.ts +57 -0
- package/dist/rendering/world3d/Rig3D.js +219 -0
- package/dist/rendering/world3d/Sdf3D.d.ts +181 -0
- package/dist/rendering/world3d/Sdf3D.js +1136 -0
- package/dist/rendering/world3d/SdfLod3D.d.ts +17 -0
- package/dist/rendering/world3d/SdfLod3D.js +56 -0
- package/dist/rendering/world3d/Serialize3D.d.ts +66 -0
- package/dist/rendering/world3d/Serialize3D.js +629 -0
- package/dist/rendering/world3d/Simplify3D.d.ts +29 -0
- package/dist/rendering/world3d/Simplify3D.js +426 -0
- package/dist/rendering/world3d/StateMachine3D.d.ts +87 -0
- package/dist/rendering/world3d/StateMachine3D.js +280 -0
- package/dist/rendering/world3d/SurfaceMaterial3D.d.ts +26 -0
- package/dist/rendering/world3d/SurfaceMaterial3D.js +138 -0
- package/dist/rendering/world3d/Terrain3D.d.ts +248 -0
- package/dist/rendering/world3d/Terrain3D.js +827 -0
- package/dist/rendering/world3d/Text3D.d.ts +95 -0
- package/dist/rendering/world3d/Text3D.js +560 -0
- package/dist/rendering/world3d/Texture3D.d.ts +148 -0
- package/dist/rendering/world3d/Texture3D.js +270 -0
- package/dist/rendering/world3d/Trail3D.d.ts +62 -0
- package/dist/rendering/world3d/Trail3D.js +195 -0
- package/dist/rendering/world3d/Vehicle3D.d.ts +102 -0
- package/dist/rendering/world3d/Vehicle3D.js +228 -0
- package/dist/rendering/world3d/VolumetricFog3D.d.ts +57 -0
- package/dist/rendering/world3d/VolumetricFog3D.js +230 -0
- package/dist/rendering/world3d/Water3D.d.ts +165 -0
- package/dist/rendering/world3d/Water3D.js +607 -0
- package/dist/rendering/world3d/core3D.d.ts +36 -0
- package/dist/rendering/world3d/core3D.js +99 -0
- package/dist/rendering/world3d/debug3D.d.ts +69 -0
- package/dist/rendering/world3d/debug3D.js +262 -0
- package/dist/rendering/world3d/decoders3D.d.ts +42 -0
- package/dist/rendering/world3d/decoders3D.js +133 -0
- package/dist/rendering/world3d/geometries3D.d.ts +111 -0
- package/dist/rendering/world3d/geometries3D.js +610 -0
- package/dist/rendering/world3d/helpers3D.d.ts +67 -0
- package/dist/rendering/world3d/helpers3D.js +178 -0
- package/dist/rendering/world3d/index.d.ts +103 -0
- package/dist/rendering/world3d/index.js +62 -0
- package/dist/rendering/world3d/math3D.d.ts +114 -0
- package/dist/rendering/world3d/math3D.js +675 -0
- package/dist/rendering/world3d/primitives3D.d.ts +67 -0
- package/dist/rendering/world3d/primitives3D.js +197 -0
- package/dist/resources.d.ts +8 -0
- package/dist/resources.js +6 -0
- package/dist/saveStore.d.ts +71 -0
- package/dist/saveStore.js +182 -0
- package/dist/semanticList.d.ts +126 -0
- package/dist/semanticList.js +175 -0
- package/dist/semanticTree.d.ts +10 -0
- package/dist/semanticTree.js +539 -0
- package/dist/semanticTypes.d.ts +175 -0
- package/dist/semanticTypes.js +2 -0
- package/dist/semantics.d.ts +6 -0
- package/dist/semantics.js +5 -0
- package/dist/sequencePlayback.d.ts +19 -0
- package/dist/sequencePlayback.js +391 -0
- package/dist/sequencePlaybackTypes.d.ts +24 -0
- package/dist/sequencePlaybackTypes.js +2 -0
- package/dist/sequenceTargetClaims.d.ts +10 -0
- package/dist/sequenceTargetClaims.js +31 -0
- package/dist/srgbBytes.d.ts +3 -0
- package/dist/srgbBytes.js +64 -0
- package/dist/startEngine.d.ts +5 -0
- package/dist/startEngine.js +31 -0
- package/dist/surfaceOwnership.d.ts +3 -0
- package/dist/surfaceOwnership.js +15 -0
- package/dist/text.d.ts +24 -0
- package/dist/text.js +4 -0
- package/dist/textField.d.ts +6 -0
- package/dist/textField.js +6 -0
- package/dist/textTable.d.ts +41 -0
- package/dist/textTable.js +114 -0
- package/dist/tileMapDraw.d.ts +7 -0
- package/dist/tileMapDraw.js +310 -0
- package/dist/tiledImport.d.ts +9 -0
- package/dist/tiledImport.js +357 -0
- package/dist/tilemap.d.ts +5 -0
- package/dist/tilemap.js +5 -0
- package/dist/tilemapTypes.d.ts +182 -0
- package/dist/tilemapTypes.js +2 -0
- package/dist/timer.d.ts +34 -0
- package/dist/timer.js +119 -0
- package/dist/tween.d.ts +15 -0
- package/dist/tween.js +329 -0
- package/dist/tweenTypes.d.ts +31 -0
- package/dist/tweenTypes.js +2 -0
- package/dist/ui/controlKeys.d.ts +113 -0
- package/dist/ui/controlKeys.js +250 -0
- package/dist/ui/controls.d.ts +58 -0
- package/dist/ui/controls.js +290 -0
- package/dist/ui/editing.d.ts +3 -0
- package/dist/ui/editing.js +3 -0
- package/dist/ui/index.d.ts +19 -0
- package/dist/ui/index.js +11 -0
- package/dist/ui/keyboardFocus.d.ts +32 -0
- package/dist/ui/keyboardFocus.js +146 -0
- package/dist/ui/layerTypes.d.ts +98 -0
- package/dist/ui/layerTypes.js +2 -0
- package/dist/ui/layers.d.ts +4 -0
- package/dist/ui/layers.js +586 -0
- package/dist/ui/leafContent.d.ts +21 -0
- package/dist/ui/leafContent.js +136 -0
- package/dist/ui/rangeControl.d.ts +53 -0
- package/dist/ui/rangeControl.js +168 -0
- package/dist/ui/scrollControl.d.ts +84 -0
- package/dist/ui/scrollControl.js +222 -0
- package/dist/ui/stateControls.d.ts +90 -0
- package/dist/ui/stateControls.js +331 -0
- package/dist/ui/textEditor.d.ts +54 -0
- package/dist/ui/textEditor.js +371 -0
- package/dist/ui/textEditorTypes.d.ts +85 -0
- package/dist/ui/textEditorTypes.js +2 -0
- package/dist/ui/textFieldControl.d.ts +100 -0
- package/dist/ui/textFieldControl.js +260 -0
- package/dist/ui/theme.d.ts +64 -0
- package/dist/ui/theme.js +166 -0
- package/dist/ui/types.d.ts +285 -0
- package/dist/ui/types.js +2 -0
- package/dist/ui/uiRoot.d.ts +4 -0
- package/dist/ui/uiRoot.js +1526 -0
- package/dist/ui/uiRootDisplay.d.ts +46 -0
- package/dist/ui/uiRootDisplay.js +148 -0
- package/dist/ui/uiRootModel.d.ts +114 -0
- package/dist/ui/uiRootModel.js +66 -0
- package/dist/ui/virtualList.d.ts +20 -0
- package/dist/ui/virtualList.js +105 -0
- package/dist/video.d.ts +4 -0
- package/dist/video.js +4 -0
- package/dist/videoPlayer.d.ts +4 -0
- package/dist/videoPlayer.js +215 -0
- package/dist/videoTypes.d.ts +77 -0
- package/dist/videoTypes.js +2 -0
- package/dist/web/BrowserAssetBundle.d.ts +41 -0
- package/dist/web/BrowserAssetBundle.js +136 -0
- package/dist/web/BrowserAudio.d.ts +74 -0
- package/dist/web/BrowserAudio.js +503 -0
- package/dist/web/BrowserFrameLoop.d.ts +69 -0
- package/dist/web/BrowserFrameLoop.js +125 -0
- package/dist/web/BrowserGame.d.ts +174 -0
- package/dist/web/BrowserGame.js +473 -0
- package/dist/web/BrowserGamepadInput.d.ts +38 -0
- package/dist/web/BrowserGamepadInput.js +134 -0
- package/dist/web/BrowserHoverInput.d.ts +25 -0
- package/dist/web/BrowserHoverInput.js +266 -0
- package/dist/web/BrowserImageTextures.d.ts +72 -0
- package/dist/web/BrowserImageTextures.js +169 -0
- package/dist/web/BrowserInputActions.d.ts +63 -0
- package/dist/web/BrowserInputActions.js +345 -0
- package/dist/web/BrowserKeyboardInput.d.ts +4 -0
- package/dist/web/BrowserKeyboardInput.js +223 -0
- package/dist/web/BrowserPlay.d.ts +417 -0
- package/dist/web/BrowserPlay.js +1648 -0
- package/dist/web/BrowserPointerInput.d.ts +4 -0
- package/dist/web/BrowserPointerInput.js +511 -0
- package/dist/web/BrowserPreferences.d.ts +10 -0
- package/dist/web/BrowserPreferences.js +39 -0
- package/dist/web/BrowserSemantics.d.ts +36 -0
- package/dist/web/BrowserSemantics.js +418 -0
- package/dist/web/BrowserStatsPanel.d.ts +56 -0
- package/dist/web/BrowserStatsPanel.js +143 -0
- package/dist/web/BrowserStorage.d.ts +35 -0
- package/dist/web/BrowserStorage.js +132 -0
- package/dist/web/BrowserTextEditor.d.ts +52 -0
- package/dist/web/BrowserTextEditor.js +839 -0
- package/dist/web/BrowserTextInput.d.ts +89 -0
- package/dist/web/BrowserTextInput.js +524 -0
- package/dist/web/BrowserTextureProvider.d.ts +58 -0
- package/dist/web/BrowserTextureProvider.js +935 -0
- package/dist/web/BrowserVideo.d.ts +40 -0
- package/dist/web/BrowserVideo.js +237 -0
- package/dist/web/CanvasKitFontSetProvider.d.ts +32 -0
- package/dist/web/CanvasKitFontSetProvider.js +215 -0
- package/dist/web/CanvasKitParagraphProvider.d.ts +173 -0
- package/dist/web/CanvasKitParagraphProvider.js +692 -0
- package/dist/web/CanvasTextRasterProvider.d.ts +4 -0
- package/dist/web/CanvasTextRasterProvider.js +312 -0
- package/dist/web/ManifestByteSource.d.ts +151 -0
- package/dist/web/ManifestByteSource.js +975 -0
- package/dist/web/ManifestFontContentLoader.d.ts +13 -0
- package/dist/web/ManifestFontContentLoader.js +30 -0
- package/dist/web/MouseInput.d.ts +4 -0
- package/dist/web/MouseInput.js +218 -0
- package/dist/web/WebGL2Host.d.ts +5 -0
- package/dist/web/WebGL2Host.js +2711 -0
- package/dist/web/WebGPUHost.d.ts +100 -0
- package/dist/web/WebGPUHost.js +3430 -0
- package/dist/web/audio.d.ts +3 -0
- package/dist/web/audio.js +4 -0
- package/dist/web/canvasKitParagraphGeometry.d.ts +27 -0
- package/dist/web/canvasKitParagraphGeometry.js +83 -0
- package/dist/web/editing.d.ts +5 -0
- package/dist/web/editing.js +4 -0
- package/dist/web/editorFonts.d.ts +54 -0
- package/dist/web/editorFonts.js +297 -0
- package/dist/web/game.d.ts +5 -0
- package/dist/web/game.js +6 -0
- package/dist/web/gamepad.d.ts +3 -0
- package/dist/web/gamepad.js +4 -0
- package/dist/web/hover.d.ts +3 -0
- package/dist/web/hover.js +4 -0
- package/dist/web/image.d.ts +4 -0
- package/dist/web/image.js +4 -0
- package/dist/web/imageProjections2D.d.ts +16 -0
- package/dist/web/imageProjections2D.js +2 -0
- package/dist/web/input.d.ts +6 -0
- package/dist/web/input.js +4 -0
- package/dist/web/keyboard.d.ts +3 -0
- package/dist/web/keyboard.js +3 -0
- package/dist/web/kit.d.ts +11 -0
- package/dist/web/kit.js +8 -0
- package/dist/web/loop.d.ts +3 -0
- package/dist/web/loop.js +4 -0
- package/dist/web/paragraph.d.ts +6 -0
- package/dist/web/paragraph.js +4 -0
- package/dist/web/play.d.ts +10 -0
- package/dist/web/play.js +9 -0
- package/dist/web/playMusic.d.ts +33 -0
- package/dist/web/playMusic.js +194 -0
- package/dist/web/playSfx.d.ts +36 -0
- package/dist/web/playSfx.js +112 -0
- package/dist/web/playTouch.d.ts +45 -0
- package/dist/web/playTouch.js +141 -0
- package/dist/web/playWidgets.d.ts +71 -0
- package/dist/web/playWidgets.js +431 -0
- package/dist/web/pointer.d.ts +3 -0
- package/dist/web/pointer.js +3 -0
- package/dist/web/prepareSharedSubmission2D.d.ts +27 -0
- package/dist/web/prepareSharedSubmission2D.js +63 -0
- package/dist/web/resources.d.ts +29 -0
- package/dist/web/resources.js +96 -0
- package/dist/web/semantics.d.ts +3 -0
- package/dist/web/semantics.js +4 -0
- package/dist/web/sharedDeviceSession.d.ts +64 -0
- package/dist/web/sharedDeviceSession.js +2 -0
- package/dist/web/sharedEffectShaders.d.ts +13 -0
- package/dist/web/sharedEffectShaders.js +181 -0
- package/dist/web/sharedFrameUpload.d.ts +25 -0
- package/dist/web/sharedFrameUpload.js +2 -0
- package/dist/web/sharedHostDeferred.d.ts +7 -0
- package/dist/web/sharedHostDeferred.js +12 -0
- package/dist/web/sharedRetentionLedger.d.ts +85 -0
- package/dist/web/sharedRetentionLedger.js +391 -0
- package/dist/web/sharedSubmissionStorage2D.d.ts +56 -0
- package/dist/web/sharedSubmissionStorage2D.js +73 -0
- package/dist/web/sharedWebGL2Arena.d.ts +40 -0
- package/dist/web/sharedWebGL2Arena.js +77 -0
- package/dist/web/sharedWebGL2Options.d.ts +33 -0
- package/dist/web/sharedWebGL2Options.js +102 -0
- package/dist/web/sharedWebGL2Shaders.d.ts +33 -0
- package/dist/web/sharedWebGL2Shaders.js +408 -0
- package/dist/web/sharedWebGPUOptions.d.ts +41 -0
- package/dist/web/sharedWebGPUOptions.js +130 -0
- package/dist/web/text.d.ts +3 -0
- package/dist/web/text.js +3 -0
- package/dist/web/textInput.d.ts +3 -0
- package/dist/web/textInput.js +3 -0
- package/dist/web/video.d.ts +3 -0
- package/dist/web/video.js +4 -0
- package/dist/web/webgl2.d.ts +7 -0
- package/dist/web/webgl2.js +4 -0
- package/dist/web/webgl2LayerState.d.ts +50 -0
- package/dist/web/webgl2LayerState.js +102 -0
- package/dist/web/webgl2Native.d.ts +72 -0
- package/dist/web/webgl2Native.js +572 -0
- package/dist/web/webgl2Types.d.ts +150 -0
- package/dist/web/webgl2Types.js +2 -0
- package/dist/web/webgpu.d.ts +6 -0
- package/dist/web/webgpu.js +2 -0
- package/dist/web/webgpuBindingCache.d.ts +26 -0
- package/dist/web/webgpuBindingCache.js +223 -0
- package/dist/web/webgpuBufferPool.d.ts +51 -0
- package/dist/web/webgpuBufferPool.js +58 -0
- package/dist/web/webgpuImageResidency.d.ts +56 -0
- package/dist/web/webgpuImageResidency.js +65 -0
- package/dist/web/webgpuLifetime.d.ts +45 -0
- package/dist/web/webgpuLifetime.js +64 -0
- package/dist/web/webgpuRetentionPool.d.ts +66 -0
- package/dist/web/webgpuRetentionPool.js +85 -0
- package/dist/web/webgpuSharedPass.d.ts +7 -0
- package/dist/web/webgpuSharedPass.js +293 -0
- package/dist/web/webgpuSharedResolvePass.d.ts +3 -0
- package/dist/web/webgpuSharedResolvePass.js +34 -0
- package/dist/web/world3d/Audio3D.d.ts +85 -0
- package/dist/web/world3d/Audio3D.js +271 -0
- package/dist/web/world3d/BrowserPlay3D.d.ts +295 -0
- package/dist/web/world3d/BrowserPlay3D.js +1256 -0
- package/dist/web/world3d/FlyControls3D.d.ts +59 -0
- package/dist/web/world3d/FlyControls3D.js +162 -0
- package/dist/web/world3d/FollowControls3D.d.ts +31 -0
- package/dist/web/world3d/FollowControls3D.js +119 -0
- package/dist/web/world3d/OrbitControls3D.d.ts +58 -0
- package/dist/web/world3d/OrbitControls3D.js +189 -0
- package/dist/web/world3d/TransformControls3D.d.ts +37 -0
- package/dist/web/world3d/TransformControls3D.js +128 -0
- package/dist/web/world3d/WebGL2Renderer3D.d.ts +136 -0
- package/dist/web/world3d/WebGL2Renderer3D.js +1175 -0
- package/dist/web/world3d/WebGPURenderer3D.d.ts +112 -0
- package/dist/web/world3d/WebGPURenderer3D.js +1916 -0
- package/dist/web/world3d/World3DView.d.ts +54 -0
- package/dist/web/world3d/World3DView.js +79 -0
- package/dist/web/world3d/app3D.d.ts +143 -0
- package/dist/web/world3d/app3D.js +305 -0
- package/dist/web/world3d/assets3D.d.ts +39 -0
- package/dist/web/world3d/assets3D.js +112 -0
- package/dist/web/world3d/atmosphere3D.d.ts +56 -0
- package/dist/web/world3d/atmosphere3D.js +193 -0
- package/dist/web/world3d/canvasFont3D.d.ts +21 -0
- package/dist/web/world3d/canvasFont3D.js +165 -0
- package/dist/web/world3d/frame3D.d.ts +144 -0
- package/dist/web/world3d/frame3D.js +388 -0
- package/dist/web/world3d/gpuResources3D.d.ts +98 -0
- package/dist/web/world3d/gpuResources3D.js +901 -0
- package/dist/web/world3d/host3D.d.ts +24 -0
- package/dist/web/world3d/host3D.js +61 -0
- package/dist/web/world3d/index.d.ts +40 -0
- package/dist/web/world3d/index.js +24 -0
- package/dist/web/world3d/loaders3D.d.ts +27 -0
- package/dist/web/world3d/loaders3D.js +138 -0
- package/dist/web/world3d/markers3D.d.ts +53 -0
- package/dist/web/world3d/markers3D.js +130 -0
- package/dist/web/world3d/materialWebGL23D.d.ts +34 -0
- package/dist/web/world3d/materialWebGL23D.js +218 -0
- package/dist/web/world3d/overlay3D.d.ts +47 -0
- package/dist/web/world3d/overlay3D.js +187 -0
- package/dist/web/world3d/post3D.d.ts +116 -0
- package/dist/web/world3d/post3D.js +462 -0
- package/dist/web/world3d/postWebGL23D.d.ts +24 -0
- package/dist/web/world3d/postWebGL23D.js +237 -0
- package/dist/web/world3d/postWebGPU3D.d.ts +23 -0
- package/dist/web/world3d/postWebGPU3D.js +255 -0
- package/dist/web/world3d/probe3D.d.ts +15 -0
- package/dist/web/world3d/probe3D.js +66 -0
- package/dist/web/world3d/shaders3D.d.ts +43 -0
- package/dist/web/world3d/shaders3D.js +851 -0
- package/dist/web/world3d/stats3D.d.ts +34 -0
- package/dist/web/world3d/stats3D.js +81 -0
- package/dist/web/world3d/webGL2FrameMetrics3D.d.ts +71 -0
- package/dist/web/world3d/webGL2FrameMetrics3D.js +185 -0
- package/dist/web/world3d/webgpu.d.ts +37 -0
- package/dist/web/world3d/webgpu.js +23 -0
- package/dist/web/world3d/webgpuPacking3D.d.ts +13 -0
- package/dist/web/world3d/webgpuPacking3D.js +85 -0
- package/dist/web/world3d/wgsl3D.d.ts +68 -0
- package/dist/web/world3d/wgsl3D.js +781 -0
- 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
|
package/dist/tilemap.js
ADDED
|
@@ -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,182 @@
|
|
|
1
|
+
import type { AssetLease, DisplayObjectContainer, Mesh2D, Texture } from '@egret/runtime';
|
|
2
|
+
import type { TexturedGeometry2D } from '@egret/contracts';
|
|
3
|
+
/** The value of a tile map property. */
|
|
4
|
+
export type TileMapPropertyValue = string | number | boolean;
|
|
5
|
+
/** The properties of a map, layer, tile or object, by name. */
|
|
6
|
+
export type TileMapProperties = Readonly<Record<string, TileMapPropertyValue>>;
|
|
7
|
+
/** One frame of an animated tile: the tile it shows and for how long. */
|
|
8
|
+
export interface TileAnimationFrame {
|
|
9
|
+
readonly tileId: number;
|
|
10
|
+
readonly duration: number;
|
|
11
|
+
}
|
|
12
|
+
/** A tileset: its tiles' size and count, its image, and the properties and animations of its tiles. */
|
|
13
|
+
export interface TileSetData {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
/** The global id of the first tile of the set. */
|
|
16
|
+
readonly firstGid: number;
|
|
17
|
+
readonly tileWidth: number;
|
|
18
|
+
readonly tileHeight: number;
|
|
19
|
+
readonly columns: number;
|
|
20
|
+
readonly tileCount: number;
|
|
21
|
+
readonly spacing: number;
|
|
22
|
+
readonly margin: number;
|
|
23
|
+
/** Where the image is, as the map says it; the game loads it. */
|
|
24
|
+
readonly image: string;
|
|
25
|
+
readonly imageWidth: number;
|
|
26
|
+
readonly imageHeight: number;
|
|
27
|
+
readonly properties: TileMapProperties;
|
|
28
|
+
/** What a tile of the set says of itself, by its id in the set. */
|
|
29
|
+
readonly tiles: ReadonlyMap<number, {
|
|
30
|
+
readonly properties: TileMapProperties;
|
|
31
|
+
readonly animation?: readonly TileAnimationFrame[];
|
|
32
|
+
readonly type?: string;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
/** A layer of tiles: its name, size, offset, opacity and parallax, and its tiles' global ids. */
|
|
36
|
+
export interface TileLayerData {
|
|
37
|
+
readonly type: 'tile';
|
|
38
|
+
readonly name: string;
|
|
39
|
+
/** Cells across and down. An infinite map is cut to the cells it has, starting at `startX`, `startY`. */
|
|
40
|
+
readonly width: number;
|
|
41
|
+
readonly height: number;
|
|
42
|
+
readonly startX: number;
|
|
43
|
+
readonly startY: number;
|
|
44
|
+
readonly offsetX: number;
|
|
45
|
+
readonly offsetY: number;
|
|
46
|
+
readonly opacity: number;
|
|
47
|
+
readonly visible: boolean;
|
|
48
|
+
readonly parallaxX: number;
|
|
49
|
+
readonly parallaxY: number;
|
|
50
|
+
readonly properties: TileMapProperties;
|
|
51
|
+
/** A global id with its flip flags in the top three bits, row by row. 0 is no tile. */
|
|
52
|
+
readonly data: Uint32Array;
|
|
53
|
+
}
|
|
54
|
+
/** An object of an object layer: its place and size, its shape or tile, its text and properties. */
|
|
55
|
+
export interface TileMapObject {
|
|
56
|
+
readonly id: number;
|
|
57
|
+
readonly name: string;
|
|
58
|
+
readonly type: string;
|
|
59
|
+
readonly x: number;
|
|
60
|
+
readonly y: number;
|
|
61
|
+
readonly width: number;
|
|
62
|
+
readonly height: number;
|
|
63
|
+
readonly rotation: number;
|
|
64
|
+
readonly visible: boolean;
|
|
65
|
+
/** A tile drawn as the object, with its flip flags. */
|
|
66
|
+
readonly gid?: number;
|
|
67
|
+
readonly shape: 'rectangle' | 'ellipse' | 'point' | 'polygon' | 'polyline' | 'text';
|
|
68
|
+
readonly points?: readonly {
|
|
69
|
+
readonly x: number;
|
|
70
|
+
readonly y: number;
|
|
71
|
+
}[];
|
|
72
|
+
readonly text?: string;
|
|
73
|
+
readonly properties: TileMapProperties;
|
|
74
|
+
}
|
|
75
|
+
/** A layer of objects: its name, offset, opacity and objects. */
|
|
76
|
+
export interface ObjectLayerData {
|
|
77
|
+
readonly type: 'object';
|
|
78
|
+
readonly name: string;
|
|
79
|
+
readonly offsetX: number;
|
|
80
|
+
readonly offsetY: number;
|
|
81
|
+
readonly opacity: number;
|
|
82
|
+
readonly visible: boolean;
|
|
83
|
+
readonly properties: TileMapProperties;
|
|
84
|
+
readonly objects: readonly TileMapObject[];
|
|
85
|
+
}
|
|
86
|
+
/** A layer of a map: tiles or objects. */
|
|
87
|
+
export type TileMapLayerData = TileLayerData | ObjectLayerData;
|
|
88
|
+
/** A map as plain, frozen data: what a tile map is made from. */
|
|
89
|
+
export interface TileMapData {
|
|
90
|
+
readonly orientation: 'orthogonal';
|
|
91
|
+
/** Cells across and down, and the size of one. */
|
|
92
|
+
readonly width: number;
|
|
93
|
+
readonly height: number;
|
|
94
|
+
readonly tileWidth: number;
|
|
95
|
+
readonly tileHeight: number;
|
|
96
|
+
readonly infinite: boolean;
|
|
97
|
+
readonly backgroundColor: number | undefined;
|
|
98
|
+
readonly properties: TileMapProperties;
|
|
99
|
+
readonly tilesets: readonly TileSetData[];
|
|
100
|
+
/** Back to front. Layers inside groups are given with the names of their groups before theirs, `group/layer`. */
|
|
101
|
+
readonly layers: readonly TileMapLayerData[];
|
|
102
|
+
}
|
|
103
|
+
/** Tilesets kept in files of their own, for importing a map from Tiled. */
|
|
104
|
+
export interface TiledImportOptions {
|
|
105
|
+
/** Tilesets kept in files of their own, by the `source` the map names, as the JSON Tiled writes for them. */
|
|
106
|
+
readonly tilesets?: Readonly<Record<string, unknown>>;
|
|
107
|
+
}
|
|
108
|
+
/** What a cell holds: its tile, tileset and flips, and the tile's properties. */
|
|
109
|
+
export interface TileInfo {
|
|
110
|
+
/** The global id, without flip flags. */
|
|
111
|
+
readonly gid: number;
|
|
112
|
+
readonly tileset: TileSetData;
|
|
113
|
+
/** The id inside its set. */
|
|
114
|
+
readonly id: number;
|
|
115
|
+
readonly flippedHorizontally: boolean;
|
|
116
|
+
readonly flippedVertically: boolean;
|
|
117
|
+
readonly flippedDiagonally: boolean;
|
|
118
|
+
readonly properties: TileMapProperties;
|
|
119
|
+
}
|
|
120
|
+
/** A chunk of a layer drawn as one: its first cell, whether it shows, and its meshes. */
|
|
121
|
+
export interface TileMapChunk {
|
|
122
|
+
/** The first cell of the chunk. */
|
|
123
|
+
readonly column: number;
|
|
124
|
+
readonly row: number;
|
|
125
|
+
readonly visible: boolean;
|
|
126
|
+
/** One mesh for each tileset the chunk draws from. */
|
|
127
|
+
readonly meshes: readonly {
|
|
128
|
+
readonly tileset: string;
|
|
129
|
+
readonly mesh: Mesh2D;
|
|
130
|
+
readonly geometry: TexturedGeometry2D;
|
|
131
|
+
readonly tiles: number;
|
|
132
|
+
}[];
|
|
133
|
+
}
|
|
134
|
+
/** A layer as drawn: its name and data, its display object and its chunks. */
|
|
135
|
+
export interface TileMapLayer {
|
|
136
|
+
readonly name: string;
|
|
137
|
+
readonly data: TileLayerData;
|
|
138
|
+
readonly display: DisplayObjectContainer;
|
|
139
|
+
readonly chunks: readonly TileMapChunk[];
|
|
140
|
+
}
|
|
141
|
+
/** A tile map to make: its map, its tileset textures and the size of its chunks. */
|
|
142
|
+
export interface TileMapOptions {
|
|
143
|
+
readonly map: TileMapData;
|
|
144
|
+
/** The image of each tileset that is drawn, by its name. A set without one cannot be drawn. */
|
|
145
|
+
readonly textures: Readonly<Record<string, AssetLease<Texture>>>;
|
|
146
|
+
/** Cells across and down in one chunk, 4 to 128. Defaults to 32. */
|
|
147
|
+
readonly chunkSize?: number;
|
|
148
|
+
}
|
|
149
|
+
/** A map drawn: one container for each tile layer, cut into chunks of meshes that can be left out when they cannot be seen. */
|
|
150
|
+
export interface TileMap {
|
|
151
|
+
readonly state: 'active' | 'closed';
|
|
152
|
+
readonly data: TileMapData;
|
|
153
|
+
/** Holds the layers back to front. Put it in the world. */
|
|
154
|
+
readonly display: DisplayObjectContainer;
|
|
155
|
+
readonly layers: readonly TileMapLayer[];
|
|
156
|
+
layer(name: string): TileMapLayer;
|
|
157
|
+
/** The tile at a cell of a layer, or undefined for none or a cell outside it. */
|
|
158
|
+
tileAt(layer: string, column: number, row: number): TileInfo | undefined;
|
|
159
|
+
/** Puts a tile, with its flip flags, at a cell, or takes it away with 0. Its chunk is drawn again. */
|
|
160
|
+
setTile(layer: string, column: number, row: number, gid: number): void;
|
|
161
|
+
/** What a tile says of itself, by global id. */
|
|
162
|
+
propertiesOf(gid: number): TileMapProperties;
|
|
163
|
+
/** The cell under a point of the map, and the top left corner of a cell. */
|
|
164
|
+
cellAt(x: number, y: number): {
|
|
165
|
+
readonly column: number;
|
|
166
|
+
readonly row: number;
|
|
167
|
+
};
|
|
168
|
+
cellOrigin(column: number, row: number): {
|
|
169
|
+
readonly x: number;
|
|
170
|
+
readonly y: number;
|
|
171
|
+
};
|
|
172
|
+
/** Shows only the chunks that meet a rectangle of the map. Returns how many chunks show. */
|
|
173
|
+
cull(view: {
|
|
174
|
+
readonly x: number;
|
|
175
|
+
readonly y: number;
|
|
176
|
+
readonly width: number;
|
|
177
|
+
readonly height: number;
|
|
178
|
+
}): number;
|
|
179
|
+
/** Takes the meshes off the display and lets go of them. A scope can own a tile map through this. */
|
|
180
|
+
dispose(): void;
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=tilemapTypes.d.ts.map
|
package/dist/timer.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Scope } from '@egret/runtime';
|
|
2
|
+
import type { Engine } from './Engine.js';
|
|
3
|
+
/** Calls a function every `delay` seconds, `repeatCount` times or until it is stopped, as Egret's Timer. */
|
|
4
|
+
export interface Timer {
|
|
5
|
+
/** Seconds between calls. It can be changed while it runs; the next call comes that long after the last. */
|
|
6
|
+
delay: number;
|
|
7
|
+
/** How many calls in all before it completes; 0 for no end. */
|
|
8
|
+
repeatCount: number;
|
|
9
|
+
/** How many calls there have been since it was made or reset. */
|
|
10
|
+
readonly currentCount: number;
|
|
11
|
+
readonly running: boolean;
|
|
12
|
+
/** Called each time, with the count so far. Several can be added; they are called in the order they were. */
|
|
13
|
+
onTimer(callback: (count: number) => void): this;
|
|
14
|
+
/** Called once, after the last call of a timer with a `repeatCount`. */
|
|
15
|
+
onComplete(callback: () => void): this;
|
|
16
|
+
start(): this;
|
|
17
|
+
/** Stops it, keeping its count; `start` waits a whole delay again before the next call, as Egret's did. */
|
|
18
|
+
stop(): this;
|
|
19
|
+
/** Stops it and sets its count back to 0. */
|
|
20
|
+
reset(): this;
|
|
21
|
+
}
|
|
22
|
+
/** A call to come: `cancel` takes it back if it has not been made. */
|
|
23
|
+
export interface Delayed {
|
|
24
|
+
readonly done: boolean;
|
|
25
|
+
cancel(): void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A timer: `createTimer(engine, scope, 1, 5).onTimer(n => …).onComplete(() => …).start()`. A frame longer than the
|
|
29
|
+
* delay makes as many calls as the delay fits into it, so a count of seconds stays right however the frames fall.
|
|
30
|
+
*/
|
|
31
|
+
export declare function createTimer(engine: Engine, scope: Scope, delay: number, repeatCount?: number): Timer;
|
|
32
|
+
/** Calls a function once, `seconds` from now on the Engine's clock, as Egret's setTimeout. */
|
|
33
|
+
export declare function after(engine: Engine, scope: Scope, seconds: number, callback: () => void): Delayed;
|
|
34
|
+
//# sourceMappingURL=timer.d.ts.map
|