@egret/engine 7.0.1-rc.3 → 7.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Engine.js +7 -2
- package/dist/animation/sequenceResetTypes.d.ts +6 -0
- package/dist/animation/types.d.ts +6 -0
- package/dist/assetBundle.d.ts +2 -0
- package/dist/assetGroupTypes.d.ts +2 -0
- package/dist/audioCues.d.ts +4 -0
- package/dist/audioTypes.d.ts +13 -0
- package/dist/bitmapButtonTypes.d.ts +2 -0
- package/dist/bitmapFontTypes.d.ts +3 -0
- package/dist/bitmapResourceSlot.d.ts +1 -0
- package/dist/camera2d.js +10 -2
- package/dist/cameraTypes.d.ts +12 -0
- package/dist/contentTypes.d.ts +2 -0
- package/dist/createEngineForProfile.js +8 -5
- package/dist/fontContentTypes.d.ts +5 -0
- package/dist/gameClockTypes.d.ts +6 -0
- package/dist/gameRun.d.ts +3 -0
- package/dist/gamepadTypes.d.ts +8 -0
- package/dist/hoverInputTypes.d.ts +10 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +2 -1
- package/dist/inputActions.d.ts +5 -0
- package/dist/internal/uiFactoryState.d.ts +4 -0
- package/dist/internal/uiFactoryState.js +18 -2
- package/dist/keyboardInput.d.ts +1 -0
- package/dist/keyboardInput.js +1 -0
- package/dist/keyboardInputTypes.d.ts +12 -0
- package/dist/kit.d.ts +3 -1
- package/dist/kit.js +2 -1
- package/dist/manifestResourceState.d.ts +1 -0
- package/dist/manifestResourceState.js +1 -0
- package/dist/manifestResourceTypes.d.ts +1 -0
- package/dist/motion.d.ts +2 -0
- package/dist/mouseInputTypes.d.ts +4 -0
- package/dist/particleEmitter.js +8 -0
- package/dist/particleTypes.d.ts +8 -0
- package/dist/physics2d.d.ts +2 -2
- package/dist/physics2d.js +1 -1
- package/dist/physics2dTypes.d.ts +55 -1
- package/dist/physics2dWorld.js +209 -9
- package/dist/pointerInput.d.ts +1 -0
- package/dist/pointerInput.js +1 -0
- package/dist/pointerInputTypes.d.ts +3 -0
- package/dist/random.d.ts +1 -0
- package/dist/rendering/packSharedDraws2D.js +53 -5
- package/dist/rendering/prepareSharedDraws2D.d.ts +2 -0
- package/dist/rendering/prepareSharedDraws2D.js +17 -6
- package/dist/rendering/sharedColor2D.d.ts +35 -1
- package/dist/rendering/sharedColor2D.js +131 -8
- package/dist/rendering/sharedEffects2D.js +16 -8
- package/dist/rendering/world3d/Animation3D.d.ts +9 -0
- package/dist/rendering/world3d/Animation3D.js +4 -0
- package/dist/rendering/world3d/AnimationTexture3D.d.ts +6 -0
- package/dist/rendering/world3d/AnimationTexture3D.js +2 -0
- package/dist/rendering/world3d/Batch3D.d.ts +4 -0
- package/dist/rendering/world3d/Batch3D.js +3 -0
- package/dist/rendering/world3d/Camera3D.d.ts +5 -0
- package/dist/rendering/world3d/Camera3D.js +3 -0
- package/dist/rendering/world3d/Character3D.d.ts +4 -0
- package/dist/rendering/world3d/Character3D.js +2 -0
- package/dist/rendering/world3d/Cloth3D.d.ts +18 -3
- package/dist/rendering/world3d/Cloth3D.js +6 -1
- package/dist/rendering/world3d/Compression3D.d.ts +1 -0
- package/dist/rendering/world3d/Compression3D.js +1 -0
- package/dist/rendering/world3d/Curves3D.d.ts +8 -0
- package/dist/rendering/world3d/Curves3D.js +5 -0
- package/dist/rendering/world3d/Decal3D.d.ts +2 -0
- package/dist/rendering/world3d/Decal3D.js +1 -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 +11 -1
- package/dist/rendering/world3d/Geometry3D.js +10 -1
- package/dist/rendering/world3d/GeometryBuilder3D.d.ts +2 -0
- package/dist/rendering/world3d/Gizmo3D.d.ts +5 -0
- package/dist/rendering/world3d/Gizmo3D.js +2 -0
- package/dist/rendering/world3d/Gltf3D.d.ts +6 -0
- package/dist/rendering/world3d/Gltf3D.js +25 -5
- package/dist/rendering/world3d/GpuParticles3D.d.ts +2 -0
- package/dist/rendering/world3d/GpuParticles3D.js +1 -0
- package/dist/rendering/world3d/Hdr3D.d.ts +2 -0
- package/dist/rendering/world3d/Hdr3D.js +1 -0
- package/dist/rendering/world3d/Jelly3D.d.ts +2 -0
- package/dist/rendering/world3d/Jelly3D.js +1 -0
- package/dist/rendering/world3d/Ktx23D.d.ts +3 -0
- package/dist/rendering/world3d/Light3D.d.ts +9 -0
- package/dist/rendering/world3d/Light3D.js +4 -0
- package/dist/rendering/world3d/Material3D.d.ts +10 -0
- package/dist/rendering/world3d/Material3D.js +2 -0
- package/dist/rendering/world3d/Mesh3D.d.ts +4 -0
- package/dist/rendering/world3d/Mesh3D.js +16 -2
- package/dist/rendering/world3d/Meshopt3D.d.ts +3 -0
- package/dist/rendering/world3d/Meshopt3D.js +1 -0
- package/dist/rendering/world3d/Navigation3D.d.ts +41 -1
- package/dist/rendering/world3d/Navigation3D.js +74 -2
- package/dist/rendering/world3d/Object3D.d.ts +11 -0
- package/dist/rendering/world3d/Object3D.js +10 -0
- package/dist/rendering/world3d/Particles3D.d.ts +5 -0
- package/dist/rendering/world3d/Particles3D.js +3 -0
- package/dist/rendering/world3d/Physics3D.d.ts +14 -0
- package/dist/rendering/world3d/Physics3D.js +5 -0
- package/dist/rendering/world3d/PhysicsHull3D.d.ts +2 -0
- package/dist/rendering/world3d/PhysicsHull3D.js +2 -0
- package/dist/rendering/world3d/PhysicsMesh3D.d.ts +2 -0
- package/dist/rendering/world3d/PhysicsMesh3D.js +2 -0
- package/dist/rendering/world3d/PhysicsRemote3D.d.ts +5 -0
- package/dist/rendering/world3d/PhysicsRemote3D.js +2 -0
- package/dist/rendering/world3d/Ragdoll3D.d.ts +5 -0
- package/dist/rendering/world3d/Ragdoll3D.js +2 -0
- package/dist/rendering/world3d/Raycast3D.d.ts +3 -0
- package/dist/rendering/world3d/Raycast3D.js +1 -0
- package/dist/rendering/world3d/RenderList3D.d.ts +3 -0
- package/dist/rendering/world3d/RenderList3D.js +12 -0
- package/dist/rendering/world3d/Retarget3D.d.ts +1 -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 +17 -0
- package/dist/rendering/world3d/Serialize3D.js +22 -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 +9 -0
- package/dist/rendering/world3d/StateMachine3D.js +3 -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 +21 -0
- package/dist/rendering/world3d/Terrain3D.js +25 -1
- package/dist/rendering/world3d/Text3D.d.ts +5 -0
- package/dist/rendering/world3d/Text3D.js +2 -0
- package/dist/rendering/world3d/Texture3D.d.ts +16 -1
- package/dist/rendering/world3d/Texture3D.js +19 -1
- package/dist/rendering/world3d/Trail3D.d.ts +3 -0
- package/dist/rendering/world3d/Trail3D.js +2 -0
- package/dist/rendering/world3d/Vehicle3D.d.ts +5 -0
- package/dist/rendering/world3d/Vehicle3D.js +2 -0
- package/dist/rendering/world3d/VolumetricFog3D.d.ts +2 -0
- package/dist/rendering/world3d/VolumetricFog3D.js +1 -0
- package/dist/rendering/world3d/Water3D.d.ts +2 -0
- package/dist/rendering/world3d/Water3D.js +1 -0
- package/dist/rendering/world3d/core3D.d.ts +2 -0
- package/dist/rendering/world3d/debug3D.d.ts +5 -0
- package/dist/rendering/world3d/debug3D.js +5 -0
- package/dist/rendering/world3d/geometries3D.d.ts +12 -0
- package/dist/rendering/world3d/geometries3D.js +5 -0
- package/dist/rendering/world3d/helpers3D.d.ts +2 -0
- package/dist/rendering/world3d/helpers3D.js +1 -0
- package/dist/rendering/world3d/index.d.ts +12 -0
- package/dist/rendering/world3d/index.js +6 -0
- package/dist/rendering/world3d/math3D.d.ts +36 -0
- package/dist/rendering/world3d/math3D.js +35 -0
- package/dist/rendering/world3d/primitives3D.d.ts +7 -0
- package/dist/rendering/world3d/primitives3D.js +1 -0
- package/dist/saveStore.d.ts +18 -3
- package/dist/saveStore.js +23 -4
- package/dist/semanticList.d.ts +4 -0
- package/dist/semanticList.js +1 -0
- package/dist/semanticTree.js +11 -4
- package/dist/semanticTypes.d.ts +8 -0
- package/dist/sequencePlaybackTypes.d.ts +3 -0
- package/dist/text.d.ts +1 -0
- package/dist/textTable.d.ts +41 -0
- package/dist/textTable.js +114 -0
- package/dist/tilemapTypes.d.ts +13 -0
- package/dist/timer.d.ts +34 -0
- package/dist/timer.js +119 -0
- package/dist/tweenTypes.d.ts +4 -0
- package/dist/ui/controlKeys.d.ts +4 -0
- package/dist/ui/controlKeys.js +1 -0
- package/dist/ui/controls.d.ts +6 -0
- package/dist/ui/controls.js +2 -0
- package/dist/ui/layerTypes.d.ts +7 -0
- package/dist/ui/rangeControl.d.ts +3 -0
- package/dist/ui/rangeControl.js +1 -0
- package/dist/ui/scrollControl.d.ts +12 -0
- package/dist/ui/scrollControl.js +5 -1
- package/dist/ui/stateControls.d.ts +8 -0
- package/dist/ui/stateControls.js +3 -0
- package/dist/ui/textEditor.d.ts +1 -0
- package/dist/ui/textEditor.js +1 -0
- package/dist/ui/textEditorTypes.d.ts +7 -0
- package/dist/ui/textFieldControl.d.ts +4 -0
- package/dist/ui/textFieldControl.js +1 -0
- package/dist/ui/theme.d.ts +5 -0
- package/dist/ui/theme.js +1 -0
- package/dist/ui/types.d.ts +20 -0
- package/dist/ui/uiRoot.js +38 -9
- package/dist/ui/uiRootModel.d.ts +3 -1
- package/dist/ui/uiRootModel.js +8 -2
- package/dist/videoTypes.d.ts +3 -0
- package/dist/web/BrowserAssetBundle.d.ts +2 -0
- package/dist/web/BrowserAudio.d.ts +34 -1
- package/dist/web/BrowserAudio.js +69 -39
- package/dist/web/BrowserFrameLoop.d.ts +4 -0
- package/dist/web/BrowserGame.d.ts +64 -2
- package/dist/web/BrowserGame.js +129 -8
- package/dist/web/BrowserGamepadInput.d.ts +3 -0
- package/dist/web/BrowserHoverInput.d.ts +1 -0
- package/dist/web/BrowserImageTextures.d.ts +6 -0
- package/dist/web/BrowserInputActions.d.ts +10 -0
- package/dist/web/BrowserInputActions.js +4 -1
- package/dist/web/BrowserPlay.d.ts +130 -2
- package/dist/web/BrowserPlay.js +366 -19
- package/dist/web/BrowserPreferences.d.ts +10 -0
- package/dist/web/BrowserPreferences.js +39 -0
- package/dist/web/BrowserSemantics.d.ts +2 -0
- package/dist/web/BrowserStatsPanel.d.ts +10 -0
- package/dist/web/BrowserStatsPanel.js +9 -3
- package/dist/web/BrowserStorage.d.ts +2 -0
- package/dist/web/BrowserTextEditor.d.ts +3 -0
- package/dist/web/BrowserTextInput.d.ts +6 -0
- package/dist/web/BrowserTextureProvider.d.ts +6 -0
- package/dist/web/BrowserVideo.d.ts +13 -1
- package/dist/web/BrowserVideo.js +28 -2
- package/dist/web/CanvasKitFontSetProvider.d.ts +3 -0
- package/dist/web/CanvasKitParagraphProvider.d.ts +4 -0
- package/dist/web/CanvasKitParagraphProvider.js +1 -0
- package/dist/web/ManifestByteSource.d.ts +4 -0
- package/dist/web/ManifestByteSource.js +1 -0
- package/dist/web/ManifestFontContentLoader.d.ts +1 -0
- package/dist/web/WebGL2Host.js +64 -25
- package/dist/web/WebGPUHost.d.ts +13 -0
- package/dist/web/WebGPUHost.js +117 -36
- package/dist/web/audio.d.ts +2 -2
- package/dist/web/audio.js +1 -1
- package/dist/web/editorFonts.d.ts +4 -0
- package/dist/web/game.d.ts +1 -1
- package/dist/web/imageProjections2D.d.ts +2 -0
- package/dist/web/kit.d.ts +1 -0
- package/dist/web/kit.js +1 -0
- package/dist/web/play.d.ts +6 -1
- package/dist/web/play.js +4 -1
- package/dist/web/playMusic.d.ts +33 -0
- package/dist/web/playMusic.js +194 -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/prepareSharedSubmission2D.js +9 -3
- package/dist/web/resources.d.ts +2 -0
- package/dist/web/sharedEffectShaders.d.ts +6 -2
- package/dist/web/sharedEffectShaders.js +23 -7
- package/dist/web/sharedSubmissionStorage2D.js +1 -1
- package/dist/web/sharedWebGL2Options.d.ts +3 -0
- package/dist/web/sharedWebGL2Options.js +8 -2
- package/dist/web/sharedWebGL2Shaders.d.ts +15 -2
- package/dist/web/sharedWebGL2Shaders.js +108 -14
- package/dist/web/sharedWebGPUOptions.d.ts +5 -1
- package/dist/web/sharedWebGPUOptions.js +6 -2
- package/dist/web/video.d.ts +1 -1
- package/dist/web/webgl2Native.d.ts +3 -1
- package/dist/web/webgl2Native.js +9 -5
- package/dist/web/webgl2Types.d.ts +18 -0
- package/dist/web/webgpuImageResidency.d.ts +5 -2
- package/dist/web/webgpuImageResidency.js +7 -3
- package/dist/web/webgpuRetentionPool.d.ts +2 -2
- package/dist/web/webgpuRetentionPool.js +2 -1
- package/dist/web/webgpuSharedPass.d.ts +1 -1
- package/dist/web/webgpuSharedPass.js +87 -5
- package/dist/web/webgpuSharedResolvePass.d.ts +1 -1
- package/dist/web/webgpuSharedResolvePass.js +9 -4
- package/dist/web/world3d/Audio3D.d.ts +18 -1
- package/dist/web/world3d/Audio3D.js +62 -3
- package/dist/web/world3d/BrowserPlay3D.d.ts +115 -2
- package/dist/web/world3d/BrowserPlay3D.js +448 -43
- package/dist/web/world3d/FlyControls3D.d.ts +4 -0
- package/dist/web/world3d/FlyControls3D.js +2 -0
- package/dist/web/world3d/FollowControls3D.d.ts +3 -0
- package/dist/web/world3d/FollowControls3D.js +2 -0
- package/dist/web/world3d/OrbitControls3D.d.ts +3 -0
- package/dist/web/world3d/OrbitControls3D.js +2 -0
- package/dist/web/world3d/TransformControls3D.d.ts +5 -2
- package/dist/web/world3d/TransformControls3D.js +7 -4
- package/dist/web/world3d/WebGL2Renderer3D.d.ts +3 -0
- package/dist/web/world3d/WebGL2Renderer3D.js +2 -0
- package/dist/web/world3d/WebGPURenderer3D.d.ts +2 -0
- package/dist/web/world3d/WebGPURenderer3D.js +1 -0
- package/dist/web/world3d/World3DView.d.ts +3 -0
- package/dist/web/world3d/World3DView.js +2 -0
- package/dist/web/world3d/app3D.d.ts +7 -0
- package/dist/web/world3d/app3D.js +1 -0
- package/dist/web/world3d/assets3D.d.ts +1 -0
- package/dist/web/world3d/atmosphere3D.d.ts +9 -0
- package/dist/web/world3d/atmosphere3D.js +19 -4
- package/dist/web/world3d/canvasFont3D.d.ts +21 -0
- package/dist/web/world3d/canvasFont3D.js +165 -0
- package/dist/web/world3d/frame3D.d.ts +2 -0
- package/dist/web/world3d/host3D.d.ts +1 -0
- package/dist/web/world3d/index.d.ts +4 -2
- package/dist/web/world3d/index.js +2 -1
- package/dist/web/world3d/loaders3D.d.ts +1 -0
- package/dist/web/world3d/markers3D.d.ts +4 -0
- package/dist/web/world3d/overlay3D.d.ts +19 -0
- package/dist/web/world3d/overlay3D.js +21 -4
- package/dist/web/world3d/post3D.d.ts +4 -0
- package/dist/web/world3d/post3D.js +3 -0
- package/dist/web/world3d/probe3D.d.ts +1 -0
- package/dist/web/world3d/stats3D.d.ts +3 -0
- package/dist/web/world3d/stats3D.js +1 -0
- package/dist/web/world3d/webGL2FrameMetrics3D.d.ts +5 -0
- package/dist/web/world3d/webgpu.d.ts +2 -0
- package/dist/web/world3d/webgpu.js +1 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,10 @@ export type { Point2D } from '@egret/contracts';
|
|
|
18
18
|
export type { CancellationListener, CancellationSignal, Disposable, Releasable, ScopeValue, Diagnostic, DiagnosticHandler, HostAdapter } from '@egret/contracts';
|
|
19
19
|
export { AssetManager, AssetLease, createAssetType, createAssetRef } from '@egret/runtime';
|
|
20
20
|
export type { AssetProvider, AssetAcquireOptions, AssetLoadContext, AssetType, AssetRef } from '@egret/runtime';
|
|
21
|
-
export { Sprite, Graphics } from '@egret/runtime';
|
|
21
|
+
export { Sprite, Graphics, Shape, Point, Rectangle, Matrix } from '@egret/runtime';
|
|
22
|
+
export type { RectangleLike, MatrixLike } from '@egret/runtime';
|
|
23
|
+
export { createTimer, after } from './timer.js';
|
|
24
|
+
export type { Timer, Delayed } from './timer.js';
|
|
22
25
|
export type { Matrix2D, Rectangle2D, ClipRectangle2D } from '@egret/contracts';
|
|
23
26
|
export { IMAGE_LIMITS_2D, createImageData2D, isImageData2D, copyImageData2DPixels } from '@egret/contracts';
|
|
24
27
|
export type { ImageData2DInput, ImageData2D, TextureRegion2D } from '@egret/contracts';
|
|
@@ -27,7 +30,7 @@ export type { TexturedFloatArray2D, TexturedIndexArray2D, TexturedGeometry2DInpu
|
|
|
27
30
|
export { createSharedMaterial2D, createSharedGeometry2D } from '@egret/contracts';
|
|
28
31
|
export type { SharedMaterialInput2D, SharedMaterial2D, SharedFloatArray2D, SharedIndexArray2D, SharedGeometryInput2D, SharedGeometry2D, TextureViewRegionInput2D, TextureViewRegion2D } from '@egret/contracts';
|
|
29
32
|
export { SHARED_FRAME_PROFILE_2D } from '@egret/contracts';
|
|
30
|
-
export type { SharedFrameProfile2D, SharedOutputAlpha2D, SharedFrameOptions2D, SharedPage2D, SharedRegion2D, SharedDrawState2D, SharedRectangleCommand2D, SharedImageCommand2D, SharedMeshCommand2D, SharedBarrierCommand2D, SharedEffect2D, SharedGlow2D, SharedRenderCommand2D, SharedRenderFrame2D, SharedRenderHostAdapter } from '@egret/contracts';
|
|
33
|
+
export type { SharedFrameProfile2D, SharedOutputAlpha2D, SharedBlendSpace2D, SharedFrameOptions2D, SharedPage2D, SharedRegion2D, SharedDrawState2D, SharedRectangleCommand2D, SharedImageCommand2D, SharedMeshCommand2D, SharedBarrierCommand2D, SharedEffect2D, SharedGlow2D, SharedRenderCommand2D, SharedRenderFrame2D, SharedRenderHostAdapter } from '@egret/contracts';
|
|
31
34
|
export { Texture, createTexture, createTextureView, isTexture, Bitmap, Mesh2D } from '@egret/runtime';
|
|
32
35
|
export { createSequenceClip, SequencePlayer } from '@egret/runtime';
|
|
33
36
|
export type { SequenceFrameInput, SequenceClipInput, SequenceClip, SequenceRegion, SequenceSample, SequencePlaybackMode } from '@egret/runtime';
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,8 @@ export { animate } from './motion.js';
|
|
|
5
5
|
export { describeErrorCode, setErrorLanguage, getErrorLanguage } from '@egret/runtime';
|
|
6
6
|
export { CancellationController, EgretError, Event, createEventType, EventDispatcher, DisplayObject, DisplayObjectContainer, Scope, Stage } from '@egret/runtime';
|
|
7
7
|
export { AssetManager, AssetLease, createAssetType, createAssetRef } from '@egret/runtime';
|
|
8
|
-
export { Sprite, Graphics } from '@egret/runtime';
|
|
8
|
+
export { Sprite, Graphics, Shape, Point, Rectangle, Matrix } from '@egret/runtime';
|
|
9
|
+
export { createTimer, after } from './timer.js';
|
|
9
10
|
export { IMAGE_LIMITS_2D, createImageData2D, isImageData2D, copyImageData2DPixels } from '@egret/contracts';
|
|
10
11
|
export { createTexturedGeometry2D, isTexturedGeometry2D } from '@egret/contracts';
|
|
11
12
|
export { createSharedMaterial2D, createSharedGeometry2D } from '@egret/contracts';
|
package/dist/inputActions.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* stick axis, for buttons and axes), and `Touch:<name>` for an on-screen control.
|
|
6
6
|
*/
|
|
7
7
|
export type InputBinding = string;
|
|
8
|
+
/** Whether an action is a button, one axis, or a vector of two. */
|
|
8
9
|
export type InputActionKind = 'button' | 'axis' | 'vector';
|
|
9
10
|
/** An action and the controls that drive it. */
|
|
10
11
|
export interface InputActionDefinition {
|
|
@@ -24,13 +25,16 @@ export interface InputActionDefinition {
|
|
|
24
25
|
/** Analog input below this is taken as nothing. Defaults to 0.2. */
|
|
25
26
|
readonly deadZone?: number;
|
|
26
27
|
}
|
|
28
|
+
/** Actions by name, with the controls that drive each. */
|
|
27
29
|
export type InputActionMap = Readonly<Record<string, InputActionDefinition>>;
|
|
28
30
|
/** A slot of an action that a binding can be put in: `bindings`, `negative`, `positive`, `up`, ... */
|
|
29
31
|
export type InputBindingSlot = 'bindings' | 'negative' | 'positive' | 'up' | 'down' | 'left' | 'right' | 'sticks';
|
|
32
|
+
/** The value of a vector action, each axis -1 to 1. */
|
|
30
33
|
export interface InputVector {
|
|
31
34
|
readonly x: number;
|
|
32
35
|
readonly y: number;
|
|
33
36
|
}
|
|
37
|
+
/** Named actions driven by keys, buttons and sticks: what is pressed now, values, rebinding and saving. */
|
|
34
38
|
export interface InputActions {
|
|
35
39
|
/** The names of the actions, in the order they were defined. */
|
|
36
40
|
readonly names: readonly string[];
|
|
@@ -70,6 +74,7 @@ export interface InputActions {
|
|
|
70
74
|
/** The control last pressed, for a "press a key" rebinding screen; undefined after `endFrame` until another. */
|
|
71
75
|
readonly lastPressed: InputBinding | undefined;
|
|
72
76
|
}
|
|
77
|
+
/** Bindings as saved, to load back with `loadBindings`. */
|
|
73
78
|
export interface InputBindingsSave {
|
|
74
79
|
readonly version: 1;
|
|
75
80
|
readonly actions: Readonly<Record<string, Partial<Record<InputBindingSlot, readonly InputBinding[]>>>>;
|
|
@@ -31,6 +31,10 @@ export interface UiEnginePort {
|
|
|
31
31
|
keyboardScope(input: KeyboardInput, owner: object): UiKeyboardScope;
|
|
32
32
|
assertOpen(): void;
|
|
33
33
|
assertIdle(): void;
|
|
34
|
+
/** Neither a frame is drawn nor input delivered now. */
|
|
35
|
+
isIdle(): boolean;
|
|
36
|
+
/** Refuses while a frame is drawn; input being delivered is allowed. */
|
|
37
|
+
assertNotDrawing(): void;
|
|
34
38
|
isEngineScope(value: unknown): value is Scope;
|
|
35
39
|
createScope(): Scope;
|
|
36
40
|
scope(value: unknown): UiScopePort;
|
|
@@ -41,8 +41,24 @@ export function registerUiEngine(engine, assembly) {
|
|
|
41
41
|
assertOpen: assembly.assertOpen,
|
|
42
42
|
assertIdle() {
|
|
43
43
|
assembly.assertOpen();
|
|
44
|
-
if (assembly.isFrameBusy()
|
|
45
|
-
throw new EgretError('UI_BUSY'
|
|
44
|
+
if (assembly.isFrameBusy())
|
|
45
|
+
throw new EgretError('UI_BUSY', {
|
|
46
|
+
cause: new Error('a frame is being drawn: call this after the frame, not from inside it')
|
|
47
|
+
});
|
|
48
|
+
if (delivery.depth !== 0)
|
|
49
|
+
throw new EgretError('UI_BUSY', {
|
|
50
|
+
cause: new Error('input is being delivered: call this after the delivery, as from a promise that has settled or the next frame')
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
isIdle() {
|
|
54
|
+
return !assembly.isFrameBusy() && delivery.depth === 0;
|
|
55
|
+
},
|
|
56
|
+
assertNotDrawing() {
|
|
57
|
+
assembly.assertOpen();
|
|
58
|
+
if (assembly.isFrameBusy())
|
|
59
|
+
throw new EgretError('UI_BUSY', {
|
|
60
|
+
cause: new Error('a frame is being drawn: call this after the frame, not from inside it')
|
|
61
|
+
});
|
|
46
62
|
},
|
|
47
63
|
isEngineScope(value) {
|
|
48
64
|
return scopes.has(value);
|
package/dist/keyboardInput.d.ts
CHANGED
|
@@ -8,5 +8,6 @@ interface Binding {
|
|
|
8
8
|
}
|
|
9
9
|
/** Private browser binding reuses the genuine eager Engine authority. */
|
|
10
10
|
export declare function bindKeyboardSurface(input: KeyboardInput): Binding;
|
|
11
|
+
/** Keyboard input for the stage: key events go to the focused target, and focus moves with Tab. */
|
|
11
12
|
export declare function createKeyboardInput(options: KeyboardInputOptions): KeyboardInput;
|
|
12
13
|
//# sourceMappingURL=keyboardInput.d.ts.map
|
package/dist/keyboardInput.js
CHANGED
|
@@ -54,6 +54,7 @@ function sample(value) {
|
|
|
54
54
|
export function bindKeyboardSurface(input) {
|
|
55
55
|
return bindings.get(input) ?? fail('KEYBOARD_INPUT_CLOSED');
|
|
56
56
|
}
|
|
57
|
+
/** Keyboard input for the stage: key events go to the focused target, and focus moves with Tab. */
|
|
57
58
|
export function createKeyboardInput(options) {
|
|
58
59
|
if (!object(options))
|
|
59
60
|
fail('KEYBOARD_INPUT_OPTIONS_INVALID');
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DisplayObject, EventType, Scope } from '@egret/runtime';
|
|
2
2
|
import type { Engine } from './Engine.js';
|
|
3
|
+
/** One key as the host gives it: its code and key, whether it repeats, and the modifiers held. */
|
|
3
4
|
export interface KeyboardSample {
|
|
4
5
|
readonly code: string;
|
|
5
6
|
readonly key: string;
|
|
@@ -9,25 +10,31 @@ export interface KeyboardSample {
|
|
|
9
10
|
readonly metaKey?: boolean;
|
|
10
11
|
readonly shiftKey?: boolean;
|
|
11
12
|
}
|
|
13
|
+
/** Why a held key was let go of without its key up. */
|
|
12
14
|
export type KeyboardCancelReason = 'focus' | 'rebind' | 'removed' | 'owner' | 'suspended' | 'dispose' | 'blur' | 'hidden' | 'pagehide' | 'error';
|
|
15
|
+
/** A key event and the target it went to. */
|
|
13
16
|
export interface KeyboardKeyPayload extends Required<KeyboardSample> {
|
|
14
17
|
readonly targetId: string;
|
|
15
18
|
}
|
|
19
|
+
/** A key that was let go of without its key up, and why. */
|
|
16
20
|
export interface KeyboardCancelPayload extends KeyboardKeyPayload {
|
|
17
21
|
readonly reason: KeyboardCancelReason;
|
|
18
22
|
}
|
|
23
|
+
/** A target that gained or lost focus, the other target, why, and whether focus is shown. */
|
|
19
24
|
export interface KeyboardFocusPayload {
|
|
20
25
|
readonly targetId: string;
|
|
21
26
|
readonly relatedId: string | undefined;
|
|
22
27
|
readonly reason: string;
|
|
23
28
|
readonly focusVisible: boolean;
|
|
24
29
|
}
|
|
30
|
+
/** Focus that moved: from which target to which, why, and whether it is shown. */
|
|
25
31
|
export interface KeyboardFocusChange {
|
|
26
32
|
readonly previousId: string | undefined;
|
|
27
33
|
readonly focusedId: string | undefined;
|
|
28
34
|
readonly reason: string;
|
|
29
35
|
readonly focusVisible: boolean;
|
|
30
36
|
}
|
|
37
|
+
/** Keyboard input to make: its engine and scope, its limits, and what is called when focus moves. */
|
|
31
38
|
export interface KeyboardInputOptions {
|
|
32
39
|
readonly engine: Engine;
|
|
33
40
|
readonly scope: Scope;
|
|
@@ -36,16 +43,19 @@ export interface KeyboardInputOptions {
|
|
|
36
43
|
readonly maxNodes?: number;
|
|
37
44
|
readonly onFocusChange?: (change: KeyboardFocusChange) => void;
|
|
38
45
|
}
|
|
46
|
+
/** A target to register: its id, its display object, its place in Tab order and whether it is disabled. */
|
|
39
47
|
export interface KeyboardTargetOptions {
|
|
40
48
|
readonly id: string;
|
|
41
49
|
readonly target: DisplayObject;
|
|
42
50
|
readonly tabIndex?: number;
|
|
43
51
|
readonly disabled?: boolean;
|
|
44
52
|
}
|
|
53
|
+
/** A registered target: change it, or dispose of it to take it out. */
|
|
45
54
|
export interface KeyboardTargetRegistration {
|
|
46
55
|
update(options: Partial<Omit<KeyboardTargetOptions, 'id'>>): void;
|
|
47
56
|
dispose(): void;
|
|
48
57
|
}
|
|
58
|
+
/** Keyboard input as it is now: its state, the focused target, and the keys held. */
|
|
49
59
|
export interface KeyboardInputSnapshot {
|
|
50
60
|
readonly state: 'active' | 'suspended' | 'closed';
|
|
51
61
|
readonly focusedId: string | undefined;
|
|
@@ -53,6 +63,7 @@ export interface KeyboardInputSnapshot {
|
|
|
53
63
|
readonly pressedKeys: readonly string[];
|
|
54
64
|
readonly targetCount: number;
|
|
55
65
|
}
|
|
66
|
+
/** The event types keyboard input dispatches: key down and up, cancel, and focus in and out. */
|
|
56
67
|
export interface KeyboardInputEvents {
|
|
57
68
|
readonly keyDown: EventType<KeyboardKeyPayload>;
|
|
58
69
|
readonly keyUp: EventType<KeyboardKeyPayload>;
|
|
@@ -60,6 +71,7 @@ export interface KeyboardInputEvents {
|
|
|
60
71
|
readonly focusIn: EventType<KeyboardFocusPayload>;
|
|
61
72
|
readonly focusOut: EventType<KeyboardFocusPayload>;
|
|
62
73
|
}
|
|
74
|
+
/** How focus is given: whether it is shown, and why it moved. */
|
|
63
75
|
export interface KeyboardFocusOptions {
|
|
64
76
|
readonly visible?: boolean;
|
|
65
77
|
readonly reason?: 'programmatic' | 'keyboard' | 'pointer';
|
package/dist/kit.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** DOM-free parts a game builds on: named input actions, versioned saves, repeatable random numbers, sound cues and
|
|
1
|
+
/** DOM-free parts a game builds on: named input actions, versioned saves, repeatable random numbers, sound cues, asset bundles and a table of words in each language. */
|
|
2
2
|
export { createInputActions, describeInputBinding } from './inputActions.js';
|
|
3
3
|
export type { InputActionDefinition, InputActionKind, InputActionMap, InputActions, InputBinding, InputBindingSlot, InputBindingsSave, InputVector } from './inputActions.js';
|
|
4
4
|
export { createMemorySaveStorage, createSaveStore } from './saveStore.js';
|
|
@@ -11,4 +11,6 @@ export { ASSET_BUNDLE_HEADER_BYTES, assetBundleCheck, planAssetBundleRanges, rea
|
|
|
11
11
|
export type { AssetBundleEntry, AssetBundleIndex, AssetBundleInput } from './assetBundle.js';
|
|
12
12
|
export { QUALITY_TIERS, pickQualityFiles, pickQualityVariant, runHeadless } from './gameRun.js';
|
|
13
13
|
export type { HeadlessGame, HeadlessRunOptions, HeadlessRunResult, QualityTier } from './gameRun.js';
|
|
14
|
+
export { createTextTable, pickLanguage } from './textTable.js';
|
|
15
|
+
export type { TextTable, TextTableOptions, TextTableWords } from './textTable.js';
|
|
14
16
|
//# sourceMappingURL=kit.d.ts.map
|
package/dist/kit.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
/** DOM-free parts a game builds on: named input actions, versioned saves, repeatable random numbers, sound cues and
|
|
2
|
+
/** DOM-free parts a game builds on: named input actions, versioned saves, repeatable random numbers, sound cues, asset bundles and a table of words in each language. */
|
|
3
3
|
export { createInputActions, describeInputBinding } from './inputActions.js';
|
|
4
4
|
export { createMemorySaveStorage, createSaveStore } from './saveStore.js';
|
|
5
5
|
export { createRandom, hashSeed } from './random.js';
|
|
6
6
|
export { createAudioCues, encodeWav } from './audioCues.js';
|
|
7
7
|
export { ASSET_BUNDLE_HEADER_BYTES, assetBundleCheck, planAssetBundleRanges, readAssetBundleHeader, readAssetBundleIndex, sliceAssetBundle, writeAssetBundle } from './assetBundle.js';
|
|
8
8
|
export { QUALITY_TIERS, pickQualityFiles, pickQualityVariant, runHeadless } from './gameRun.js';
|
|
9
|
+
export { createTextTable, pickLanguage } from './textTable.js';
|
|
9
10
|
//# sourceMappingURL=kit.js.map
|
|
@@ -11,6 +11,7 @@ export interface ManifestBindingState {
|
|
|
11
11
|
export declare function requireManifestBinding(value: unknown): ManifestBindingState;
|
|
12
12
|
/** A matching ref ID alone cannot turn caller metadata into a verified source. */
|
|
13
13
|
export declare function requireManifestAssetRef(value: unknown): ManifestBindingState;
|
|
14
|
+
/** Binds one asset of an admitted manifest to an asset type, for its group to load. */
|
|
14
15
|
export declare function createManifestAssetBinding<T>(manifest: AdmittedResourceManifest, assetId: string, type: AssetType<T>): ManifestAssetBinding<T>;
|
|
15
16
|
export type { ManifestBinding } from './manifestResourceTypes.js';
|
|
16
17
|
//# sourceMappingURL=manifestResourceState.d.ts.map
|
|
@@ -23,6 +23,7 @@ export function requireManifestAssetRef(value) {
|
|
|
23
23
|
throw new EgretError('MANIFEST_BINDING_REF_INVALID');
|
|
24
24
|
return state;
|
|
25
25
|
}
|
|
26
|
+
/** Binds one asset of an admitted manifest to an asset type, for its group to load. */
|
|
26
27
|
export function createManifestAssetBinding(manifest, assetId, type) {
|
|
27
28
|
if (!isAdmittedResourceManifest(manifest))
|
|
28
29
|
throw new EgretError('MANIFEST_BINDING_MANIFEST_INVALID');
|
|
@@ -11,6 +11,7 @@ export interface ManifestAssetBinding<T> extends ManifestBinding {
|
|
|
11
11
|
readonly ref: AssetRef<T>;
|
|
12
12
|
readonly [manifestBindingValue]?: (value: T) => T;
|
|
13
13
|
}
|
|
14
|
+
/** How urgently a manifest group loads: for what is needed now, or in the background. */
|
|
14
15
|
export interface ManifestGroupOptions {
|
|
15
16
|
readonly priority?: 'interactive' | 'background';
|
|
16
17
|
}
|
package/dist/motion.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ import type { Scope } from '@egret/runtime';
|
|
|
2
2
|
import type { Engine } from './Engine.js';
|
|
3
3
|
/** How a step runs from its start to its end: a name, or a function from 0–1 to 0–1 (it may pass both on the way). */
|
|
4
4
|
export type MotionEasing = MotionEasingName | ((fraction: number) => number);
|
|
5
|
+
/** The name of an easing a motion step can use. */
|
|
5
6
|
export type MotionEasingName = 'linear' | 'quadIn' | 'quadOut' | 'quadInOut' | 'cubicIn' | 'cubicOut' | 'cubicInOut' | 'quartIn' | 'quartOut' | 'quartInOut' | 'sineIn' | 'sineOut' | 'sineInOut' | 'expoIn' | 'expoOut' | 'expoInOut' | 'backIn' | 'backOut' | 'backInOut' | 'elasticOut' | 'bounceOut';
|
|
7
|
+
/** Whether a motion is idle, running, paused, finished or stopped. */
|
|
6
8
|
export type MotionState = 'idle' | 'running' | 'paused' | 'finished' | 'stopped';
|
|
7
9
|
/** A chain of steps for one object. Steps are added before `start`; the calls return the motion, so they chain. */
|
|
8
10
|
export interface Motion<T extends object> {
|
|
@@ -9,8 +9,11 @@ export interface MouseInputOptions {
|
|
|
9
9
|
readonly height: number;
|
|
10
10
|
readonly maxNodes?: number;
|
|
11
11
|
}
|
|
12
|
+
/** Whether mouse input is idle, has a button pressed, or has closed. */
|
|
12
13
|
export type MouseInputState = 'idle' | 'pressed' | 'closed';
|
|
14
|
+
/** Why a press was cancelled. */
|
|
13
15
|
export type MouseInputCancelReason = 'pointercancel' | 'blur' | 'pagehide';
|
|
16
|
+
/** A mouse event: which pointer, where on the stage, what made it and which button. */
|
|
14
17
|
export interface MouseInputPayload {
|
|
15
18
|
readonly pointerId: number;
|
|
16
19
|
readonly globalX: number;
|
|
@@ -18,6 +21,7 @@ export interface MouseInputPayload {
|
|
|
18
21
|
readonly pointerType: 'mouse';
|
|
19
22
|
readonly button: 0;
|
|
20
23
|
}
|
|
24
|
+
/** The event types mouse input dispatches: begin, end, activate and cancel. */
|
|
21
25
|
export interface MouseInputEvents {
|
|
22
26
|
readonly begin: EventType<MouseInputPayload>;
|
|
23
27
|
readonly end: EventType<MouseInputPayload>;
|
package/dist/particleEmitter.js
CHANGED
|
@@ -87,6 +87,14 @@ export function createParticleEmitter(options) {
|
|
|
87
87
|
};
|
|
88
88
|
const pick = (pair) => (pair[0] === pair[1] ? pair[0] : mix(pair[0], pair[1], random()));
|
|
89
89
|
const display = new DisplayObjectContainer();
|
|
90
|
+
if (o.blendMode !== undefined) {
|
|
91
|
+
try {
|
|
92
|
+
display.blendMode = o.blendMode;
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
throw new EgretError('PARTICLE_OPTIONS_INVALID');
|
|
96
|
+
}
|
|
97
|
+
}
|
|
90
98
|
let mesh;
|
|
91
99
|
function spawn(count) {
|
|
92
100
|
for (let n = 0; n < count; n++) {
|
package/dist/particleTypes.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export type ParticleShape = {
|
|
|
13
13
|
readonly radius: number;
|
|
14
14
|
readonly edge?: boolean;
|
|
15
15
|
};
|
|
16
|
+
/** An emitter to make: its texture and how many particles, and how they are born, move, grow, fade and turn. */
|
|
16
17
|
export interface ParticleEmitterOptions {
|
|
17
18
|
/** The image of each particle: the whole of the texture. */
|
|
18
19
|
readonly texture: AssetLease<Texture>;
|
|
@@ -57,7 +58,13 @@ export interface ParticleEmitterOptions {
|
|
|
57
58
|
readonly running?: boolean;
|
|
58
59
|
/** Seconds after which it stops by itself. Defaults to running until stopped. */
|
|
59
60
|
readonly duration?: number;
|
|
61
|
+
/**
|
|
62
|
+
* How the particles are combined with what is under them, as `DisplayObject.blendMode`: `add` for glows and sparks.
|
|
63
|
+
* Defaults to `normal`. The same as setting `blendMode` on `emitter.display` after it is made.
|
|
64
|
+
*/
|
|
65
|
+
readonly blendMode?: 'normal' | 'add' | 'multiply' | 'screen' | 'erase';
|
|
60
66
|
}
|
|
67
|
+
/** An emitter as it is now: how many particles live, were born and were refused, and its time. */
|
|
61
68
|
export interface ParticleSnapshot {
|
|
62
69
|
readonly alive: number;
|
|
63
70
|
readonly born: number;
|
|
@@ -66,6 +73,7 @@ export interface ParticleSnapshot {
|
|
|
66
73
|
readonly running: boolean;
|
|
67
74
|
readonly time: number;
|
|
68
75
|
}
|
|
76
|
+
/** One live particle: where it is and how fast it moves, its age, scale, alpha, color and rotation. */
|
|
69
77
|
export interface ParticleView {
|
|
70
78
|
readonly x: number;
|
|
71
79
|
readonly y: number;
|
package/dist/physics2d.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Optional 2D collision and simple physics: bodies without turning, queries, and character movement. */
|
|
1
|
+
/** Optional 2D collision and simple physics: bodies without turning, distance and rope joints, queries, and character movement. */
|
|
2
2
|
export { createPhysicsWorld } from './physics2dWorld.js';
|
|
3
|
-
export type { PhysicsBody, PhysicsBodyKind, PhysicsBodyOptions, PhysicsContact, PhysicsMoveResult, PhysicsRayHit, PhysicsShape, PhysicsSnapshot, PhysicsTileColliders, PhysicsVector, PhysicsWorld, PhysicsWorldOptions } from './physics2dTypes.js';
|
|
3
|
+
export type { PhysicsBody, PhysicsBodyKind, PhysicsBodyOptions, PhysicsContact, PhysicsJoint, PhysicsJointOptions, PhysicsMoveResult, PhysicsRayHit, PhysicsShape, PhysicsSnapshot, PhysicsTileColliders, PhysicsVector, PhysicsWorld, PhysicsWorldOptions } from './physics2dTypes.js';
|
|
4
4
|
//# sourceMappingURL=physics2d.d.ts.map
|
package/dist/physics2d.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
/** Optional 2D collision and simple physics: bodies without turning, queries, and character movement. */
|
|
2
|
+
/** Optional 2D collision and simple physics: bodies without turning, distance and rope joints, queries, and character movement. */
|
|
3
3
|
export { createPhysicsWorld } from './physics2dWorld.js';
|
|
4
4
|
//# sourceMappingURL=physics2d.js.map
|
package/dist/physics2dTypes.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DisplayObject } from '@egret/runtime';
|
|
2
|
+
/** A 2D vector of the physics world. */
|
|
2
3
|
export interface PhysicsVector {
|
|
3
4
|
readonly x: number;
|
|
4
5
|
readonly y: number;
|
|
@@ -17,6 +18,7 @@ export type PhysicsShape = {
|
|
|
17
18
|
};
|
|
18
19
|
/** A static body never moves; a kinematic one moves by its speed alone and pushes; a dynamic one is moved by everything. */
|
|
19
20
|
export type PhysicsBodyKind = 'static' | 'kinematic' | 'dynamic';
|
|
21
|
+
/** A body to add: its kind and shape, where it is and how it moves, its material, its layers and what it moves. */
|
|
20
22
|
export interface PhysicsBodyOptions {
|
|
21
23
|
readonly kind?: PhysicsBodyKind;
|
|
22
24
|
readonly shape: PhysicsShape;
|
|
@@ -44,10 +46,13 @@ export interface PhysicsBodyOptions {
|
|
|
44
46
|
/** Whatever the game keeps with the body. */
|
|
45
47
|
readonly data?: unknown;
|
|
46
48
|
}
|
|
49
|
+
/** A body in the physics world: its place and motion, its material and layers, and the calls that push it. */
|
|
47
50
|
export interface PhysicsBody {
|
|
48
51
|
readonly id: number;
|
|
52
|
+
/** What it is now; `setKind` changes it. */
|
|
49
53
|
readonly kind: PhysicsBodyKind;
|
|
50
54
|
readonly shape: PhysicsShape;
|
|
55
|
+
/** Infinity unless it is dynamic. */
|
|
51
56
|
readonly mass: number;
|
|
52
57
|
readonly sensor: boolean;
|
|
53
58
|
readonly state: 'active' | 'removed';
|
|
@@ -66,6 +71,12 @@ export interface PhysicsBody {
|
|
|
66
71
|
applyImpulse(x: number, y: number): void;
|
|
67
72
|
/** Adds to the force on the body for the next step. */
|
|
68
73
|
applyForce(x: number, y: number): void;
|
|
74
|
+
/**
|
|
75
|
+
* Makes it static, kinematic or dynamic, keeping its place, its contacts, its joints and what the game keeps with it:
|
|
76
|
+
* a weight held up until its rope is cut, a crate that falls once struck. A static body stops; one made dynamic has the
|
|
77
|
+
* mass of its density, as given when it was added. The change takes effect from the next step.
|
|
78
|
+
*/
|
|
79
|
+
setKind(kind: PhysicsBodyKind): void;
|
|
69
80
|
/** The box around the body, in the world. */
|
|
70
81
|
bounds(): {
|
|
71
82
|
readonly x: number;
|
|
@@ -74,6 +85,36 @@ export interface PhysicsBody {
|
|
|
74
85
|
readonly height: number;
|
|
75
86
|
};
|
|
76
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* A joint to add between two bodies, or between a body and a fixed point of the world. `'distance'` keeps the two
|
|
90
|
+
* anchors at one length, as a rod; `'rope'` keeps them no further apart than it, and lets them come closer, as a rope.
|
|
91
|
+
* A distance joint of length 0 pins a body to a point, as a pendulum's bob is pinned to its string.
|
|
92
|
+
*/
|
|
93
|
+
export interface PhysicsJointOptions {
|
|
94
|
+
readonly kind: 'distance' | 'rope';
|
|
95
|
+
readonly a: PhysicsBody;
|
|
96
|
+
/** The other body. Without it the joint holds `a` to `point`, a place in the world. */
|
|
97
|
+
readonly b?: PhysicsBody;
|
|
98
|
+
readonly point?: PhysicsVector;
|
|
99
|
+
/** Where on each body the joint is held, from its centre, turned with the body's angle. Default to the centre. */
|
|
100
|
+
readonly anchorA?: PhysicsVector;
|
|
101
|
+
readonly anchorB?: PhysicsVector;
|
|
102
|
+
/** Defaults to the distance between the anchors when the joint is added. */
|
|
103
|
+
readonly length?: number;
|
|
104
|
+
/** How firmly a distance joint keeps its length, from above 0 (a soft spring) to 1 (a rod). Defaults to 1. */
|
|
105
|
+
readonly stiffness?: number;
|
|
106
|
+
}
|
|
107
|
+
/** A joint of the world: its kind, its bodies and its length, which can change, as a rope that is wound in. */
|
|
108
|
+
export interface PhysicsJoint {
|
|
109
|
+
readonly kind: 'distance' | 'rope';
|
|
110
|
+
readonly a: PhysicsBody;
|
|
111
|
+
readonly b: PhysicsBody | undefined;
|
|
112
|
+
readonly state: 'active' | 'removed';
|
|
113
|
+
length: number;
|
|
114
|
+
/** How far apart its anchors are now. */
|
|
115
|
+
distance(): number;
|
|
116
|
+
}
|
|
117
|
+
/** Two bodies that began or ended touching, with the normal between them. */
|
|
77
118
|
export interface PhysicsContact {
|
|
78
119
|
readonly type: 'begin' | 'end';
|
|
79
120
|
readonly a: PhysicsBody;
|
|
@@ -83,6 +124,7 @@ export interface PhysicsContact {
|
|
|
83
124
|
/** One of the two is a sensor: nothing was pushed. */
|
|
84
125
|
readonly sensor: boolean;
|
|
85
126
|
}
|
|
127
|
+
/** What a ray hit: the body, where, its normal, and how far along the ray. */
|
|
86
128
|
export interface PhysicsRayHit {
|
|
87
129
|
readonly body: PhysicsBody;
|
|
88
130
|
readonly point: PhysicsVector;
|
|
@@ -90,6 +132,7 @@ export interface PhysicsRayHit {
|
|
|
90
132
|
/** How far along the ray, from 0 at its start to 1 at its end. */
|
|
91
133
|
readonly fraction: number;
|
|
92
134
|
}
|
|
135
|
+
/** Where a moved body ended up, and the normals of what it hit on the way. */
|
|
93
136
|
export interface PhysicsMoveResult {
|
|
94
137
|
readonly x: number;
|
|
95
138
|
readonly y: number;
|
|
@@ -98,6 +141,7 @@ export interface PhysicsMoveResult {
|
|
|
98
141
|
/** The normals of what it slid along, pointing away from it. */
|
|
99
142
|
readonly normals: readonly PhysicsVector[];
|
|
100
143
|
}
|
|
144
|
+
/** A physics world to make: its gravity, its step and iterations, and its limits. */
|
|
101
145
|
export interface PhysicsWorldOptions {
|
|
102
146
|
/** Units a second, every second. Defaults to 0 across and 0 down. */
|
|
103
147
|
readonly gravity?: PhysicsVector;
|
|
@@ -115,6 +159,7 @@ export interface PhysicsWorldOptions {
|
|
|
115
159
|
/** The most bodies, 1 to 65536. Defaults to 4096. */
|
|
116
160
|
readonly maxBodies?: number;
|
|
117
161
|
}
|
|
162
|
+
/** A grid of solid tiles to collide with: its size in tiles, its tile size, which are solid and where it is. */
|
|
118
163
|
export interface PhysicsTileColliders {
|
|
119
164
|
readonly columns: number;
|
|
120
165
|
readonly rows: number;
|
|
@@ -128,6 +173,7 @@ export interface PhysicsTileColliders {
|
|
|
128
173
|
readonly layer?: number;
|
|
129
174
|
readonly friction?: number;
|
|
130
175
|
}
|
|
176
|
+
/** The physics world as it is now: its bodies, contacts and steps. */
|
|
131
177
|
export interface PhysicsSnapshot {
|
|
132
178
|
readonly bodies: number;
|
|
133
179
|
readonly contacts: number;
|
|
@@ -146,7 +192,15 @@ export interface PhysicsWorld {
|
|
|
146
192
|
addTileColliders(grid: PhysicsTileColliders): readonly PhysicsBody[];
|
|
147
193
|
/** Takes the time given in fixed steps, and leaves the rest for the next update. Returns the steps taken. */
|
|
148
194
|
step(seconds: number): number;
|
|
149
|
-
/**
|
|
195
|
+
/** Joins two bodies, or a body and a point. A joint goes with either of its bodies when that is removed. */
|
|
196
|
+
addJoint(options: PhysicsJointOptions): PhysicsJoint;
|
|
197
|
+
removeJoint(joint: PhysicsJoint): void;
|
|
198
|
+
readonly joints: readonly PhysicsJoint[];
|
|
199
|
+
/**
|
|
200
|
+
* Told each contact that begins and ends, after the step it happened in, once that step is done. A listener may change
|
|
201
|
+
* the world: add and remove bodies and joints, push bodies, change their kind. What it changes takes effect from the
|
|
202
|
+
* next step, and a body it removes tells the end of its contacts at once. It may not call `step`.
|
|
203
|
+
*/
|
|
150
204
|
onContact(listener: (contact: PhysicsContact) => void): () => void;
|
|
151
205
|
/** The bodies whose shapes hold a point, or meet a rectangle. */
|
|
152
206
|
queryPoint(x: number, y: number, mask?: number): readonly PhysicsBody[];
|