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,308 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useContext, useMemo } from 'react';
|
|
4
|
+
import { Atlas, Picture, Skia } from '@shopify/react-native-skia';
|
|
5
|
+
import { useColorBuffer, useRectBuffer, useRSXformBuffer } from '@shopify/react-native-skia';
|
|
6
|
+
import { useDerivedValue } from 'react-native-reanimated';
|
|
7
|
+
import { GameWorldContext } from "../sprites/GameWorld2D.js";
|
|
8
|
+
import { PARTICLE_CULL_PADDING, cameraVisibleWorldBounds, maxParticleExtent, screenVisibleBounds, viewportWorldBounds, visibleInBounds } from "./culling.js";
|
|
9
|
+
import { assertUniformParticleSpriteRatio, particleSpriteXform } from "./spriteXForm.js";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
/**
|
|
12
|
+
* Presentation-only particle renderer.
|
|
13
|
+
*
|
|
14
|
+
* Topology is CONSTANT per effect regardless of capacity (T15-RF5): exactly
|
|
15
|
+
* one React node (`Picture` for shapes, `Atlas` for sprites) plus a single
|
|
16
|
+
* UI-runtime derived worklet that walks the effect's emission records and
|
|
17
|
+
* computes analytic transforms from the scalar active-time clock. No per-slot
|
|
18
|
+
* data crosses the runtime boundary per frame (T15-SF1).
|
|
19
|
+
*
|
|
20
|
+
* Coordinate ownership (GS-PARTICLE-02): `space: 'world'` effects sample in
|
|
21
|
+
* world units and must mount inside world space (no parent transform);
|
|
22
|
+
* `space: 'screen'` effects sample in surface pixels and must mount inside
|
|
23
|
+
* screen space. World culling uses the presented camera when one exists
|
|
24
|
+
* and the resolved viewport bounds otherwise; zoom applies through the
|
|
25
|
+
* camera, and there is no parallax factor on particles by design.
|
|
26
|
+
*/
|
|
27
|
+
export function ParticleView({
|
|
28
|
+
system,
|
|
29
|
+
effect,
|
|
30
|
+
width,
|
|
31
|
+
height,
|
|
32
|
+
presentation,
|
|
33
|
+
spriteSource
|
|
34
|
+
}) {
|
|
35
|
+
const definition = useMemo(() => system.bindPresentation().definition(effect), [system, effect]);
|
|
36
|
+
// GS-PARTICLE-02: conservative cull extent from authored geometry and
|
|
37
|
+
// scale endpoints (bounding radius, rotation-proof); overscan stays in
|
|
38
|
+
// the bounds padding, never in this extent.
|
|
39
|
+
const cullExtent = useMemo(() => maxParticleExtent(definition), [definition]);
|
|
40
|
+
const world = useContext(GameWorldContext);
|
|
41
|
+
const camera = world?.camera ?? null;
|
|
42
|
+
const viewport = world?.viewport ?? null;
|
|
43
|
+
if (definition.particle.kind === 'sprite') {
|
|
44
|
+
if (spriteSource === undefined) {
|
|
45
|
+
throw new Error(`[rn-gamekit/particles] effect "${effect}" declares kind "sprite" but no spriteSource was provided — resolve the sheet via the asset store before rendering`);
|
|
46
|
+
}
|
|
47
|
+
assertUniformParticleSpriteRatio(definition.particle.size.width, definition.particle.size.height, spriteSource.frame.width, spriteSource.frame.height);
|
|
48
|
+
return /*#__PURE__*/_jsx(SpriteSlots, {
|
|
49
|
+
clock: presentation.clock,
|
|
50
|
+
registry: presentation.registry,
|
|
51
|
+
effect: effect,
|
|
52
|
+
capacity: definition.capacity,
|
|
53
|
+
image: spriteSource.image,
|
|
54
|
+
frameRect: spriteSource.frame,
|
|
55
|
+
drawWidth: definition.particle.size.width,
|
|
56
|
+
drawHeight: definition.particle.size.height,
|
|
57
|
+
cullExtent: cullExtent,
|
|
58
|
+
fadeOut: definition.fadeOut,
|
|
59
|
+
gravityX: definition.gravity.x,
|
|
60
|
+
gravityY: definition.gravity.y,
|
|
61
|
+
width: width,
|
|
62
|
+
height: height,
|
|
63
|
+
space: definition.space,
|
|
64
|
+
camera: camera,
|
|
65
|
+
viewport: viewport
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return /*#__PURE__*/_jsx(ShapeBatch, {
|
|
69
|
+
clock: presentation.clock,
|
|
70
|
+
registry: presentation.registry,
|
|
71
|
+
effect: effect,
|
|
72
|
+
capacity: definition.capacity,
|
|
73
|
+
shape: definition.particle.shape === 'rectangle' ? 'rect' : 'circle',
|
|
74
|
+
radius: definition.particle.radius ?? 3,
|
|
75
|
+
rectWidth: definition.particle.width ?? 6,
|
|
76
|
+
rectHeight: definition.particle.height ?? 6,
|
|
77
|
+
cullExtent: cullExtent,
|
|
78
|
+
color: definition.particle.color ?? '#ffffff',
|
|
79
|
+
fadeOut: definition.fadeOut,
|
|
80
|
+
gravityX: definition.gravity.x,
|
|
81
|
+
gravityY: definition.gravity.y,
|
|
82
|
+
width: width,
|
|
83
|
+
height: height,
|
|
84
|
+
space: definition.space,
|
|
85
|
+
camera: camera,
|
|
86
|
+
viewport: viewport
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Analytic transform for one emission at the given ACTIVE time.
|
|
92
|
+
*
|
|
93
|
+
* T15-TF3: opacity honors the definition's fade policy — `fadeOut: true`
|
|
94
|
+
* ramps `1 -> t`, `fadeOut: false` stays fully opaque for the whole life.
|
|
95
|
+
*/
|
|
96
|
+
export function sampleEmission(e, now, gravityX, gravityY, fadeOut) {
|
|
97
|
+
'worklet';
|
|
98
|
+
|
|
99
|
+
const age = now - e.bornAt;
|
|
100
|
+
if (age < 0 || age >= e.lifetime) {
|
|
101
|
+
return {
|
|
102
|
+
x: 0,
|
|
103
|
+
y: 0,
|
|
104
|
+
rotation: 0,
|
|
105
|
+
scale: 0,
|
|
106
|
+
opacity: 0,
|
|
107
|
+
alive: false
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
const t = age / e.lifetime;
|
|
111
|
+
const x = e.originX + e.vx * age + 0.5 * gravityX * age * age;
|
|
112
|
+
const y = e.originY + e.vy * age + 0.5 * gravityY * age * age;
|
|
113
|
+
const rotation = e.rotation + e.rotationSpeed * age;
|
|
114
|
+
// T20A-R1: definitions guarantee non-negative scale. The clamp keeps any
|
|
115
|
+
// legacy negative `scaleOverLife` value DEFINED (collapse to a point)
|
|
116
|
+
// instead of handing Skia a signed radius or rectangle extent.
|
|
117
|
+
const scale = Math.max(0, e.scaleStart + (e.scaleEnd - e.scaleStart) * t);
|
|
118
|
+
const opacity = fadeOut ? 1 - t : 1;
|
|
119
|
+
return {
|
|
120
|
+
x,
|
|
121
|
+
y,
|
|
122
|
+
rotation,
|
|
123
|
+
scale,
|
|
124
|
+
opacity,
|
|
125
|
+
alive: true
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// ---------------------------------------------------------------------------
|
|
130
|
+
// Shapes: ONE immediate Picture built in ONE worklet per effect (T15-RF5).
|
|
131
|
+
// ---------------------------------------------------------------------------
|
|
132
|
+
|
|
133
|
+
function ShapeBatch(props) {
|
|
134
|
+
const {
|
|
135
|
+
clock,
|
|
136
|
+
registry,
|
|
137
|
+
effect,
|
|
138
|
+
capacity,
|
|
139
|
+
shape,
|
|
140
|
+
radius,
|
|
141
|
+
rectWidth,
|
|
142
|
+
rectHeight,
|
|
143
|
+
color,
|
|
144
|
+
fadeOut,
|
|
145
|
+
gravityX,
|
|
146
|
+
gravityY,
|
|
147
|
+
width,
|
|
148
|
+
height,
|
|
149
|
+
space,
|
|
150
|
+
cullExtent,
|
|
151
|
+
camera,
|
|
152
|
+
viewport
|
|
153
|
+
} = props;
|
|
154
|
+
const picture = useDerivedValue(() => {
|
|
155
|
+
'worklet';
|
|
156
|
+
|
|
157
|
+
const reg = registry.value;
|
|
158
|
+
const entry = reg.effects[effect];
|
|
159
|
+
const now = clock.value;
|
|
160
|
+
// Culling bounds computed ONCE per revision. World space without a
|
|
161
|
+
// presented camera falls back to the resolved viewport bounds (never
|
|
162
|
+
// fail-closed hide); the particle extent keeps crossings visible.
|
|
163
|
+
const bounds = space === 'world' ? camera?.value?.camera === undefined ? viewportWorldBounds(viewport, PARTICLE_CULL_PADDING) : cameraVisibleWorldBounds(camera, viewport, PARTICLE_CULL_PADDING) : screenVisibleBounds(width, height, PARTICLE_CULL_PADDING);
|
|
164
|
+
const recorder = Skia.PictureRecorder();
|
|
165
|
+
const canvas = recorder.beginRecording();
|
|
166
|
+
if (entry === undefined) return recorder.finishRecordingAsPicture();
|
|
167
|
+
const paint = Skia.Paint();
|
|
168
|
+
paint.setColor(Skia.Color(color));
|
|
169
|
+
const particles = entry.particles;
|
|
170
|
+
for (let i = 0; i < particles.length && i < capacity; i++) {
|
|
171
|
+
const e = particles[i];
|
|
172
|
+
const s = sampleEmission(e, now, gravityX, gravityY, fadeOut);
|
|
173
|
+
if (!s.alive || s.opacity <= 0) continue;
|
|
174
|
+
if (!visibleInBounds(s.x, s.y, cullExtent, bounds)) continue;
|
|
175
|
+
paint.setAlphaf(Math.max(0, Math.min(1, s.opacity)));
|
|
176
|
+
if (shape === 'circle') {
|
|
177
|
+
canvas.drawCircle(s.x, s.y, radius * s.scale, paint);
|
|
178
|
+
} else {
|
|
179
|
+
const w = rectWidth * s.scale;
|
|
180
|
+
const h = rectHeight * s.scale;
|
|
181
|
+
const matrix = Skia.Matrix().translate(s.x, s.y).rotate(s.rotation);
|
|
182
|
+
canvas.save();
|
|
183
|
+
canvas.concat(matrix);
|
|
184
|
+
canvas.drawRect({
|
|
185
|
+
x: -w / 2,
|
|
186
|
+
y: -h / 2,
|
|
187
|
+
width: w,
|
|
188
|
+
height: h
|
|
189
|
+
}, paint);
|
|
190
|
+
canvas.restore();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return recorder.finishRecordingAsPicture();
|
|
194
|
+
});
|
|
195
|
+
return /*#__PURE__*/_jsx(Picture, {
|
|
196
|
+
picture: picture
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// ---------------------------------------------------------------------------
|
|
201
|
+
// Sprites: fixed-capacity Atlas buffers filled by ONE worklet (T15-F3/R4/SF2).
|
|
202
|
+
// ---------------------------------------------------------------------------
|
|
203
|
+
|
|
204
|
+
function SpriteSlots(props) {
|
|
205
|
+
const {
|
|
206
|
+
clock,
|
|
207
|
+
registry,
|
|
208
|
+
effect,
|
|
209
|
+
capacity,
|
|
210
|
+
image,
|
|
211
|
+
frameRect,
|
|
212
|
+
drawWidth,
|
|
213
|
+
drawHeight,
|
|
214
|
+
fadeOut,
|
|
215
|
+
gravityX,
|
|
216
|
+
gravityY,
|
|
217
|
+
width,
|
|
218
|
+
height,
|
|
219
|
+
space,
|
|
220
|
+
cullExtent,
|
|
221
|
+
camera,
|
|
222
|
+
viewport
|
|
223
|
+
} = props;
|
|
224
|
+
|
|
225
|
+
// UI-owned buffers created once per mount (T15-SF1). Colors use the
|
|
226
|
+
// supported Skia color buffer (T15-TF3): each entry is an SkColor
|
|
227
|
+
// Float32Array [r,g,b,a] mutated on the UI runtime.
|
|
228
|
+
const rects = useRectBuffer(capacity, rect => {
|
|
229
|
+
'worklet';
|
|
230
|
+
|
|
231
|
+
rect.setXYWH(0, 0, 0, 0);
|
|
232
|
+
});
|
|
233
|
+
const xforms = useRSXformBuffer(capacity, xform => {
|
|
234
|
+
'worklet';
|
|
235
|
+
|
|
236
|
+
xform.set(1, 0, 0, 0);
|
|
237
|
+
});
|
|
238
|
+
const colors = useColorBuffer(capacity, color => {
|
|
239
|
+
'worklet';
|
|
240
|
+
|
|
241
|
+
color[0] = 1;
|
|
242
|
+
color[1] = 1;
|
|
243
|
+
color[2] = 1;
|
|
244
|
+
color[3] = 0;
|
|
245
|
+
});
|
|
246
|
+
useDerivedValue(() => {
|
|
247
|
+
'worklet';
|
|
248
|
+
|
|
249
|
+
const reg = registry.value;
|
|
250
|
+
const entry = reg.effects[effect];
|
|
251
|
+
const now = clock.value;
|
|
252
|
+
const bounds = space === 'world' ? camera?.value?.camera === undefined ? viewportWorldBounds(viewport, PARTICLE_CULL_PADDING) : cameraVisibleWorldBounds(camera, viewport, PARTICLE_CULL_PADDING) : screenVisibleBounds(width, height, PARTICLE_CULL_PADDING);
|
|
253
|
+
for (let i = 0; i < capacity; i++) {
|
|
254
|
+
const rectSlot = rects.value[i];
|
|
255
|
+
const xformSlot = xforms.value[i];
|
|
256
|
+
const colorSlot = colors.value[i];
|
|
257
|
+
if (rectSlot === undefined || xformSlot === undefined || colorSlot === undefined) continue;
|
|
258
|
+
let placed = false;
|
|
259
|
+
if (entry !== undefined && i < entry.particles.length) {
|
|
260
|
+
const e = entry.particles[i];
|
|
261
|
+
const age = now - e.bornAt;
|
|
262
|
+
if (age >= 0 && age < e.lifetime) {
|
|
263
|
+
const t = age / e.lifetime;
|
|
264
|
+
const x = e.originX + e.vx * age + 0.5 * gravityX * age * age;
|
|
265
|
+
const y = e.originY + e.vy * age + 0.5 * gravityY * age * age;
|
|
266
|
+
if (visibleInBounds(x, y, cullExtent, bounds)) {
|
|
267
|
+
const op = fadeOut ? 1 - t : 1;
|
|
268
|
+
const xf = particleSpriteXform({
|
|
269
|
+
x,
|
|
270
|
+
y,
|
|
271
|
+
rotation: e.rotation + e.rotationSpeed * age,
|
|
272
|
+
// T20A-R1: non-negative clamp — see the shape sampler note.
|
|
273
|
+
scale: Math.max(0, e.scaleStart + (e.scaleEnd - e.scaleStart) * t),
|
|
274
|
+
drawWidth,
|
|
275
|
+
drawHeight,
|
|
276
|
+
frameWidth: frameRect.width,
|
|
277
|
+
frameHeight: frameRect.height
|
|
278
|
+
});
|
|
279
|
+
rectSlot.setXYWH(frameRect.x, frameRect.y, frameRect.width, frameRect.height);
|
|
280
|
+
xformSlot.set(xf.scos, xf.ssin, xf.tx, xf.ty);
|
|
281
|
+
// White modulates the texture; alpha carries sampled fade.
|
|
282
|
+
colorSlot[0] = 1;
|
|
283
|
+
colorSlot[1] = 1;
|
|
284
|
+
colorSlot[2] = 1;
|
|
285
|
+
colorSlot[3] = Math.max(0, Math.min(1, op));
|
|
286
|
+
placed = true;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
if (!placed) {
|
|
291
|
+
// Hide inactive/culled slots AND clear stale alpha (T15-SF2).
|
|
292
|
+
rectSlot.setXYWH(0, 0, 0, 0);
|
|
293
|
+
colorSlot[0] = 1;
|
|
294
|
+
colorSlot[1] = 1;
|
|
295
|
+
colorSlot[2] = 1;
|
|
296
|
+
colorSlot[3] = 0;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return colors;
|
|
300
|
+
});
|
|
301
|
+
return /*#__PURE__*/_jsx(Atlas, {
|
|
302
|
+
image: image,
|
|
303
|
+
sprites: rects,
|
|
304
|
+
transforms: xforms,
|
|
305
|
+
colors: colors
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
//# sourceMappingURL=ParticleView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useContext","useMemo","Atlas","Picture","Skia","useColorBuffer","useRectBuffer","useRSXformBuffer","useDerivedValue","GameWorldContext","PARTICLE_CULL_PADDING","cameraVisibleWorldBounds","maxParticleExtent","screenVisibleBounds","viewportWorldBounds","visibleInBounds","assertUniformParticleSpriteRatio","particleSpriteXform","jsx","_jsx","ParticleView","system","effect","width","height","presentation","spriteSource","definition","bindPresentation","cullExtent","world","camera","viewport","particle","kind","undefined","Error","size","frame","SpriteSlots","clock","registry","capacity","image","frameRect","drawWidth","drawHeight","fadeOut","gravityX","gravity","x","gravityY","y","space","ShapeBatch","shape","radius","rectWidth","rectHeight","color","sampleEmission","e","now","age","bornAt","lifetime","rotation","scale","opacity","alive","t","originX","vx","originY","vy","rotationSpeed","Math","max","scaleStart","scaleEnd","props","picture","reg","value","entry","effects","bounds","recorder","PictureRecorder","canvas","beginRecording","finishRecordingAsPicture","paint","Paint","setColor","Color","particles","i","length","s","setAlphaf","min","drawCircle","w","h","matrix","Matrix","translate","rotate","save","concat","drawRect","restore","rects","rect","setXYWH","xforms","xform","set","colors","rectSlot","xformSlot","colorSlot","placed","op","xf","frameWidth","frameHeight","scos","ssin","tx","ty","sprites","transforms"],"sourceRoot":"../../../../src","sources":["react/particles/ParticleView.tsx"],"mappings":";;AAAA,SAASA,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAC3C,SAASC,KAAK,EAAEC,OAAO,EAAEC,IAAI,QAAQ,4BAA4B;AACjE,SAASC,cAAc,EAAEC,aAAa,EAAEC,gBAAgB,QAAQ,4BAA4B;AAC5F,SAASC,eAAe,QAA0B,yBAAyB;AAG3E,SAASC,gBAAgB,QAAQ,2BAAwB;AAQzD,SACEC,qBAAqB,EACrBC,wBAAwB,EACxBC,iBAAiB,EACjBC,mBAAmB,EACnBC,mBAAmB,EACnBC,eAAe,QACV,cAAW;AAClB,SAASC,gCAAgC,EAAEC,mBAAmB,QAAQ,kBAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA;AA4BtF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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AAQ,CAACL,OAAO,CAACvE,SAAS,CAACM,CAAC,EAAEN,SAAS,CAACQ,CAAC,EAAER,SAAS,CAACrB,KAAK,EAAEqB,SAAS,CAACpB,MAAM,CAAC;YAC7EiG,SAAS,CAACH,GAAG,CAACO,EAAE,CAACG,IAAI,EAAEH,EAAE,CAACI,IAAI,EAAEJ,EAAE,CAACK,EAAE,EAAEL,EAAE,CAACM,EAAE,CAAC;YAC7C;YACAT,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC;YAChBA,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC;YAChBA,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC;YAChBA,SAAS,CAAC,CAAC,CAAC,GAAG9C,IAAI,CAACC,GAAG,CAAC,CAAC,EAAED,IAAI,CAACyB,GAAG,CAAC,CAAC,EAAEuB,EAAE,CAAC,CAAC;YAC3CD,MAAM,GAAG,IAAI;UACf;QACF;MACF;MACA,IAAI,CAACA,MAAM,EAAE;QACX;QACAH,QAAQ,CAACL,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAC5BO,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC;QAChBA,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC;QAChBA,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC;QAChBA,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC;MAClB;IACF;IACA,OAAOH,MAAM;EACf,CAAC,CAAC;EAEF,oBAAOpG,IAAA,CAACjB,KAAK;IAACyC,KAAK,EAAEA,KAAM;IAACyF,OAAO,EAAEnB,KAAM;IAACoB,UAAU,EAAEjB,MAAO;IAACG,MAAM,EAAEA;EAAO,CAAE,CAAC;AACpF","ignoreList":[]}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/** Conservative world-space AABB used for presentation-only culling. */
|
|
4
|
+
import { rotatedHalfExtents2D } from "../../camera2d/extents.js";
|
|
5
|
+
export const PARTICLE_CULL_PADDING = 16;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The world region visible through the PRESENTED camera (T15-RF2).
|
|
9
|
+
*
|
|
10
|
+
* The logical viewport rectangle is rotated/zoomed by the camera, so its
|
|
11
|
+
* axis-aligned world bounds are the center plus the rotated half-extents:
|
|
12
|
+
*
|
|
13
|
+
* ex = |hx·cosθ| + |hy·sinθ|, ey = |hx·sinθ| + |hy·cosθ|
|
|
14
|
+
*
|
|
15
|
+
* which is the exact AABB of the rotated view rect. Padding is applied in
|
|
16
|
+
* world units. Worklet-safe; shared by the shape Picture and Atlas paths so
|
|
17
|
+
* their culling results cannot diverge.
|
|
18
|
+
*/
|
|
19
|
+
export function cameraVisibleWorldBounds(camera, viewport, pad) {
|
|
20
|
+
'worklet';
|
|
21
|
+
|
|
22
|
+
if (camera === null || viewport === null) return undefined;
|
|
23
|
+
const view = viewport.value?.visibleLogicalBounds;
|
|
24
|
+
const cam = camera.value?.camera;
|
|
25
|
+
if (view === undefined || cam === undefined) return undefined;
|
|
26
|
+
const hx = view.width / (2 * cam.zoom);
|
|
27
|
+
const hy = view.height / (2 * cam.zoom);
|
|
28
|
+
const extent = rotatedHalfExtents2D(hx, hy, cam.rotationRadians);
|
|
29
|
+
const ex = extent.x + pad;
|
|
30
|
+
const ey = extent.y + pad;
|
|
31
|
+
return {
|
|
32
|
+
minX: cam.center.x - ex,
|
|
33
|
+
minY: cam.center.y - ey,
|
|
34
|
+
maxX: cam.center.x + ex,
|
|
35
|
+
maxY: cam.center.y + ey
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export function screenVisibleBounds(width, height, pad) {
|
|
39
|
+
'worklet';
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
minX: -pad,
|
|
43
|
+
minY: -pad,
|
|
44
|
+
maxX: width + pad,
|
|
45
|
+
maxY: height + pad
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Viewport-only world bounds for presentation without a presented camera
|
|
51
|
+
* (GS-PARTICLE-02): the tile layer's viewport-only path — the resolved
|
|
52
|
+
* logical bounds expanded by world-unit padding. World particles inside an
|
|
53
|
+
* ordinary viewport-only GameWorld2D render instead of failing closed.
|
|
54
|
+
*/
|
|
55
|
+
export function viewportWorldBounds(viewport, pad) {
|
|
56
|
+
'worklet';
|
|
57
|
+
|
|
58
|
+
const view = viewport?.value?.visibleLogicalBounds;
|
|
59
|
+
if (view === undefined) return undefined;
|
|
60
|
+
return {
|
|
61
|
+
minX: view.x - pad,
|
|
62
|
+
minY: view.y - pad,
|
|
63
|
+
maxX: view.x + view.width + pad,
|
|
64
|
+
maxY: view.y + view.height + pad
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Circle-vs-bounds visibility (GS-PARTICLE-02): the particle's
|
|
70
|
+
* conservative extent (bounding radius from geometry and scale endpoints)
|
|
71
|
+
* expands the bounds, so partially crossing shapes stay visible while
|
|
72
|
+
* fully outside shapes cull. Extra overscan stays in the bounds padding —
|
|
73
|
+
* never folded into the shape extent. A missing bounds still hides.
|
|
74
|
+
*/
|
|
75
|
+
export function visibleInBounds(x, y, extent, b) {
|
|
76
|
+
'worklet';
|
|
77
|
+
|
|
78
|
+
if (b === undefined) return false;
|
|
79
|
+
return x >= b.minX - extent && x <= b.maxX + extent && y >= b.minY - extent && y <= b.maxY + extent;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Conservative per-effect cull extent (GS-PARTICLE-02): the bounding
|
|
84
|
+
* radius of the authored geometry times the largest scale endpoint, so
|
|
85
|
+
* rotation can never push drawn pixels past the culled region. Circles
|
|
86
|
+
* use radius; rectangles and sprites use half the diagonal; absent
|
|
87
|
+
* dimensions fall back to the render defaults. The legacy scale range
|
|
88
|
+
* contributes its maximum; definitions without scale use 1.
|
|
89
|
+
*/
|
|
90
|
+
export function maxParticleExtent(definition) {
|
|
91
|
+
'worklet';
|
|
92
|
+
|
|
93
|
+
let maxScale = 1;
|
|
94
|
+
const scale = definition.scale;
|
|
95
|
+
if (scale !== undefined) {
|
|
96
|
+
if (scale.start.max > maxScale) maxScale = scale.start.max;
|
|
97
|
+
if (scale.end.max > maxScale) maxScale = scale.end.max;
|
|
98
|
+
}
|
|
99
|
+
const legacy = definition.scaleOverLife;
|
|
100
|
+
if (legacy !== undefined && legacy.max > maxScale) maxScale = legacy.max;
|
|
101
|
+
const particle = definition.particle;
|
|
102
|
+
if (particle.kind === 'sprite') {
|
|
103
|
+
return Math.hypot(particle.size.width, particle.size.height) / 2 * maxScale;
|
|
104
|
+
}
|
|
105
|
+
if (particle.shape === 'circle') {
|
|
106
|
+
return (particle.radius ?? 3) * maxScale;
|
|
107
|
+
}
|
|
108
|
+
return Math.hypot(particle.width ?? 6, particle.height ?? 6) / 2 * maxScale;
|
|
109
|
+
}
|
|
110
|
+
// keeping this pure module free of Reanimated/RN imports while accepting
|
|
111
|
+
// real SharedValue<CameraCut2D|ResolvedViewport2D> instances.
|
|
112
|
+
// Minimal structural mirrors of the shared refs the view layer passes in,
|
|
113
|
+
// keeping this pure module free of Reanimated/RN imports while accepting
|
|
114
|
+
// real SharedValue<CameraCut2D|ResolvedViewport2D> instances.
|
|
115
|
+
//# sourceMappingURL=culling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["rotatedHalfExtents2D","PARTICLE_CULL_PADDING","cameraVisibleWorldBounds","camera","viewport","pad","undefined","view","value","visibleLogicalBounds","cam","hx","width","zoom","hy","height","extent","rotationRadians","ex","x","ey","y","minX","center","minY","maxX","maxY","screenVisibleBounds","viewportWorldBounds","visibleInBounds","b","maxParticleExtent","definition","maxScale","scale","start","max","end","legacy","scaleOverLife","particle","kind","Math","hypot","size","shape","radius"],"sourceRoot":"../../../../src","sources":["react/particles/culling.ts"],"mappings":";;AAAA;AACA,SAASA,oBAAoB,QAAQ,2BAAwB;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,UAAU,CAAkEE,KAAK;EAChG,IAAIA,KAAK,KAAK5B,SAAS,EAAE;IACvB,IAAI4B,KAAK,CAACC,KAAK,CAACC,GAAG,GAAGH,QAAQ,EAAEA,QAAQ,GAAGC,KAAK,CAACC,KAAK,CAACC,GAAG;IAC1D,IAAIF,KAAK,CAACG,GAAG,CAACD,GAAG,GAAGH,QAAQ,EAAEA,QAAQ,GAAGC,KAAK,CAACG,GAAG,CAACD,GAAG;EACxD;EACA,MAAME,MAAM,GACVN,UAAU,CACVO,aAAa;EACf,IAAID,MAAM,KAAKhC,SAAS,IAAIgC,MAAM,CAACF,GAAG,GAAGH,QAAQ,EAAEA,QAAQ,GAAGK,MAAM,CAACF,GAAG;EACxE,MAAMI,QAAQ,GAAGR,UAAU,CAACQ,QAAQ;EACpC,IAAIA,QAAQ,CAACC,IAAI,KAAK,QAAQ,EAAE;IAC9B,OAAQC,IAAI,CAACC,KAAK,CAACH,QAAQ,CAACI,IAAI,CAAChC,KAAK,EAAE4B,QAAQ,CAACI,IAAI,CAAC7B,MAAM,CAAC,GAAG,CAAC,GAAIkB,QAAQ;EAC/E;EACA,IAAIO,QAAQ,CAACK,KAAK,KAAK,QAAQ,EAAE;IAC/B,OAAO,CAACL,QAAQ,CAACM,MAAM,IAAI,CAAC,IAAIb,QAAQ;EAC1C;EACA,OAAQS,IAAI,CAACC,KAAK,CAACH,QAAQ,CAAC5B,KAAK,IAAI,CAAC,EAAE4B,QAAQ,CAACzB,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,GAAIkB,QAAQ;AAC/E;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export { ParticleView } from "./ParticleView.js";
|
|
4
|
+
export { useParticlePresentation } from "./useParticlePresentation.js";
|
|
5
|
+
export { particleSpriteXform, assertUniformParticleSpriteRatio } from "./spriteXForm.js";
|
|
6
|
+
export { cameraVisibleWorldBounds, screenVisibleBounds, visibleInBounds, PARTICLE_CULL_PADDING } from "./culling.js";
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ParticleView","useParticlePresentation","particleSpriteXform","assertUniformParticleSpriteRatio","cameraVisibleWorldBounds","screenVisibleBounds","visibleInBounds","PARTICLE_CULL_PADDING"],"sourceRoot":"../../../../src","sources":["react/particles/index.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,mBAAgB;AAE7C,SAASC,uBAAuB,QAAQ,8BAA2B;AAEnE,SAASC,mBAAmB,EAAEC,gCAAgC,QAAQ,kBAAe;AACrF,SAASC,wBAAwB,EAAEC,mBAAmB,EAAEC,eAAe,EAAEC,qBAAqB,QAAQ,cAAW","ignoreList":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Particle sprite transform (T15-RF4).
|
|
5
|
+
*
|
|
6
|
+
* Atlas RSXform carries rotation AND uniform scale in its 2×2 part:
|
|
7
|
+
* \`scos = s·cosθ\`, \`ssin = s·sinθ\`. The pivot compensation uses the
|
|
8
|
+
* AUTHORED draw size (the definition's \`size\`), and the source rect stays
|
|
9
|
+
* the sheet frame — so the authored-to-source ratio scales the drawn sprite.
|
|
10
|
+
*
|
|
11
|
+
* v1 requires the authored size ratio to match the source frame ratio; a
|
|
12
|
+
* mismatch is a structured error (RSXform cannot express nonuniform scale).
|
|
13
|
+
*/
|
|
14
|
+
import { ParticleError } from "../../particles/errors.js";
|
|
15
|
+
export function particleSpriteXform(input) {
|
|
16
|
+
'worklet';
|
|
17
|
+
|
|
18
|
+
// T15-SF2: Atlas draws the SOURCE rect, so the authored-to-source ratio
|
|
19
|
+
// must ride in scos/ssin or the drawn size ignores particle.size entirely.
|
|
20
|
+
const effScale = input.scale * (input.drawWidth / input.frameWidth);
|
|
21
|
+
const cos = Math.cos(input.rotation);
|
|
22
|
+
const sin = Math.sin(input.rotation);
|
|
23
|
+
// Center anchor pivot against the DRAWN (scaled source) extent.
|
|
24
|
+
const px = input.frameWidth / 2 * effScale;
|
|
25
|
+
const py = input.frameHeight / 2 * effScale;
|
|
26
|
+
return {
|
|
27
|
+
scos: effScale * cos,
|
|
28
|
+
ssin: effScale * sin,
|
|
29
|
+
tx: input.x - px * cos + py * sin,
|
|
30
|
+
ty: input.y - px * sin - py * cos
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Validate that the authored size ratio matches the source frame ratio so
|
|
36
|
+
* uniform-scale Atlas drawing preserves the intended aspect.
|
|
37
|
+
*/
|
|
38
|
+
export function assertUniformParticleSpriteRatio(drawWidth, drawHeight, frameWidth, frameHeight) {
|
|
39
|
+
const drawRatio = drawWidth / drawHeight;
|
|
40
|
+
const frameRatio = frameWidth / frameHeight;
|
|
41
|
+
if (!Number.isFinite(drawRatio) || !Number.isFinite(frameRatio) || Math.abs(drawRatio - frameRatio) > 1e-3) {
|
|
42
|
+
throw new ParticleError(`[rn-gamekit/particles] sprite effect size ${drawWidth}x${drawHeight} does not match source frame ${frameWidth}x${frameHeight} aspect — nonuniform sprite scaling is not supported in v1`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=spriteXForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ParticleError","particleSpriteXform","input","effScale","scale","drawWidth","frameWidth","cos","Math","rotation","sin","px","py","frameHeight","scos","ssin","tx","x","ty","y","assertUniformParticleSpriteRatio","drawHeight","drawRatio","frameRatio","Number","isFinite","abs"],"sourceRoot":"../../../../src","sources":["react/particles/spriteXForm.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,2BAAwB;AAyBtD,OAAO,SAASC,mBAAmBA,CAACC,KAA+B,EAAuB;EACxF,SAAS;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