rn-gamekit 0.1.0 → 0.2.1
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 +75 -0
- package/README.md +97 -16
- package/lib/module/assets/defineAssets.js +28 -3
- package/lib/module/assets/defineAssets.js.map +1 -1
- package/lib/module/assets.js +11 -0
- package/lib/module/assets.js.map +1 -0
- package/lib/module/audio/createGameAudio.js +784 -0
- package/lib/module/audio/createGameAudio.js.map +1 -0
- package/lib/module/audio/errors.js +12 -0
- package/lib/module/audio/errors.js.map +1 -0
- package/lib/module/audio/index.js +5 -0
- package/lib/module/audio/index.js.map +1 -0
- package/lib/module/audio/resolver.js +37 -0
- package/lib/module/audio/resolver.js.map +1 -0
- package/lib/module/audio/types.js +4 -0
- package/lib/module/audio/types.js.map +1 -0
- package/lib/module/audio.js +9 -0
- package/lib/module/audio.js.map +1 -0
- package/lib/module/camera2d/bounds.js +59 -0
- package/lib/module/camera2d/bounds.js.map +1 -0
- package/lib/module/camera2d/extents.js +25 -0
- package/lib/module/camera2d/extents.js.map +1 -0
- package/lib/module/camera2d/follow.js +138 -0
- package/lib/module/camera2d/follow.js.map +1 -0
- package/lib/module/camera2d/index.js +20 -0
- package/lib/module/camera2d/index.js.map +1 -0
- package/lib/module/camera2d/interpolation.js +98 -0
- package/lib/module/camera2d/interpolation.js.map +1 -0
- package/lib/module/camera2d/shake.js +85 -0
- package/lib/module/camera2d/shake.js.map +1 -0
- package/lib/module/camera2d/transform.js +151 -0
- package/lib/module/camera2d/transform.js.map +1 -0
- package/lib/module/camera2d/types.js +4 -0
- package/lib/module/camera2d/types.js.map +1 -0
- package/lib/module/camera2d/validation.js +98 -0
- package/lib/module/camera2d/validation.js.map +1 -0
- package/lib/module/camera2d/visibility.js +138 -0
- package/lib/module/camera2d/visibility.js.map +1 -0
- package/lib/module/camera2d.js +9 -0
- package/lib/module/camera2d.js.map +1 -0
- package/lib/module/collision2d/colliders.js +266 -0
- package/lib/module/collision2d/colliders.js.map +1 -0
- package/lib/module/collision2d/debug.js +105 -0
- package/lib/module/collision2d/debug.js.map +1 -0
- package/lib/module/collision2d/filters.js +40 -0
- package/lib/module/collision2d/filters.js.map +1 -0
- package/lib/module/collision2d/index.js +12 -0
- package/lib/module/collision2d/index.js.map +1 -0
- package/lib/module/collision2d/intersections.js +67 -0
- package/lib/module/collision2d/intersections.js.map +1 -0
- package/lib/module/collision2d/manifolds.js +218 -0
- package/lib/module/collision2d/manifolds.js.map +1 -0
- package/lib/module/collision2d/segments.js +187 -0
- package/lib/module/collision2d/segments.js.map +1 -0
- package/lib/module/collision2d/spatialHash.js +167 -0
- package/lib/module/collision2d/spatialHash.js.map +1 -0
- package/lib/module/collision2d/sweeps.js +255 -0
- package/lib/module/collision2d/sweeps.js.map +1 -0
- package/lib/module/collision2d.js +9 -0
- package/lib/module/collision2d.js.map +1 -0
- package/lib/module/core/input/buttonPad.js +214 -0
- package/lib/module/core/input/buttonPad.js.map +1 -0
- package/lib/module/core/input/createInputBuffer.js +66 -14
- package/lib/module/core/input/createInputBuffer.js.map +1 -1
- package/lib/module/core/session/createGameSession.js +454 -50
- package/lib/module/core/session/createGameSession.js.map +1 -1
- package/lib/module/core/session/deepFreeze.js +92 -2
- package/lib/module/core/session/deepFreeze.js.map +1 -1
- package/lib/module/core/session/types.js +12 -0
- package/lib/module/core/session/types.js.map +1 -1
- package/lib/module/definition/defineGame.js +23 -0
- package/lib/module/definition/defineGame.js.map +1 -1
- package/lib/module/events/defineGameEvents.js +46 -0
- package/lib/module/events/defineGameEvents.js.map +1 -0
- package/lib/module/events/errors.js +16 -0
- package/lib/module/events/errors.js.map +1 -0
- package/lib/module/events/index.js +7 -0
- package/lib/module/events/index.js.map +1 -0
- package/lib/module/events/payload.js +219 -0
- package/lib/module/events/payload.js.map +1 -0
- package/lib/module/events/seed.js +33 -0
- package/lib/module/events/seed.js.map +1 -0
- package/lib/module/events/types.js +4 -0
- package/lib/module/events/types.js.map +1 -0
- package/lib/module/events.js +13 -0
- package/lib/module/events.js.map +1 -0
- package/lib/module/geometry/helpers.js +140 -0
- package/lib/module/geometry/helpers.js.map +1 -0
- package/lib/module/geometry/index.js +5 -0
- package/lib/module/geometry/index.js.map +1 -0
- package/lib/module/geometry/validation.js +104 -0
- package/lib/module/geometry/validation.js.map +1 -0
- package/lib/module/geometry.js +9 -0
- package/lib/module/geometry.js.map +1 -0
- package/lib/module/haptics/createGameHaptics.js +214 -0
- package/lib/module/haptics/createGameHaptics.js.map +1 -0
- package/lib/module/haptics/errors.js +12 -0
- package/lib/module/haptics/errors.js.map +1 -0
- package/lib/module/haptics/index.js +5 -0
- package/lib/module/haptics/index.js.map +1 -0
- package/lib/module/haptics/resolver.js +37 -0
- package/lib/module/haptics/resolver.js.map +1 -0
- package/lib/module/haptics/types.js +4 -0
- package/lib/module/haptics/types.js.map +1 -0
- package/lib/module/haptics.js +9 -0
- package/lib/module/haptics.js.map +1 -0
- package/lib/module/index.js +8 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/particles/createParticleSystem.js +481 -0
- package/lib/module/particles/createParticleSystem.js.map +1 -0
- package/lib/module/particles/defineParticleEffect.js +178 -0
- package/lib/module/particles/defineParticleEffect.js.map +1 -0
- package/lib/module/particles/errors.js +9 -0
- package/lib/module/particles/errors.js.map +1 -0
- package/lib/module/particles/index.js +8 -0
- package/lib/module/particles/index.js.map +1 -0
- package/lib/module/particles/sampling.js +121 -0
- package/lib/module/particles/sampling.js.map +1 -0
- package/lib/module/particles/types.js +4 -0
- package/lib/module/particles/types.js.map +1 -0
- package/lib/module/particles.js +4 -0
- package/lib/module/particles.js.map +1 -0
- package/lib/module/react/GameButtonPad.js +344 -0
- package/lib/module/react/GameButtonPad.js.map +1 -0
- package/lib/module/react/GamePointerInput.js +74 -16
- package/lib/module/react/GamePointerInput.js.map +1 -1
- package/lib/module/react/GameView.js +139 -60
- package/lib/module/react/GameView.js.map +1 -1
- package/lib/module/react/assets/createGameAssetStore.js +145 -95
- package/lib/module/react/assets/createGameAssetStore.js.map +1 -1
- package/lib/module/react/assets/useGameAssets.js +60 -35
- package/lib/module/react/assets/useGameAssets.js.map +1 -1
- package/lib/module/react/bindAppLifecycle.js +46 -17
- package/lib/module/react/bindAppLifecycle.js.map +1 -1
- package/lib/module/react/bindGameSession.js +13 -2
- package/lib/module/react/bindGameSession.js.map +1 -1
- package/lib/module/react/camera2d/GameLayer2D.js +50 -0
- package/lib/module/react/camera2d/GameLayer2D.js.map +1 -0
- package/lib/module/react/camera2d/defineGameCamera2D.js +30 -0
- package/lib/module/react/camera2d/defineGameCamera2D.js.map +1 -0
- package/lib/module/react/camera2d/usePresentedCameraBinding.js +177 -0
- package/lib/module/react/camera2d/usePresentedCameraBinding.js.map +1 -0
- package/lib/module/react/cleanupList.js +38 -0
- package/lib/module/react/cleanupList.js.map +1 -0
- package/lib/module/react/lifecycleSource.js +49 -0
- package/lib/module/react/lifecycleSource.js.map +1 -0
- package/lib/module/react/particles/ParticleView.js +308 -0
- package/lib/module/react/particles/ParticleView.js.map +1 -0
- package/lib/module/react/particles/culling.js +115 -0
- package/lib/module/react/particles/culling.js.map +1 -0
- package/lib/module/react/particles/index.js +7 -0
- package/lib/module/react/particles/index.js.map +1 -0
- package/lib/module/react/particles/spriteXForm.js +45 -0
- package/lib/module/react/particles/spriteXForm.js.map +1 -0
- package/lib/module/react/particles/useParticlePresentation.js +204 -0
- package/lib/module/react/particles/useParticlePresentation.js.map +1 -0
- package/lib/module/react/pointerBinding.js +55 -17
- package/lib/module/react/pointerBinding.js.map +1 -1
- package/lib/module/react/pointerCamera.js +28 -0
- package/lib/module/react/pointerCamera.js.map +1 -0
- package/lib/module/react/pointerCoalescer.js +16 -9
- package/lib/module/react/pointerCoalescer.js.map +1 -1
- package/lib/module/react/sprites/GameSprite.js +5 -17
- package/lib/module/react/sprites/GameSprite.js.map +1 -1
- package/lib/module/react/sprites/GameWorld2D.js +112 -9
- package/lib/module/react/sprites/GameWorld2D.js.map +1 -1
- package/lib/module/react/sprites/Sprite.js +48 -63
- package/lib/module/react/sprites/Sprite.js.map +1 -1
- package/lib/module/react/sprites/SpriteBatch.js +53 -28
- package/lib/module/react/sprites/SpriteBatch.js.map +1 -1
- package/lib/module/react/sprites/batchVisibility.js +58 -0
- package/lib/module/react/sprites/batchVisibility.js.map +1 -0
- package/lib/module/react/sprites/spriteSelection.js +103 -0
- package/lib/module/react/sprites/spriteSelection.js.map +1 -0
- package/lib/module/react/sprites/spriteTransform.js +46 -25
- package/lib/module/react/sprites/spriteTransform.js.map +1 -1
- package/lib/module/react/tilemap/TileMapLayer2D.js +217 -0
- package/lib/module/react/tilemap/TileMapLayer2D.js.map +1 -0
- package/lib/module/react/tilemap/tilePresentation.js +374 -0
- package/lib/module/react/tilemap/tilePresentation.js.map +1 -0
- package/lib/module/react/useGameSession.js +70 -0
- package/lib/module/react/useGameSession.js.map +1 -0
- package/lib/module/react/useGameSessionStatus.js +46 -0
- package/lib/module/react/useGameSessionStatus.js.map +1 -0
- package/lib/module/react/viewportBinding.js +5 -1
- package/lib/module/react/viewportBinding.js.map +1 -1
- package/lib/module/react.js +12 -1
- package/lib/module/react.js.map +1 -1
- package/lib/module/scene/defineScene.js +17 -0
- package/lib/module/scene/defineScene.js.map +1 -1
- package/lib/module/sprites/sampleSpriteClip.js +66 -6
- package/lib/module/sprites/sampleSpriteClip.js.map +1 -1
- package/lib/module/sprites/spriteAnimationState.js +10 -20
- package/lib/module/sprites/spriteAnimationState.js.map +1 -1
- package/lib/module/sprites.js +11 -0
- package/lib/module/sprites.js.map +1 -0
- package/lib/module/storage/adapters/asyncStorage.js +57 -0
- package/lib/module/storage/adapters/asyncStorage.js.map +1 -0
- package/lib/module/storage/adapters/memory.js +50 -0
- package/lib/module/storage/adapters/memory.js.map +1 -0
- package/lib/module/storage/errors.js +34 -0
- package/lib/module/storage/errors.js.map +1 -0
- package/lib/module/storage/index.js +11 -0
- package/lib/module/storage/index.js.map +1 -0
- package/lib/module/storage/schema.js +151 -0
- package/lib/module/storage/schema.js.map +1 -0
- package/lib/module/storage/serialization.js +249 -0
- package/lib/module/storage/serialization.js.map +1 -0
- package/lib/module/storage/store.js +387 -0
- package/lib/module/storage/store.js.map +1 -0
- package/lib/module/storage/types.js +16 -0
- package/lib/module/storage/types.js.map +1 -0
- package/lib/module/storage/validation.js +111 -0
- package/lib/module/storage/validation.js.map +1 -0
- package/lib/module/storage.js +4 -0
- package/lib/module/storage.js.map +1 -0
- package/lib/module/testing.js +4 -0
- package/lib/module/testing.js.map +1 -1
- package/lib/module/tilemap/chunkStats.js +27 -0
- package/lib/module/tilemap/chunkStats.js.map +1 -0
- package/lib/module/tilemap/definitions.js +308 -0
- package/lib/module/tilemap/definitions.js.map +1 -0
- package/lib/module/tilemap/errors.js +13 -0
- package/lib/module/tilemap/errors.js.map +1 -0
- package/lib/module/tilemap/index.js +10 -0
- package/lib/module/tilemap/index.js.map +1 -0
- package/lib/module/tilemap/movement.js +379 -0
- package/lib/module/tilemap/movement.js.map +1 -0
- package/lib/module/tilemap/queries.js +114 -0
- package/lib/module/tilemap/queries.js.map +1 -0
- package/lib/module/tilemap/tiledAdapter.js +141 -0
- package/lib/module/tilemap/tiledAdapter.js.map +1 -0
- package/lib/module/tilemap/types.js +4 -0
- package/lib/module/tilemap/types.js.map +1 -0
- package/lib/module/tilemap.js +4 -0
- package/lib/module/tilemap.js.map +1 -0
- package/lib/typescript/src/assets/defineAssets.d.ts +1 -1
- package/lib/typescript/src/assets/defineAssets.d.ts.map +1 -1
- package/lib/typescript/src/assets.d.ts +11 -0
- package/lib/typescript/src/assets.d.ts.map +1 -0
- package/lib/typescript/src/audio/createGameAudio.d.ts +5 -0
- package/lib/typescript/src/audio/createGameAudio.d.ts.map +1 -0
- package/lib/typescript/src/audio/errors.d.ts +6 -0
- package/lib/typescript/src/audio/errors.d.ts.map +1 -0
- package/lib/typescript/src/audio/index.d.ts +4 -0
- package/lib/typescript/src/audio/index.d.ts.map +1 -0
- package/lib/typescript/src/audio/resolver.d.ts +44 -0
- package/lib/typescript/src/audio/resolver.d.ts.map +1 -0
- package/lib/typescript/src/audio/types.d.ts +42 -0
- package/lib/typescript/src/audio/types.d.ts.map +1 -0
- package/lib/typescript/src/audio.d.ts +8 -0
- package/lib/typescript/src/audio.d.ts.map +1 -0
- package/lib/typescript/src/camera2d/bounds.d.ts +25 -0
- package/lib/typescript/src/camera2d/bounds.d.ts.map +1 -0
- package/lib/typescript/src/camera2d/extents.d.ts +17 -0
- package/lib/typescript/src/camera2d/extents.d.ts.map +1 -0
- package/lib/typescript/src/camera2d/follow.d.ts +24 -0
- package/lib/typescript/src/camera2d/follow.d.ts.map +1 -0
- package/lib/typescript/src/camera2d/index.d.ts +19 -0
- package/lib/typescript/src/camera2d/index.d.ts.map +1 -0
- package/lib/typescript/src/camera2d/interpolation.d.ts +17 -0
- package/lib/typescript/src/camera2d/interpolation.d.ts.map +1 -0
- package/lib/typescript/src/camera2d/shake.d.ts +20 -0
- package/lib/typescript/src/camera2d/shake.d.ts.map +1 -0
- package/lib/typescript/src/camera2d/transform.d.ts +44 -0
- package/lib/typescript/src/camera2d/transform.d.ts.map +1 -0
- package/lib/typescript/src/camera2d/types.d.ts +74 -0
- package/lib/typescript/src/camera2d/types.d.ts.map +1 -0
- package/lib/typescript/src/camera2d/validation.d.ts +30 -0
- package/lib/typescript/src/camera2d/validation.d.ts.map +1 -0
- package/lib/typescript/src/camera2d/visibility.d.ts +47 -0
- package/lib/typescript/src/camera2d/visibility.d.ts.map +1 -0
- package/lib/typescript/src/camera2d.d.ts +7 -0
- package/lib/typescript/src/camera2d.d.ts.map +1 -0
- package/lib/typescript/src/collision2d/colliders.d.ts +120 -0
- package/lib/typescript/src/collision2d/colliders.d.ts.map +1 -0
- package/lib/typescript/src/collision2d/debug.d.ts +67 -0
- package/lib/typescript/src/collision2d/debug.d.ts.map +1 -0
- package/lib/typescript/src/collision2d/filters.d.ts +28 -0
- package/lib/typescript/src/collision2d/filters.d.ts.map +1 -0
- package/lib/typescript/src/collision2d/index.d.ts +17 -0
- package/lib/typescript/src/collision2d/index.d.ts.map +1 -0
- package/lib/typescript/src/collision2d/intersections.d.ts +24 -0
- package/lib/typescript/src/collision2d/intersections.d.ts.map +1 -0
- package/lib/typescript/src/collision2d/manifolds.d.ts +39 -0
- package/lib/typescript/src/collision2d/manifolds.d.ts.map +1 -0
- package/lib/typescript/src/collision2d/segments.d.ts +24 -0
- package/lib/typescript/src/collision2d/segments.d.ts.map +1 -0
- package/lib/typescript/src/collision2d/spatialHash.d.ts +50 -0
- package/lib/typescript/src/collision2d/spatialHash.d.ts.map +1 -0
- package/lib/typescript/src/collision2d/sweeps.d.ts +60 -0
- package/lib/typescript/src/collision2d/sweeps.d.ts.map +1 -0
- package/lib/typescript/src/collision2d.d.ts +7 -0
- package/lib/typescript/src/collision2d.d.ts.map +1 -0
- package/lib/typescript/src/core/input/buttonPad.d.ts +59 -0
- package/lib/typescript/src/core/input/buttonPad.d.ts.map +1 -0
- package/lib/typescript/src/core/input/createInputBuffer.d.ts +1 -1
- package/lib/typescript/src/core/input/createInputBuffer.d.ts.map +1 -1
- package/lib/typescript/src/core/input/types.d.ts +7 -0
- package/lib/typescript/src/core/input/types.d.ts.map +1 -1
- package/lib/typescript/src/core/session/createGameSession.d.ts +4 -2
- package/lib/typescript/src/core/session/createGameSession.d.ts.map +1 -1
- package/lib/typescript/src/core/session/deepFreeze.d.ts +21 -1
- package/lib/typescript/src/core/session/deepFreeze.d.ts.map +1 -1
- package/lib/typescript/src/core/session/diagnostics.d.ts +2 -0
- package/lib/typescript/src/core/session/diagnostics.d.ts.map +1 -1
- package/lib/typescript/src/core/session/types.d.ts +69 -4
- package/lib/typescript/src/core/session/types.d.ts.map +1 -1
- package/lib/typescript/src/definition/defineGame.d.ts +12 -1
- package/lib/typescript/src/definition/defineGame.d.ts.map +1 -1
- package/lib/typescript/src/definition/types.d.ts +10 -1
- package/lib/typescript/src/definition/types.d.ts.map +1 -1
- package/lib/typescript/src/events/defineGameEvents.d.ts +26 -0
- package/lib/typescript/src/events/defineGameEvents.d.ts.map +1 -0
- package/lib/typescript/src/events/errors.d.ts +12 -0
- package/lib/typescript/src/events/errors.d.ts.map +1 -0
- package/lib/typescript/src/events/index.d.ts +6 -0
- package/lib/typescript/src/events/index.d.ts.map +1 -0
- package/lib/typescript/src/events/payload.d.ts +21 -0
- package/lib/typescript/src/events/payload.d.ts.map +1 -0
- package/lib/typescript/src/events/seed.d.ts +3 -0
- package/lib/typescript/src/events/seed.d.ts.map +1 -0
- package/lib/typescript/src/events/types.d.ts +42 -0
- package/lib/typescript/src/events/types.d.ts.map +1 -0
- package/lib/typescript/src/events.d.ts +12 -0
- package/lib/typescript/src/events.d.ts.map +1 -0
- package/lib/typescript/src/geometry/helpers.d.ts +35 -0
- package/lib/typescript/src/geometry/helpers.d.ts.map +1 -0
- package/lib/typescript/src/geometry/index.d.ts +4 -0
- package/lib/typescript/src/geometry/index.d.ts.map +1 -0
- package/lib/typescript/src/geometry/types.d.ts +49 -0
- package/lib/typescript/src/geometry/types.d.ts.map +1 -1
- package/lib/typescript/src/geometry/validation.d.ts +44 -0
- package/lib/typescript/src/geometry/validation.d.ts.map +1 -0
- package/lib/typescript/src/geometry.d.ts +7 -0
- package/lib/typescript/src/geometry.d.ts.map +1 -0
- package/lib/typescript/src/haptics/createGameHaptics.d.ts +3 -0
- package/lib/typescript/src/haptics/createGameHaptics.d.ts.map +1 -0
- package/lib/typescript/src/haptics/errors.d.ts +6 -0
- package/lib/typescript/src/haptics/errors.d.ts.map +1 -0
- package/lib/typescript/src/haptics/index.d.ts +4 -0
- package/lib/typescript/src/haptics/index.d.ts.map +1 -0
- package/lib/typescript/src/haptics/resolver.d.ts +22 -0
- package/lib/typescript/src/haptics/resolver.d.ts.map +1 -0
- package/lib/typescript/src/haptics/types.d.ts +37 -0
- package/lib/typescript/src/haptics/types.d.ts.map +1 -0
- package/lib/typescript/src/haptics.d.ts +8 -0
- package/lib/typescript/src/haptics.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +10 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/particles/createParticleSystem.d.ts +5 -0
- package/lib/typescript/src/particles/createParticleSystem.d.ts.map +1 -0
- package/lib/typescript/src/particles/defineParticleEffect.d.ts +3 -0
- package/lib/typescript/src/particles/defineParticleEffect.d.ts.map +1 -0
- package/lib/typescript/src/particles/errors.d.ts +5 -0
- package/lib/typescript/src/particles/errors.d.ts.map +1 -0
- package/lib/typescript/src/particles/index.d.ts +6 -0
- package/lib/typescript/src/particles/index.d.ts.map +1 -0
- package/lib/typescript/src/particles/sampling.d.ts +54 -0
- package/lib/typescript/src/particles/sampling.d.ts.map +1 -0
- package/lib/typescript/src/particles/types.d.ts +292 -0
- package/lib/typescript/src/particles/types.d.ts.map +1 -0
- package/lib/typescript/src/particles.d.ts +2 -0
- package/lib/typescript/src/particles.d.ts.map +1 -0
- package/lib/typescript/src/react/GameButtonPad.d.ts +84 -0
- package/lib/typescript/src/react/GameButtonPad.d.ts.map +1 -0
- package/lib/typescript/src/react/GamePointerInput.d.ts.map +1 -1
- package/lib/typescript/src/react/GameView.d.ts +27 -1
- package/lib/typescript/src/react/GameView.d.ts.map +1 -1
- package/lib/typescript/src/react/assets/createGameAssetStore.d.ts.map +1 -1
- package/lib/typescript/src/react/assets/useGameAssets.d.ts.map +1 -1
- package/lib/typescript/src/react/bindAppLifecycle.d.ts +7 -1
- package/lib/typescript/src/react/bindAppLifecycle.d.ts.map +1 -1
- package/lib/typescript/src/react/bindGameSession.d.ts.map +1 -1
- package/lib/typescript/src/react/camera2d/GameLayer2D.d.ts +24 -0
- package/lib/typescript/src/react/camera2d/GameLayer2D.d.ts.map +1 -0
- package/lib/typescript/src/react/camera2d/defineGameCamera2D.d.ts +44 -0
- package/lib/typescript/src/react/camera2d/defineGameCamera2D.d.ts.map +1 -0
- package/lib/typescript/src/react/camera2d/usePresentedCameraBinding.d.ts +22 -0
- package/lib/typescript/src/react/camera2d/usePresentedCameraBinding.d.ts.map +1 -0
- package/lib/typescript/src/react/cleanupList.d.ts +21 -0
- package/lib/typescript/src/react/cleanupList.d.ts.map +1 -0
- package/lib/typescript/src/react/instrumentation.d.ts +33 -3
- package/lib/typescript/src/react/instrumentation.d.ts.map +1 -1
- package/lib/typescript/src/react/lifecycleSource.d.ts +21 -0
- package/lib/typescript/src/react/lifecycleSource.d.ts.map +1 -0
- package/lib/typescript/src/react/particles/ParticleView.d.ts +65 -0
- package/lib/typescript/src/react/particles/ParticleView.d.ts.map +1 -0
- package/lib/typescript/src/react/particles/culling.d.ts +70 -0
- package/lib/typescript/src/react/particles/culling.d.ts.map +1 -0
- package/lib/typescript/src/react/particles/index.d.ts +7 -0
- package/lib/typescript/src/react/particles/index.d.ts.map +1 -0
- package/lib/typescript/src/react/particles/spriteXForm.d.ts +28 -0
- package/lib/typescript/src/react/particles/spriteXForm.d.ts.map +1 -0
- package/lib/typescript/src/react/particles/useParticlePresentation.d.ts +48 -0
- package/lib/typescript/src/react/particles/useParticlePresentation.d.ts.map +1 -0
- package/lib/typescript/src/react/pointerBinding.d.ts +38 -8
- package/lib/typescript/src/react/pointerBinding.d.ts.map +1 -1
- package/lib/typescript/src/react/pointerCamera.d.ts +20 -0
- package/lib/typescript/src/react/pointerCamera.d.ts.map +1 -0
- package/lib/typescript/src/react/pointerCoalescer.d.ts +17 -1
- package/lib/typescript/src/react/pointerCoalescer.d.ts.map +1 -1
- package/lib/typescript/src/react/sprites/GameSprite.d.ts +3 -10
- package/lib/typescript/src/react/sprites/GameSprite.d.ts.map +1 -1
- package/lib/typescript/src/react/sprites/GameWorld2D.d.ts +51 -6
- package/lib/typescript/src/react/sprites/GameWorld2D.d.ts.map +1 -1
- package/lib/typescript/src/react/sprites/Sprite.d.ts.map +1 -1
- package/lib/typescript/src/react/sprites/SpriteBatch.d.ts +22 -1
- package/lib/typescript/src/react/sprites/SpriteBatch.d.ts.map +1 -1
- package/lib/typescript/src/react/sprites/batchVisibility.d.ts +28 -0
- package/lib/typescript/src/react/sprites/batchVisibility.d.ts.map +1 -0
- package/lib/typescript/src/react/sprites/spriteSelection.d.ts +58 -0
- package/lib/typescript/src/react/sprites/spriteSelection.d.ts.map +1 -0
- package/lib/typescript/src/react/sprites/spriteTransform.d.ts +27 -12
- package/lib/typescript/src/react/sprites/spriteTransform.d.ts.map +1 -1
- package/lib/typescript/src/react/tilemap/TileMapLayer2D.d.ts +69 -0
- package/lib/typescript/src/react/tilemap/TileMapLayer2D.d.ts.map +1 -0
- package/lib/typescript/src/react/tilemap/tilePresentation.d.ts +217 -0
- package/lib/typescript/src/react/tilemap/tilePresentation.d.ts.map +1 -0
- package/lib/typescript/src/react/useGameSession.d.ts +48 -0
- package/lib/typescript/src/react/useGameSession.d.ts.map +1 -0
- package/lib/typescript/src/react/useGameSessionStatus.d.ts +23 -0
- package/lib/typescript/src/react/useGameSessionStatus.d.ts.map +1 -0
- package/lib/typescript/src/react/viewportBinding.d.ts +5 -1
- package/lib/typescript/src/react/viewportBinding.d.ts.map +1 -1
- package/lib/typescript/src/react.d.ts +18 -1
- package/lib/typescript/src/react.d.ts.map +1 -1
- package/lib/typescript/src/scene/defineScene.d.ts +22 -2
- package/lib/typescript/src/scene/defineScene.d.ts.map +1 -1
- package/lib/typescript/src/scene/types.d.ts +24 -4
- package/lib/typescript/src/scene/types.d.ts.map +1 -1
- package/lib/typescript/src/sprites/sampleSpriteClip.d.ts +26 -2
- package/lib/typescript/src/sprites/sampleSpriteClip.d.ts.map +1 -1
- package/lib/typescript/src/sprites/spriteAnimationState.d.ts +6 -7
- package/lib/typescript/src/sprites/spriteAnimationState.d.ts.map +1 -1
- package/lib/typescript/src/sprites.d.ts +10 -0
- package/lib/typescript/src/sprites.d.ts.map +1 -0
- package/lib/typescript/src/storage/adapters/asyncStorage.d.ts +18 -0
- package/lib/typescript/src/storage/adapters/asyncStorage.d.ts.map +1 -0
- package/lib/typescript/src/storage/adapters/memory.d.ts +16 -0
- package/lib/typescript/src/storage/adapters/memory.d.ts.map +1 -0
- package/lib/typescript/src/storage/errors.d.ts +37 -0
- package/lib/typescript/src/storage/errors.d.ts.map +1 -0
- package/lib/typescript/src/storage/index.d.ts +11 -0
- package/lib/typescript/src/storage/index.d.ts.map +1 -0
- package/lib/typescript/src/storage/schema.d.ts +22 -0
- package/lib/typescript/src/storage/schema.d.ts.map +1 -0
- package/lib/typescript/src/storage/serialization.d.ts +23 -0
- package/lib/typescript/src/storage/serialization.d.ts.map +1 -0
- package/lib/typescript/src/storage/store.d.ts +3 -0
- package/lib/typescript/src/storage/store.d.ts.map +1 -0
- package/lib/typescript/src/storage/types.d.ts +69 -0
- package/lib/typescript/src/storage/types.d.ts.map +1 -0
- package/lib/typescript/src/storage/validation.d.ts +24 -0
- package/lib/typescript/src/storage/validation.d.ts.map +1 -0
- package/lib/typescript/src/storage.d.ts +2 -0
- package/lib/typescript/src/storage.d.ts.map +1 -0
- package/lib/typescript/src/testing.d.ts +1 -0
- package/lib/typescript/src/testing.d.ts.map +1 -1
- package/lib/typescript/src/tilemap/chunkStats.d.ts +14 -0
- package/lib/typescript/src/tilemap/chunkStats.d.ts.map +1 -0
- package/lib/typescript/src/tilemap/definitions.d.ts +38 -0
- package/lib/typescript/src/tilemap/definitions.d.ts.map +1 -0
- package/lib/typescript/src/tilemap/errors.d.ts +7 -0
- package/lib/typescript/src/tilemap/errors.d.ts.map +1 -0
- package/lib/typescript/src/tilemap/index.d.ts +8 -0
- package/lib/typescript/src/tilemap/index.d.ts.map +1 -0
- package/lib/typescript/src/tilemap/movement.d.ts +52 -0
- package/lib/typescript/src/tilemap/movement.d.ts.map +1 -0
- package/lib/typescript/src/tilemap/queries.d.ts +21 -0
- package/lib/typescript/src/tilemap/queries.d.ts.map +1 -0
- package/lib/typescript/src/tilemap/tiledAdapter.d.ts +32 -0
- package/lib/typescript/src/tilemap/tiledAdapter.d.ts.map +1 -0
- package/lib/typescript/src/tilemap/types.d.ts +127 -0
- package/lib/typescript/src/tilemap/types.d.ts.map +1 -0
- package/lib/typescript/src/tilemap.d.ts +2 -0
- package/lib/typescript/src/tilemap.d.ts.map +1 -0
- package/package.json +100 -10
- package/src/assets/defineAssets.ts +31 -5
- package/src/assets.ts +27 -0
- package/src/audio/createGameAudio.ts +749 -0
- package/src/audio/errors.ts +12 -0
- package/src/audio/index.ts +9 -0
- package/src/audio/resolver.ts +74 -0
- package/src/audio/types.ts +47 -0
- package/src/audio.ts +13 -0
- package/src/camera2d/bounds.ts +69 -0
- package/src/camera2d/extents.ts +25 -0
- package/src/camera2d/follow.ts +165 -0
- package/src/camera2d/index.ts +29 -0
- package/src/camera2d/interpolation.ts +113 -0
- package/src/camera2d/shake.ts +90 -0
- package/src/camera2d/transform.ts +148 -0
- package/src/camera2d/types.ts +73 -0
- package/src/camera2d/validation.ts +126 -0
- package/src/camera2d/visibility.ts +181 -0
- package/src/camera2d.ts +6 -0
- package/src/collision2d/colliders.ts +292 -0
- package/src/collision2d/debug.ts +133 -0
- package/src/collision2d/filters.ts +48 -0
- package/src/collision2d/index.ts +74 -0
- package/src/collision2d/intersections.ts +82 -0
- package/src/collision2d/manifolds.ts +191 -0
- package/src/collision2d/segments.ts +176 -0
- package/src/collision2d/spatialHash.ts +211 -0
- package/src/collision2d/sweeps.ts +269 -0
- package/src/collision2d.ts +6 -0
- package/src/core/input/buttonPad.ts +235 -0
- package/src/core/input/createInputBuffer.ts +95 -14
- package/src/core/input/types.ts +7 -0
- package/src/core/session/createGameSession.ts +480 -53
- package/src/core/session/deepFreeze.ts +104 -3
- package/src/core/session/diagnostics.ts +2 -0
- package/src/core/session/types.ts +77 -4
- package/src/definition/defineGame.ts +61 -3
- package/src/definition/types.ts +10 -0
- package/src/events/defineGameEvents.ts +46 -0
- package/src/events/errors.ts +14 -0
- package/src/events/index.ts +14 -0
- package/src/events/payload.ts +234 -0
- package/src/events/seed.ts +33 -0
- package/src/events/types.ts +53 -0
- package/src/events.ts +20 -0
- package/src/geometry/helpers.ts +136 -0
- package/src/geometry/index.ts +14 -0
- package/src/geometry/types.ts +54 -0
- package/src/geometry/validation.ts +131 -0
- package/src/geometry.ts +6 -0
- package/src/haptics/createGameHaptics.ts +214 -0
- package/src/haptics/errors.ts +12 -0
- package/src/haptics/index.ts +3 -0
- package/src/haptics/resolver.ts +58 -0
- package/src/haptics/types.ts +48 -0
- package/src/haptics.ts +7 -0
- package/src/index.ts +37 -1
- package/src/particles/createParticleSystem.ts +505 -0
- package/src/particles/defineParticleEffect.ts +164 -0
- package/src/particles/errors.ts +6 -0
- package/src/particles/index.ts +5 -0
- package/src/particles/sampling.ts +141 -0
- package/src/particles/types.ts +327 -0
- package/src/particles.ts +1 -0
- package/src/react/GameButtonPad.tsx +436 -0
- package/src/react/GamePointerInput.tsx +73 -8
- package/src/react/GameView.tsx +160 -61
- package/src/react/assets/createGameAssetStore.ts +140 -107
- package/src/react/assets/useGameAssets.ts +63 -31
- package/src/react/bindAppLifecycle.ts +55 -19
- package/src/react/bindGameSession.ts +12 -2
- package/src/react/camera2d/GameLayer2D.tsx +43 -0
- package/src/react/camera2d/defineGameCamera2D.ts +59 -0
- package/src/react/camera2d/usePresentedCameraBinding.ts +185 -0
- package/src/react/cleanupList.ts +48 -0
- package/src/react/instrumentation.ts +31 -3
- package/src/react/lifecycleSource.ts +58 -0
- package/src/react/particles/ParticleView.tsx +358 -0
- package/src/react/particles/culling.ts +145 -0
- package/src/react/particles/index.ts +6 -0
- package/src/react/particles/spriteXForm.ts +72 -0
- package/src/react/particles/useParticlePresentation.ts +261 -0
- package/src/react/pointerBinding.ts +74 -16
- package/src/react/pointerCamera.ts +33 -0
- package/src/react/pointerCoalescer.ts +36 -10
- package/src/react/sprites/GameSprite.tsx +4 -33
- package/src/react/sprites/GameWorld2D.tsx +113 -7
- package/src/react/sprites/Sprite.tsx +51 -72
- package/src/react/sprites/SpriteBatch.tsx +74 -22
- package/src/react/sprites/batchVisibility.ts +76 -0
- package/src/react/sprites/spriteSelection.ts +133 -0
- package/src/react/sprites/spriteTransform.ts +46 -26
- package/src/react/tilemap/TileMapLayer2D.tsx +274 -0
- package/src/react/tilemap/tilePresentation.ts +491 -0
- package/src/react/useGameSession.ts +90 -0
- package/src/react/useGameSessionStatus.ts +53 -0
- package/src/react/viewportBinding.ts +5 -1
- package/src/react.ts +18 -1
- package/src/scene/defineScene.ts +47 -5
- package/src/scene/types.ts +37 -3
- package/src/sprites/sampleSpriteClip.ts +82 -14
- package/src/sprites/spriteAnimationState.ts +29 -25
- package/src/sprites.ts +22 -0
- package/src/storage/adapters/asyncStorage.ts +77 -0
- package/src/storage/adapters/memory.ts +58 -0
- package/src/storage/errors.ts +88 -0
- package/src/storage/index.ts +18 -0
- package/src/storage/schema.ts +147 -0
- package/src/storage/serialization.ts +248 -0
- package/src/storage/store.ts +380 -0
- package/src/storage/types.ts +76 -0
- package/src/storage/validation.ts +102 -0
- package/src/storage.ts +1 -0
- package/src/testing.ts +4 -0
- package/src/tilemap/chunkStats.ts +24 -0
- package/src/tilemap/definitions.ts +327 -0
- package/src/tilemap/errors.ts +11 -0
- package/src/tilemap/index.ts +10 -0
- package/src/tilemap/movement.ts +368 -0
- package/src/tilemap/queries.ts +136 -0
- package/src/tilemap/tiledAdapter.ts +165 -0
- package/src/tilemap/types.ts +119 -0
- package/src/tilemap.ts +1 -0
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attachable collider records and placement (T11.4).
|
|
3
|
+
*
|
|
4
|
+
* A `LocalCollider2D` is immutable local-space data: its `offset` and shape
|
|
5
|
+
* dimensions are relative to an authored object position. `placeCollider2D`
|
|
6
|
+
* is the ONLY local -> world path; world colliders feed broad-phase,
|
|
7
|
+
* collider-pair, and debug operations. Placement preserves filter, sensor,
|
|
8
|
+
* identifier, and author metadata and never mutates the source.
|
|
9
|
+
*
|
|
10
|
+
* Translation only: a rectangle stays axis-aligned and a circle stays a
|
|
11
|
+
* circle. There is no general transform, and rendering never owns gameplay
|
|
12
|
+
* collision state.
|
|
13
|
+
*/
|
|
14
|
+
import type { Aabb2D, Circle2D, Point2D, Vector2D } from '../geometry/types';
|
|
15
|
+
import {
|
|
16
|
+
assertValidAabb2D,
|
|
17
|
+
assertValidCircle2D,
|
|
18
|
+
assertValidPoint2D,
|
|
19
|
+
assertUnsigned32Bits,
|
|
20
|
+
} from '../geometry/validation';
|
|
21
|
+
import type { CollisionFilter2D } from './filters';
|
|
22
|
+
import { ALL_FILTER2D, canCollide2D } from './filters';
|
|
23
|
+
import {
|
|
24
|
+
collideAabbAabb2D,
|
|
25
|
+
collideCircleAabb2D,
|
|
26
|
+
collideCircleCircle2D,
|
|
27
|
+
type CollisionHit2D,
|
|
28
|
+
} from './manifolds';
|
|
29
|
+
|
|
30
|
+
/** Shared collider metadata. */
|
|
31
|
+
export interface ColliderMetadata2D {
|
|
32
|
+
/** Optional collision filter; absent means eligible with everything. */
|
|
33
|
+
readonly filter?: CollisionFilter2D;
|
|
34
|
+
/** True marks detection intent; never changes geometry results. */
|
|
35
|
+
readonly sensor?: boolean;
|
|
36
|
+
/** Stable user/entity identifier, independent of array indexes. */
|
|
37
|
+
readonly id?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** A local-space AABB collider. */
|
|
41
|
+
export interface LocalAabbCollider2D extends ColliderMetadata2D {
|
|
42
|
+
readonly space: 'local';
|
|
43
|
+
readonly shape: 'aabb';
|
|
44
|
+
/** Offset of the AABB's top-left corner from the authored object position. */
|
|
45
|
+
readonly offset: Vector2D;
|
|
46
|
+
/** Local width in logical world units. */
|
|
47
|
+
readonly width: number;
|
|
48
|
+
/** Local height in logical world units. */
|
|
49
|
+
readonly height: number;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** A local-space circle collider. */
|
|
53
|
+
export interface LocalCircleCollider2D extends ColliderMetadata2D {
|
|
54
|
+
readonly space: 'local';
|
|
55
|
+
readonly shape: 'circle';
|
|
56
|
+
/** Offset of the circle's center from the authored object position. */
|
|
57
|
+
readonly offset: Vector2D;
|
|
58
|
+
/** Local radius in logical world units. */
|
|
59
|
+
readonly radius: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** A collider definition in the authored object's local space. */
|
|
63
|
+
export type LocalCollider2D = LocalAabbCollider2D | LocalCircleCollider2D;
|
|
64
|
+
|
|
65
|
+
/** A world-space AABB collider (already placed). */
|
|
66
|
+
export interface WorldAabbCollider2D extends ColliderMetadata2D {
|
|
67
|
+
readonly space: 'world';
|
|
68
|
+
readonly shape: 'aabb';
|
|
69
|
+
/** World top-left corner. */
|
|
70
|
+
readonly x: number;
|
|
71
|
+
/** World top-left corner. */
|
|
72
|
+
readonly y: number;
|
|
73
|
+
/** World width. */
|
|
74
|
+
readonly width: number;
|
|
75
|
+
/** World height. */
|
|
76
|
+
readonly height: number;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** A world-space circle collider (already placed). */
|
|
80
|
+
export interface WorldCircleCollider2D extends ColliderMetadata2D {
|
|
81
|
+
readonly space: 'world';
|
|
82
|
+
readonly shape: 'circle';
|
|
83
|
+
/** World center x. */
|
|
84
|
+
readonly x: number;
|
|
85
|
+
/** World center y. */
|
|
86
|
+
readonly y: number;
|
|
87
|
+
/** World radius. */
|
|
88
|
+
readonly radius: number;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** A collider placed in world space. */
|
|
92
|
+
export type WorldCollider2D = WorldAabbCollider2D | WorldCircleCollider2D;
|
|
93
|
+
|
|
94
|
+
/** Options for the beginner rectangle collider constructor. */
|
|
95
|
+
export interface RectangleCollider2DOptions {
|
|
96
|
+
/** Offset of the top-left corner from the object position. */
|
|
97
|
+
readonly offset: Vector2D;
|
|
98
|
+
/** Local width. */
|
|
99
|
+
readonly width: number;
|
|
100
|
+
/** Local height. */
|
|
101
|
+
readonly height: number;
|
|
102
|
+
readonly filter?: CollisionFilter2D;
|
|
103
|
+
readonly sensor?: boolean;
|
|
104
|
+
readonly id?: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Options for the beginner circle collider constructor. */
|
|
108
|
+
export interface CircleCollider2DOptions {
|
|
109
|
+
/** Offset of the center from the object position. */
|
|
110
|
+
readonly offset: Vector2D;
|
|
111
|
+
/** Local radius. */
|
|
112
|
+
readonly radius: number;
|
|
113
|
+
readonly filter?: CollisionFilter2D;
|
|
114
|
+
readonly sensor?: boolean;
|
|
115
|
+
readonly id?: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Clone and freeze a caller-provided filter so later mutation cannot
|
|
119
|
+
* change already-created colliders or their placements. */
|
|
120
|
+
function freezeFilter(filter: CollisionFilter2D): CollisionFilter2D {
|
|
121
|
+
return Object.freeze({ categoryBits: filter.categoryBits, maskBits: filter.maskBits });
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function validateMetadata(metadata: ColliderMetadata2D): void {
|
|
125
|
+
if (metadata.filter !== undefined) {
|
|
126
|
+
assertUnsigned32Bits(metadata.filter.categoryBits, 'filter.categoryBits');
|
|
127
|
+
assertUnsigned32Bits(metadata.filter.maskBits, 'filter.maskBits');
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Create an immutable local AABB collider. */
|
|
132
|
+
export function rectangleCollider2D(options: RectangleCollider2DOptions): LocalAabbCollider2D {
|
|
133
|
+
const collider: LocalAabbCollider2D = {
|
|
134
|
+
space: 'local',
|
|
135
|
+
shape: 'aabb',
|
|
136
|
+
offset: Object.freeze({ x: options.offset.x, y: options.offset.y }),
|
|
137
|
+
width: options.width,
|
|
138
|
+
height: options.height,
|
|
139
|
+
...(options.filter === undefined ? {} : { filter: freezeFilter(options.filter) }),
|
|
140
|
+
...(options.sensor === undefined ? {} : { sensor: options.sensor }),
|
|
141
|
+
...(options.id === undefined ? {} : { id: options.id }),
|
|
142
|
+
};
|
|
143
|
+
validateMetadata(collider);
|
|
144
|
+
assertValidAabb2D(
|
|
145
|
+
{
|
|
146
|
+
x: options.offset.x,
|
|
147
|
+
y: options.offset.y,
|
|
148
|
+
width: options.width,
|
|
149
|
+
height: options.height,
|
|
150
|
+
},
|
|
151
|
+
'collider',
|
|
152
|
+
);
|
|
153
|
+
return Object.freeze(collider);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Create an immutable local circle collider. */
|
|
157
|
+
export function circleCollider2D(options: CircleCollider2DOptions): LocalCircleCollider2D {
|
|
158
|
+
const collider: LocalCircleCollider2D = {
|
|
159
|
+
space: 'local',
|
|
160
|
+
shape: 'circle',
|
|
161
|
+
offset: Object.freeze({ x: options.offset.x, y: options.offset.y }),
|
|
162
|
+
radius: options.radius,
|
|
163
|
+
...(options.filter === undefined ? {} : { filter: freezeFilter(options.filter) }),
|
|
164
|
+
...(options.sensor === undefined ? {} : { sensor: options.sensor }),
|
|
165
|
+
...(options.id === undefined ? {} : { id: options.id }),
|
|
166
|
+
};
|
|
167
|
+
validateMetadata(collider);
|
|
168
|
+
assertValidCircle2D(
|
|
169
|
+
{ x: options.offset.x, y: options.offset.y, radius: options.radius },
|
|
170
|
+
'collider',
|
|
171
|
+
);
|
|
172
|
+
return Object.freeze(collider);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Place a local collider at an authored object position, returning an
|
|
177
|
+
* immutable world-space collider. Rejects local colliders at compile time.
|
|
178
|
+
*/
|
|
179
|
+
export function placeCollider2D(local: LocalCollider2D, position: Point2D): WorldCollider2D {
|
|
180
|
+
assertValidPoint2D(position, 'position');
|
|
181
|
+
const worldX = position.x + local.offset.x;
|
|
182
|
+
const worldY = position.y + local.offset.y;
|
|
183
|
+
const metadata = {
|
|
184
|
+
...(local.filter === undefined ? {} : { filter: local.filter }),
|
|
185
|
+
...(local.sensor === undefined ? {} : { sensor: local.sensor }),
|
|
186
|
+
...(local.id === undefined ? {} : { id: local.id }),
|
|
187
|
+
};
|
|
188
|
+
if (local.shape === 'aabb') {
|
|
189
|
+
const world: WorldAabbCollider2D = {
|
|
190
|
+
space: 'world',
|
|
191
|
+
shape: 'aabb',
|
|
192
|
+
x: worldX,
|
|
193
|
+
y: worldY,
|
|
194
|
+
width: local.width,
|
|
195
|
+
height: local.height,
|
|
196
|
+
...metadata,
|
|
197
|
+
};
|
|
198
|
+
assertValidAabb2D(world, 'world');
|
|
199
|
+
return Object.freeze(world);
|
|
200
|
+
}
|
|
201
|
+
const world: WorldCircleCollider2D = {
|
|
202
|
+
space: 'world',
|
|
203
|
+
shape: 'circle',
|
|
204
|
+
x: worldX,
|
|
205
|
+
y: worldY,
|
|
206
|
+
radius: local.radius,
|
|
207
|
+
...metadata,
|
|
208
|
+
};
|
|
209
|
+
assertValidCircle2D(world, 'world');
|
|
210
|
+
return Object.freeze(world);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** World-space AABB view of a collider (for broad-phase bounds). */
|
|
214
|
+
export function worldColliderBounds2D(world: WorldCollider2D): Aabb2D {
|
|
215
|
+
if (world.shape === 'aabb') {
|
|
216
|
+
return Object.freeze({
|
|
217
|
+
x: world.x,
|
|
218
|
+
y: world.y,
|
|
219
|
+
width: world.width,
|
|
220
|
+
height: world.height,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
return Object.freeze({
|
|
224
|
+
x: world.x - world.radius,
|
|
225
|
+
y: world.y - world.radius,
|
|
226
|
+
width: world.radius * 2,
|
|
227
|
+
height: world.radius * 2,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** World-space circle view of a collider (for narrow-phase pairs). */
|
|
232
|
+
export function worldColliderCircle2D(world: WorldCollider2D): Circle2D | undefined {
|
|
233
|
+
if (world.shape === 'circle') {
|
|
234
|
+
return Object.freeze({ x: world.x, y: world.y, radius: world.radius });
|
|
235
|
+
}
|
|
236
|
+
return undefined;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Narrow-phase contact between two placed world colliders.
|
|
241
|
+
*
|
|
242
|
+
* Filters are normalized first: an absent filter behaves exactly as
|
|
243
|
+
* `ALL_FILTER2D`, so `NONE_FILTER2D` on either side truly collides with
|
|
244
|
+
* nothing. The dispatch preserves the public argument order: the returned
|
|
245
|
+
* normal always moves the FIRST argument out of the SECOND, including for
|
|
246
|
+
* mixed AABB/circle pairs (the AABB-first wrapper inverts only the
|
|
247
|
+
* circle-first manifold normal, keeping depth and the world contact point).
|
|
248
|
+
*/
|
|
249
|
+
export function collideWorldColliders2D(
|
|
250
|
+
first: WorldCollider2D,
|
|
251
|
+
second: WorldCollider2D,
|
|
252
|
+
): CollisionHit2D | undefined {
|
|
253
|
+
const firstFilter = first.filter ?? ALL_FILTER2D;
|
|
254
|
+
const secondFilter = second.filter ?? ALL_FILTER2D;
|
|
255
|
+
if (!canCollide2D(firstFilter, secondFilter)) {
|
|
256
|
+
return undefined;
|
|
257
|
+
}
|
|
258
|
+
if (first.shape === 'aabb' && second.shape === 'aabb') {
|
|
259
|
+
return collideAabbAabb2D(
|
|
260
|
+
{ x: first.x, y: first.y, width: first.width, height: first.height },
|
|
261
|
+
{ x: second.x, y: second.y, width: second.width, height: second.height },
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
if (first.shape === 'circle' && second.shape === 'circle') {
|
|
265
|
+
return collideCircleCircle2D(
|
|
266
|
+
{ x: first.x, y: first.y, radius: first.radius },
|
|
267
|
+
{ x: second.x, y: second.y, radius: second.radius },
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
if (first.shape === 'circle' && second.shape === 'aabb') {
|
|
271
|
+
return collideCircleAabb2D(
|
|
272
|
+
{ x: first.x, y: first.y, radius: first.radius },
|
|
273
|
+
{ x: second.x, y: second.y, width: second.width, height: second.height },
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
// AABB first, circle second: invert the circle-first manifold normal so
|
|
277
|
+
// the normal still moves the FIRST argument (the AABB) out of the second.
|
|
278
|
+
const aabbFirst = first as WorldAabbCollider2D;
|
|
279
|
+
const circleSecond = second as WorldCircleCollider2D;
|
|
280
|
+
const circleFirst = collideCircleAabb2D(
|
|
281
|
+
{ x: circleSecond.x, y: circleSecond.y, radius: circleSecond.radius },
|
|
282
|
+
{ x: aabbFirst.x, y: aabbFirst.y, width: aabbFirst.width, height: aabbFirst.height },
|
|
283
|
+
);
|
|
284
|
+
if (circleFirst === undefined) {
|
|
285
|
+
return undefined;
|
|
286
|
+
}
|
|
287
|
+
return Object.freeze({
|
|
288
|
+
normal: Object.freeze({ x: 0 - circleFirst.normal.x, y: 0 - circleFirst.normal.y }),
|
|
289
|
+
depth: circleFirst.depth,
|
|
290
|
+
point: circleFirst.point,
|
|
291
|
+
});
|
|
292
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless debug projections (T11.6).
|
|
3
|
+
*
|
|
4
|
+
* Immutable debug primitives a renderer can draw without importing Skia
|
|
5
|
+
* into the collision module. Colors and labels are optional presentation
|
|
6
|
+
* metadata, never gameplay semantics. Production collision results never
|
|
7
|
+
* allocate debug data; projection is opt-in.
|
|
8
|
+
*/
|
|
9
|
+
import type { Point2D, Vector2D } from '../geometry/types';
|
|
10
|
+
import { assertValidPoint2D, assertValidVector2D } from '../geometry/validation';
|
|
11
|
+
import type { CollisionHit2D } from './manifolds';
|
|
12
|
+
import type { WorldCollider2D } from './colliders';
|
|
13
|
+
|
|
14
|
+
/** Optional presentation metadata. */
|
|
15
|
+
export interface DebugStyle2D {
|
|
16
|
+
/** Optional presentation color (renderer-specific encoding). */
|
|
17
|
+
readonly color?: string;
|
|
18
|
+
/** Optional author label (collider names, for example). */
|
|
19
|
+
readonly label?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Debug AABB. */
|
|
23
|
+
export interface DebugAabb2D extends DebugStyle2D {
|
|
24
|
+
readonly kind: 'aabb';
|
|
25
|
+
readonly x: number;
|
|
26
|
+
readonly y: number;
|
|
27
|
+
readonly width: number;
|
|
28
|
+
readonly height: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Debug circle. */
|
|
32
|
+
export interface DebugCircle2D extends DebugStyle2D {
|
|
33
|
+
readonly kind: 'circle';
|
|
34
|
+
readonly x: number;
|
|
35
|
+
readonly y: number;
|
|
36
|
+
readonly radius: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Debug segment (sweep paths, rays). */
|
|
40
|
+
export interface DebugSegment2D extends DebugStyle2D {
|
|
41
|
+
readonly kind: 'segment';
|
|
42
|
+
readonly start: Point2D;
|
|
43
|
+
readonly end: Point2D;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Debug point (contact points). */
|
|
47
|
+
export interface DebugPoint2D extends DebugStyle2D {
|
|
48
|
+
readonly kind: 'point';
|
|
49
|
+
readonly x: number;
|
|
50
|
+
readonly y: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Debug vector (normals), drawn from `(x, y)` along `(dx, dy)`. */
|
|
54
|
+
export interface DebugVector2D extends DebugStyle2D {
|
|
55
|
+
readonly kind: 'vector';
|
|
56
|
+
readonly x: number;
|
|
57
|
+
readonly y: number;
|
|
58
|
+
readonly dx: number;
|
|
59
|
+
readonly dy: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Any headless debug primitive. */
|
|
63
|
+
export type DebugPrimitive2D =
|
|
64
|
+
| DebugAabb2D
|
|
65
|
+
| DebugCircle2D
|
|
66
|
+
| DebugSegment2D
|
|
67
|
+
| DebugPoint2D
|
|
68
|
+
| DebugVector2D;
|
|
69
|
+
|
|
70
|
+
/** Project a world collider into a debug primitive, preserving its id. */
|
|
71
|
+
export function projectWorldCollider2D(world: WorldCollider2D): DebugAabb2D | DebugCircle2D {
|
|
72
|
+
const style = world.id === undefined ? {} : { label: world.id };
|
|
73
|
+
if (world.shape === 'aabb') {
|
|
74
|
+
return Object.freeze({
|
|
75
|
+
kind: 'aabb',
|
|
76
|
+
x: world.x,
|
|
77
|
+
y: world.y,
|
|
78
|
+
width: world.width,
|
|
79
|
+
height: world.height,
|
|
80
|
+
...style,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return Object.freeze({
|
|
84
|
+
kind: 'circle',
|
|
85
|
+
x: world.x,
|
|
86
|
+
y: world.y,
|
|
87
|
+
radius: world.radius,
|
|
88
|
+
...style,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Project a contact hit into its contact point and normal arrow. */
|
|
93
|
+
export function projectHit2D(hit: CollisionHit2D): {
|
|
94
|
+
readonly point: DebugPoint2D;
|
|
95
|
+
readonly normal: DebugVector2D;
|
|
96
|
+
} {
|
|
97
|
+
return Object.freeze({
|
|
98
|
+
point: Object.freeze({ kind: 'point', x: hit.point.x, y: hit.point.y }),
|
|
99
|
+
normal: Object.freeze({
|
|
100
|
+
kind: 'vector',
|
|
101
|
+
x: hit.point.x,
|
|
102
|
+
y: hit.point.y,
|
|
103
|
+
dx: hit.normal.x,
|
|
104
|
+
dy: hit.normal.y,
|
|
105
|
+
}),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Project a sweep path (start to end of the swept reference point). */
|
|
110
|
+
export function projectSweepPath2D(start: Point2D, end: Point2D, label?: string): DebugSegment2D {
|
|
111
|
+
assertValidPoint2D(start, 'start');
|
|
112
|
+
assertValidPoint2D(end, 'end');
|
|
113
|
+
return Object.freeze({
|
|
114
|
+
kind: 'segment',
|
|
115
|
+
start: Object.freeze({ x: start.x, y: start.y }),
|
|
116
|
+
end: Object.freeze({ x: end.x, y: end.y }),
|
|
117
|
+
...(label === undefined ? {} : { label }),
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Project a plain vector arrow (for example a velocity). */
|
|
122
|
+
export function projectVector2D(origin: Point2D, vector: Vector2D, label?: string): DebugVector2D {
|
|
123
|
+
assertValidPoint2D(origin, 'origin');
|
|
124
|
+
assertValidVector2D(vector, 'vector');
|
|
125
|
+
return Object.freeze({
|
|
126
|
+
kind: 'vector',
|
|
127
|
+
x: origin.x,
|
|
128
|
+
y: origin.y,
|
|
129
|
+
dx: vector.x,
|
|
130
|
+
dy: vector.y,
|
|
131
|
+
...(label === undefined ? {} : { label }),
|
|
132
|
+
});
|
|
133
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collision filters (T11.4).
|
|
3
|
+
*
|
|
4
|
+
* Symmetric category/mask filtering with unsigned 32-bit bit sets,
|
|
5
|
+
* following the Box2D convention: two colliders are eligible only when each
|
|
6
|
+
* category is included by the other mask. No bit positions are reserved.
|
|
7
|
+
*/
|
|
8
|
+
import type { Vector2D } from '../geometry/types';
|
|
9
|
+
import { assertUnsigned32Bits } from '../geometry/validation';
|
|
10
|
+
|
|
11
|
+
/** Two explicit unsigned 32-bit bit sets for collision eligibility. */
|
|
12
|
+
export interface CollisionFilter2D {
|
|
13
|
+
/** The bits this collider belongs to. */
|
|
14
|
+
readonly categoryBits: number;
|
|
15
|
+
/** The category bits this collider can collide with. */
|
|
16
|
+
readonly maskBits: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* True when the two filters allow a collision (symmetric check).
|
|
21
|
+
*
|
|
22
|
+
* Invalid (non-unsigned-32-bit) values throw `GeometryError` before any
|
|
23
|
+
* comparison; `false` never implies malformed input.
|
|
24
|
+
*/
|
|
25
|
+
export function canCollide2D(first: CollisionFilter2D, second: CollisionFilter2D): boolean {
|
|
26
|
+
assertUnsigned32Bits(first.categoryBits, 'first.categoryBits');
|
|
27
|
+
assertUnsigned32Bits(first.maskBits, 'first.maskBits');
|
|
28
|
+
assertUnsigned32Bits(second.categoryBits, 'second.categoryBits');
|
|
29
|
+
assertUnsigned32Bits(second.maskBits, 'second.maskBits');
|
|
30
|
+
return (
|
|
31
|
+
(first.categoryBits & second.maskBits) !== 0 &&
|
|
32
|
+
(second.categoryBits & first.maskBits) !== 0
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** A collider without a filter: eligible with everything. */
|
|
37
|
+
export const ALL_FILTER2D: CollisionFilter2D = Object.freeze({
|
|
38
|
+
categoryBits: 0xffffffff,
|
|
39
|
+
maskBits: 0xffffffff,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
/** A collider that collides with nothing. */
|
|
43
|
+
export const NONE_FILTER2D: CollisionFilter2D = Object.freeze({
|
|
44
|
+
categoryBits: 0,
|
|
45
|
+
maskBits: 0,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export type { Vector2D };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export type { CollisionHit2D } from './manifolds';
|
|
2
|
+
export { RESOLUTION_TOLERANCE } from './manifolds';
|
|
3
|
+
export {
|
|
4
|
+
collideAabbAabb2D,
|
|
5
|
+
collideCircleAabb2D,
|
|
6
|
+
collideCircleCircle2D,
|
|
7
|
+
} from './manifolds';
|
|
8
|
+
export {
|
|
9
|
+
closestPointOnAabb2D,
|
|
10
|
+
intersectsAabbAabb2D,
|
|
11
|
+
intersectsCircleAabb2D,
|
|
12
|
+
intersectsCircleCircle2D,
|
|
13
|
+
pointInAabb2D,
|
|
14
|
+
pointInCircle2D,
|
|
15
|
+
} from './intersections';
|
|
16
|
+
export type { SegmentHit2D } from './segments';
|
|
17
|
+
export {
|
|
18
|
+
intersectSegmentAabb2D,
|
|
19
|
+
intersectSegmentCircle2D,
|
|
20
|
+
} from './segments';
|
|
21
|
+
export type {
|
|
22
|
+
SweepAabbAabb2DOptions,
|
|
23
|
+
SweepCircleAabb2DOptions,
|
|
24
|
+
SweepHit2D,
|
|
25
|
+
} from './sweeps';
|
|
26
|
+
export {
|
|
27
|
+
sweepAabbAabb2D,
|
|
28
|
+
sweepCircleAabb2D,
|
|
29
|
+
} from './sweeps';
|
|
30
|
+
export type { CollisionFilter2D } from './filters';
|
|
31
|
+
export {
|
|
32
|
+
ALL_FILTER2D,
|
|
33
|
+
canCollide2D,
|
|
34
|
+
NONE_FILTER2D,
|
|
35
|
+
} from './filters';
|
|
36
|
+
export type {
|
|
37
|
+
CircleCollider2DOptions,
|
|
38
|
+
ColliderMetadata2D,
|
|
39
|
+
LocalAabbCollider2D,
|
|
40
|
+
LocalCircleCollider2D,
|
|
41
|
+
LocalCollider2D,
|
|
42
|
+
RectangleCollider2DOptions,
|
|
43
|
+
WorldAabbCollider2D,
|
|
44
|
+
WorldCircleCollider2D,
|
|
45
|
+
WorldCollider2D,
|
|
46
|
+
} from './colliders';
|
|
47
|
+
export {
|
|
48
|
+
circleCollider2D,
|
|
49
|
+
collideWorldColliders2D,
|
|
50
|
+
placeCollider2D,
|
|
51
|
+
rectangleCollider2D,
|
|
52
|
+
worldColliderBounds2D,
|
|
53
|
+
worldColliderCircle2D,
|
|
54
|
+
} from './colliders';
|
|
55
|
+
export type { BuildSpatialHash2DOptions, SpatialHashIndex2D, SpatialHashItem2D } from './spatialHash';
|
|
56
|
+
export {
|
|
57
|
+
buildSpatialHash2D,
|
|
58
|
+
querySpatialHash2D,
|
|
59
|
+
} from './spatialHash';
|
|
60
|
+
export type {
|
|
61
|
+
DebugAabb2D,
|
|
62
|
+
DebugCircle2D,
|
|
63
|
+
DebugPoint2D,
|
|
64
|
+
DebugPrimitive2D,
|
|
65
|
+
DebugSegment2D,
|
|
66
|
+
DebugStyle2D,
|
|
67
|
+
DebugVector2D,
|
|
68
|
+
} from './debug';
|
|
69
|
+
export {
|
|
70
|
+
projectHit2D,
|
|
71
|
+
projectSweepPath2D,
|
|
72
|
+
projectVector2D,
|
|
73
|
+
projectWorldCollider2D,
|
|
74
|
+
} from './debug';
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static intersection predicates (T11.2).
|
|
3
|
+
*
|
|
4
|
+
* Boundary contact counts as intersection. Invalid geometry throws
|
|
5
|
+
* `GeometryError`; `false` means normal domain absence. All predicates
|
|
6
|
+
* allocate nothing.
|
|
7
|
+
*/
|
|
8
|
+
import type { Aabb2D, Circle2D, Point2D } from '../geometry/types';
|
|
9
|
+
import {
|
|
10
|
+
assertValidAabb2D,
|
|
11
|
+
assertValidCircle2D,
|
|
12
|
+
assertValidPoint2D,
|
|
13
|
+
} from '../geometry/validation';
|
|
14
|
+
|
|
15
|
+
/** True when `point` lies in or on `aabb` (boundary inclusive). */
|
|
16
|
+
export function pointInAabb2D(point: Point2D, aabb: Aabb2D): boolean {
|
|
17
|
+
assertValidPoint2D(point, 'point');
|
|
18
|
+
assertValidAabb2D(aabb);
|
|
19
|
+
return (
|
|
20
|
+
point.x >= aabb.x &&
|
|
21
|
+
point.x <= aabb.x + aabb.width &&
|
|
22
|
+
point.y >= aabb.y &&
|
|
23
|
+
point.y <= aabb.y + aabb.height
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** True when `point` lies in or on `circle` (boundary inclusive). */
|
|
28
|
+
export function pointInCircle2D(point: Point2D, circle: Circle2D): boolean {
|
|
29
|
+
assertValidPoint2D(point, 'point');
|
|
30
|
+
assertValidCircle2D(circle);
|
|
31
|
+
const dx = point.x - circle.x;
|
|
32
|
+
const dy = point.y - circle.y;
|
|
33
|
+
return dx * dx + dy * dy <= circle.radius * circle.radius;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** True when the two AABBs intersect or touch. */
|
|
37
|
+
export function intersectsAabbAabb2D(first: Aabb2D, second: Aabb2D): boolean {
|
|
38
|
+
assertValidAabb2D(first, 'first');
|
|
39
|
+
assertValidAabb2D(second, 'second');
|
|
40
|
+
return (
|
|
41
|
+
first.x <= second.x + second.width &&
|
|
42
|
+
first.x + first.width >= second.x &&
|
|
43
|
+
first.y <= second.y + second.height &&
|
|
44
|
+
first.y + first.height >= second.y
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** True when the two circles intersect or touch. */
|
|
49
|
+
export function intersectsCircleCircle2D(first: Circle2D, second: Circle2D): boolean {
|
|
50
|
+
assertValidCircle2D(first, 'first');
|
|
51
|
+
assertValidCircle2D(second, 'second');
|
|
52
|
+
const dx = second.x - first.x;
|
|
53
|
+
const dy = second.y - first.y;
|
|
54
|
+
const radiusSum = first.radius + second.radius;
|
|
55
|
+
return dx * dx + dy * dy <= radiusSum * radiusSum;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** True when the circle intersects or touches the AABB. */
|
|
59
|
+
export function intersectsCircleAabb2D(circle: Circle2D, aabb: Aabb2D): boolean {
|
|
60
|
+
assertValidCircle2D(circle);
|
|
61
|
+
assertValidAabb2D(aabb);
|
|
62
|
+
const closestX = clamp(circle.x, aabb.x, aabb.x + aabb.width);
|
|
63
|
+
const closestY = clamp(circle.y, aabb.y, aabb.y + aabb.height);
|
|
64
|
+
const dx = circle.x - closestX;
|
|
65
|
+
const dy = circle.y - closestY;
|
|
66
|
+
return dx * dx + dy * dy <= circle.radius * circle.radius;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Closest point on the AABB to the circle center (shared by manifold code). */
|
|
70
|
+
export function closestPointOnAabb2D(
|
|
71
|
+
point: Point2D,
|
|
72
|
+
aabb: Aabb2D,
|
|
73
|
+
): { readonly x: number; readonly y: number } {
|
|
74
|
+
return {
|
|
75
|
+
x: clamp(point.x, aabb.x, aabb.x + aabb.width),
|
|
76
|
+
y: clamp(point.y, aabb.y, aabb.y + aabb.height),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function clamp(value: number, min: number, max: number): number {
|
|
81
|
+
return value < min ? min : value > max ? max : value;
|
|
82
|
+
}
|