excalibur 0.25.2 → 0.25.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -2
- package/build/dist/Actions/Action/Blink.js +51 -0
- package/build/dist/Actions/Action/Blink.js.map +1 -0
- package/build/dist/Actions/Action/CallMethod.js +21 -0
- package/build/dist/Actions/Action/CallMethod.js.map +1 -0
- package/build/dist/Actions/Action/Delay.js +25 -0
- package/build/dist/Actions/Action/Delay.js.map +1 -0
- package/build/dist/Actions/Action/Die.js +22 -0
- package/build/dist/Actions/Action/Die.js.map +1 -0
- package/build/dist/Actions/Action/EaseTo.js +69 -0
- package/build/dist/Actions/Action/EaseTo.js.map +1 -0
- package/build/dist/Actions/Action/Fade.js +46 -0
- package/build/dist/Actions/Action/Fade.js.map +1 -0
- package/build/dist/Actions/Action/Follow.js +55 -0
- package/build/dist/Actions/Action/Follow.js.map +1 -0
- package/build/dist/Actions/Action/Meet.js +52 -0
- package/build/dist/Actions/Action/Meet.js.map +1 -0
- package/build/dist/Actions/Action/MoveBy.js +47 -0
- package/build/dist/Actions/Action/MoveBy.js.map +1 -0
- package/build/dist/Actions/Action/MoveTo.js +40 -0
- package/build/dist/Actions/Action/MoveTo.js.map +1 -0
- package/build/dist/Actions/Action/Repeat.js +31 -0
- package/build/dist/Actions/Action/Repeat.js.map +1 -0
- package/build/dist/Actions/Action/RepeatForever.js +37 -0
- package/build/dist/Actions/Action/RepeatForever.js.map +1 -0
- package/build/dist/Actions/Action/RotateBy.js +91 -0
- package/build/dist/Actions/Action/RotateBy.js.map +1 -0
- package/build/dist/Actions/Action/RotateTo.js +90 -0
- package/build/dist/Actions/Action/RotateTo.js.map +1 -0
- package/build/dist/Actions/Action/ScaleBy.js +45 -0
- package/build/dist/Actions/Action/ScaleBy.js.map +1 -0
- package/build/dist/Actions/Action/ScaleTo.js +56 -0
- package/build/dist/Actions/Action/ScaleTo.js.map +1 -0
- package/build/dist/Actions/Action.js +2 -0
- package/build/dist/Actions/Action.js.map +1 -0
- package/build/dist/Actions/ActionContext.js +305 -0
- package/build/dist/Actions/ActionContext.js.map +1 -0
- package/build/dist/Actions/ActionQueue.js +87 -0
- package/build/dist/Actions/ActionQueue.js.map +1 -0
- package/build/dist/Actions/Actionable.js +2 -0
- package/build/dist/Actions/Actionable.js.map +1 -0
- package/build/dist/Actions/ActionsComponent.js +198 -0
- package/build/dist/Actions/ActionsComponent.js.map +1 -0
- package/build/dist/Actions/ActionsSystem.js +18 -0
- package/build/dist/Actions/ActionsSystem.js.map +1 -0
- package/build/dist/Actions/Index.js +22 -0
- package/build/dist/Actions/Index.js.map +1 -0
- package/build/dist/Actions/RotationType.js +27 -0
- package/build/dist/Actions/RotationType.js.map +1 -0
- package/build/dist/Actor.js +831 -0
- package/build/dist/Actor.js.map +1 -0
- package/build/dist/Camera.js +663 -0
- package/build/dist/Camera.js.map +1 -0
- package/build/dist/Class.js +48 -0
- package/build/dist/Class.js.map +1 -0
- package/build/dist/Collision/BodyComponent.js +351 -0
- package/build/dist/Collision/BodyComponent.js.map +1 -0
- package/build/dist/Collision/BoundingBox.js +361 -0
- package/build/dist/Collision/BoundingBox.js.map +1 -0
- package/build/dist/Collision/ColliderComponent.js +198 -0
- package/build/dist/Collision/ColliderComponent.js.map +1 -0
- package/build/dist/Collision/Colliders/CircleCollider.js +264 -0
- package/build/dist/Collision/Colliders/CircleCollider.js.map +1 -0
- package/build/dist/Collision/Colliders/ClosestLineJumpTable.js +211 -0
- package/build/dist/Collision/Colliders/ClosestLineJumpTable.js.map +1 -0
- package/build/dist/Collision/Colliders/Collider.js +26 -0
- package/build/dist/Collision/Colliders/Collider.js.map +1 -0
- package/build/dist/Collision/Colliders/CollisionJumpTable.js +301 -0
- package/build/dist/Collision/Colliders/CollisionJumpTable.js.map +1 -0
- package/build/dist/Collision/Colliders/CompositeCollider.js +232 -0
- package/build/dist/Collision/Colliders/CompositeCollider.js.map +1 -0
- package/build/dist/Collision/Colliders/EdgeCollider.js +253 -0
- package/build/dist/Collision/Colliders/EdgeCollider.js.map +1 -0
- package/build/dist/Collision/Colliders/PolygonCollider.js +389 -0
- package/build/dist/Collision/Colliders/PolygonCollider.js.map +1 -0
- package/build/dist/Collision/Colliders/SeparatingAxis.js +67 -0
- package/build/dist/Collision/Colliders/SeparatingAxis.js.map +1 -0
- package/build/dist/Collision/Colliders/Shape.js +102 -0
- package/build/dist/Collision/Colliders/Shape.js.map +1 -0
- package/build/dist/Collision/CollisionSystem.js +116 -0
- package/build/dist/Collision/CollisionSystem.js.map +1 -0
- package/build/dist/Collision/CollisionType.js +33 -0
- package/build/dist/Collision/CollisionType.js.map +1 -0
- package/build/dist/Collision/Detection/CollisionContact.js +46 -0
- package/build/dist/Collision/Detection/CollisionContact.js.map +1 -0
- package/build/dist/Collision/Detection/CollisionProcessor.js +2 -0
- package/build/dist/Collision/Detection/CollisionProcessor.js.map +1 -0
- package/build/dist/Collision/Detection/DynamicTree.js +442 -0
- package/build/dist/Collision/Detection/DynamicTree.js.map +1 -0
- package/build/dist/Collision/Detection/DynamicTreeCollisionProcessor.js +211 -0
- package/build/dist/Collision/Detection/DynamicTreeCollisionProcessor.js.map +1 -0
- package/build/dist/Collision/Detection/Pair.js +92 -0
- package/build/dist/Collision/Detection/Pair.js.map +1 -0
- package/build/dist/Collision/Group/CollisionGroup.js +114 -0
- package/build/dist/Collision/Group/CollisionGroup.js.map +1 -0
- package/build/dist/Collision/Group/CollisionGroupManager.js +52 -0
- package/build/dist/Collision/Group/CollisionGroupManager.js.map +1 -0
- package/build/dist/Collision/Index.js +29 -0
- package/build/dist/Collision/Index.js.map +1 -0
- package/build/dist/Collision/Integrator.js +11 -0
- package/build/dist/Collision/Integrator.js.map +1 -0
- package/build/dist/Collision/MotionSystem.js +42 -0
- package/build/dist/Collision/MotionSystem.js.map +1 -0
- package/build/dist/Collision/Physics.js +163 -0
- package/build/dist/Collision/Physics.js.map +1 -0
- package/build/dist/Collision/Side.js +51 -0
- package/build/dist/Collision/Side.js.map +1 -0
- package/build/dist/Collision/Solver/ArcadeSolver.js +101 -0
- package/build/dist/Collision/Solver/ArcadeSolver.js.map +1 -0
- package/build/dist/Collision/Solver/ContactConstraintPoint.js +83 -0
- package/build/dist/Collision/Solver/ContactConstraintPoint.js.map +1 -0
- package/build/dist/Collision/Solver/RealisticSolver.js +248 -0
- package/build/dist/Collision/Solver/RealisticSolver.js.map +1 -0
- package/build/dist/Collision/Solver/Solver.js +37 -0
- package/build/dist/Collision/Solver/Solver.js.map +1 -0
- package/build/dist/Color.js +461 -0
- package/build/dist/Color.js.map +1 -0
- package/build/dist/Configurable.js +32 -0
- package/build/dist/Configurable.js.map +1 -0
- package/build/dist/Debug/Debug.js +375 -0
- package/build/dist/Debug/Debug.js.map +1 -0
- package/build/dist/Debug/DebugFlags.js +40 -0
- package/build/dist/Debug/DebugFlags.js.map +1 -0
- package/build/dist/Debug/DebugSystem.js +251 -0
- package/build/dist/Debug/DebugSystem.js.map +1 -0
- package/build/dist/Debug/index.js +4 -0
- package/build/dist/Debug/index.js.map +1 -0
- package/build/dist/Deprecated.js +2 -0
- package/build/dist/Deprecated.js.map +1 -0
- package/build/dist/Drawing/Animation.js +294 -0
- package/build/dist/Drawing/Animation.js.map +1 -0
- package/build/dist/Drawing/CanvasDrawComponent.js +16 -0
- package/build/dist/Drawing/CanvasDrawComponent.js.map +1 -0
- package/build/dist/Drawing/CanvasDrawingSystem.js +95 -0
- package/build/dist/Drawing/CanvasDrawingSystem.js.map +1 -0
- package/build/dist/Drawing/Index.js +10 -0
- package/build/dist/Drawing/Index.js.map +1 -0
- package/build/dist/Drawing/Polygon.js +139 -0
- package/build/dist/Drawing/Polygon.js.map +1 -0
- package/build/dist/Drawing/Sprite.js +355 -0
- package/build/dist/Drawing/Sprite.js.map +1 -0
- package/build/dist/Drawing/SpriteEffects.js +246 -0
- package/build/dist/Drawing/SpriteEffects.js.map +1 -0
- package/build/dist/Drawing/SpriteSheet.js +413 -0
- package/build/dist/Drawing/SpriteSheet.js.map +1 -0
- package/build/dist/Drawing/Texture.js +69 -0
- package/build/dist/Drawing/Texture.js.map +1 -0
- package/build/dist/Engine.d.ts +4 -1
- package/build/dist/Engine.js +985 -0
- package/build/dist/Engine.js.map +1 -0
- package/build/dist/EntityComponentSystem/Component.js +65 -0
- package/build/dist/EntityComponentSystem/Component.js.map +1 -0
- package/build/dist/EntityComponentSystem/Components/MotionComponent.js +33 -0
- package/build/dist/EntityComponentSystem/Components/MotionComponent.js.map +1 -0
- package/build/dist/EntityComponentSystem/Components/TransformComponent.js +249 -0
- package/build/dist/EntityComponentSystem/Components/TransformComponent.js.map +1 -0
- package/build/dist/EntityComponentSystem/Entity.js +452 -0
- package/build/dist/EntityComponentSystem/Entity.js.map +1 -0
- package/build/dist/EntityComponentSystem/EntityManager.js +128 -0
- package/build/dist/EntityComponentSystem/EntityManager.js.map +1 -0
- package/build/dist/EntityComponentSystem/Query.js +91 -0
- package/build/dist/EntityComponentSystem/Query.js.map +1 -0
- package/build/dist/EntityComponentSystem/QueryManager.js +90 -0
- package/build/dist/EntityComponentSystem/QueryManager.js.map +1 -0
- package/build/dist/EntityComponentSystem/System.js +76 -0
- package/build/dist/EntityComponentSystem/System.js.map +1 -0
- package/build/dist/EntityComponentSystem/SystemManager.js +102 -0
- package/build/dist/EntityComponentSystem/SystemManager.js.map +1 -0
- package/build/dist/EntityComponentSystem/Util.js +5 -0
- package/build/dist/EntityComponentSystem/Util.js.map +1 -0
- package/build/dist/EntityComponentSystem/World.js +55 -0
- package/build/dist/EntityComponentSystem/World.js.map +1 -0
- package/build/dist/EntityComponentSystem/index.js +11 -0
- package/build/dist/EntityComponentSystem/index.js.map +1 -0
- package/build/dist/EventDispatcher.js +114 -0
- package/build/dist/EventDispatcher.js.map +1 -0
- package/build/dist/Events/ExEvent.js +12 -0
- package/build/dist/Events/ExEvent.js.map +1 -0
- package/build/dist/Events/MediaEvents.js +75 -0
- package/build/dist/Events/MediaEvents.js.map +1 -0
- package/build/dist/Events/PointerEvents.js +52 -0
- package/build/dist/Events/PointerEvents.js.map +1 -0
- package/build/dist/Events.js +497 -0
- package/build/dist/Events.js.map +1 -0
- package/build/dist/Flags.js +90 -0
- package/build/dist/Flags.js.map +1 -0
- package/build/dist/Graphics/Animation.js +310 -0
- package/build/dist/Graphics/Animation.js.map +1 -0
- package/build/dist/Graphics/Canvas.js +38 -0
- package/build/dist/Graphics/Canvas.js.map +1 -0
- package/build/dist/Graphics/Circle.js +47 -0
- package/build/dist/Graphics/Circle.js.map +1 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContext.js +2 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContext.js.map +1 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContext2DCanvas.js +207 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContext2DCanvas.js.map +1 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.js +331 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.js.map +1 -0
- package/build/dist/Graphics/Context/circle-renderer/circle-renderer.js +160 -0
- package/build/dist/Graphics/Context/circle-renderer/circle-renderer.js.map +1 -0
- package/build/dist/Graphics/Context/debug-text.js +47 -0
- package/build/dist/Graphics/Context/debug-text.js.map +1 -0
- package/build/dist/Graphics/Context/image-renderer/image-renderer.js +209 -0
- package/build/dist/Graphics/Context/image-renderer/image-renderer.js.map +1 -0
- package/build/dist/Graphics/Context/line-renderer/line-renderer.js +87 -0
- package/build/dist/Graphics/Context/line-renderer/line-renderer.js.map +1 -0
- package/build/dist/Graphics/Context/point-renderer/point-renderer.js +82 -0
- package/build/dist/Graphics/Context/point-renderer/point-renderer.js.map +1 -0
- package/build/dist/Graphics/Context/quad-index-buffer.js +69 -0
- package/build/dist/Graphics/Context/quad-index-buffer.js.map +1 -0
- package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.js +272 -0
- package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.js.map +1 -0
- package/build/dist/Graphics/Context/render-source.js +16 -0
- package/build/dist/Graphics/Context/render-source.js.map +1 -0
- package/build/dist/Graphics/Context/render-target.js +65 -0
- package/build/dist/Graphics/Context/render-target.js.map +1 -0
- package/build/dist/Graphics/Context/renderer.js +2 -0
- package/build/dist/Graphics/Context/renderer.js.map +1 -0
- package/build/dist/Graphics/Context/screen-pass-painter/screen-pass-painter.js +53 -0
- package/build/dist/Graphics/Context/screen-pass-painter/screen-pass-painter.js.map +1 -0
- package/build/dist/Graphics/Context/shader.js +236 -0
- package/build/dist/Graphics/Context/shader.js.map +1 -0
- package/build/dist/Graphics/Context/state-stack.js +27 -0
- package/build/dist/Graphics/Context/state-stack.js.map +1 -0
- package/build/dist/Graphics/Context/texture-loader.d.ts +8 -0
- package/build/dist/Graphics/Context/texture-loader.js +121 -0
- package/build/dist/Graphics/Context/texture-loader.js.map +1 -0
- package/build/dist/Graphics/Context/transform-stack.js +30 -0
- package/build/dist/Graphics/Context/transform-stack.js.map +1 -0
- package/build/dist/Graphics/Context/vertex-buffer.js +45 -0
- package/build/dist/Graphics/Context/vertex-buffer.js.map +1 -0
- package/build/dist/Graphics/Context/vertex-layout.js +93 -0
- package/build/dist/Graphics/Context/vertex-layout.js.map +1 -0
- package/build/dist/Graphics/Context/webgl-adapter.js +19 -0
- package/build/dist/Graphics/Context/webgl-adapter.js.map +1 -0
- package/build/dist/Graphics/Context/webgl-util.js +105 -0
- package/build/dist/Graphics/Context/webgl-util.js.map +1 -0
- package/build/dist/Graphics/DebugGraphicsComponent.js +15 -0
- package/build/dist/Graphics/DebugGraphicsComponent.js.map +1 -0
- package/build/dist/Graphics/Filtering.js +17 -0
- package/build/dist/Graphics/Filtering.js.map +1 -0
- package/build/dist/Graphics/Font.js +293 -0
- package/build/dist/Graphics/Font.js.map +1 -0
- package/build/dist/Graphics/FontCommon.js +109 -0
- package/build/dist/Graphics/FontCommon.js.map +1 -0
- package/build/dist/Graphics/Graphic.js +200 -0
- package/build/dist/Graphics/Graphic.js.map +1 -0
- package/build/dist/Graphics/GraphicsComponent.js +290 -0
- package/build/dist/Graphics/GraphicsComponent.js.map +1 -0
- package/build/dist/Graphics/GraphicsDiagnostics.js +9 -0
- package/build/dist/Graphics/GraphicsDiagnostics.js.map +1 -0
- package/build/dist/Graphics/GraphicsGroup.js +69 -0
- package/build/dist/Graphics/GraphicsGroup.js.map +1 -0
- package/build/dist/Graphics/GraphicsSystem.js +153 -0
- package/build/dist/Graphics/GraphicsSystem.js.map +1 -0
- package/build/dist/Graphics/ImageSource.js +116 -0
- package/build/dist/Graphics/ImageSource.js.map +1 -0
- package/build/dist/Graphics/Polygon.js +59 -0
- package/build/dist/Graphics/Polygon.js.map +1 -0
- package/build/dist/Graphics/PostProcessor/ColorBlindnessMode.js +7 -0
- package/build/dist/Graphics/PostProcessor/ColorBlindnessMode.js.map +1 -0
- package/build/dist/Graphics/PostProcessor/ColorBlindnessPostProcessor.js +52 -0
- package/build/dist/Graphics/PostProcessor/ColorBlindnessPostProcessor.js.map +1 -0
- package/build/dist/Graphics/PostProcessor/PostProcessor.js +2 -0
- package/build/dist/Graphics/PostProcessor/PostProcessor.js.map +1 -0
- package/build/dist/Graphics/PostProcessor/ScreenShader.js +56 -0
- package/build/dist/Graphics/PostProcessor/ScreenShader.js.map +1 -0
- package/build/dist/Graphics/Raster.js +207 -0
- package/build/dist/Graphics/Raster.js.map +1 -0
- package/build/dist/Graphics/Rectangle.js +29 -0
- package/build/dist/Graphics/Rectangle.js.map +1 -0
- package/build/dist/Graphics/Sprite.js +103 -0
- package/build/dist/Graphics/Sprite.js.map +1 -0
- package/build/dist/Graphics/SpriteFont.js +120 -0
- package/build/dist/Graphics/SpriteFont.js.map +1 -0
- package/build/dist/Graphics/SpriteSheet.js +115 -0
- package/build/dist/Graphics/SpriteSheet.js.map +1 -0
- package/build/dist/Graphics/Text.js +94 -0
- package/build/dist/Graphics/Text.js.map +1 -0
- package/build/dist/Graphics/index.js +42 -0
- package/build/dist/Graphics/index.js.map +1 -0
- package/build/dist/Id.js +8 -0
- package/build/dist/Id.js.map +1 -0
- package/build/dist/Input/CapturePointerConfig.js +5 -0
- package/build/dist/Input/CapturePointerConfig.js.map +1 -0
- package/build/dist/Input/EngineInput.js +2 -0
- package/build/dist/Input/EngineInput.js.map +1 -0
- package/build/dist/Input/Gamepad.js +358 -0
- package/build/dist/Input/Gamepad.js.map +1 -0
- package/build/dist/Input/Index.js +22 -0
- package/build/dist/Input/Index.js.map +1 -0
- package/build/dist/Input/Keyboard.js +267 -0
- package/build/dist/Input/Keyboard.js.map +1 -0
- package/build/dist/Input/NativePointerButton.js +12 -0
- package/build/dist/Input/NativePointerButton.js.map +1 -0
- package/build/dist/Input/PointerAbstraction.js +41 -0
- package/build/dist/Input/PointerAbstraction.js.map +1 -0
- package/build/dist/Input/PointerButton.js +12 -0
- package/build/dist/Input/PointerButton.js.map +1 -0
- package/build/dist/Input/PointerComponent.js +28 -0
- package/build/dist/Input/PointerComponent.js.map +1 -0
- package/build/dist/Input/PointerEvent.js +25 -0
- package/build/dist/Input/PointerEvent.js.map +1 -0
- package/build/dist/Input/PointerEventReceiver.js +414 -0
- package/build/dist/Input/PointerEventReceiver.js.map +1 -0
- package/build/dist/Input/PointerScope.js +16 -0
- package/build/dist/Input/PointerScope.js.map +1 -0
- package/build/dist/Input/PointerSystem.js +217 -0
- package/build/dist/Input/PointerSystem.js.map +1 -0
- package/build/dist/Input/PointerType.js +11 -0
- package/build/dist/Input/PointerType.js.map +1 -0
- package/build/dist/Input/WheelDeltaMode.js +7 -0
- package/build/dist/Input/WheelDeltaMode.js.map +1 -0
- package/build/dist/Input/WheelEvent.js +21 -0
- package/build/dist/Input/WheelEvent.js.map +1 -0
- package/build/dist/Interfaces/Audio.js +2 -0
- package/build/dist/Interfaces/Audio.js.map +1 -0
- package/build/dist/Interfaces/AudioImplementation.js +11 -0
- package/build/dist/Interfaces/AudioImplementation.js.map +1 -0
- package/build/dist/Interfaces/Clonable.js +2 -0
- package/build/dist/Interfaces/Clonable.js.map +1 -0
- package/build/dist/Interfaces/Drawable.js +2 -0
- package/build/dist/Interfaces/Drawable.js.map +1 -0
- package/build/dist/Interfaces/Evented.js +2 -0
- package/build/dist/Interfaces/Evented.js.map +1 -0
- package/build/dist/Interfaces/Index.js +10 -0
- package/build/dist/Interfaces/Index.js.map +1 -0
- package/build/dist/Interfaces/LifecycleEvents.js +51 -0
- package/build/dist/Interfaces/LifecycleEvents.js.map +1 -0
- package/build/dist/Interfaces/Loadable.js +2 -0
- package/build/dist/Interfaces/Loadable.js.map +1 -0
- package/build/dist/Interfaces/PointerEventHandlers.js +2 -0
- package/build/dist/Interfaces/PointerEventHandlers.js.map +1 -0
- package/build/dist/Interfaces/Trait.js +2 -0
- package/build/dist/Interfaces/Trait.js.map +1 -0
- package/build/dist/Label.js +273 -0
- package/build/dist/Label.js.map +1 -0
- package/build/dist/Loader.js +367 -0
- package/build/dist/Loader.js.map +1 -0
- package/build/dist/Math/Index.js +10 -0
- package/build/dist/Math/Index.js.map +1 -0
- package/build/dist/Math/Random.js +239 -0
- package/build/dist/Math/Random.js.map +1 -0
- package/build/dist/Math/global-coordinates.js +30 -0
- package/build/dist/Math/global-coordinates.js.map +1 -0
- package/build/dist/Math/line.js +194 -0
- package/build/dist/Math/line.js.map +1 -0
- package/build/dist/Math/matrix.js +446 -0
- package/build/dist/Math/matrix.js.map +1 -0
- package/build/dist/Math/projection.js +24 -0
- package/build/dist/Math/projection.js.map +1 -0
- package/build/dist/Math/ray.js +52 -0
- package/build/dist/Math/ray.js.map +1 -0
- package/build/dist/Math/util.js +82 -0
- package/build/dist/Math/util.js.map +1 -0
- package/build/dist/Math/vector-view.js +25 -0
- package/build/dist/Math/vector-view.js.map +1 -0
- package/build/dist/Math/vector.js +326 -0
- package/build/dist/Math/vector.js.map +1 -0
- package/build/dist/Particles.js +449 -0
- package/build/dist/Particles.js.map +1 -0
- package/build/dist/Polyfill.js +56 -0
- package/build/dist/Polyfill.js.map +1 -0
- package/build/dist/Promises.js +205 -0
- package/build/dist/Promises.js.map +1 -0
- package/build/dist/Resources/Gif.js +479 -0
- package/build/dist/Resources/Gif.js.map +1 -0
- package/build/dist/Resources/Index.js +4 -0
- package/build/dist/Resources/Index.js.map +1 -0
- package/build/dist/Resources/Resource.js +74 -0
- package/build/dist/Resources/Resource.js.map +1 -0
- package/build/dist/Resources/Sound/AudioContext.js +16 -0
- package/build/dist/Resources/Sound/AudioContext.js.map +1 -0
- package/build/dist/Resources/Sound/Index.js +4 -0
- package/build/dist/Resources/Sound/Index.js.map +1 -0
- package/build/dist/Resources/Sound/Sound.js +240 -0
- package/build/dist/Resources/Sound/Sound.js.map +1 -0
- package/build/dist/Resources/Sound/WebAudioInstance.js +160 -0
- package/build/dist/Resources/Sound/WebAudioInstance.js.map +1 -0
- package/build/dist/Scene.js +458 -0
- package/build/dist/Scene.js.map +1 -0
- package/build/dist/Screen.js +634 -0
- package/build/dist/Screen.js.map +1 -0
- package/build/dist/ScreenElement.js +29 -0
- package/build/dist/ScreenElement.js.map +1 -0
- package/build/dist/TileMap.js +488 -0
- package/build/dist/TileMap.js.map +1 -0
- package/build/dist/Timer.js +198 -0
- package/build/dist/Timer.js.map +1 -0
- package/build/dist/Traits/Index.js +5 -0
- package/build/dist/Traits/Index.js.map +1 -0
- package/build/dist/Traits/OffscreenCulling.js +35 -0
- package/build/dist/Traits/OffscreenCulling.js.map +1 -0
- package/build/dist/Trigger.js +113 -0
- package/build/dist/Trigger.js.map +1 -0
- package/build/dist/Util/Actors.js +19 -0
- package/build/dist/Util/Actors.js.map +1 -0
- package/build/dist/Util/Browser.js +66 -0
- package/build/dist/Util/Browser.js.map +1 -0
- package/build/dist/Util/Clock.js +219 -0
- package/build/dist/Util/Clock.js.map +1 -0
- package/build/dist/Util/CullingBox.js +104 -0
- package/build/dist/Util/CullingBox.js.map +1 -0
- package/build/dist/Util/Decorators.js +78 -0
- package/build/dist/Util/Decorators.js.map +1 -0
- package/build/dist/Util/Detector.js +167 -0
- package/build/dist/Util/Detector.js.map +1 -0
- package/build/dist/Util/DrawUtil.js +117 -0
- package/build/dist/Util/DrawUtil.js.map +1 -0
- package/build/dist/Util/EasingFunctions.js +118 -0
- package/build/dist/Util/EasingFunctions.js.map +1 -0
- package/build/dist/Util/Fps.js +47 -0
- package/build/dist/Util/Fps.js.map +1 -0
- package/build/dist/Util/Index.js +7 -0
- package/build/dist/Util/Index.js.map +1 -0
- package/build/dist/Util/Log.js +195 -0
- package/build/dist/Util/Log.js.map +1 -0
- package/build/dist/Util/Observable.js +60 -0
- package/build/dist/Util/Observable.js.map +1 -0
- package/build/dist/Util/Pool.js +66 -0
- package/build/dist/Util/Pool.js.map +1 -0
- package/build/dist/Util/SortedList.js +261 -0
- package/build/dist/Util/SortedList.js.map +1 -0
- package/build/dist/Util/Sound.js +22 -0
- package/build/dist/Util/Sound.js.map +1 -0
- package/build/dist/Util/Util.js +294 -0
- package/build/dist/Util/Util.js.map +1 -0
- package/build/dist/Util/Watch.js +67 -0
- package/build/dist/Util/Watch.js.map +1 -0
- package/build/dist/Util/WebAudio.js +62 -0
- package/build/dist/Util/WebAudio.js.map +1 -0
- package/build/dist/excalibur.js +101 -22
- package/build/dist/excalibur.js.map +1 -1
- package/build/dist/excalibur.min.js +1 -1
- package/build/dist/excalibur.min.js.LICENSE.txt +1 -1
- package/build/dist/excalibur.min.js.map +1 -1
- package/build/dist/index.js +74 -0
- package/build/dist/index.js.map +1 -0
- package/build/esm/Engine.d.ts +4 -1
- package/build/esm/Graphics/Context/texture-loader.d.ts +8 -0
- package/build/esm/excalibur.js +101 -22
- package/build/esm/excalibur.js.map +1 -1
- package/build/esm/excalibur.min.js +1 -1
- package/build/esm/excalibur.min.js.LICENSE.txt +1 -1
- package/build/esm/excalibur.min.js.map +1 -1
- package/package.json +23 -22
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { BoundingBox } from '../BoundingBox';
|
|
2
|
+
import { CollisionJumpTable } from './CollisionJumpTable';
|
|
3
|
+
import { PolygonCollider } from './PolygonCollider';
|
|
4
|
+
import { EdgeCollider } from './EdgeCollider';
|
|
5
|
+
import { Projection } from '../../Math/projection';
|
|
6
|
+
import { Vector } from '../../Math/vector';
|
|
7
|
+
import { Color } from '../../Color';
|
|
8
|
+
import { Collider } from './Collider';
|
|
9
|
+
import { ClosestLineJumpTable } from './ClosestLineJumpTable';
|
|
10
|
+
/**
|
|
11
|
+
* This is a circle collider for the excalibur rigid body physics simulation
|
|
12
|
+
*/
|
|
13
|
+
export class CircleCollider extends Collider {
|
|
14
|
+
constructor(options) {
|
|
15
|
+
super();
|
|
16
|
+
/**
|
|
17
|
+
* Position of the circle relative to the collider, by default (0, 0).
|
|
18
|
+
*/
|
|
19
|
+
this.offset = Vector.Zero;
|
|
20
|
+
this.offset = options.offset || Vector.Zero;
|
|
21
|
+
this.radius = options.radius || 0;
|
|
22
|
+
}
|
|
23
|
+
get worldPos() {
|
|
24
|
+
var _a, _b, _c, _d;
|
|
25
|
+
const tx = this._transform;
|
|
26
|
+
const scale = (_a = tx === null || tx === void 0 ? void 0 : tx.globalScale) !== null && _a !== void 0 ? _a : Vector.One;
|
|
27
|
+
const rotation = (_b = tx === null || tx === void 0 ? void 0 : tx.globalRotation) !== null && _b !== void 0 ? _b : 0;
|
|
28
|
+
const pos = ((_c = tx === null || tx === void 0 ? void 0 : tx.globalPos) !== null && _c !== void 0 ? _c : Vector.Zero);
|
|
29
|
+
return ((_d = this.offset) !== null && _d !== void 0 ? _d : Vector.Zero).scale(scale).rotate(rotation).add(pos);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get the radius of the circle
|
|
33
|
+
*/
|
|
34
|
+
get radius() {
|
|
35
|
+
var _a;
|
|
36
|
+
const tx = this._transform;
|
|
37
|
+
const scale = (_a = tx === null || tx === void 0 ? void 0 : tx.globalScale) !== null && _a !== void 0 ? _a : Vector.One;
|
|
38
|
+
// This is a trade off, the alternative is retooling circles to support ellipse collisions
|
|
39
|
+
return this._naturalRadius * Math.min(scale.x, scale.y);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Set the radius of the circle
|
|
43
|
+
*/
|
|
44
|
+
set radius(val) {
|
|
45
|
+
var _a;
|
|
46
|
+
const tx = this._transform;
|
|
47
|
+
const scale = (_a = tx === null || tx === void 0 ? void 0 : tx.globalScale) !== null && _a !== void 0 ? _a : Vector.One;
|
|
48
|
+
// This is a trade off, the alternative is retooling circles to support ellipse collisions
|
|
49
|
+
this._naturalRadius = val / Math.min(scale.x, scale.y);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Returns a clone of this shape, not associated with any collider
|
|
53
|
+
*/
|
|
54
|
+
clone() {
|
|
55
|
+
return new CircleCollider({
|
|
56
|
+
offset: this.offset.clone(),
|
|
57
|
+
radius: this.radius
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get the center of the collider in world coordinates
|
|
62
|
+
*/
|
|
63
|
+
get center() {
|
|
64
|
+
var _a, _b, _c, _d;
|
|
65
|
+
const tx = this._transform;
|
|
66
|
+
const scale = (_a = tx === null || tx === void 0 ? void 0 : tx.globalScale) !== null && _a !== void 0 ? _a : Vector.One;
|
|
67
|
+
const rotation = (_b = tx === null || tx === void 0 ? void 0 : tx.globalRotation) !== null && _b !== void 0 ? _b : 0;
|
|
68
|
+
const pos = ((_c = tx === null || tx === void 0 ? void 0 : tx.globalPos) !== null && _c !== void 0 ? _c : Vector.Zero);
|
|
69
|
+
return ((_d = this.offset) !== null && _d !== void 0 ? _d : Vector.Zero).scale(scale).rotate(rotation).add(pos);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Tests if a point is contained in this collider
|
|
73
|
+
*/
|
|
74
|
+
contains(point) {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
const pos = (_b = (_a = this._transform) === null || _a === void 0 ? void 0 : _a.pos) !== null && _b !== void 0 ? _b : this.offset;
|
|
77
|
+
const distance = pos.distance(point);
|
|
78
|
+
if (distance <= this.radius) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Casts a ray at the Circle collider and returns the nearest point of collision
|
|
85
|
+
* @param ray
|
|
86
|
+
*/
|
|
87
|
+
rayCast(ray, max = Infinity) {
|
|
88
|
+
//https://en.wikipedia.org/wiki/Line%E2%80%93sphere_intersection
|
|
89
|
+
const c = this.center;
|
|
90
|
+
const dir = ray.dir;
|
|
91
|
+
const orig = ray.pos;
|
|
92
|
+
const discriminant = Math.sqrt(Math.pow(dir.dot(orig.sub(c)), 2) - Math.pow(orig.sub(c).distance(), 2) + Math.pow(this.radius, 2));
|
|
93
|
+
if (discriminant < 0) {
|
|
94
|
+
// no intersection
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
let toi = 0;
|
|
99
|
+
if (discriminant === 0) {
|
|
100
|
+
toi = -dir.dot(orig.sub(c));
|
|
101
|
+
if (toi > 0 && toi < max) {
|
|
102
|
+
return ray.getPoint(toi);
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
const toi1 = -dir.dot(orig.sub(c)) + discriminant;
|
|
108
|
+
const toi2 = -dir.dot(orig.sub(c)) - discriminant;
|
|
109
|
+
const positiveToi = [];
|
|
110
|
+
if (toi1 >= 0) {
|
|
111
|
+
positiveToi.push(toi1);
|
|
112
|
+
}
|
|
113
|
+
if (toi2 >= 0) {
|
|
114
|
+
positiveToi.push(toi2);
|
|
115
|
+
}
|
|
116
|
+
const mintoi = Math.min(...positiveToi);
|
|
117
|
+
if (mintoi <= max) {
|
|
118
|
+
return ray.getPoint(mintoi);
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
getClosestLineBetween(shape) {
|
|
125
|
+
if (shape instanceof CircleCollider) {
|
|
126
|
+
return ClosestLineJumpTable.CircleCircleClosestLine(this, shape);
|
|
127
|
+
}
|
|
128
|
+
else if (shape instanceof PolygonCollider) {
|
|
129
|
+
return ClosestLineJumpTable.PolygonCircleClosestLine(shape, this).flip();
|
|
130
|
+
}
|
|
131
|
+
else if (shape instanceof EdgeCollider) {
|
|
132
|
+
return ClosestLineJumpTable.CircleEdgeClosestLine(this, shape).flip();
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
throw new Error(`Polygon could not collide with unknown CollisionShape ${typeof shape}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* @inheritdoc
|
|
140
|
+
*/
|
|
141
|
+
collide(collider) {
|
|
142
|
+
if (collider instanceof CircleCollider) {
|
|
143
|
+
return CollisionJumpTable.CollideCircleCircle(this, collider);
|
|
144
|
+
}
|
|
145
|
+
else if (collider instanceof PolygonCollider) {
|
|
146
|
+
return CollisionJumpTable.CollideCirclePolygon(this, collider);
|
|
147
|
+
}
|
|
148
|
+
else if (collider instanceof EdgeCollider) {
|
|
149
|
+
return CollisionJumpTable.CollideCircleEdge(this, collider);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
throw new Error(`Circle could not collide with unknown CollisionShape ${typeof collider}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Find the point on the collider furthest in the direction specified
|
|
157
|
+
*/
|
|
158
|
+
getFurthestPoint(direction) {
|
|
159
|
+
return this.center.add(direction.normalize().scale(this.radius));
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Find the local point on the shape in the direction specified
|
|
163
|
+
* @param direction
|
|
164
|
+
*/
|
|
165
|
+
getFurthestLocalPoint(direction) {
|
|
166
|
+
const dir = direction.normalize();
|
|
167
|
+
return dir.scale(this.radius);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Get the axis aligned bounding box for the circle collider in world coordinates
|
|
171
|
+
*/
|
|
172
|
+
get bounds() {
|
|
173
|
+
var _a, _b, _c;
|
|
174
|
+
const tx = this._transform;
|
|
175
|
+
const scale = (_a = tx === null || tx === void 0 ? void 0 : tx.globalScale) !== null && _a !== void 0 ? _a : Vector.One;
|
|
176
|
+
const rotation = (_b = tx === null || tx === void 0 ? void 0 : tx.globalRotation) !== null && _b !== void 0 ? _b : 0;
|
|
177
|
+
const pos = ((_c = tx === null || tx === void 0 ? void 0 : tx.globalPos) !== null && _c !== void 0 ? _c : Vector.Zero);
|
|
178
|
+
return new BoundingBox(this.offset.x - this._naturalRadius, this.offset.y - this._naturalRadius, this.offset.x + this._naturalRadius, this.offset.y + this._naturalRadius).rotate(rotation).scale(scale).translate(pos);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Get the axis aligned bounding box for the circle collider in local coordinates
|
|
182
|
+
*/
|
|
183
|
+
get localBounds() {
|
|
184
|
+
return new BoundingBox(this.offset.x - this._naturalRadius, this.offset.y - this._naturalRadius, this.offset.x + this._naturalRadius, this.offset.y + this._naturalRadius);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Get axis not implemented on circles, since there are infinite axis in a circle
|
|
188
|
+
*/
|
|
189
|
+
get axes() {
|
|
190
|
+
return [];
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Returns the moment of inertia of a circle given it's mass
|
|
194
|
+
* https://en.wikipedia.org/wiki/List_of_moments_of_inertia
|
|
195
|
+
*/
|
|
196
|
+
getInertia(mass) {
|
|
197
|
+
return (mass * this.radius * this.radius) / 2;
|
|
198
|
+
}
|
|
199
|
+
/* istanbul ignore next */
|
|
200
|
+
update(transform) {
|
|
201
|
+
this._transform = transform;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Project the circle along a specified axis
|
|
205
|
+
*/
|
|
206
|
+
project(axis) {
|
|
207
|
+
const scalars = [];
|
|
208
|
+
const point = this.center;
|
|
209
|
+
const dotProduct = point.dot(axis);
|
|
210
|
+
scalars.push(dotProduct);
|
|
211
|
+
scalars.push(dotProduct + this.radius);
|
|
212
|
+
scalars.push(dotProduct - this.radius);
|
|
213
|
+
return new Projection(Math.min.apply(Math, scalars), Math.max.apply(Math, scalars));
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* @deprecated signature will change in v0.26.0
|
|
217
|
+
* @param ctx
|
|
218
|
+
* @param color
|
|
219
|
+
* @param pos
|
|
220
|
+
*/
|
|
221
|
+
draw(ctx, color = Color.Green, pos = Vector.Zero) {
|
|
222
|
+
const newPos = pos.add(this.offset);
|
|
223
|
+
ctx.beginPath();
|
|
224
|
+
ctx.fillStyle = color.toString();
|
|
225
|
+
ctx.arc(newPos.x, newPos.y, this.radius, 0, Math.PI * 2);
|
|
226
|
+
ctx.closePath();
|
|
227
|
+
ctx.fill();
|
|
228
|
+
}
|
|
229
|
+
debug(ex, color) {
|
|
230
|
+
var _a, _b, _c, _d;
|
|
231
|
+
const tx = this._transform;
|
|
232
|
+
const scale = (_a = tx === null || tx === void 0 ? void 0 : tx.globalScale) !== null && _a !== void 0 ? _a : Vector.One;
|
|
233
|
+
const rotation = (_b = tx === null || tx === void 0 ? void 0 : tx.globalRotation) !== null && _b !== void 0 ? _b : 0;
|
|
234
|
+
const pos = ((_c = tx === null || tx === void 0 ? void 0 : tx.globalPos) !== null && _c !== void 0 ? _c : Vector.Zero);
|
|
235
|
+
ex.save();
|
|
236
|
+
ex.translate(pos.x, pos.y);
|
|
237
|
+
ex.rotate(rotation);
|
|
238
|
+
ex.scale(scale.x, scale.y);
|
|
239
|
+
ex.drawCircle(((_d = this.offset) !== null && _d !== void 0 ? _d : Vector.Zero), this._naturalRadius, Color.Transparent, color, 2);
|
|
240
|
+
ex.restore();
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* @deprecated signature will change in v0.26.0
|
|
244
|
+
* @param ctx
|
|
245
|
+
* @param color
|
|
246
|
+
*/
|
|
247
|
+
/* istanbul ignore next */
|
|
248
|
+
debugDraw(ctx, color = Color.Green) {
|
|
249
|
+
const transform = this._transform;
|
|
250
|
+
const pos = transform ? transform.pos.add(this.offset) : this.offset;
|
|
251
|
+
const rotation = transform ? transform.rotation : 0;
|
|
252
|
+
ctx.beginPath();
|
|
253
|
+
ctx.strokeStyle = color.toString();
|
|
254
|
+
ctx.arc(pos.x, pos.y, this.radius, 0, Math.PI * 2);
|
|
255
|
+
ctx.closePath();
|
|
256
|
+
ctx.stroke();
|
|
257
|
+
ctx.beginPath();
|
|
258
|
+
ctx.moveTo(pos.x, pos.y);
|
|
259
|
+
ctx.lineTo(Math.cos(rotation) * this.radius + pos.x, Math.sin(rotation) * this.radius + pos.y);
|
|
260
|
+
ctx.closePath();
|
|
261
|
+
ctx.stroke();
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
//# sourceMappingURL=CircleCollider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CircleCollider.js","sourceRoot":"","sources":["../../../../src/engine/Collision/Colliders/CircleCollider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAe9D;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,QAAQ;IAsC1C,YAAY,OAA8B;QACxC,KA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CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QAC/F,GAAG,CAAC,SAAS,EAAE,CAAC;QAChB,GAAG,CAAC,MAAM,EAAE,CAAC;IACf,CAAC;CACF"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { Line } from '../../Math/line';
|
|
2
|
+
import { Vector } from '../../Math/vector';
|
|
3
|
+
import { Ray } from '../../Math/ray';
|
|
4
|
+
/**
|
|
5
|
+
* Finds the closes line between 2 line segments, were the magnitude of u, v are the lengths of each segment
|
|
6
|
+
* L1 = P(s) = p0 + s * u, where s is time and p0 is the start of the line
|
|
7
|
+
* L2 = Q(t) = q0 + t * v, where t is time and q0 is the start of the line
|
|
8
|
+
* @param p0 Point where L1 begins
|
|
9
|
+
* @param u Direction and length of L1
|
|
10
|
+
* @param q0 Point were L2 begins
|
|
11
|
+
* @param v Direction and length of L2
|
|
12
|
+
*/
|
|
13
|
+
export function ClosestLine(p0, u, q0, v) {
|
|
14
|
+
// Distance between 2 lines http://geomalgorithms.com/a07-_distance.html
|
|
15
|
+
// w(s, t) = P(s) - Q(t)
|
|
16
|
+
// The w(s, t) that has the minimum distance we will say is w(sClosest, tClosest) = wClosest
|
|
17
|
+
//
|
|
18
|
+
// wClosest is the vector that is uniquely perpendicular to the 2 line directions u & v.
|
|
19
|
+
// wClosest = w0 + sClosest * u - tClosest * v, where w0 is p0 - q0
|
|
20
|
+
//
|
|
21
|
+
// The closest point between 2 lines then satisfies this pair of equations
|
|
22
|
+
// 1: u * wClosest = 0
|
|
23
|
+
// 2: v * wClosest = 0
|
|
24
|
+
//
|
|
25
|
+
// Substituting wClosest into the equations we get
|
|
26
|
+
//
|
|
27
|
+
// 1: (u * u) * sClosest - (u * v) tClosest = -u * w0
|
|
28
|
+
// 2: (v * u) * sClosest - (v * v) tClosest = -v * w0
|
|
29
|
+
// simplify w0
|
|
30
|
+
const w0 = p0.sub(q0);
|
|
31
|
+
// simplify (u * u);
|
|
32
|
+
const a = u.dot(u);
|
|
33
|
+
// simplify (u * v);
|
|
34
|
+
const b = u.dot(v);
|
|
35
|
+
// simplify (v * v)
|
|
36
|
+
const c = v.dot(v);
|
|
37
|
+
// simplify (u * w0)
|
|
38
|
+
const d = u.dot(w0);
|
|
39
|
+
// simplify (v * w0)
|
|
40
|
+
const e = v.dot(w0);
|
|
41
|
+
// denominator ac - b^2
|
|
42
|
+
const denom = a * c - b * b;
|
|
43
|
+
let sDenom = denom;
|
|
44
|
+
let tDenom = denom;
|
|
45
|
+
// if denom is 0 they are parallel, use any point from either as the start in this case p0
|
|
46
|
+
if (denom === 0 || denom <= 0.01) {
|
|
47
|
+
const tClosestParallel = d / b;
|
|
48
|
+
return new Line(p0, q0.add(v.scale(tClosestParallel)));
|
|
49
|
+
}
|
|
50
|
+
// Solve for sClosest for infinite line
|
|
51
|
+
let sClosest = b * e - c * d; // / denom;
|
|
52
|
+
// Solve for tClosest for infinite line
|
|
53
|
+
let tClosest = a * e - b * d; // / denom;
|
|
54
|
+
// Solve for segments candidate edges, if sClosest and tClosest are outside their segments
|
|
55
|
+
if (sClosest < 0) {
|
|
56
|
+
sClosest = 0;
|
|
57
|
+
tClosest = e;
|
|
58
|
+
tDenom = c;
|
|
59
|
+
}
|
|
60
|
+
else if (sClosest > sDenom) {
|
|
61
|
+
sClosest = sDenom;
|
|
62
|
+
tClosest = e + b;
|
|
63
|
+
tDenom = c;
|
|
64
|
+
}
|
|
65
|
+
if (tClosest < 0) {
|
|
66
|
+
tClosest = 0;
|
|
67
|
+
if (-d < 0) {
|
|
68
|
+
sClosest = 0;
|
|
69
|
+
}
|
|
70
|
+
else if (-d > a) {
|
|
71
|
+
sClosest = sDenom;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
sClosest = -d;
|
|
75
|
+
sDenom = a;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else if (tClosest > tDenom) {
|
|
79
|
+
tClosest = tDenom;
|
|
80
|
+
if (-d + b < 0) {
|
|
81
|
+
sClosest = 0;
|
|
82
|
+
}
|
|
83
|
+
else if (-d + b > a) {
|
|
84
|
+
sClosest = sDenom;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
sClosest = -d + b;
|
|
88
|
+
sDenom = a;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
sClosest = Math.abs(sClosest) < 0.001 ? 0 : sClosest / sDenom;
|
|
92
|
+
tClosest = Math.abs(tClosest) < 0.001 ? 0 : tClosest / tDenom;
|
|
93
|
+
return new Line(p0.add(u.scale(sClosest)), q0.add(v.scale(tClosest)));
|
|
94
|
+
}
|
|
95
|
+
export const ClosestLineJumpTable = {
|
|
96
|
+
PolygonPolygonClosestLine(polygonA, polygonB) {
|
|
97
|
+
// Find the 2 closest faces on each polygon
|
|
98
|
+
const otherWorldPos = polygonB.worldPos;
|
|
99
|
+
const otherDirection = otherWorldPos.sub(polygonA.worldPos);
|
|
100
|
+
const thisDirection = otherDirection.negate();
|
|
101
|
+
const rayTowardsOther = new Ray(polygonA.worldPos, otherDirection);
|
|
102
|
+
const rayTowardsThis = new Ray(otherWorldPos, thisDirection);
|
|
103
|
+
const thisPoint = polygonA.rayCast(rayTowardsOther).add(rayTowardsOther.dir.scale(0.1));
|
|
104
|
+
const otherPoint = polygonB.rayCast(rayTowardsThis).add(rayTowardsThis.dir.scale(0.1));
|
|
105
|
+
const thisFace = polygonA.getClosestFace(thisPoint);
|
|
106
|
+
const otherFace = polygonB.getClosestFace(otherPoint);
|
|
107
|
+
// L1 = P(s) = p0 + s * u, where s is time and p0 is the start of the line
|
|
108
|
+
const p0 = thisFace.face.begin;
|
|
109
|
+
const u = thisFace.face.getEdge();
|
|
110
|
+
// L2 = Q(t) = q0 + t * v, where t is time and q0 is the start of the line
|
|
111
|
+
const q0 = otherFace.face.begin;
|
|
112
|
+
const v = otherFace.face.getEdge();
|
|
113
|
+
return ClosestLine(p0, u, q0, v);
|
|
114
|
+
},
|
|
115
|
+
PolygonEdgeClosestLine(polygon, edge) {
|
|
116
|
+
// Find the 2 closest faces on each polygon
|
|
117
|
+
const otherWorldPos = edge.worldPos;
|
|
118
|
+
const otherDirection = otherWorldPos.sub(polygon.worldPos);
|
|
119
|
+
const rayTowardsOther = new Ray(polygon.worldPos, otherDirection);
|
|
120
|
+
const thisPoint = polygon.rayCast(rayTowardsOther).add(rayTowardsOther.dir.scale(0.1));
|
|
121
|
+
const thisFace = polygon.getClosestFace(thisPoint);
|
|
122
|
+
// L1 = P(s) = p0 + s * u, where s is time and p0 is the start of the line
|
|
123
|
+
const p0 = thisFace.face.begin;
|
|
124
|
+
const u = thisFace.face.getEdge();
|
|
125
|
+
// L2 = Q(t) = q0 + t * v, where t is time and q0 is the start of the line
|
|
126
|
+
const edgeLine = edge.asLine();
|
|
127
|
+
const edgeStart = edgeLine.begin;
|
|
128
|
+
const edgeVector = edgeLine.getEdge();
|
|
129
|
+
const q0 = edgeStart;
|
|
130
|
+
const v = edgeVector;
|
|
131
|
+
return ClosestLine(p0, u, q0, v);
|
|
132
|
+
},
|
|
133
|
+
PolygonCircleClosestLine(polygon, circle) {
|
|
134
|
+
// https://math.stackexchange.com/questions/1919177/how-to-find-point-on-line-closest-to-sphere
|
|
135
|
+
// Find the 2 closest faces on each polygon
|
|
136
|
+
const otherWorldPos = circle.worldPos;
|
|
137
|
+
const otherDirection = otherWorldPos.sub(polygon.worldPos);
|
|
138
|
+
const rayTowardsOther = new Ray(polygon.worldPos, otherDirection.normalize());
|
|
139
|
+
const thisPoint = polygon.rayCast(rayTowardsOther).add(rayTowardsOther.dir.scale(0.1));
|
|
140
|
+
const thisFace = polygon.getClosestFace(thisPoint);
|
|
141
|
+
// L1 = P(s) = p0 + s * u, where s is time and p0 is the start of the line
|
|
142
|
+
const p0 = thisFace.face.begin;
|
|
143
|
+
const u = thisFace.face.getEdge();
|
|
144
|
+
// Time of minimum distance
|
|
145
|
+
let t = (u.x * (otherWorldPos.x - p0.x) + u.y * (otherWorldPos.y - p0.y)) / (u.x * u.x + u.y * u.y);
|
|
146
|
+
// If time of minimum is past the edge clamp
|
|
147
|
+
if (t > 1) {
|
|
148
|
+
t = 1;
|
|
149
|
+
}
|
|
150
|
+
else if (t < 0) {
|
|
151
|
+
t = 0;
|
|
152
|
+
}
|
|
153
|
+
// Minimum distance
|
|
154
|
+
const d = Math.sqrt(Math.pow(p0.x + u.x * t - otherWorldPos.x, 2) + Math.pow(p0.y + u.y * t - otherWorldPos.y, 2)) - circle.radius;
|
|
155
|
+
const circlex = ((p0.x + u.x * t - otherWorldPos.x) * circle.radius) / (circle.radius + d);
|
|
156
|
+
const circley = ((p0.y + u.y * t - otherWorldPos.y) * circle.radius) / (circle.radius + d);
|
|
157
|
+
return new Line(u.scale(t).add(p0), new Vector(otherWorldPos.x + circlex, otherWorldPos.y + circley));
|
|
158
|
+
},
|
|
159
|
+
CircleCircleClosestLine(circleA, circleB) {
|
|
160
|
+
// Find the 2 closest faces on each polygon
|
|
161
|
+
const otherWorldPos = circleB.worldPos;
|
|
162
|
+
const otherDirection = otherWorldPos.sub(circleA.worldPos);
|
|
163
|
+
const thisWorldPos = circleA.worldPos;
|
|
164
|
+
const thisDirection = thisWorldPos.sub(circleB.worldPos);
|
|
165
|
+
const rayTowardsOther = new Ray(circleA.worldPos, otherDirection);
|
|
166
|
+
const rayTowardsThis = new Ray(circleB.worldPos, thisDirection);
|
|
167
|
+
const thisPoint = circleA.rayCast(rayTowardsOther);
|
|
168
|
+
const otherPoint = circleB.rayCast(rayTowardsThis);
|
|
169
|
+
return new Line(thisPoint, otherPoint);
|
|
170
|
+
},
|
|
171
|
+
CircleEdgeClosestLine(circle, edge) {
|
|
172
|
+
// https://math.stackexchange.com/questions/1919177/how-to-find-point-on-line-closest-to-sphere
|
|
173
|
+
const circleWorlPos = circle.worldPos;
|
|
174
|
+
// L1 = P(s) = p0 + s * u, where s is time and p0 is the start of the line
|
|
175
|
+
const edgeLine = edge.asLine();
|
|
176
|
+
const edgeStart = edgeLine.begin;
|
|
177
|
+
const edgeVector = edgeLine.getEdge();
|
|
178
|
+
const p0 = edgeStart;
|
|
179
|
+
const u = edgeVector;
|
|
180
|
+
// Time of minimum distance
|
|
181
|
+
let t = (u.x * (circleWorlPos.x - p0.x) + u.y * (circleWorlPos.y - p0.y)) / (u.x * u.x + u.y * u.y);
|
|
182
|
+
// If time of minimum is past the edge clamp to edge
|
|
183
|
+
if (t > 1) {
|
|
184
|
+
t = 1;
|
|
185
|
+
}
|
|
186
|
+
else if (t < 0) {
|
|
187
|
+
t = 0;
|
|
188
|
+
}
|
|
189
|
+
// Minimum distance
|
|
190
|
+
const d = Math.sqrt(Math.pow(p0.x + u.x * t - circleWorlPos.x, 2) + Math.pow(p0.y + u.y * t - circleWorlPos.y, 2)) - circle.radius;
|
|
191
|
+
const circlex = ((p0.x + u.x * t - circleWorlPos.x) * circle.radius) / (circle.radius + d);
|
|
192
|
+
const circley = ((p0.y + u.y * t - circleWorlPos.y) * circle.radius) / (circle.radius + d);
|
|
193
|
+
return new Line(u.scale(t).add(p0), new Vector(circleWorlPos.x + circlex, circleWorlPos.y + circley));
|
|
194
|
+
},
|
|
195
|
+
EdgeEdgeClosestLine(edgeA, edgeB) {
|
|
196
|
+
// L1 = P(s) = p0 + s * u, where s is time and p0 is the start of the line
|
|
197
|
+
const edgeLineA = edgeA.asLine();
|
|
198
|
+
const edgeStartA = edgeLineA.begin;
|
|
199
|
+
const edgeVectorA = edgeLineA.getEdge();
|
|
200
|
+
const p0 = edgeStartA;
|
|
201
|
+
const u = edgeVectorA;
|
|
202
|
+
// L2 = Q(t) = q0 + t * v, where t is time and q0 is the start of the line
|
|
203
|
+
const edgeLineB = edgeB.asLine();
|
|
204
|
+
const edgeStartB = edgeLineB.begin;
|
|
205
|
+
const edgeVectorB = edgeLineB.getEdge();
|
|
206
|
+
const q0 = edgeStartB;
|
|
207
|
+
const v = edgeVectorB;
|
|
208
|
+
return ClosestLine(p0, u, q0, v);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
//# sourceMappingURL=ClosestLineJumpTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClosestLineJumpTable.js","sourceRoot":"","sources":["../../../../src/engine/Collision/Colliders/ClosestLineJumpTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAKrC;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,EAAU,EAAE,CAAS,EAAE,EAAU,EAAE,CAAS;IACtE,wEAAwE;IAExE,wBAAwB;IACxB,4FAA4F;IAC5F,EAAE;IACF,wFAAwF;IACxF,mEAAmE;IACnE,EAAE;IACF,0EAA0E;IAC1E,sBAAsB;IACtB,sBAAsB;IACtB,EAAE;IACF,kDAAkD;IAClD,EAAE;IACF,qDAAqD;IACrD,qDAAqD;IAErD,cAAc;IACd,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAEtB,oBAAoB;IACpB,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACnB,oBAAoB;IACpB,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACnB,mBAAmB;IACnB,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACnB,oBAAoB;IACpB,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACpB,oBAAoB;IACpB,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAEpB,uBAAuB;IACvB,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,M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AAC,EAAE,CAAC,EAAE,IAAI,MAAM,CAAC,aAAa,CAAC,CAAC,GAAG,OAAO,EAAE,aAAa,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IACxG,CAAC;IAED,mBAAmB,CAAC,KAAmB,EAAE,KAAmB;QAC1D,0EAA0E;QAC1E,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QACjC,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC;QACnC,MAAM,WAAW,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC;QACxC,MAAM,EAAE,GAAG,UAAU,CAAC;QACtB,MAAM,CAAC,GAAG,WAAW,CAAC;QAEtB,0EAA0E;QAC1E,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QACjC,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC;QACnC,MAAM,WAAW,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC;QACxC,MAAM,EAAE,GAAG,UAAU,CAAC;QACtB,MAAM,CAAC,GAAG,WAAW,CAAC;QAEtB,OAAO,WAAW,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IACnC,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createId } from '../../Id';
|
|
2
|
+
import { EventDispatcher } from '../../EventDispatcher';
|
|
3
|
+
/**
|
|
4
|
+
* A collision collider specifies the geometry that can detect when other collision colliders intersect
|
|
5
|
+
* for the purposes of colliding 2 objects in excalibur.
|
|
6
|
+
*/
|
|
7
|
+
export class Collider {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.id = createId('collider', Collider._ID++);
|
|
10
|
+
this.events = new EventDispatcher();
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Returns a boolean indicating whether this body collided with
|
|
14
|
+
* or was in stationary contact with
|
|
15
|
+
* the body of the other [[Collider]]
|
|
16
|
+
*/
|
|
17
|
+
touching(other) {
|
|
18
|
+
const contact = this.collide(other);
|
|
19
|
+
if (contact) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
Collider._ID = 0;
|
|
26
|
+
//# sourceMappingURL=Collider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Collider.js","sourceRoot":"","sources":["../../../../src/engine/Collision/Colliders/Collider.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,QAAQ,EAAM,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD;;;GAGG;AACH,MAAM,OAAgB,QAAQ;IAA9B;QAEkB,OAAE,GAAmB,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC;QACnE,WAAM,GAA8B,IAAI,eAAe,EAAY,CAAC;IAuG7E,CAAC;IArGC;;;;OAIG;IACI,QAAQ,CAAC,KAAe;QAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAEpC,IAAI,OAAO,EAAE;YACX,OAAO,IAAI,CAAC;SACb;QAED,OAAO,KAAK,CAAC;IACf,CAAC;;AAjBc,YAAG,GAAG,CAAC,CAAC"}
|