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,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Camera2D public values (T12.1).
|
|
3
|
+
*
|
|
4
|
+
* A camera is immutable plain data: where the view is centered in world
|
|
5
|
+
* space, how much it zooms, and how it rotates. It carries no Skia
|
|
6
|
+
* matrices, no shared values, no viewport dimensions — presentation and
|
|
7
|
+
* conversion derive everything from this value plus the authored logical
|
|
8
|
+
* view.
|
|
9
|
+
*/
|
|
10
|
+
import type { Point2D } from '../geometry/types.js';
|
|
11
|
+
/** The authored 2D camera value. */
|
|
12
|
+
export interface Camera2D {
|
|
13
|
+
/** World-space point the camera looks at. */
|
|
14
|
+
readonly center: Point2D;
|
|
15
|
+
/** Finite uniform zoom, greater than zero. */
|
|
16
|
+
readonly zoom: number;
|
|
17
|
+
/** Rotation in radians, positive per the Skia coordinate convention. */
|
|
18
|
+
readonly rotationRadians: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A presented camera with an explicit cut signal.
|
|
22
|
+
*
|
|
23
|
+
* `cutId` increases monotonically across the lifetime of a camera binding.
|
|
24
|
+
* A changed `cutId` means the previous camera is unrelated: presentation
|
|
25
|
+
* snaps instead of interpolating (scene transitions, session replacement,
|
|
26
|
+
* binding-generation changes, explicit teleports, invalid prior data).
|
|
27
|
+
*/
|
|
28
|
+
export interface CameraCut2D {
|
|
29
|
+
/** The camera to present. */
|
|
30
|
+
readonly camera: Camera2D;
|
|
31
|
+
/** Monotonic cut signal; a new value disables interpolation. */
|
|
32
|
+
readonly cutId: number;
|
|
33
|
+
}
|
|
34
|
+
/** Per-axis follow enablement. Both default to true. */
|
|
35
|
+
export interface CameraFollowAxisOptions2D {
|
|
36
|
+
/** Follow on the horizontal axis. */
|
|
37
|
+
readonly x?: boolean;
|
|
38
|
+
/** Follow on the vertical axis. */
|
|
39
|
+
readonly y?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/** Options for `followCamera2D`. */
|
|
42
|
+
export interface FollowCamera2DOptions2D {
|
|
43
|
+
/**
|
|
44
|
+
* Axis-aligned dead zone in world units, centered on the camera center.
|
|
45
|
+
* A target inside the zone leaves the camera untouched.
|
|
46
|
+
*/
|
|
47
|
+
readonly deadZone?: {
|
|
48
|
+
readonly x: number;
|
|
49
|
+
readonly y: number;
|
|
50
|
+
readonly width: number;
|
|
51
|
+
readonly height: number;
|
|
52
|
+
};
|
|
53
|
+
/** Per-axis follow enablement. */
|
|
54
|
+
readonly perAxis?: CameraFollowAxisOptions2D;
|
|
55
|
+
/**
|
|
56
|
+
* Damping half-life in seconds: after this many seconds the remaining
|
|
57
|
+
* follow distance halves. Requires `deltaSeconds` on the call.
|
|
58
|
+
*/
|
|
59
|
+
readonly dampingHalfLifeSeconds?: number;
|
|
60
|
+
}
|
|
61
|
+
/** Options for `sampleCameraShake2D`. */
|
|
62
|
+
export interface CameraShakeOptions2D {
|
|
63
|
+
/** Deterministic seed; equal seeds produce equal offsets. */
|
|
64
|
+
readonly seed: number;
|
|
65
|
+
/** Elapsed simulation time in seconds since the shake began. */
|
|
66
|
+
readonly elapsedSeconds: number;
|
|
67
|
+
/** Shake duration in seconds; the base camera returns exactly at end. */
|
|
68
|
+
readonly durationSeconds: number;
|
|
69
|
+
/** Peak offset magnitude in world units. */
|
|
70
|
+
readonly amplitude: number;
|
|
71
|
+
/** Angular frequency in radians per second (defaults to 2π). */
|
|
72
|
+
readonly frequency?: number;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/camera2d/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAmB,CAAC;AAEjD,oCAAoC;AACpC,MAAM,WAAW,QAAQ;IACvB,6CAA6C;IAC7C,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wEAAwE;IACxE,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW;IAC1B,6BAA6B;IAC7B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,gEAAgE;IAChE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,wDAAwD;AACxD,MAAM,WAAW,yBAAyB;IACxC,qCAAqC;IACrC,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC;IACrB,mCAAmC;IACnC,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,oCAAoC;AACpC,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAChH,kCAAkC;IAClC,QAAQ,CAAC,OAAO,CAAC,EAAE,yBAAyB,CAAC;IAC7C;;;OAGG;IACH,QAAQ,CAAC,sBAAsB,CAAC,EAAE,MAAM,CAAC;CAC1C;AAED,yCAAyC;AACzC,MAAM,WAAW,oBAAoB;IACnC,6DAA6D;IAC7D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,gEAAgE;IAChE,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,yEAAyE;IACzE,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,4CAA4C;IAC5C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,gEAAgE;IAChE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Camera2D validation (T12.1, T12-F6).
|
|
3
|
+
*
|
|
4
|
+
* Reuses the Task 11 structured `GeometryError` codes so failures identify
|
|
5
|
+
* the operation and the invalid field. Validation happens at public
|
|
6
|
+
* operation boundaries; values are never coerced. Outer shapes are checked
|
|
7
|
+
* BEFORE field dereferencing, so null, arrays, and missing nested objects
|
|
8
|
+
* produce structured errors instead of incidental `TypeError`s.
|
|
9
|
+
*/
|
|
10
|
+
import type { Aabb2D, Point2D } from '../geometry/types.js';
|
|
11
|
+
import type { Camera2D } from './types.js';
|
|
12
|
+
/** Assert the outer shape of a camera before dereferencing fields. */
|
|
13
|
+
export declare function assertCameraShape(camera: unknown, field: string): asserts camera is Camera2D;
|
|
14
|
+
/** Assert a valid camera value (shape + fields). */
|
|
15
|
+
export declare function assertValidCamera2D(camera: Camera2D): void;
|
|
16
|
+
/** Assert a finite point (shape first). */
|
|
17
|
+
export declare function assertFinitePoint2D(point: unknown, field: string): asserts point is Point2D;
|
|
18
|
+
/** Assert a valid logical view rect (shape + finite positive size). */
|
|
19
|
+
export declare function assertValidLogicalView(view: unknown): asserts view is Aabb2D;
|
|
20
|
+
/** Assert a nonnegative padding. */
|
|
21
|
+
export declare function assertNonnegativePadding(padding: number): void;
|
|
22
|
+
/**
|
|
23
|
+
* Strict full-camera clone (T12-SF3): validates a COMPLETE runtime camera —
|
|
24
|
+
* every required field present and finite — and returns an owned frozen
|
|
25
|
+
* copy. Unlike `createCamera2D` (which fills partial authored options with
|
|
26
|
+
* identity defaults), a missing field is rejected. Used at publication
|
|
27
|
+
* boundaries where a partial value must never be silently completed.
|
|
28
|
+
*/
|
|
29
|
+
export declare function cloneValidCamera2D(camera: unknown, field?: string): Camera2D;
|
|
30
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../../src/camera2d/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,sBAAmB,CAAC;AAEzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAS,CAAC;AAMxC,sEAAsE;AACtE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,QAAQ,CAe5F;AAED,oDAAoD;AACpD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI,CAa1D;AAED,2CAA2C;AAC3C,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAW3F;AAED,uEAAuE;AACvE,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,IAAI,MAAM,CAoB5E;AAED,oCAAoC;AACpC,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE9D;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,SAAW,GAAG,QAAQ,CAyB9E"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Camera2D visibility (T12.6).
|
|
3
|
+
*
|
|
4
|
+
* Presentation-only culling: computes what the camera can see and filters
|
|
5
|
+
* render records without changing simulation. An off-screen entity keeps
|
|
6
|
+
* simulating, colliding, and re-entering view. For rotated cameras the
|
|
7
|
+
* broad test uses the conservative visible AABB (a superset of the actual
|
|
8
|
+
* view polygon), so false positives are possible but false negatives are
|
|
9
|
+
* not — a visible object can never pop out.
|
|
10
|
+
*/
|
|
11
|
+
import type { Aabb2D, Circle2D, Point2D } from '../geometry/types.js';
|
|
12
|
+
import type { Camera2D } from './types.js';
|
|
13
|
+
/** A shape queryable against the camera view. */
|
|
14
|
+
export type CameraViewShape2D = {
|
|
15
|
+
readonly kind: 'aabb';
|
|
16
|
+
readonly bounds: Aabb2D;
|
|
17
|
+
} | {
|
|
18
|
+
readonly kind: 'circle';
|
|
19
|
+
readonly circle: Circle2D;
|
|
20
|
+
} | {
|
|
21
|
+
readonly kind: 'point';
|
|
22
|
+
readonly point: Point2D;
|
|
23
|
+
};
|
|
24
|
+
/** The visible world bounds expanded by an optional padding. */
|
|
25
|
+
export declare function paddedCameraBounds2D(camera: Camera2D, logicalView: Aabb2D, padding?: number): Aabb2D;
|
|
26
|
+
/**
|
|
27
|
+
* Whether a shape intersects the camera's visible region.
|
|
28
|
+
*
|
|
29
|
+
* The test is conservative: it uses the visible world AABB (exact for
|
|
30
|
+
* unrotated cameras, a superset for rotated ones). `padding` extends the
|
|
31
|
+
* region in world units for sprites and effects that draw outside their
|
|
32
|
+
* logical bounds.
|
|
33
|
+
*/
|
|
34
|
+
export declare function intersectsCameraView2D(shape: CameraViewShape2D, camera: Camera2D, logicalView: Aabb2D, padding?: number): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Filter indexed render records, preserving stable order.
|
|
37
|
+
*
|
|
38
|
+
* Returns a frozen copy containing only the records whose world bounds
|
|
39
|
+
* intersect the visible region (plus `padding`). Off-screen records keep
|
|
40
|
+
* their identity and order in the caller's array; nothing here mutates
|
|
41
|
+
* them or changes simulation.
|
|
42
|
+
*/
|
|
43
|
+
export declare function filterCameraVisible2D<T extends {
|
|
44
|
+
readonly id: string;
|
|
45
|
+
readonly bounds: Aabb2D;
|
|
46
|
+
}>(items: readonly T[], camera: Camera2D, logicalView: Aabb2D, padding?: number): readonly T[];
|
|
47
|
+
//# sourceMappingURL=visibility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visibility.d.ts","sourceRoot":"","sources":["../../../../src/camera2d/visibility.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,sBAAmB,CAAC;AAInE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAS,CAAC;AA6FxC,iDAAiD;AACjD,MAAM,MAAM,iBAAiB,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAA;CAAE,GACtD;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAExD,gEAAgE;AAChE,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,QAAQ,EAChB,WAAW,EAAE,MAAM,EACnB,OAAO,SAAI,GACV,MAAM,CAWR;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,iBAAiB,EACxB,MAAM,EAAE,QAAQ,EAChB,WAAW,EAAE,MAAM,EACnB,OAAO,SAAI,GACV,OAAO,CAWT;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAC9F,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,MAAM,EAAE,QAAQ,EAChB,WAAW,EAAE,MAAM,EACnB,OAAO,SAAI,GACV,SAAS,CAAC,EAAE,CAUd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camera2d.d.ts","sourceRoot":"","sources":["../../../src/camera2d.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,qBAAkB,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
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.js';
|
|
15
|
+
import type { CollisionFilter2D } from './filters.js';
|
|
16
|
+
import { type CollisionHit2D } from './manifolds.js';
|
|
17
|
+
/** Shared collider metadata. */
|
|
18
|
+
export interface ColliderMetadata2D {
|
|
19
|
+
/** Optional collision filter; absent means eligible with everything. */
|
|
20
|
+
readonly filter?: CollisionFilter2D;
|
|
21
|
+
/** True marks detection intent; never changes geometry results. */
|
|
22
|
+
readonly sensor?: boolean;
|
|
23
|
+
/** Stable user/entity identifier, independent of array indexes. */
|
|
24
|
+
readonly id?: string;
|
|
25
|
+
}
|
|
26
|
+
/** A local-space AABB collider. */
|
|
27
|
+
export interface LocalAabbCollider2D extends ColliderMetadata2D {
|
|
28
|
+
readonly space: 'local';
|
|
29
|
+
readonly shape: 'aabb';
|
|
30
|
+
/** Offset of the AABB's top-left corner from the authored object position. */
|
|
31
|
+
readonly offset: Vector2D;
|
|
32
|
+
/** Local width in logical world units. */
|
|
33
|
+
readonly width: number;
|
|
34
|
+
/** Local height in logical world units. */
|
|
35
|
+
readonly height: number;
|
|
36
|
+
}
|
|
37
|
+
/** A local-space circle collider. */
|
|
38
|
+
export interface LocalCircleCollider2D extends ColliderMetadata2D {
|
|
39
|
+
readonly space: 'local';
|
|
40
|
+
readonly shape: 'circle';
|
|
41
|
+
/** Offset of the circle's center from the authored object position. */
|
|
42
|
+
readonly offset: Vector2D;
|
|
43
|
+
/** Local radius in logical world units. */
|
|
44
|
+
readonly radius: number;
|
|
45
|
+
}
|
|
46
|
+
/** A collider definition in the authored object's local space. */
|
|
47
|
+
export type LocalCollider2D = LocalAabbCollider2D | LocalCircleCollider2D;
|
|
48
|
+
/** A world-space AABB collider (already placed). */
|
|
49
|
+
export interface WorldAabbCollider2D extends ColliderMetadata2D {
|
|
50
|
+
readonly space: 'world';
|
|
51
|
+
readonly shape: 'aabb';
|
|
52
|
+
/** World top-left corner. */
|
|
53
|
+
readonly x: number;
|
|
54
|
+
/** World top-left corner. */
|
|
55
|
+
readonly y: number;
|
|
56
|
+
/** World width. */
|
|
57
|
+
readonly width: number;
|
|
58
|
+
/** World height. */
|
|
59
|
+
readonly height: number;
|
|
60
|
+
}
|
|
61
|
+
/** A world-space circle collider (already placed). */
|
|
62
|
+
export interface WorldCircleCollider2D extends ColliderMetadata2D {
|
|
63
|
+
readonly space: 'world';
|
|
64
|
+
readonly shape: 'circle';
|
|
65
|
+
/** World center x. */
|
|
66
|
+
readonly x: number;
|
|
67
|
+
/** World center y. */
|
|
68
|
+
readonly y: number;
|
|
69
|
+
/** World radius. */
|
|
70
|
+
readonly radius: number;
|
|
71
|
+
}
|
|
72
|
+
/** A collider placed in world space. */
|
|
73
|
+
export type WorldCollider2D = WorldAabbCollider2D | WorldCircleCollider2D;
|
|
74
|
+
/** Options for the beginner rectangle collider constructor. */
|
|
75
|
+
export interface RectangleCollider2DOptions {
|
|
76
|
+
/** Offset of the top-left corner from the object position. */
|
|
77
|
+
readonly offset: Vector2D;
|
|
78
|
+
/** Local width. */
|
|
79
|
+
readonly width: number;
|
|
80
|
+
/** Local height. */
|
|
81
|
+
readonly height: number;
|
|
82
|
+
readonly filter?: CollisionFilter2D;
|
|
83
|
+
readonly sensor?: boolean;
|
|
84
|
+
readonly id?: string;
|
|
85
|
+
}
|
|
86
|
+
/** Options for the beginner circle collider constructor. */
|
|
87
|
+
export interface CircleCollider2DOptions {
|
|
88
|
+
/** Offset of the center from the object position. */
|
|
89
|
+
readonly offset: Vector2D;
|
|
90
|
+
/** Local radius. */
|
|
91
|
+
readonly radius: number;
|
|
92
|
+
readonly filter?: CollisionFilter2D;
|
|
93
|
+
readonly sensor?: boolean;
|
|
94
|
+
readonly id?: string;
|
|
95
|
+
}
|
|
96
|
+
/** Create an immutable local AABB collider. */
|
|
97
|
+
export declare function rectangleCollider2D(options: RectangleCollider2DOptions): LocalAabbCollider2D;
|
|
98
|
+
/** Create an immutable local circle collider. */
|
|
99
|
+
export declare function circleCollider2D(options: CircleCollider2DOptions): LocalCircleCollider2D;
|
|
100
|
+
/**
|
|
101
|
+
* Place a local collider at an authored object position, returning an
|
|
102
|
+
* immutable world-space collider. Rejects local colliders at compile time.
|
|
103
|
+
*/
|
|
104
|
+
export declare function placeCollider2D(local: LocalCollider2D, position: Point2D): WorldCollider2D;
|
|
105
|
+
/** World-space AABB view of a collider (for broad-phase bounds). */
|
|
106
|
+
export declare function worldColliderBounds2D(world: WorldCollider2D): Aabb2D;
|
|
107
|
+
/** World-space circle view of a collider (for narrow-phase pairs). */
|
|
108
|
+
export declare function worldColliderCircle2D(world: WorldCollider2D): Circle2D | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* Narrow-phase contact between two placed world colliders.
|
|
111
|
+
*
|
|
112
|
+
* Filters are normalized first: an absent filter behaves exactly as
|
|
113
|
+
* `ALL_FILTER2D`, so `NONE_FILTER2D` on either side truly collides with
|
|
114
|
+
* nothing. The dispatch preserves the public argument order: the returned
|
|
115
|
+
* normal always moves the FIRST argument out of the SECOND, including for
|
|
116
|
+
* mixed AABB/circle pairs (the AABB-first wrapper inverts only the
|
|
117
|
+
* circle-first manifold normal, keeping depth and the world contact point).
|
|
118
|
+
*/
|
|
119
|
+
export declare function collideWorldColliders2D(first: WorldCollider2D, second: WorldCollider2D): CollisionHit2D | undefined;
|
|
120
|
+
//# sourceMappingURL=colliders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colliders.d.ts","sourceRoot":"","sources":["../../../../src/collision2d/colliders.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAmB,CAAC;AAO7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAW,CAAC;AAEnD,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,gBAAa,CAAC;AAErB,gCAAgC;AAChC,MAAM,WAAW,kBAAkB;IACjC,wEAAwE;IACxE,QAAQ,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC;IACpC,mEAAmE;IACnE,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,mEAAmE;IACnE,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,mCAAmC;AACnC,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAC7D,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,0CAA0C;IAC1C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,2CAA2C;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,qCAAqC;AACrC,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB;IAC/D,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,uEAAuE;IACvE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,2CAA2C;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,kEAAkE;AAClE,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,qBAAqB,CAAC;AAE1E,oDAAoD;AACpD,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAC7D,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,6BAA6B;IAC7B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,6BAA6B;IAC7B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,mBAAmB;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,oBAAoB;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,sDAAsD;AACtD,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB;IAC/D,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,sBAAsB;IACtB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,wCAAwC;AACxC,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,qBAAqB,CAAC;AAE1E,+DAA+D;AAC/D,MAAM,WAAW,0BAA0B;IACzC,8DAA8D;IAC9D,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,mBAAmB;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,oBAAoB;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC;IACpC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,4DAA4D;AAC5D,MAAM,WAAW,uBAAuB;IACtC,qDAAqD;IACrD,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,oBAAoB;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC;IACpC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;CACtB;AAeD,+CAA+C;AAC/C,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,mBAAmB,CAsB5F;AAED,iDAAiD;AACjD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,qBAAqB,CAgBxF;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,OAAO,GAAG,eAAe,CAgC1F;AAED,oEAAoE;AACpE,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAepE;AAED,sEAAsE;AACtE,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,eAAe,GAAG,QAAQ,GAAG,SAAS,CAKlF;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE,eAAe,GACtB,cAAc,GAAG,SAAS,CAwC5B"}
|
|
@@ -0,0 +1,67 @@
|
|
|
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.js';
|
|
10
|
+
import type { CollisionHit2D } from './manifolds.js';
|
|
11
|
+
import type { WorldCollider2D } from './colliders.js';
|
|
12
|
+
/** Optional presentation metadata. */
|
|
13
|
+
export interface DebugStyle2D {
|
|
14
|
+
/** Optional presentation color (renderer-specific encoding). */
|
|
15
|
+
readonly color?: string;
|
|
16
|
+
/** Optional author label (collider names, for example). */
|
|
17
|
+
readonly label?: string;
|
|
18
|
+
}
|
|
19
|
+
/** Debug AABB. */
|
|
20
|
+
export interface DebugAabb2D extends DebugStyle2D {
|
|
21
|
+
readonly kind: 'aabb';
|
|
22
|
+
readonly x: number;
|
|
23
|
+
readonly y: number;
|
|
24
|
+
readonly width: number;
|
|
25
|
+
readonly height: number;
|
|
26
|
+
}
|
|
27
|
+
/** Debug circle. */
|
|
28
|
+
export interface DebugCircle2D extends DebugStyle2D {
|
|
29
|
+
readonly kind: 'circle';
|
|
30
|
+
readonly x: number;
|
|
31
|
+
readonly y: number;
|
|
32
|
+
readonly radius: number;
|
|
33
|
+
}
|
|
34
|
+
/** Debug segment (sweep paths, rays). */
|
|
35
|
+
export interface DebugSegment2D extends DebugStyle2D {
|
|
36
|
+
readonly kind: 'segment';
|
|
37
|
+
readonly start: Point2D;
|
|
38
|
+
readonly end: Point2D;
|
|
39
|
+
}
|
|
40
|
+
/** Debug point (contact points). */
|
|
41
|
+
export interface DebugPoint2D extends DebugStyle2D {
|
|
42
|
+
readonly kind: 'point';
|
|
43
|
+
readonly x: number;
|
|
44
|
+
readonly y: number;
|
|
45
|
+
}
|
|
46
|
+
/** Debug vector (normals), drawn from `(x, y)` along `(dx, dy)`. */
|
|
47
|
+
export interface DebugVector2D extends DebugStyle2D {
|
|
48
|
+
readonly kind: 'vector';
|
|
49
|
+
readonly x: number;
|
|
50
|
+
readonly y: number;
|
|
51
|
+
readonly dx: number;
|
|
52
|
+
readonly dy: number;
|
|
53
|
+
}
|
|
54
|
+
/** Any headless debug primitive. */
|
|
55
|
+
export type DebugPrimitive2D = DebugAabb2D | DebugCircle2D | DebugSegment2D | DebugPoint2D | DebugVector2D;
|
|
56
|
+
/** Project a world collider into a debug primitive, preserving its id. */
|
|
57
|
+
export declare function projectWorldCollider2D(world: WorldCollider2D): DebugAabb2D | DebugCircle2D;
|
|
58
|
+
/** Project a contact hit into its contact point and normal arrow. */
|
|
59
|
+
export declare function projectHit2D(hit: CollisionHit2D): {
|
|
60
|
+
readonly point: DebugPoint2D;
|
|
61
|
+
readonly normal: DebugVector2D;
|
|
62
|
+
};
|
|
63
|
+
/** Project a sweep path (start to end of the swept reference point). */
|
|
64
|
+
export declare function projectSweepPath2D(start: Point2D, end: Point2D, label?: string): DebugSegment2D;
|
|
65
|
+
/** Project a plain vector arrow (for example a velocity). */
|
|
66
|
+
export declare function projectVector2D(origin: Point2D, vector: Vector2D, label?: string): DebugVector2D;
|
|
67
|
+
//# sourceMappingURL=debug.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../../../src/collision2d/debug.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAmB,CAAC;AAE3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAa,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAa,CAAC;AAEnD,sCAAsC;AACtC,MAAM,WAAW,YAAY;IAC3B,gEAAgE;IAChE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,2DAA2D;IAC3D,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,kBAAkB;AAClB,MAAM,WAAW,WAAY,SAAQ,YAAY;IAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,oBAAoB;AACpB,MAAM,WAAW,aAAc,SAAQ,YAAY;IACjD,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,yCAAyC;AACzC,MAAM,WAAW,cAAe,SAAQ,YAAY;IAClD,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;CACvB;AAED,oCAAoC;AACpC,MAAM,WAAW,YAAa,SAAQ,YAAY;IAChD,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,oEAAoE;AACpE,MAAM,WAAW,aAAc,SAAQ,YAAY;IACjD,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAED,oCAAoC;AACpC,MAAM,MAAM,gBAAgB,GACxB,WAAW,GACX,aAAa,GACb,cAAc,GACd,YAAY,GACZ,aAAa,CAAC;AAElB,0EAA0E;AAC1E,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,eAAe,GAAG,WAAW,GAAG,aAAa,CAmB1F;AAED,qEAAqE;AACrE,wBAAgB,YAAY,CAAC,GAAG,EAAE,cAAc,GAAG;IACjD,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;CAChC,CAWA;AAED,wEAAwE;AACxE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,cAAc,CAS/F;AAED,6DAA6D;AAC7D,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,aAAa,CAWhG"}
|
|
@@ -0,0 +1,28 @@
|
|
|
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.js';
|
|
9
|
+
/** Two explicit unsigned 32-bit bit sets for collision eligibility. */
|
|
10
|
+
export interface CollisionFilter2D {
|
|
11
|
+
/** The bits this collider belongs to. */
|
|
12
|
+
readonly categoryBits: number;
|
|
13
|
+
/** The category bits this collider can collide with. */
|
|
14
|
+
readonly maskBits: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* True when the two filters allow a collision (symmetric check).
|
|
18
|
+
*
|
|
19
|
+
* Invalid (non-unsigned-32-bit) values throw `GeometryError` before any
|
|
20
|
+
* comparison; `false` never implies malformed input.
|
|
21
|
+
*/
|
|
22
|
+
export declare function canCollide2D(first: CollisionFilter2D, second: CollisionFilter2D): boolean;
|
|
23
|
+
/** A collider without a filter: eligible with everything. */
|
|
24
|
+
export declare const ALL_FILTER2D: CollisionFilter2D;
|
|
25
|
+
/** A collider that collides with nothing. */
|
|
26
|
+
export declare const NONE_FILTER2D: CollisionFilter2D;
|
|
27
|
+
export type { Vector2D };
|
|
28
|
+
//# sourceMappingURL=filters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../../../src/collision2d/filters.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAmB,CAAC;AAGlD,uEAAuE;AACvE,MAAM,WAAW,iBAAiB;IAChC,yCAAyC;IACzC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,iBAAiB,GAAG,OAAO,CASzF;AAED,6DAA6D;AAC7D,eAAO,MAAM,YAAY,EAAE,iBAGzB,CAAC;AAEH,6CAA6C;AAC7C,eAAO,MAAM,aAAa,EAAE,iBAG1B,CAAC;AAEH,YAAY,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type { CollisionHit2D } from './manifolds.js';
|
|
2
|
+
export { RESOLUTION_TOLERANCE } from './manifolds.js';
|
|
3
|
+
export { collideAabbAabb2D, collideCircleAabb2D, collideCircleCircle2D, } from './manifolds.js';
|
|
4
|
+
export { closestPointOnAabb2D, intersectsAabbAabb2D, intersectsCircleAabb2D, intersectsCircleCircle2D, pointInAabb2D, pointInCircle2D, } from './intersections.js';
|
|
5
|
+
export type { SegmentHit2D } from './segments.js';
|
|
6
|
+
export { intersectSegmentAabb2D, intersectSegmentCircle2D, } from './segments.js';
|
|
7
|
+
export type { SweepAabbAabb2DOptions, SweepCircleAabb2DOptions, SweepHit2D, } from './sweeps.js';
|
|
8
|
+
export { sweepAabbAabb2D, sweepCircleAabb2D, } from './sweeps.js';
|
|
9
|
+
export type { CollisionFilter2D } from './filters.js';
|
|
10
|
+
export { ALL_FILTER2D, canCollide2D, NONE_FILTER2D, } from './filters.js';
|
|
11
|
+
export type { CircleCollider2DOptions, ColliderMetadata2D, LocalAabbCollider2D, LocalCircleCollider2D, LocalCollider2D, RectangleCollider2DOptions, WorldAabbCollider2D, WorldCircleCollider2D, WorldCollider2D, } from './colliders.js';
|
|
12
|
+
export { circleCollider2D, collideWorldColliders2D, placeCollider2D, rectangleCollider2D, worldColliderBounds2D, worldColliderCircle2D, } from './colliders.js';
|
|
13
|
+
export type { BuildSpatialHash2DOptions, SpatialHashIndex2D, SpatialHashItem2D } from './spatialHash.js';
|
|
14
|
+
export { buildSpatialHash2D, querySpatialHash2D, } from './spatialHash.js';
|
|
15
|
+
export type { DebugAabb2D, DebugCircle2D, DebugPoint2D, DebugPrimitive2D, DebugSegment2D, DebugStyle2D, DebugVector2D, } from './debug.js';
|
|
16
|
+
export { projectHit2D, projectSweepPath2D, projectVector2D, projectWorldCollider2D, } from './debug.js';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/collision2d/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAa,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAa,CAAC;AACnD,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,gBAAa,CAAC;AACrB,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,aAAa,EACb,eAAe,GAChB,MAAM,oBAAiB,CAAC;AACzB,YAAY,EAAE,YAAY,EAAE,MAAM,eAAY,CAAC;AAC/C,OAAO,EACL,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,eAAY,CAAC;AACpB,YAAY,EACV,sBAAsB,EACtB,wBAAwB,EACxB,UAAU,GACX,MAAM,aAAU,CAAC;AAClB,OAAO,EACL,eAAe,EACf,iBAAiB,GAClB,MAAM,aAAU,CAAC;AAClB,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAW,CAAC;AACnD,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,aAAa,GACd,MAAM,cAAW,CAAC;AACnB,YAAY,EACV,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,0BAA0B,EAC1B,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,GAChB,MAAM,gBAAa,CAAC;AACrB,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,gBAAa,CAAC;AACrB,YAAY,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,kBAAe,CAAC;AACtG,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,kBAAe,CAAC;AACvB,YAAY,EACV,WAAW,EACX,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,aAAa,GACd,MAAM,YAAS,CAAC;AACjB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,sBAAsB,GACvB,MAAM,YAAS,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
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.js';
|
|
9
|
+
/** True when `point` lies in or on `aabb` (boundary inclusive). */
|
|
10
|
+
export declare function pointInAabb2D(point: Point2D, aabb: Aabb2D): boolean;
|
|
11
|
+
/** True when `point` lies in or on `circle` (boundary inclusive). */
|
|
12
|
+
export declare function pointInCircle2D(point: Point2D, circle: Circle2D): boolean;
|
|
13
|
+
/** True when the two AABBs intersect or touch. */
|
|
14
|
+
export declare function intersectsAabbAabb2D(first: Aabb2D, second: Aabb2D): boolean;
|
|
15
|
+
/** True when the two circles intersect or touch. */
|
|
16
|
+
export declare function intersectsCircleCircle2D(first: Circle2D, second: Circle2D): boolean;
|
|
17
|
+
/** True when the circle intersects or touches the AABB. */
|
|
18
|
+
export declare function intersectsCircleAabb2D(circle: Circle2D, aabb: Aabb2D): boolean;
|
|
19
|
+
/** Closest point on the AABB to the circle center (shared by manifold code). */
|
|
20
|
+
export declare function closestPointOnAabb2D(point: Point2D, aabb: Aabb2D): {
|
|
21
|
+
readonly x: number;
|
|
22
|
+
readonly y: number;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=intersections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intersections.d.ts","sourceRoot":"","sources":["../../../../src/collision2d/intersections.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,sBAAmB,CAAC;AAOnE,mEAAmE;AACnE,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CASnE;AAED,qEAAqE;AACrE,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,GAAG,OAAO,CAMzE;AAED,kDAAkD;AAClD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAS3E;AAED,oDAAoD;AACpD,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAG,OAAO,CAOnF;AAED,2DAA2D;AAC3D,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAQ9E;AAED,gFAAgF;AAChF,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,MAAM,GACX;IAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAK5C"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contact manifolds (T11.2).
|
|
3
|
+
*
|
|
4
|
+
* A `CollisionHit2D` reports geometry only: the normal that moves the FIRST
|
|
5
|
+
* argument out of the SECOND, the nonnegative penetration depth, and a
|
|
6
|
+
* stable contact point. Applying `first += normal * depth` resolves an
|
|
7
|
+
* ordinary overlap within documented floating-point tolerance. Misses
|
|
8
|
+
* return `undefined` and allocate nothing.
|
|
9
|
+
*
|
|
10
|
+
* Conventions (locked in T11.0):
|
|
11
|
+
* - Boundary contact counts as intersection and may return a zero-depth hit.
|
|
12
|
+
* - Circle-AABB: the contact point is the closest point on the AABB to the
|
|
13
|
+
* circle center; when the center is inside the AABB, the minimum
|
|
14
|
+
* penetration face wins with ties in the order left, top, right, bottom.
|
|
15
|
+
* - Circle-circle: the contact point is on the first circle's boundary
|
|
16
|
+
* toward the second; coincident centers use the fallback normal `(0, 1)`
|
|
17
|
+
* (straight up the positive-y axis) with full overlap depth `r1 + r2`.
|
|
18
|
+
* - AABB-AABB: the contact point is the center of the overlap rectangle;
|
|
19
|
+
* exact corner ties use the normal `(0, 1)`.
|
|
20
|
+
*/
|
|
21
|
+
import type { Aabb2D, Circle2D, Point2D, Vector2D } from '../geometry/types.js';
|
|
22
|
+
/** One contact between two shapes, in the first shape's local resolution. */
|
|
23
|
+
export interface CollisionHit2D {
|
|
24
|
+
/** Unit normal moving the first argument out of the second. */
|
|
25
|
+
readonly normal: Vector2D;
|
|
26
|
+
/** Nonnegative penetration depth in logical world units. */
|
|
27
|
+
readonly depth: number;
|
|
28
|
+
/** Stable contact point in world coordinates. */
|
|
29
|
+
readonly point: Point2D;
|
|
30
|
+
}
|
|
31
|
+
/** Resolution tolerance used by tests: relative to the shape size. */
|
|
32
|
+
export declare const RESOLUTION_TOLERANCE = 1e-9;
|
|
33
|
+
/** AABB-AABB contact manifold. `undefined` when the shapes do not touch. */
|
|
34
|
+
export declare function collideAabbAabb2D(first: Aabb2D, second: Aabb2D): CollisionHit2D | undefined;
|
|
35
|
+
/** Circle-circle contact manifold. `undefined` when the circles do not touch. */
|
|
36
|
+
export declare function collideCircleCircle2D(first: Circle2D, second: Circle2D): CollisionHit2D | undefined;
|
|
37
|
+
/** Circle-AABB contact manifold. `undefined` when they do not touch. */
|
|
38
|
+
export declare function collideCircleAabb2D(circle: Circle2D, aabb: Aabb2D): CollisionHit2D | undefined;
|
|
39
|
+
//# sourceMappingURL=manifolds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifolds.d.ts","sourceRoot":"","sources":["../../../../src/collision2d/manifolds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAmB,CAAC;AAO7E,6EAA6E;AAC7E,MAAM,WAAW,cAAc;IAC7B,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,4DAA4D;IAC5D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,iDAAiD;IACjD,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED,sEAAsE;AACtE,eAAO,MAAM,oBAAoB,OAAO,CAAC;AAEzC,4EAA4E;AAC5E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CA+C3F;AAED,iFAAiF;AACjF,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,QAAQ,GACf,cAAc,GAAG,SAAS,CAqC5B;AAED,wEAAwE;AACxE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAwD9F"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Segment queries (T11.3).
|
|
3
|
+
*
|
|
4
|
+
* Return the earliest crossing of a directed segment with a shape, with
|
|
5
|
+
* `time` in `[0, 1]`. A segment starting inside a shape returns `time: 0`
|
|
6
|
+
* with the deterministic nearest-face normal (same tie rule as the
|
|
7
|
+
* manifolds: left, top, right, bottom for AABBs; the outward radial
|
|
8
|
+
* direction for circles with the `(0, 1)` fallback at the center).
|
|
9
|
+
*/
|
|
10
|
+
import type { Aabb2D, Circle2D, Point2D, Segment2D, Vector2D } from '../geometry/types.js';
|
|
11
|
+
/** Earliest segment crossing of a shape. */
|
|
12
|
+
export interface SegmentHit2D {
|
|
13
|
+
/** Normalized crossing time in `[0, 1]`. */
|
|
14
|
+
readonly time: number;
|
|
15
|
+
/** Unit normal at the crossed boundary (nearest-face rule inside). */
|
|
16
|
+
readonly normal: Vector2D;
|
|
17
|
+
/** Crossing point in world coordinates. */
|
|
18
|
+
readonly point: Point2D;
|
|
19
|
+
}
|
|
20
|
+
/** Earliest crossing of a segment with an AABB (slab method). */
|
|
21
|
+
export declare function intersectSegmentAabb2D(segment: Segment2D, aabb: Aabb2D): SegmentHit2D | undefined;
|
|
22
|
+
/** Earliest crossing of a segment with a circle. */
|
|
23
|
+
export declare function intersectSegmentCircle2D(segment: Segment2D, circle: Circle2D): SegmentHit2D | undefined;
|
|
24
|
+
//# sourceMappingURL=segments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"segments.d.ts","sourceRoot":"","sources":["../../../../src/collision2d/segments.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,sBAAmB,CAAC;AAQxF,4CAA4C;AAC5C,MAAM,WAAW,YAAY;IAC3B,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,sEAAsE;IACtE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,2CAA2C;IAC3C,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED,iEAAiE;AACjE,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAgEjG;AA0BD,oDAAoD;AACpD,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,SAAS,EAClB,MAAM,EAAE,QAAQ,GACf,YAAY,GAAG,SAAS,CAqD1B"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic spatial hash broad phase (T11.5).
|
|
3
|
+
*
|
|
4
|
+
* `buildSpatialHash2D` validates and freezes a plain immutable index value;
|
|
5
|
+
* the per-cell buckets live in an internal WeakMap so callers can never
|
|
6
|
+
* mutate or depend on them. `querySpatialHash2D` visits only the query's
|
|
7
|
+
* cells and returns candidate ids deduplicated and in original insertion
|
|
8
|
+
* order. The broad phase is conservative: it returns candidates, never a
|
|
9
|
+
* narrow-phase collision claim.
|
|
10
|
+
*/
|
|
11
|
+
import type { Aabb2D } from '../geometry/types.js';
|
|
12
|
+
/** One indexed item with a stable identifier and AABB bounds. */
|
|
13
|
+
export interface SpatialHashItem2D {
|
|
14
|
+
/** Stable identifier; must be unique within one index. */
|
|
15
|
+
readonly id: string;
|
|
16
|
+
/** AABB bounds in world coordinates. */
|
|
17
|
+
readonly bounds: Aabb2D;
|
|
18
|
+
}
|
|
19
|
+
/** A frozen, immutable spatial-hash index. */
|
|
20
|
+
export interface SpatialHashIndex2D {
|
|
21
|
+
/** Positive finite cell size in world units. */
|
|
22
|
+
readonly cellSize: number;
|
|
23
|
+
/** The ordered items, deduplicated by identifier. */
|
|
24
|
+
readonly items: readonly SpatialHashItem2D[];
|
|
25
|
+
}
|
|
26
|
+
/** Options for building an index. */
|
|
27
|
+
export interface BuildSpatialHash2DOptions {
|
|
28
|
+
/** Items to index, in the order candidates must be returned. */
|
|
29
|
+
readonly items: readonly SpatialHashItem2D[];
|
|
30
|
+
/** Positive finite cell size in world units. */
|
|
31
|
+
readonly cellSize: number;
|
|
32
|
+
}
|
|
33
|
+
/** Maximum cells an item or query may OCCUPY per axis (bounded execution). */
|
|
34
|
+
export declare const MAX_SPATIAL_HASH_SPAN_CELLS = 1024;
|
|
35
|
+
/**
|
|
36
|
+
* Maximum cells visited by ONE item insert or ONE query (GS-COLLISION-02).
|
|
37
|
+
*
|
|
38
|
+
* The per-axis bound alone permits ~1M cell visits per operation (~38ms
|
|
39
|
+
* on desktop V8, multiples of that on mobile). The total budget fails
|
|
40
|
+
* clearly before such spans do any work. Ordinary game spans (a few
|
|
41
|
+
* hundred cells per axis at most) pass with wide headroom; aggregate build
|
|
42
|
+
* cost still scales with item count, so prefer an appropriate cell size
|
|
43
|
+
* and reuse static indexes instead of rebuilding per dynamic body per tick.
|
|
44
|
+
*/
|
|
45
|
+
export declare const MAX_SPATIAL_HASH_TOTAL_CELLS = 65536;
|
|
46
|
+
/** Build a spatial-hash index over the given items. */
|
|
47
|
+
export declare function buildSpatialHash2D(options: BuildSpatialHash2DOptions): SpatialHashIndex2D;
|
|
48
|
+
/** Query candidates whose bounds share a cell with the query bounds. */
|
|
49
|
+
export declare function querySpatialHash2D(index: SpatialHashIndex2D, bounds: Aabb2D): readonly string[];
|
|
50
|
+
//# sourceMappingURL=spatialHash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spatialHash.d.ts","sourceRoot":"","sources":["../../../../src/collision2d/spatialHash.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAmB,CAAC;AAMhD,iEAAiE;AACjE,MAAM,WAAW,iBAAiB;IAChC,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,8CAA8C;AAC9C,MAAM,WAAW,kBAAkB;IACjC,gDAAgD;IAChD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,qDAAqD;IACrD,QAAQ,CAAC,KAAK,EAAE,SAAS,iBAAiB,EAAE,CAAC;CAC9C;AAED,qCAAqC;AACrC,MAAM,WAAW,yBAAyB;IACxC,gEAAgE;IAChE,QAAQ,CAAC,KAAK,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC7C,gDAAgD;IAChD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,8EAA8E;AAC9E,eAAO,MAAM,2BAA2B,OAAO,CAAC;AAEhD;;;;;;;;;GASG;AACH,eAAO,MAAM,4BAA4B,QAAS,CAAC;AAQnD,uDAAuD;AACvD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,kBAAkB,CAqDzF;AAED,wEAAwE;AACxE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CA6B/F"}
|