@codexo/exojs 0.7.11 → 0.7.13
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 +442 -0
- package/dist/esm/animation/Tween.d.ts +60 -1
- package/dist/esm/animation/Tween.js +60 -1
- package/dist/esm/animation/Tween.js.map +1 -1
- package/dist/esm/animation/TweenManager.d.ts +10 -0
- package/dist/esm/animation/TweenManager.js +10 -0
- package/dist/esm/animation/TweenManager.js.map +1 -1
- package/dist/esm/animation/types.d.ts +15 -0
- package/dist/esm/animation/types.js +6 -0
- package/dist/esm/animation/types.js.map +1 -1
- package/dist/esm/audio/AbstractMedia.d.ts +11 -0
- package/dist/esm/audio/AbstractMedia.js +10 -0
- package/dist/esm/audio/AbstractMedia.js.map +1 -1
- package/dist/esm/audio/AudioAnalyser.d.ts +21 -0
- package/dist/esm/audio/AudioAnalyser.js +16 -0
- package/dist/esm/audio/AudioAnalyser.js.map +1 -1
- package/dist/esm/audio/AudioBus.d.ts +37 -0
- package/dist/esm/audio/AudioBus.js +36 -0
- package/dist/esm/audio/AudioBus.js.map +1 -1
- package/dist/esm/audio/AudioFilter.d.ts +7 -0
- package/dist/esm/audio/AudioFilter.js +6 -0
- package/dist/esm/audio/AudioFilter.js.map +1 -1
- package/dist/esm/audio/AudioListener.d.ts +19 -0
- package/dist/esm/audio/AudioListener.js +11 -0
- package/dist/esm/audio/AudioListener.js.map +1 -1
- package/dist/esm/audio/AudioManager.d.ts +37 -0
- package/dist/esm/audio/AudioManager.js +37 -0
- package/dist/esm/audio/AudioManager.js.map +1 -1
- package/dist/esm/audio/BeatDetector.d.ts +21 -0
- package/dist/esm/audio/BeatDetector.js +21 -0
- package/dist/esm/audio/BeatDetector.js.map +1 -1
- package/dist/esm/audio/Media.d.ts +11 -0
- package/dist/esm/audio/Music.d.ts +12 -0
- package/dist/esm/audio/Music.js +12 -0
- package/dist/esm/audio/Music.js.map +1 -1
- package/dist/esm/audio/Sound.d.ts +25 -0
- package/dist/esm/audio/Sound.js +18 -0
- package/dist/esm/audio/Sound.js.map +1 -1
- package/dist/esm/audio/audio-context.d.ts +48 -0
- package/dist/esm/audio/audio-context.js +48 -5
- package/dist/esm/audio/audio-context.js.map +1 -1
- package/dist/esm/audio/filters/ChorusFilter.d.ts +5 -0
- package/dist/esm/audio/filters/ChorusFilter.js +4 -0
- package/dist/esm/audio/filters/ChorusFilter.js.map +1 -1
- package/dist/esm/audio/filters/CompressorFilter.d.ts +12 -0
- package/dist/esm/audio/filters/CompressorFilter.js +11 -0
- package/dist/esm/audio/filters/CompressorFilter.js.map +1 -1
- package/dist/esm/audio/filters/DelayFilter.d.ts +11 -0
- package/dist/esm/audio/filters/DelayFilter.js +10 -0
- package/dist/esm/audio/filters/DelayFilter.js.map +1 -1
- package/dist/esm/audio/filters/DuckingFilter.d.ts +13 -0
- package/dist/esm/audio/filters/DuckingFilter.js +12 -0
- package/dist/esm/audio/filters/DuckingFilter.js.map +1 -1
- package/dist/esm/audio/filters/EqualizerFilter.d.ts +20 -0
- package/dist/esm/audio/filters/EqualizerFilter.js +40 -0
- package/dist/esm/audio/filters/EqualizerFilter.js.map +1 -1
- package/dist/esm/audio/filters/GranularFilter.d.ts +6 -0
- package/dist/esm/audio/filters/GranularFilter.js +6 -0
- package/dist/esm/audio/filters/GranularFilter.js.map +1 -1
- package/dist/esm/audio/filters/HighpassFilter.d.ts +10 -0
- package/dist/esm/audio/filters/HighpassFilter.js +9 -0
- package/dist/esm/audio/filters/HighpassFilter.js.map +1 -1
- package/dist/esm/audio/filters/LowpassFilter.d.ts +10 -0
- package/dist/esm/audio/filters/LowpassFilter.js +9 -0
- package/dist/esm/audio/filters/LowpassFilter.js.map +1 -1
- package/dist/esm/audio/filters/PitchShiftFilter.d.ts +2 -0
- package/dist/esm/audio/filters/PitchShiftFilter.js +2 -0
- package/dist/esm/audio/filters/PitchShiftFilter.js.map +1 -1
- package/dist/esm/audio/filters/ReverbFilter.d.ts +12 -0
- package/dist/esm/audio/filters/ReverbFilter.js +11 -0
- package/dist/esm/audio/filters/ReverbFilter.js.map +1 -1
- package/dist/esm/audio/filters/VocoderFilter.d.ts +11 -0
- package/dist/esm/audio/filters/VocoderFilter.js +11 -0
- package/dist/esm/audio/filters/VocoderFilter.js.map +1 -1
- package/dist/esm/audio/filters/WorkletFilter.d.ts +6 -1
- package/dist/esm/audio/filters/WorkletFilter.js +6 -1
- package/dist/esm/audio/filters/WorkletFilter.js.map +1 -1
- package/dist/esm/core/Application.d.ts +66 -1
- package/dist/esm/core/Application.js +68 -6
- package/dist/esm/core/Application.js.map +1 -1
- package/dist/esm/core/Bounds.d.ts +23 -0
- package/dist/esm/core/Bounds.js +23 -0
- package/dist/esm/core/Bounds.js.map +1 -1
- package/dist/esm/core/Clock.d.ts +21 -0
- package/dist/esm/core/Clock.js +21 -0
- package/dist/esm/core/Clock.js.map +1 -1
- package/dist/esm/core/Color.d.ts +35 -0
- package/dist/esm/core/Color.js +35 -0
- package/dist/esm/core/Color.js.map +1 -1
- package/dist/esm/core/Scene.d.ts +76 -0
- package/dist/esm/core/Scene.js +83 -0
- package/dist/esm/core/Scene.js.map +1 -1
- package/dist/esm/core/SceneManager.d.ts +62 -0
- package/dist/esm/core/SceneManager.js +51 -2
- package/dist/esm/core/SceneManager.js.map +1 -1
- package/dist/esm/core/SceneNode.d.ts +31 -0
- package/dist/esm/core/SceneNode.js +31 -0
- package/dist/esm/core/SceneNode.js.map +1 -1
- package/dist/esm/core/Signal.d.ts +44 -0
- package/dist/esm/core/Signal.js +39 -0
- package/dist/esm/core/Signal.js.map +1 -1
- package/dist/esm/core/Time.d.ts +21 -0
- package/dist/esm/core/Time.js +21 -0
- package/dist/esm/core/Time.js.map +1 -1
- package/dist/esm/core/Timer.d.ts +7 -0
- package/dist/esm/core/Timer.js +7 -0
- package/dist/esm/core/Timer.js.map +1 -1
- package/dist/esm/core/capabilities.d.ts +12 -0
- package/dist/esm/core/capabilities.js +12 -0
- package/dist/esm/core/capabilities.js.map +1 -1
- package/dist/esm/core/types.d.ts +37 -0
- package/dist/esm/core/utils.d.ts +48 -0
- package/dist/esm/core/utils.js +48 -0
- package/dist/esm/core/utils.js.map +1 -1
- package/dist/esm/debug/BoundingBoxesLayer.d.ts +8 -0
- package/dist/esm/debug/BoundingBoxesLayer.js +8 -0
- package/dist/esm/debug/BoundingBoxesLayer.js.map +1 -1
- package/dist/esm/debug/DebugLayer.d.ts +16 -3
- package/dist/esm/debug/DebugLayer.js +11 -3
- package/dist/esm/debug/DebugLayer.js.map +1 -1
- package/dist/esm/debug/DebugOverlay.d.ts +11 -0
- package/dist/esm/debug/DebugOverlay.js +8 -2
- package/dist/esm/debug/DebugOverlay.js.map +1 -1
- package/dist/esm/debug/HitTestLayer.d.ts +9 -0
- package/dist/esm/debug/HitTestLayer.js +9 -0
- package/dist/esm/debug/HitTestLayer.js.map +1 -1
- package/dist/esm/debug/PerformanceLayer.d.ts +17 -1
- package/dist/esm/debug/PerformanceLayer.js +18 -0
- package/dist/esm/debug/PerformanceLayer.js.map +1 -1
- package/dist/esm/debug/PointerStackLayer.d.ts +8 -0
- package/dist/esm/debug/PointerStackLayer.js +11 -3
- package/dist/esm/debug/PointerStackLayer.js.map +1 -1
- package/dist/esm/index.js +6 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/input/ArcadeStickGamepadMapping.d.ts +7 -0
- package/dist/esm/input/ArcadeStickGamepadMapping.js +25 -19
- package/dist/esm/input/ArcadeStickGamepadMapping.js.map +1 -1
- package/dist/esm/input/GameCubeGamepadMapping.d.ts +9 -0
- package/dist/esm/input/GameCubeGamepadMapping.js +9 -0
- package/dist/esm/input/GameCubeGamepadMapping.js.map +1 -1
- package/dist/esm/input/Gamepad.d.ts +181 -31
- package/dist/esm/input/Gamepad.js +307 -108
- package/dist/esm/input/Gamepad.js.map +1 -1
- package/dist/esm/input/GamepadAxis.d.ts +120 -0
- package/dist/esm/input/GamepadAxis.js +106 -0
- package/dist/esm/input/GamepadAxis.js.map +1 -0
- package/dist/esm/input/GamepadButton.d.ts +110 -0
- package/dist/esm/input/GamepadButton.js +99 -0
- package/dist/esm/input/GamepadButton.js.map +1 -0
- package/dist/esm/input/GamepadDefinitions.d.ts +64 -1
- package/dist/esm/input/GamepadDefinitions.js +44 -1
- package/dist/esm/input/GamepadDefinitions.js.map +1 -1
- package/dist/esm/input/GamepadMapping.d.ts +42 -8
- package/dist/esm/input/GamepadMapping.js +46 -5
- package/dist/esm/input/GamepadMapping.js.map +1 -1
- package/dist/esm/input/GamepadPromptLayouts.d.ts +35 -2
- package/dist/esm/input/GamepadPromptLayouts.js +43 -18
- package/dist/esm/input/GamepadPromptLayouts.js.map +1 -1
- package/dist/esm/input/GenericDualAnalogGamepadMapping.d.ts +13 -0
- package/dist/esm/input/GenericDualAnalogGamepadMapping.js +62 -43
- package/dist/esm/input/GenericDualAnalogGamepadMapping.js.map +1 -1
- package/dist/esm/input/GestureRecognizer.d.ts +11 -2
- package/dist/esm/input/GestureRecognizer.js +11 -2
- package/dist/esm/input/GestureRecognizer.js.map +1 -1
- package/dist/esm/input/InputBinding.d.ts +74 -0
- package/dist/esm/input/InputBinding.js +100 -0
- package/dist/esm/input/InputBinding.js.map +1 -0
- package/dist/esm/input/InputManager.d.ts +100 -21
- package/dist/esm/input/InputManager.js +248 -90
- package/dist/esm/input/InputManager.js.map +1 -1
- package/dist/esm/input/InteractionEvent.d.ts +13 -0
- package/dist/esm/input/InteractionEvent.js +8 -0
- package/dist/esm/input/InteractionEvent.js.map +1 -1
- package/dist/esm/input/InteractionManager.d.ts +34 -5
- package/dist/esm/input/InteractionManager.js +46 -17
- package/dist/esm/input/InteractionManager.js.map +1 -1
- package/dist/esm/input/JoyConLeftGamepadMapping.d.ts +17 -3
- package/dist/esm/input/JoyConLeftGamepadMapping.js +42 -3
- package/dist/esm/input/JoyConLeftGamepadMapping.js.map +1 -1
- package/dist/esm/input/JoyConRightGamepadMapping.d.ts +17 -3
- package/dist/esm/input/JoyConRightGamepadMapping.js +38 -3
- package/dist/esm/input/JoyConRightGamepadMapping.js.map +1 -1
- package/dist/esm/input/PlayStationGamepadMapping.d.ts +8 -0
- package/dist/esm/input/PlayStationGamepadMapping.js +8 -0
- package/dist/esm/input/PlayStationGamepadMapping.js.map +1 -1
- package/dist/esm/input/Pointer.d.ts +106 -71
- package/dist/esm/input/Pointer.js +93 -71
- package/dist/esm/input/Pointer.js.map +1 -1
- package/dist/esm/input/SteamControllerGamepadMapping.d.ts +8 -0
- package/dist/esm/input/SteamControllerGamepadMapping.js +8 -0
- package/dist/esm/input/SteamControllerGamepadMapping.js.map +1 -1
- package/dist/esm/input/SteamDeckGamepadMapping.d.ts +18 -0
- package/dist/esm/input/SteamDeckGamepadMapping.js +76 -0
- package/dist/esm/input/SteamDeckGamepadMapping.js.map +1 -0
- package/dist/esm/input/SwitchProGamepadMapping.d.ts +9 -0
- package/dist/esm/input/SwitchProGamepadMapping.js +9 -0
- package/dist/esm/input/SwitchProGamepadMapping.js.map +1 -1
- package/dist/esm/input/XboxGamepadMapping.d.ts +8 -0
- package/dist/esm/input/XboxGamepadMapping.js +8 -0
- package/dist/esm/input/XboxGamepadMapping.js.map +1 -1
- package/dist/esm/input/index.d.ts +7 -4
- package/dist/esm/input/types.d.ts +17 -73
- package/dist/esm/input/types.js +18 -77
- package/dist/esm/input/types.js.map +1 -1
- package/dist/esm/math/AbstractVector.d.ts +83 -0
- package/dist/esm/math/AbstractVector.js +83 -0
- package/dist/esm/math/AbstractVector.js.map +1 -1
- package/dist/esm/math/Circle.d.ts +32 -0
- package/dist/esm/math/Circle.js +34 -2
- package/dist/esm/math/Circle.js.map +1 -1
- package/dist/esm/math/CircleLike.d.ts +1 -0
- package/dist/esm/math/Collision.d.ts +39 -0
- package/dist/esm/math/Collision.js +5 -0
- package/dist/esm/math/Collision.js.map +1 -1
- package/dist/esm/math/Ellipse.d.ts +11 -0
- package/dist/esm/math/Ellipse.js +18 -2
- package/dist/esm/math/Ellipse.js.map +1 -1
- package/dist/esm/math/EllipseLike.d.ts +3 -0
- package/dist/esm/math/Flags.d.ts +31 -0
- package/dist/esm/math/Flags.js +31 -0
- package/dist/esm/math/Flags.js.map +1 -1
- package/dist/esm/math/Interval.d.ts +15 -0
- package/dist/esm/math/Interval.js +15 -0
- package/dist/esm/math/Interval.js.map +1 -1
- package/dist/esm/math/Line.d.ts +17 -1
- package/dist/esm/math/Line.js +17 -1
- package/dist/esm/math/Line.js.map +1 -1
- package/dist/esm/math/LineLike.d.ts +1 -0
- package/dist/esm/math/Matrix.d.ts +44 -3
- package/dist/esm/math/Matrix.js +44 -3
- package/dist/esm/math/Matrix.js.map +1 -1
- package/dist/esm/math/ObservableSize.d.ts +7 -0
- package/dist/esm/math/ObservableSize.js +7 -0
- package/dist/esm/math/ObservableSize.js.map +1 -1
- package/dist/esm/math/ObservableVector.d.ts +9 -0
- package/dist/esm/math/ObservableVector.js +9 -0
- package/dist/esm/math/ObservableVector.js.map +1 -1
- package/dist/esm/math/PointLike.d.ts +1 -0
- package/dist/esm/math/PolarVector.d.ts +15 -0
- package/dist/esm/math/PolarVector.js +16 -1
- package/dist/esm/math/PolarVector.js.map +1 -1
- package/dist/esm/math/Polygon.d.ts +20 -0
- package/dist/esm/math/Polygon.js +20 -0
- package/dist/esm/math/Polygon.js.map +1 -1
- package/dist/esm/math/PolygonLike.d.ts +4 -0
- package/dist/esm/math/Quadtree.d.ts +40 -3
- package/dist/esm/math/Quadtree.js +39 -3
- package/dist/esm/math/Quadtree.js.map +1 -1
- package/dist/esm/math/Random.d.ts +25 -0
- package/dist/esm/math/Random.js +25 -0
- package/dist/esm/math/Random.js.map +1 -1
- package/dist/esm/math/Rectangle.d.ts +15 -0
- package/dist/esm/math/Rectangle.js +17 -2
- package/dist/esm/math/Rectangle.js.map +1 -1
- package/dist/esm/math/RectangleLike.d.ts +1 -0
- package/dist/esm/math/Segment.d.ts +7 -0
- package/dist/esm/math/Segment.js +7 -0
- package/dist/esm/math/Segment.js.map +1 -1
- package/dist/esm/math/ShapeLike.d.ts +6 -0
- package/dist/esm/math/Size.d.ts +9 -0
- package/dist/esm/math/Size.js +9 -0
- package/dist/esm/math/Size.js.map +1 -1
- package/dist/esm/math/Vector.d.ts +16 -0
- package/dist/esm/math/Vector.js +16 -0
- package/dist/esm/math/Vector.js.map +1 -1
- package/dist/esm/math/collision-detection.d.ts +47 -1
- package/dist/esm/math/collision-detection.js +228 -17
- package/dist/esm/math/collision-detection.js.map +1 -1
- package/dist/esm/math/collision-primitives.d.ts +23 -0
- package/dist/esm/math/collision-primitives.js +23 -0
- package/dist/esm/math/collision-primitives.js.map +1 -1
- package/dist/esm/math/geometry.d.ts +42 -0
- package/dist/esm/math/geometry.js +37 -0
- package/dist/esm/math/geometry.js.map +1 -1
- package/dist/esm/math/utils.d.ts +41 -0
- package/dist/esm/math/utils.js +41 -0
- package/dist/esm/math/utils.js.map +1 -1
- package/dist/esm/particles/Particle.d.ts +37 -0
- package/dist/esm/particles/Particle.js +37 -0
- package/dist/esm/particles/Particle.js.map +1 -1
- package/dist/esm/particles/ParticleProperties.d.ts +15 -0
- package/dist/esm/particles/ParticleSystem.d.ts +69 -0
- package/dist/esm/particles/ParticleSystem.js +69 -0
- package/dist/esm/particles/ParticleSystem.js.map +1 -1
- package/dist/esm/particles/affectors/ColorAffector.d.ts +13 -0
- package/dist/esm/particles/affectors/ColorAffector.js +13 -0
- package/dist/esm/particles/affectors/ColorAffector.js.map +1 -1
- package/dist/esm/particles/affectors/ForceAffector.d.ts +11 -0
- package/dist/esm/particles/affectors/ForceAffector.js +11 -0
- package/dist/esm/particles/affectors/ForceAffector.js.map +1 -1
- package/dist/esm/particles/affectors/ParticleAffector.d.ts +13 -0
- package/dist/esm/particles/affectors/ScaleAffector.d.ts +10 -0
- package/dist/esm/particles/affectors/ScaleAffector.js +10 -0
- package/dist/esm/particles/affectors/ScaleAffector.js.map +1 -1
- package/dist/esm/particles/affectors/TorqueAffector.d.ts +11 -0
- package/dist/esm/particles/affectors/TorqueAffector.js +11 -0
- package/dist/esm/particles/affectors/TorqueAffector.js.map +1 -1
- package/dist/esm/particles/emitters/ParticleEmitter.d.ts +13 -0
- package/dist/esm/particles/emitters/ParticleOptions.d.ts +16 -0
- package/dist/esm/particles/emitters/ParticleOptions.js +16 -0
- package/dist/esm/particles/emitters/ParticleOptions.js.map +1 -1
- package/dist/esm/particles/emitters/UniversalEmitter.d.ts +23 -0
- package/dist/esm/particles/emitters/UniversalEmitter.js +23 -0
- package/dist/esm/particles/emitters/UniversalEmitter.js.map +1 -1
- package/dist/esm/rendering/CallbackRenderPass.d.ts +12 -0
- package/dist/esm/rendering/CallbackRenderPass.js +12 -0
- package/dist/esm/rendering/CallbackRenderPass.js.map +1 -1
- package/dist/esm/rendering/Container.d.ts +43 -0
- package/dist/esm/rendering/Container.js +43 -0
- package/dist/esm/rendering/Container.js.map +1 -1
- package/dist/esm/rendering/Drawable.d.ts +22 -0
- package/dist/esm/rendering/Drawable.js +22 -0
- package/dist/esm/rendering/Drawable.js.map +1 -1
- package/dist/esm/rendering/RenderBackend.d.ts +13 -0
- package/dist/esm/rendering/RenderBackendType.d.ts +4 -0
- package/dist/esm/rendering/RenderBackendType.js +4 -0
- package/dist/esm/rendering/RenderBackendType.js.map +1 -1
- package/dist/esm/rendering/RenderNode.d.ts +18 -0
- package/dist/esm/rendering/RenderNode.js +18 -0
- package/dist/esm/rendering/RenderNode.js.map +1 -1
- package/dist/esm/rendering/RenderPass.d.ts +8 -0
- package/dist/esm/rendering/RenderStats.d.ts +19 -0
- package/dist/esm/rendering/RenderStats.js +7 -0
- package/dist/esm/rendering/RenderStats.js.map +1 -1
- package/dist/esm/rendering/RenderTarget.d.ts +17 -0
- package/dist/esm/rendering/RenderTarget.js +17 -0
- package/dist/esm/rendering/RenderTarget.js.map +1 -1
- package/dist/esm/rendering/RenderTargetPass.d.ts +11 -0
- package/dist/esm/rendering/RenderTargetPass.js +7 -0
- package/dist/esm/rendering/RenderTargetPass.js.map +1 -1
- package/dist/esm/rendering/Renderer.d.ts +15 -0
- package/dist/esm/rendering/RendererRegistry.d.ts +7 -0
- package/dist/esm/rendering/RendererRegistry.js +7 -0
- package/dist/esm/rendering/RendererRegistry.js.map +1 -1
- package/dist/esm/rendering/View.d.ts +67 -2
- package/dist/esm/rendering/View.js +57 -0
- package/dist/esm/rendering/View.js.map +1 -1
- package/dist/esm/rendering/filters/BlurFilter.d.ts +9 -0
- package/dist/esm/rendering/filters/BlurFilter.js +8 -0
- package/dist/esm/rendering/filters/BlurFilter.js.map +1 -1
- package/dist/esm/rendering/filters/ColorFilter.d.ts +7 -0
- package/dist/esm/rendering/filters/ColorFilter.js +7 -0
- package/dist/esm/rendering/filters/ColorFilter.js.map +1 -1
- package/dist/esm/rendering/filters/Filter.d.ts +23 -0
- package/dist/esm/rendering/filters/Filter.js +20 -0
- package/dist/esm/rendering/filters/Filter.js.map +1 -1
- package/dist/esm/rendering/filters/WebGl2ShaderFilter.d.ts +5 -0
- package/dist/esm/rendering/filters/WebGl2ShaderFilter.js +5 -0
- package/dist/esm/rendering/filters/WebGl2ShaderFilter.js.map +1 -1
- package/dist/esm/rendering/filters/WebGpuShaderFilter.d.ts +5 -0
- package/dist/esm/rendering/filters/WebGpuShaderFilter.js +5 -0
- package/dist/esm/rendering/filters/WebGpuShaderFilter.js.map +1 -1
- package/dist/esm/rendering/mesh/Mesh.d.ts +2 -0
- package/dist/esm/rendering/mesh/Mesh.js +2 -0
- package/dist/esm/rendering/mesh/Mesh.js.map +1 -1
- package/dist/esm/rendering/primitives/Graphics.d.ts +34 -0
- package/dist/esm/rendering/primitives/Graphics.js +34 -0
- package/dist/esm/rendering/primitives/Graphics.js.map +1 -1
- package/dist/esm/rendering/shader/Shader.d.ts +36 -0
- package/dist/esm/rendering/shader/Shader.js +26 -0
- package/dist/esm/rendering/shader/Shader.js.map +1 -1
- package/dist/esm/rendering/shader/ShaderAttribute.d.ts +13 -0
- package/dist/esm/rendering/shader/ShaderAttribute.js +13 -0
- package/dist/esm/rendering/shader/ShaderAttribute.js.map +1 -1
- package/dist/esm/rendering/shader/ShaderUniform.d.ts +27 -0
- package/dist/esm/rendering/shader/ShaderUniform.js +28 -1
- package/dist/esm/rendering/shader/ShaderUniform.js.map +1 -1
- package/dist/esm/rendering/sprite/AnimatedSprite.d.ts +38 -0
- package/dist/esm/rendering/sprite/AnimatedSprite.js +36 -0
- package/dist/esm/rendering/sprite/AnimatedSprite.js.map +1 -1
- package/dist/esm/rendering/sprite/Sprite.d.ts +56 -0
- package/dist/esm/rendering/sprite/Sprite.js +56 -0
- package/dist/esm/rendering/sprite/Sprite.js.map +1 -1
- package/dist/esm/rendering/sprite/Spritesheet.d.ts +25 -0
- package/dist/esm/rendering/sprite/Spritesheet.js +20 -0
- package/dist/esm/rendering/sprite/Spritesheet.js.map +1 -1
- package/dist/esm/rendering/text/Text.d.ts +2 -0
- package/dist/esm/rendering/text/Text.js +2 -0
- package/dist/esm/rendering/text/Text.js.map +1 -1
- package/dist/esm/rendering/text/TextStyle.d.ts +29 -0
- package/dist/esm/rendering/text/TextStyle.js +24 -0
- package/dist/esm/rendering/text/TextStyle.js.map +1 -1
- package/dist/esm/rendering/text/types.d.ts +1 -0
- package/dist/esm/rendering/texture/RenderTexture.d.ts +16 -0
- package/dist/esm/rendering/texture/RenderTexture.js +16 -0
- package/dist/esm/rendering/texture/RenderTexture.js.map +1 -1
- package/dist/esm/rendering/texture/Sampler.d.ts +23 -0
- package/dist/esm/rendering/texture/Sampler.js +13 -0
- package/dist/esm/rendering/texture/Sampler.js.map +1 -1
- package/dist/esm/rendering/texture/Texture.d.ts +30 -0
- package/dist/esm/rendering/texture/Texture.js +30 -0
- package/dist/esm/rendering/texture/Texture.js.map +1 -1
- package/dist/esm/rendering/types.d.ts +29 -0
- package/dist/esm/rendering/types.js +29 -0
- package/dist/esm/rendering/types.js.map +1 -1
- package/dist/esm/rendering/utils.d.ts +20 -0
- package/dist/esm/rendering/utils.js +10 -0
- package/dist/esm/rendering/utils.js.map +1 -1
- package/dist/esm/rendering/video/Video.d.ts +35 -1
- package/dist/esm/rendering/video/Video.js +36 -2
- package/dist/esm/rendering/video/Video.js.map +1 -1
- package/dist/esm/rendering/webgl2/AbstractWebGl2BatchedRenderer.d.ts +7 -0
- package/dist/esm/rendering/webgl2/AbstractWebGl2BatchedRenderer.js +7 -0
- package/dist/esm/rendering/webgl2/AbstractWebGl2BatchedRenderer.js.map +1 -1
- package/dist/esm/rendering/webgl2/WebGl2Backend.d.ts +13 -0
- package/dist/esm/rendering/webgl2/WebGl2Backend.js +13 -0
- package/dist/esm/rendering/webgl2/WebGl2Backend.js.map +1 -1
- package/dist/esm/rendering/webgl2/WebGl2RenderBuffer.d.ts +8 -0
- package/dist/esm/rendering/webgl2/WebGl2RenderBuffer.js +8 -0
- package/dist/esm/rendering/webgl2/WebGl2RenderBuffer.js.map +1 -1
- package/dist/esm/rendering/webgpu/WebGpuBackend.d.ts +35 -0
- package/dist/esm/rendering/webgpu/WebGpuBackend.js +135 -5
- package/dist/esm/rendering/webgpu/WebGpuBackend.js.map +1 -1
- package/dist/esm/resources/AbstractAssetFactory.d.ts +20 -0
- package/dist/esm/resources/AbstractAssetFactory.js +20 -0
- package/dist/esm/resources/AbstractAssetFactory.js.map +1 -1
- package/dist/esm/resources/AssetFactory.d.ts +26 -0
- package/dist/esm/resources/AssetManifest.d.ts +45 -0
- package/dist/esm/resources/AssetManifest.js +25 -0
- package/dist/esm/resources/AssetManifest.js.map +1 -1
- package/dist/esm/resources/CacheFirstStrategy.d.ts +15 -0
- package/dist/esm/resources/CacheFirstStrategy.js +19 -4
- package/dist/esm/resources/CacheFirstStrategy.js.map +1 -1
- package/dist/esm/resources/CacheStore.d.ts +23 -0
- package/dist/esm/resources/CacheStrategy.d.ts +28 -0
- package/dist/esm/resources/Database.d.ts +45 -0
- package/dist/esm/resources/FactoryRegistry.d.ts +28 -0
- package/dist/esm/resources/FactoryRegistry.js +24 -0
- package/dist/esm/resources/FactoryRegistry.js.map +1 -1
- package/dist/esm/resources/IndexedDbDatabase.d.ts +22 -1
- package/dist/esm/resources/IndexedDbDatabase.js +21 -0
- package/dist/esm/resources/IndexedDbDatabase.js.map +1 -1
- package/dist/esm/resources/IndexedDbStore.d.ts +20 -0
- package/dist/esm/resources/IndexedDbStore.js +12 -0
- package/dist/esm/resources/IndexedDbStore.js.map +1 -1
- package/dist/esm/resources/Loader.d.ts +172 -0
- package/dist/esm/resources/Loader.js +129 -37
- package/dist/esm/resources/Loader.js.map +1 -1
- package/dist/esm/resources/NetworkOnlyStrategy.d.ts +11 -0
- package/dist/esm/resources/NetworkOnlyStrategy.js +16 -3
- package/dist/esm/resources/NetworkOnlyStrategy.js.map +1 -1
- package/dist/esm/resources/factories/BinaryFactory.d.ts +13 -0
- package/dist/esm/resources/factories/BinaryFactory.js +13 -0
- package/dist/esm/resources/factories/BinaryFactory.js.map +1 -1
- package/dist/esm/resources/factories/FontFactory.d.ts +37 -0
- package/dist/esm/resources/factories/FontFactory.js +26 -0
- package/dist/esm/resources/factories/FontFactory.js.map +1 -1
- package/dist/esm/resources/factories/ImageFactory.d.ts +26 -2
- package/dist/esm/resources/factories/ImageFactory.js +19 -0
- package/dist/esm/resources/factories/ImageFactory.js.map +1 -1
- package/dist/esm/resources/factories/JsonFactory.d.ts +13 -0
- package/dist/esm/resources/factories/JsonFactory.js +13 -0
- package/dist/esm/resources/factories/JsonFactory.js.map +1 -1
- package/dist/esm/resources/factories/MusicFactory.d.ts +36 -0
- package/dist/esm/resources/factories/MusicFactory.js +44 -4
- package/dist/esm/resources/factories/MusicFactory.js.map +1 -1
- package/dist/esm/resources/factories/SoundFactory.d.ts +29 -0
- package/dist/esm/resources/factories/SoundFactory.js +18 -0
- package/dist/esm/resources/factories/SoundFactory.js.map +1 -1
- package/dist/esm/resources/factories/SvgFactory.d.ts +19 -0
- package/dist/esm/resources/factories/SvgFactory.js +19 -0
- package/dist/esm/resources/factories/SvgFactory.js.map +1 -1
- package/dist/esm/resources/factories/TextFactory.d.ts +11 -0
- package/dist/esm/resources/factories/TextFactory.js +11 -0
- package/dist/esm/resources/factories/TextFactory.js.map +1 -1
- package/dist/esm/resources/factories/TextureFactory.d.ts +27 -2
- package/dist/esm/resources/factories/TextureFactory.js +20 -0
- package/dist/esm/resources/factories/TextureFactory.js.map +1 -1
- package/dist/esm/resources/factories/VideoFactory.d.ts +37 -0
- package/dist/esm/resources/factories/VideoFactory.js +48 -5
- package/dist/esm/resources/factories/VideoFactory.js.map +1 -1
- package/dist/esm/resources/factories/VttFactory.d.ts +18 -0
- package/dist/esm/resources/factories/VttFactory.js +104 -3
- package/dist/esm/resources/factories/VttFactory.js.map +1 -1
- package/dist/esm/resources/factories/WasmFactory.d.ts +16 -0
- package/dist/esm/resources/factories/WasmFactory.js +16 -0
- package/dist/esm/resources/factories/WasmFactory.js.map +1 -1
- package/dist/esm/resources/utils.d.ts +10 -0
- package/dist/esm/resources/utils.js +10 -0
- package/dist/esm/resources/utils.js.map +1 -1
- package/dist/exo.esm.js +4673 -745
- package/dist/exo.esm.js.map +1 -1
- package/package.json +8 -8
- package/dist/esm/input/GamepadChannels.d.ts +0 -39
- package/dist/esm/input/GamepadChannels.js +0 -45
- package/dist/esm/input/GamepadChannels.js.map +0 -1
- package/dist/esm/input/GamepadControl.d.ts +0 -15
- package/dist/esm/input/GamepadControl.js +0 -29
- package/dist/esm/input/GamepadControl.js.map +0 -1
- package/dist/esm/input/Input.d.ts +0 -28
- package/dist/esm/input/Input.js +0 -68
- package/dist/esm/input/Input.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InputBinding.js","sources":["../../../../src/input/InputBinding.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAgCA;;;;;;;;;;;;;;AAcG;MACU,YAAY,CAAA;AACrB;;;;AAIG;AACI,IAAA,OAAO,uBAAuB,GAAG,GAAG;AAE3B,IAAA,QAAQ;AAER,IAAA,OAAO,GAAK,IAAI,MAAM,EAAY;AAClC,IAAA,QAAQ,GAAI,IAAI,MAAM,EAAY;AAClC,IAAA,MAAM,GAAM,IAAI,MAAM,EAAY;AAClC,IAAA,SAAS,GAAG,IAAI,MAAM,EAAY;AAEjC,IAAA,aAAa;AACb,IAAA,SAAS;IAClB,MAAM,GAAG,CAAC;IACV,QAAQ,GAAG,KAAK;AAExB,IAAA,WAAA,CACI,QAA+B,EAC/B,OAAA,GAA+B,EAAE,EACjC,WAA2C,IAAI,EAAA;AAE/C,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ;AACxB,QAAA,IAAI,CAAC,aAAa,GAAG,IAAI,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,SAAS,IAAI,YAAY,CAAC,uBAAuB,CAAC,CAAC;AACvG,QAAA,IAAI,CAAC,SAAS,GAAG,QAAQ;IAC7B;;AAGA,IAAA,IAAW,KAAK,GAAA;QACZ,OAAO,IAAI,CAAC,MAAM;IACtB;;AAGA,IAAA,IAAW,MAAM,GAAA;AACb,QAAA,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC;IAC1B;AAEA;;;;;AAKG;AACI,IAAA,MAAM,CAAC,QAAsB,EAAA;AAChC,QAAA,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf;QACJ;QAEA,IAAI,KAAK,GAAG,CAAC;AAEb,QAAA,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE;AACjC,YAAA,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC;AAEhC,YAAA,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;gBACpC,KAAK,GAAG,MAAM;YAClB;QACJ;AAEA,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK;AAEnB,QAAA,IAAI,KAAK,KAAK,CAAC,EAAE;AACb,YAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;AAC7B,gBAAA,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;AAC5B,gBAAA,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;YAChC;AAEA,YAAA,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC;QACjC;AAAO,aAAA,IAAI,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;AACnC,YAAA,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;AAEvB,YAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;AAC7B,gBAAA,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC9B;AAEA,YAAA,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE;QAC7B;IACJ;AAEA;;AAEG;IACI,MAAM,GAAA;AACT,QAAA,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf;QACJ;AAEA,QAAA,IAAI,CAAC,QAAQ,GAAG,IAAI;AACpB,QAAA,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC;AAC5B,QAAA,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;AAC5B,QAAA,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;AACtB,QAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;AACvB,QAAA,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;AACrB,QAAA,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE;IAC5B;;;;;"}
|
|
@@ -2,21 +2,54 @@ import { Vector } from '@/math/Vector';
|
|
|
2
2
|
import { Signal } from '@/core/Signal';
|
|
3
3
|
import { Gamepad } from './Gamepad';
|
|
4
4
|
import { Pointer } from './Pointer';
|
|
5
|
+
import { InputBinding } from './InputBinding';
|
|
5
6
|
import type { Application } from '@/core/Application';
|
|
6
|
-
import type {
|
|
7
|
+
import type { GamepadAxis } from './GamepadAxis';
|
|
8
|
+
import type { GamepadButton } from './GamepadButton';
|
|
9
|
+
import type { InputBindingOptions, InputChannel } from './InputBinding';
|
|
10
|
+
/**
|
|
11
|
+
* Strategy used by {@link InputManager} when assigning physical gamepads to
|
|
12
|
+
* slot indices in {@link InputManager.gamepads}.
|
|
13
|
+
*
|
|
14
|
+
* - `'sticky'` (default): each physical pad keeps its slot until a new pad
|
|
15
|
+
* fills an empty slot. A disconnect leaves a gap; reconnect later fills
|
|
16
|
+
* the lowest empty slot. Best for player-stable-binding semantics.
|
|
17
|
+
* - `'compact'`: on disconnect, higher-numbered slots shift down to keep
|
|
18
|
+
* `gamepads[0..N-1]` densely populated. Good for "the first N pads are
|
|
19
|
+
* the N players" workflows.
|
|
20
|
+
*/
|
|
21
|
+
export type GamepadSlotStrategy = 'sticky' | 'compact';
|
|
22
|
+
/**
|
|
23
|
+
* Owns the unified input pipeline for an {@link Application}: keyboard
|
|
24
|
+
* events, pointer (mouse/touch/pen) events with multi-touch slot
|
|
25
|
+
* management, gamepad polling with mapping detection, mouse-wheel events,
|
|
26
|
+
* canvas-focus tracking, and high-level gesture recognition (pinch /
|
|
27
|
+
* rotate / long-press).
|
|
28
|
+
*
|
|
29
|
+
* All raw inputs are written into a shared `Float32Array` channel buffer.
|
|
30
|
+
* Bind input listeners via the {@link onTrigger} / {@link onActive} /
|
|
31
|
+
* {@link onStart} / {@link onStop} factory methods (or via
|
|
32
|
+
* {@link Gamepad.onTrigger}-style methods on individual pads), or
|
|
33
|
+
* subscribe to the signal-style notifications
|
|
34
|
+
* (`onKeyDown`, `onPointerDown`, `onGamepadConnected`, `onAnyGamepadButtonDown`, …).
|
|
35
|
+
*
|
|
36
|
+
* Driven each frame by {@link Application.update}; constructed
|
|
37
|
+
* automatically — you do not instantiate this class yourself.
|
|
38
|
+
*/
|
|
7
39
|
export declare class InputManager {
|
|
8
40
|
private readonly canvas;
|
|
9
41
|
private readonly channels;
|
|
10
|
-
private readonly inputs;
|
|
11
42
|
private readonly pointers;
|
|
12
|
-
private readonly
|
|
13
|
-
private readonly
|
|
14
|
-
private readonly
|
|
43
|
+
private readonly _gamepads;
|
|
44
|
+
private readonly gamepadsByBrowserIndex;
|
|
45
|
+
private readonly bindings;
|
|
46
|
+
private readonly bindingDetacher;
|
|
15
47
|
private readonly wheelOffset;
|
|
16
48
|
private readonly flags;
|
|
17
49
|
private readonly channelsPressed;
|
|
18
50
|
private readonly channelsReleased;
|
|
19
51
|
private readonly gamepadDefinitions;
|
|
52
|
+
private readonly slotStrategy;
|
|
20
53
|
private readonly pointerSlots;
|
|
21
54
|
private readonly freeSlots;
|
|
22
55
|
private readonly gestureRecognizer;
|
|
@@ -46,9 +79,22 @@ export declare class InputManager {
|
|
|
46
79
|
readonly onMouseWheel: Signal<[Vector]>;
|
|
47
80
|
readonly onKeyDown: Signal<[number]>;
|
|
48
81
|
readonly onKeyUp: Signal<[number]>;
|
|
49
|
-
|
|
50
|
-
readonly
|
|
51
|
-
|
|
82
|
+
/** Fires when a physical pad connects to any slot. */
|
|
83
|
+
readonly onGamepadConnected: Signal<[Gamepad]>;
|
|
84
|
+
/** Fires when a physical pad disconnects from any slot. */
|
|
85
|
+
readonly onGamepadDisconnected: Signal<[Gamepad]>;
|
|
86
|
+
/**
|
|
87
|
+
* Fires when a `'compact'`-strategy disconnect shifts a higher-numbered
|
|
88
|
+
* slot's pad into a lower one. Dispatched once per moved pad with the
|
|
89
|
+
* destination slot and the slot index it came from.
|
|
90
|
+
*/
|
|
91
|
+
readonly onAnyGamepadReassigned: Signal<[Gamepad, fromSlot: 0 | 1 | 2 | 3]>;
|
|
92
|
+
/** Fires whenever any pad reports a button press transition. */
|
|
93
|
+
readonly onAnyGamepadButtonDown: Signal<[Gamepad, GamepadButton, number]>;
|
|
94
|
+
/** Fires whenever any pad reports a button release transition. */
|
|
95
|
+
readonly onAnyGamepadButtonUp: Signal<[Gamepad, GamepadButton, number]>;
|
|
96
|
+
/** Fires whenever any pad reports an axis value change. */
|
|
97
|
+
readonly onAnyGamepadAxisChange: Signal<[Gamepad, GamepadAxis, number]>;
|
|
52
98
|
/** Fires on every two-touch-pointer move where the distance between them changed. `scale` > 1 = spreading, < 1 = pinching. */
|
|
53
99
|
readonly onPinch: Signal<[scale: number, center: Vector]>;
|
|
54
100
|
/** Fires on every two-touch-pointer move where the angle between them changed. `angleDelta` is in radians. */
|
|
@@ -67,13 +113,52 @@ export declare class InputManager {
|
|
|
67
113
|
} | null;
|
|
68
114
|
get pointersInCanvas(): boolean;
|
|
69
115
|
get canvasFocused(): boolean;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
116
|
+
/**
|
|
117
|
+
* Always-4 array of {@link Gamepad} slot mailboxes. Each entry exists for
|
|
118
|
+
* the application's full lifetime; check `pad.connected` for hardware
|
|
119
|
+
* presence. Listeners attached to a slot survive disconnect/reconnect.
|
|
120
|
+
*/
|
|
121
|
+
get gamepads(): readonly [Gamepad, Gamepad, Gamepad, Gamepad];
|
|
122
|
+
/** The slot strategy active for this `InputManager`. */
|
|
123
|
+
get gamepadSlotStrategy(): GamepadSlotStrategy;
|
|
124
|
+
/**
|
|
125
|
+
* Direct accessor for a single gamepad slot. Equivalent to
|
|
126
|
+
* `app.input.gamepads[slot]` but reads more clearly at call sites.
|
|
127
|
+
*/
|
|
128
|
+
getGamepad(slot: 0 | 1 | 2 | 3): Gamepad;
|
|
129
|
+
/** Subset of {@link gamepads} containing only currently connected pads, in slot order. */
|
|
130
|
+
get connectedGamepads(): ReadonlyArray<Gamepad>;
|
|
131
|
+
/** Number of slots currently occupied by a physical gamepad. */
|
|
132
|
+
get connectedGamepadCount(): number;
|
|
133
|
+
/** First connected gamepad in slot order, or `null` when no pads are attached. */
|
|
134
|
+
get firstConnectedGamepad(): Gamepad | null;
|
|
135
|
+
/** `true` when at least one slot is occupied by a physical gamepad. */
|
|
136
|
+
get hasGamepad(): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Register a callback fired once when any of `channels` becomes active.
|
|
139
|
+
* Manual lifecycle — call `.unbind()` on the returned binding to detach.
|
|
140
|
+
*/
|
|
141
|
+
onStart(channel: InputChannel | ReadonlyArray<InputChannel>, callback: (value: number) => void, options?: InputBindingOptions): InputBinding;
|
|
142
|
+
/** Register a callback fired every frame while any of `channels` is active. */
|
|
143
|
+
onActive(channel: InputChannel | ReadonlyArray<InputChannel>, callback: (value: number) => void, options?: InputBindingOptions): InputBinding;
|
|
144
|
+
/** Register a callback fired once when all of `channels` become inactive. */
|
|
145
|
+
onStop(channel: InputChannel | ReadonlyArray<InputChannel>, callback: (value: number) => void, options?: InputBindingOptions): InputBinding;
|
|
146
|
+
/**
|
|
147
|
+
* Register a callback fired when the input is released within
|
|
148
|
+
* {@link InputBindingOptions.threshold} ms of activation (a "tap").
|
|
149
|
+
*/
|
|
150
|
+
onTrigger(channel: InputChannel | ReadonlyArray<InputChannel>, callback: (value: number) => void, options?: InputBindingOptions): InputBinding;
|
|
151
|
+
/**
|
|
152
|
+
* Per-frame entry point invoked by {@link Application.update}. Polls
|
|
153
|
+
* the gamepad API, drains queued keyboard/pointer/wheel deltas into
|
|
154
|
+
* the channel buffer, fires the corresponding Signals, then evaluates
|
|
155
|
+
* each registered binding.
|
|
156
|
+
*/
|
|
75
157
|
update(): this;
|
|
76
158
|
destroy(): void;
|
|
159
|
+
private createBinding;
|
|
160
|
+
private resolveExternalChannel;
|
|
161
|
+
private wireGamepadEvents;
|
|
77
162
|
private _assignSlot;
|
|
78
163
|
private _releaseSlot;
|
|
79
164
|
private handleKeyDown;
|
|
@@ -88,18 +173,12 @@ export declare class InputManager {
|
|
|
88
173
|
private handleCanvasFocus;
|
|
89
174
|
private handleCanvasBlur;
|
|
90
175
|
private handleWindowBlur;
|
|
91
|
-
/**
|
|
92
|
-
* Force every currently-held keyboard channel back to zero and emit
|
|
93
|
-
* onKeyUp for each. Called on canvas/window blur so keys held when
|
|
94
|
-
* focus leaves don't stay stuck "down" forever — without this, a user
|
|
95
|
-
* who alt-tabs while pressing W would have W register as held until
|
|
96
|
-
* they manually release while focus is back.
|
|
97
|
-
*/
|
|
98
176
|
private releaseAllKeyboardChannels;
|
|
99
177
|
private addEventListeners;
|
|
100
178
|
private removeEventListeners;
|
|
101
179
|
private updateGamepads;
|
|
102
|
-
private
|
|
180
|
+
private assignSlotForNewPad;
|
|
181
|
+
private handleGamepadDisconnect;
|
|
103
182
|
private updateEvents;
|
|
104
183
|
private updatePointerEvents;
|
|
105
184
|
}
|
|
@@ -7,8 +7,10 @@ import { ChannelSize, maxPointers, ChannelOffset } from './types.js';
|
|
|
7
7
|
import { Gamepad } from './Gamepad.js';
|
|
8
8
|
import { PointerState, Pointer, PointerStateFlag } from './Pointer.js';
|
|
9
9
|
import { GestureRecognizer } from './GestureRecognizer.js';
|
|
10
|
+
import { InputBinding } from './InputBinding.js';
|
|
10
11
|
import { builtInGamepadDefinitions, resolveGamepadDefinition } from './GamepadDefinitions.js';
|
|
11
12
|
|
|
13
|
+
const gamepadSlots = 4;
|
|
12
14
|
var InputManagerFlag;
|
|
13
15
|
(function (InputManagerFlag) {
|
|
14
16
|
InputManagerFlag[InputManagerFlag["None"] = 0] = "None";
|
|
@@ -17,21 +19,39 @@ var InputManagerFlag;
|
|
|
17
19
|
InputManagerFlag[InputManagerFlag["MouseWheel"] = 4] = "MouseWheel";
|
|
18
20
|
InputManagerFlag[InputManagerFlag["PointerUpdate"] = 8] = "PointerUpdate";
|
|
19
21
|
})(InputManagerFlag || (InputManagerFlag = {}));
|
|
22
|
+
/**
|
|
23
|
+
* Owns the unified input pipeline for an {@link Application}: keyboard
|
|
24
|
+
* events, pointer (mouse/touch/pen) events with multi-touch slot
|
|
25
|
+
* management, gamepad polling with mapping detection, mouse-wheel events,
|
|
26
|
+
* canvas-focus tracking, and high-level gesture recognition (pinch /
|
|
27
|
+
* rotate / long-press).
|
|
28
|
+
*
|
|
29
|
+
* All raw inputs are written into a shared `Float32Array` channel buffer.
|
|
30
|
+
* Bind input listeners via the {@link onTrigger} / {@link onActive} /
|
|
31
|
+
* {@link onStart} / {@link onStop} factory methods (or via
|
|
32
|
+
* {@link Gamepad.onTrigger}-style methods on individual pads), or
|
|
33
|
+
* subscribe to the signal-style notifications
|
|
34
|
+
* (`onKeyDown`, `onPointerDown`, `onGamepadConnected`, `onAnyGamepadButtonDown`, …).
|
|
35
|
+
*
|
|
36
|
+
* Driven each frame by {@link Application.update}; constructed
|
|
37
|
+
* automatically — you do not instantiate this class yourself.
|
|
38
|
+
*/
|
|
20
39
|
class InputManager {
|
|
21
40
|
canvas;
|
|
22
41
|
channels = new Float32Array(ChannelSize.Container);
|
|
23
|
-
inputs = new Set();
|
|
24
42
|
pointers = {};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
43
|
+
_gamepads;
|
|
44
|
+
gamepadsByBrowserIndex = new Map();
|
|
45
|
+
bindings = new Set();
|
|
46
|
+
bindingDetacher = { detach: (binding) => { this.bindings.delete(binding); } };
|
|
28
47
|
wheelOffset = new Vector();
|
|
29
48
|
flags = new Flags();
|
|
30
49
|
channelsPressed = [];
|
|
31
50
|
channelsReleased = [];
|
|
32
51
|
gamepadDefinitions;
|
|
52
|
+
slotStrategy;
|
|
33
53
|
// Slot allocation for unified pointer tracking (mouse / touch / pen).
|
|
34
|
-
pointerSlots = new Map();
|
|
54
|
+
pointerSlots = new Map();
|
|
35
55
|
freeSlots = Array.from({ length: maxPointers }, (_, i) => i);
|
|
36
56
|
gestureRecognizer;
|
|
37
57
|
canvasFocusedValue;
|
|
@@ -60,9 +80,22 @@ class InputManager {
|
|
|
60
80
|
onMouseWheel = new Signal();
|
|
61
81
|
onKeyDown = new Signal();
|
|
62
82
|
onKeyUp = new Signal();
|
|
83
|
+
/** Fires when a physical pad connects to any slot. */
|
|
63
84
|
onGamepadConnected = new Signal();
|
|
85
|
+
/** Fires when a physical pad disconnects from any slot. */
|
|
64
86
|
onGamepadDisconnected = new Signal();
|
|
65
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Fires when a `'compact'`-strategy disconnect shifts a higher-numbered
|
|
89
|
+
* slot's pad into a lower one. Dispatched once per moved pad with the
|
|
90
|
+
* destination slot and the slot index it came from.
|
|
91
|
+
*/
|
|
92
|
+
onAnyGamepadReassigned = new Signal();
|
|
93
|
+
/** Fires whenever any pad reports a button press transition. */
|
|
94
|
+
onAnyGamepadButtonDown = new Signal();
|
|
95
|
+
/** Fires whenever any pad reports a button release transition. */
|
|
96
|
+
onAnyGamepadButtonUp = new Signal();
|
|
97
|
+
/** Fires whenever any pad reports an axis value change. */
|
|
98
|
+
onAnyGamepadAxisChange = new Signal();
|
|
66
99
|
/** Fires on every two-touch-pointer move where the distance between them changed. `scale` > 1 = spreading, < 1 = pinching. */
|
|
67
100
|
onPinch = new Signal();
|
|
68
101
|
/** Fires on every two-touch-pointer move where the angle between them changed. `angleDelta` is in radians. */
|
|
@@ -70,16 +103,25 @@ class InputManager {
|
|
|
70
103
|
/** Fires when a pointer has been held without significant movement for ≥ 500 ms. */
|
|
71
104
|
onLongPress = new Signal();
|
|
72
105
|
constructor(app) {
|
|
73
|
-
const { gamepadDefinitions = [], pointerDistanceThreshold } = app.options;
|
|
106
|
+
const { gamepadDefinitions = [], pointerDistanceThreshold, gamepadSlotStrategy = 'sticky', } = app.options;
|
|
74
107
|
this.canvas = app.canvas;
|
|
75
108
|
this.canvasFocusedValue = document.activeElement === this.canvas;
|
|
76
109
|
this.pointerDistanceThreshold = pointerDistanceThreshold;
|
|
77
110
|
this.gamepadDefinitions = [...gamepadDefinitions, ...builtInGamepadDefinitions];
|
|
111
|
+
this.slotStrategy = gamepadSlotStrategy;
|
|
78
112
|
// Disable the browser's default pan/zoom/double-tap-zoom on touch devices so
|
|
79
113
|
// pointer events reach the canvas without being swallowed by the browser's
|
|
80
114
|
// native touch gestures.
|
|
81
115
|
this.canvas.style.touchAction = 'none';
|
|
82
116
|
this.gestureRecognizer = new GestureRecognizer(pointerDistanceThreshold, this.onPinch, this.onRotate, this.onLongPress);
|
|
117
|
+
const slot0 = new Gamepad(0, this.channels);
|
|
118
|
+
const slot1 = new Gamepad(1, this.channels);
|
|
119
|
+
const slot2 = new Gamepad(2, this.channels);
|
|
120
|
+
const slot3 = new Gamepad(3, this.channels);
|
|
121
|
+
this._gamepads = [slot0, slot1, slot2, slot3];
|
|
122
|
+
for (const pad of this._gamepads) {
|
|
123
|
+
this.wireGamepadEvents(pad);
|
|
124
|
+
}
|
|
83
125
|
this.addEventListeners();
|
|
84
126
|
}
|
|
85
127
|
/**
|
|
@@ -93,7 +135,6 @@ class InputManager {
|
|
|
93
135
|
return { x: pointer.x, y: pointer.y };
|
|
94
136
|
}
|
|
95
137
|
}
|
|
96
|
-
// Fall back to first non-cancelled pointer.
|
|
97
138
|
for (const pointer of Object.values(this.pointers)) {
|
|
98
139
|
if (pointer.currentState !== PointerState.Cancelled) {
|
|
99
140
|
return { x: pointer.x, y: pointer.y };
|
|
@@ -108,41 +149,103 @@ class InputManager {
|
|
|
108
149
|
get canvasFocused() {
|
|
109
150
|
return this.canvasFocusedValue;
|
|
110
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Always-4 array of {@link Gamepad} slot mailboxes. Each entry exists for
|
|
154
|
+
* the application's full lifetime; check `pad.connected` for hardware
|
|
155
|
+
* presence. Listeners attached to a slot survive disconnect/reconnect.
|
|
156
|
+
*/
|
|
111
157
|
get gamepads() {
|
|
112
|
-
return this.
|
|
158
|
+
return this._gamepads;
|
|
113
159
|
}
|
|
114
|
-
|
|
115
|
-
|
|
160
|
+
/** The slot strategy active for this `InputManager`. */
|
|
161
|
+
get gamepadSlotStrategy() {
|
|
162
|
+
return this.slotStrategy;
|
|
116
163
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
164
|
+
/**
|
|
165
|
+
* Direct accessor for a single gamepad slot. Equivalent to
|
|
166
|
+
* `app.input.gamepads[slot]` but reads more clearly at call sites.
|
|
167
|
+
*/
|
|
168
|
+
getGamepad(slot) {
|
|
169
|
+
return this._gamepads[slot];
|
|
170
|
+
}
|
|
171
|
+
/** Subset of {@link gamepads} containing only currently connected pads, in slot order. */
|
|
172
|
+
get connectedGamepads() {
|
|
173
|
+
const result = [];
|
|
174
|
+
for (const pad of this._gamepads) {
|
|
175
|
+
if (pad.connected) {
|
|
176
|
+
result.push(pad);
|
|
177
|
+
}
|
|
121
178
|
}
|
|
122
|
-
|
|
123
|
-
return this;
|
|
179
|
+
return result;
|
|
124
180
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
181
|
+
/** Number of slots currently occupied by a physical gamepad. */
|
|
182
|
+
get connectedGamepadCount() {
|
|
183
|
+
let count = 0;
|
|
184
|
+
for (const pad of this._gamepads) {
|
|
185
|
+
if (pad.connected) {
|
|
186
|
+
count++;
|
|
187
|
+
}
|
|
129
188
|
}
|
|
130
|
-
|
|
131
|
-
return this;
|
|
189
|
+
return count;
|
|
132
190
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
191
|
+
/** First connected gamepad in slot order, or `null` when no pads are attached. */
|
|
192
|
+
get firstConnectedGamepad() {
|
|
193
|
+
for (const pad of this._gamepads) {
|
|
194
|
+
if (pad.connected) {
|
|
195
|
+
return pad;
|
|
137
196
|
}
|
|
138
197
|
}
|
|
139
|
-
|
|
140
|
-
return this;
|
|
198
|
+
return null;
|
|
141
199
|
}
|
|
200
|
+
/** `true` when at least one slot is occupied by a physical gamepad. */
|
|
201
|
+
get hasGamepad() {
|
|
202
|
+
for (const pad of this._gamepads) {
|
|
203
|
+
if (pad.connected) {
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Register a callback fired once when any of `channels` becomes active.
|
|
211
|
+
* Manual lifecycle — call `.unbind()` on the returned binding to detach.
|
|
212
|
+
*/
|
|
213
|
+
onStart(channel, callback, options) {
|
|
214
|
+
const binding = this.createBinding(channel, options);
|
|
215
|
+
binding.onStart.add(callback);
|
|
216
|
+
return binding;
|
|
217
|
+
}
|
|
218
|
+
/** Register a callback fired every frame while any of `channels` is active. */
|
|
219
|
+
onActive(channel, callback, options) {
|
|
220
|
+
const binding = this.createBinding(channel, options);
|
|
221
|
+
binding.onActive.add(callback);
|
|
222
|
+
return binding;
|
|
223
|
+
}
|
|
224
|
+
/** Register a callback fired once when all of `channels` become inactive. */
|
|
225
|
+
onStop(channel, callback, options) {
|
|
226
|
+
const binding = this.createBinding(channel, options);
|
|
227
|
+
binding.onStop.add(callback);
|
|
228
|
+
return binding;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Register a callback fired when the input is released within
|
|
232
|
+
* {@link InputBindingOptions.threshold} ms of activation (a "tap").
|
|
233
|
+
*/
|
|
234
|
+
onTrigger(channel, callback, options) {
|
|
235
|
+
const binding = this.createBinding(channel, options);
|
|
236
|
+
binding.onTrigger.add(callback);
|
|
237
|
+
return binding;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Per-frame entry point invoked by {@link Application.update}. Polls
|
|
241
|
+
* the gamepad API, drains queued keyboard/pointer/wheel deltas into
|
|
242
|
+
* the channel buffer, fires the corresponding Signals, then evaluates
|
|
243
|
+
* each registered binding.
|
|
244
|
+
*/
|
|
142
245
|
update() {
|
|
143
246
|
this.updateGamepads();
|
|
144
|
-
for (const
|
|
145
|
-
|
|
247
|
+
for (const binding of this.bindings) {
|
|
248
|
+
binding.update(this.channels);
|
|
146
249
|
}
|
|
147
250
|
if (this.flags.value !== InputManagerFlag.None) {
|
|
148
251
|
this.updateEvents();
|
|
@@ -155,12 +258,14 @@ class InputManager {
|
|
|
155
258
|
for (const pointer of Object.values(this.pointers)) {
|
|
156
259
|
pointer.destroy();
|
|
157
260
|
}
|
|
158
|
-
for (const
|
|
159
|
-
|
|
261
|
+
for (const pad of this._gamepads) {
|
|
262
|
+
pad.destroy();
|
|
263
|
+
}
|
|
264
|
+
for (const binding of Array.from(this.bindings)) {
|
|
265
|
+
binding.unbind();
|
|
160
266
|
}
|
|
161
|
-
this.
|
|
162
|
-
this.
|
|
163
|
-
this.gamepadsValue.length = 0;
|
|
267
|
+
this.bindings.clear();
|
|
268
|
+
this.gamepadsByBrowserIndex.clear();
|
|
164
269
|
this.channelsPressed.length = 0;
|
|
165
270
|
this.channelsReleased.length = 0;
|
|
166
271
|
this.pointerSlots.clear();
|
|
@@ -180,18 +285,40 @@ class InputManager {
|
|
|
180
285
|
this.onKeyUp.destroy();
|
|
181
286
|
this.onGamepadConnected.destroy();
|
|
182
287
|
this.onGamepadDisconnected.destroy();
|
|
183
|
-
this.
|
|
288
|
+
this.onAnyGamepadReassigned.destroy();
|
|
289
|
+
this.onAnyGamepadButtonDown.destroy();
|
|
290
|
+
this.onAnyGamepadButtonUp.destroy();
|
|
291
|
+
this.onAnyGamepadAxisChange.destroy();
|
|
184
292
|
this.onPinch.destroy();
|
|
185
293
|
this.onRotate.destroy();
|
|
186
294
|
this.onLongPress.destroy();
|
|
187
295
|
this.onCanvasFocusChange.destroy();
|
|
188
296
|
}
|
|
297
|
+
createBinding(channel, options = {}) {
|
|
298
|
+
const list = Array.isArray(channel) ? channel : [channel];
|
|
299
|
+
const slot = options.gamepadSlot ?? 0;
|
|
300
|
+
const resolved = list.map((c) => this.resolveExternalChannel(c, slot));
|
|
301
|
+
const binding = new InputBinding(resolved, options, this.bindingDetacher);
|
|
302
|
+
this.bindings.add(binding);
|
|
303
|
+
return binding;
|
|
304
|
+
}
|
|
305
|
+
resolveExternalChannel(channel, slot) {
|
|
306
|
+
if (channel >= ChannelOffset.Gamepads && channel < ChannelOffset.Gamepads + ChannelSize.Category) {
|
|
307
|
+
return ChannelOffset.Gamepads + (slot * ChannelSize.Gamepad) + (channel ^ ChannelOffset.Gamepads);
|
|
308
|
+
}
|
|
309
|
+
return channel;
|
|
310
|
+
}
|
|
311
|
+
wireGamepadEvents(pad) {
|
|
312
|
+
pad.onButtonDown.add((button, value) => { this.onAnyGamepadButtonDown.dispatch(pad, button, value); });
|
|
313
|
+
pad.onButtonUp.add((button, value) => { this.onAnyGamepadButtonUp.dispatch(pad, button, value); });
|
|
314
|
+
pad.onAxisChange.add((axis, value) => { this.onAnyGamepadAxisChange.dispatch(pad, axis, value); });
|
|
315
|
+
}
|
|
189
316
|
_assignSlot(pointerId) {
|
|
190
317
|
if (this.pointerSlots.has(pointerId)) {
|
|
191
318
|
return this.pointerSlots.get(pointerId);
|
|
192
319
|
}
|
|
193
320
|
if (this.freeSlots.length === 0) {
|
|
194
|
-
return null;
|
|
321
|
+
return null;
|
|
195
322
|
}
|
|
196
323
|
const slot = this.freeSlots.shift();
|
|
197
324
|
this.pointerSlots.set(pointerId, slot);
|
|
@@ -201,14 +328,10 @@ class InputManager {
|
|
|
201
328
|
const slot = this.pointerSlots.get(pointerId);
|
|
202
329
|
if (slot !== undefined) {
|
|
203
330
|
this.pointerSlots.delete(pointerId);
|
|
204
|
-
// Push to the front so slot 0 is recovered first, keeping allocation predictable.
|
|
205
331
|
this.freeSlots.unshift(slot);
|
|
206
332
|
}
|
|
207
333
|
}
|
|
208
334
|
handleKeyDown(event) {
|
|
209
|
-
// Game-engine convention: keys only register while the canvas
|
|
210
|
-
// owns focus. Otherwise typing into adjacent <input> fields would
|
|
211
|
-
// also drive game state, which is never what users want.
|
|
212
335
|
if (!this.canvasFocusedValue) {
|
|
213
336
|
return;
|
|
214
337
|
}
|
|
@@ -216,9 +339,6 @@ class InputManager {
|
|
|
216
339
|
this.channels[channel] = 1;
|
|
217
340
|
this.channelsPressed.push(channel);
|
|
218
341
|
this.flags.push(InputManagerFlag.KeyDown);
|
|
219
|
-
// Consume the event: stop default browser actions (page scroll on
|
|
220
|
-
// arrow/space, find-as-you-type on /, etc.) and stop propagation
|
|
221
|
-
// so other listeners on the page don't double-handle.
|
|
222
342
|
stopEvent(event);
|
|
223
343
|
}
|
|
224
344
|
handleKeyUp(event) {
|
|
@@ -234,7 +354,7 @@ class InputManager {
|
|
|
234
354
|
handlePointerOver(event) {
|
|
235
355
|
const slot = this._assignSlot(event.pointerId);
|
|
236
356
|
if (slot === null) {
|
|
237
|
-
return;
|
|
357
|
+
return;
|
|
238
358
|
}
|
|
239
359
|
this.pointers[event.pointerId] = new Pointer(event, this.canvas, this.channels, slot);
|
|
240
360
|
this.flags.push(InputManagerFlag.PointerUpdate);
|
|
@@ -259,10 +379,6 @@ class InputManager {
|
|
|
259
379
|
pointer.handlePress(event);
|
|
260
380
|
this.gestureRecognizer.onPointerDown(pointer);
|
|
261
381
|
this.flags.push(InputManagerFlag.PointerUpdate);
|
|
262
|
-
// preventDefault stops native drag / text-selection;
|
|
263
|
-
// stopImmediatePropagation prevents bubbling to host-page click
|
|
264
|
-
// handlers so an embedded canvas doesn't accidentally trigger UI
|
|
265
|
-
// outside its bounds.
|
|
266
382
|
stopEvent(event);
|
|
267
383
|
}
|
|
268
384
|
handlePointerMove(event) {
|
|
@@ -322,13 +438,6 @@ class InputManager {
|
|
|
322
438
|
this.onCanvasFocusChange.dispatch(false);
|
|
323
439
|
}
|
|
324
440
|
}
|
|
325
|
-
/**
|
|
326
|
-
* Force every currently-held keyboard channel back to zero and emit
|
|
327
|
-
* onKeyUp for each. Called on canvas/window blur so keys held when
|
|
328
|
-
* focus leaves don't stay stuck "down" forever — without this, a user
|
|
329
|
-
* who alt-tabs while pressing W would have W register as held until
|
|
330
|
-
* they manually release while focus is back.
|
|
331
|
-
*/
|
|
332
441
|
releaseAllKeyboardChannels() {
|
|
333
442
|
for (let offset = 0; offset < ChannelSize.Category; offset++) {
|
|
334
443
|
const channel = ChannelOffset.Keyboard + offset;
|
|
@@ -377,49 +486,98 @@ class InputManager {
|
|
|
377
486
|
this.canvas.removeEventListener('selectstart', stopEvent, activeListenerOption);
|
|
378
487
|
}
|
|
379
488
|
updateGamepads() {
|
|
380
|
-
const
|
|
381
|
-
|
|
382
|
-
for (const
|
|
383
|
-
if (!
|
|
489
|
+
const browserGamepads = window.navigator.getGamepads();
|
|
490
|
+
const seenBrowserIndices = new Set();
|
|
491
|
+
for (const browserGamepad of browserGamepads) {
|
|
492
|
+
if (!browserGamepad) {
|
|
384
493
|
continue;
|
|
385
494
|
}
|
|
386
|
-
const
|
|
387
|
-
if (
|
|
495
|
+
const browserIndex = browserGamepad.index;
|
|
496
|
+
if (browserIndex < 0) {
|
|
388
497
|
continue;
|
|
389
498
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
if (
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
this.
|
|
398
|
-
|
|
399
|
-
else {
|
|
400
|
-
gamepad.connect(activeGamepad);
|
|
499
|
+
seenBrowserIndices.add(browserIndex);
|
|
500
|
+
const existing = this.gamepadsByBrowserIndex.get(browserIndex);
|
|
501
|
+
if (existing === undefined) {
|
|
502
|
+
const pad = this.assignSlotForNewPad(browserGamepad);
|
|
503
|
+
if (pad === null) {
|
|
504
|
+
continue;
|
|
505
|
+
}
|
|
506
|
+
this.gamepadsByBrowserIndex.set(browserIndex, pad);
|
|
507
|
+
this.onGamepadConnected.dispatch(pad);
|
|
401
508
|
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
if (this.gamepadSlotsActive[gamepad.index] === 0) {
|
|
408
|
-
gamepad.disconnect();
|
|
409
|
-
this.gamepadsValue.splice(index, 1);
|
|
410
|
-
this.gamepadsByIndex.delete(gamepad.index);
|
|
411
|
-
this.onGamepadDisconnected.dispatch(gamepad, this.gamepadsValue);
|
|
412
|
-
gamepad.destroy();
|
|
509
|
+
}
|
|
510
|
+
for (const [browserIndex, pad] of Array.from(this.gamepadsByBrowserIndex.entries())) {
|
|
511
|
+
if (!seenBrowserIndices.has(browserIndex)) {
|
|
512
|
+
this.gamepadsByBrowserIndex.delete(browserIndex);
|
|
513
|
+
this.handleGamepadDisconnect(pad);
|
|
413
514
|
}
|
|
414
515
|
}
|
|
516
|
+
for (const pad of this._gamepads) {
|
|
517
|
+
pad.update();
|
|
518
|
+
}
|
|
415
519
|
return this;
|
|
416
520
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
521
|
+
assignSlotForNewPad(browserGamepad) {
|
|
522
|
+
const definition = resolveGamepadDefinition(browserGamepad, this.gamepadDefinitions);
|
|
523
|
+
for (const pad of this._gamepads) {
|
|
524
|
+
if (!pad.connected) {
|
|
525
|
+
pad._bind(browserGamepad, definition);
|
|
526
|
+
return pad;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
return null;
|
|
530
|
+
}
|
|
531
|
+
handleGamepadDisconnect(pad) {
|
|
532
|
+
if (this.slotStrategy !== 'compact') {
|
|
533
|
+
// Sticky: pad's slot becomes empty in place; fire onDisconnect
|
|
534
|
+
// on that slot directly.
|
|
535
|
+
pad._unbind();
|
|
536
|
+
this.onGamepadDisconnected.dispatch(pad);
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
// Compact: in semantic terms the user lost a player, and the trailing
|
|
540
|
+
// (highest-numbered) occupied slot is the one that becomes empty.
|
|
541
|
+
// 1. Snapshot the highest occupied slot before any state change.
|
|
542
|
+
// 2. Silently vacate the disconnecting pad (no onDisconnect yet).
|
|
543
|
+
// 3. Shift higher-numbered occupied slots down to fill any gaps,
|
|
544
|
+
// firing onPadReassigned for each slot that received a new pad.
|
|
545
|
+
// 4. Fire onDisconnect on the slot that ended up empty (the one
|
|
546
|
+
// snapshotted in step 1).
|
|
547
|
+
let lastOccupiedSlot = -1;
|
|
548
|
+
for (let i = gamepadSlots - 1; i >= 0; i--) {
|
|
549
|
+
if (this._gamepads[i].connected) {
|
|
550
|
+
lastOccupiedSlot = i;
|
|
551
|
+
break;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
pad._silentUnbind();
|
|
555
|
+
for (let target = 0; target < gamepadSlots; target++) {
|
|
556
|
+
if (this._gamepads[target].connected) {
|
|
557
|
+
continue;
|
|
558
|
+
}
|
|
559
|
+
for (let source = target + 1; source < gamepadSlots; source++) {
|
|
560
|
+
const sourcePad = this._gamepads[source];
|
|
561
|
+
if (!sourcePad.connected) {
|
|
562
|
+
continue;
|
|
563
|
+
}
|
|
564
|
+
const browserIndex = sourcePad.browserGamepad?.index;
|
|
565
|
+
const targetPad = this._gamepads[target];
|
|
566
|
+
const sourceSlot = sourcePad.slot;
|
|
567
|
+
targetPad._rebindFrom(sourcePad);
|
|
568
|
+
if (browserIndex !== undefined) {
|
|
569
|
+
this.gamepadsByBrowserIndex.set(browserIndex, targetPad);
|
|
570
|
+
}
|
|
571
|
+
targetPad.onPadReassigned.dispatch(sourceSlot);
|
|
572
|
+
this.onAnyGamepadReassigned.dispatch(targetPad, sourceSlot);
|
|
573
|
+
break;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
if (lastOccupiedSlot >= 0) {
|
|
577
|
+
const emptiedSlot = this._gamepads[lastOccupiedSlot];
|
|
578
|
+
emptiedSlot._dispatchDisconnect();
|
|
579
|
+
this.onGamepadDisconnected.dispatch(emptiedSlot);
|
|
421
580
|
}
|
|
422
|
-
this.gamepadsValue.splice(insertIndex, 0, gamepad);
|
|
423
581
|
}
|
|
424
582
|
updateEvents() {
|
|
425
583
|
if (this.flags.pop(InputManagerFlag.KeyDown)) {
|