Atlas Sphere with React Native Skia
Tuesday, June 25, 2024
demos
atlas-sphere
An ongoing collection of React Native animations crafted with Reanimated, Gesture Handler, and Skia.
TypeScript
3.2k
296
An interactive particle sphere effect built with React Native Skia's Atlas API. Touch and drag to create a mesmerizing gravitational distortion effect on a grid of particles.
What's This About?
This component creates a grid of circular particles that respond to touch interactions with a sphere-like gravitational effect. When you touch the screen, particles near your finger scale up and move towards the touch point, creating an immersive 3D-like distortion.
Technical Implementation
The component leverages Skia's powerful Atlas API for rendering thousands of particles efficiently. Key features include:
RSXform Buffers: Uses useRSXformBuffer for high-performance transformations of all particles in a single draw call
Texture Caching: Pre-renders a single particle texture and reuses it across all instances
Distance-Based Scaling: Particles scale based on their distance from the touch point
Smooth Animations: Spring animations for natural-feeling interactions
How It Works
A grid of particles is generated based on screen dimensions
Each particle's position and scale is calculated relative to the touch point
Distance from touch determines the scale factor (closer = larger)
Particles also translate towards the touch point creating a "gravity" effect
Spring animations smooth the transitions when touching and releasing
Usage
import { AtlasSphere } from './atlas-sphere';
// Simply render the component - it's fully self-contained
<AtlasSphere />;
Unlock the beauty of React Native animations
Learn Reanimated, Gesture Handler & Skia with Reanimate.dev
Feedback on Atlas Sphere
Ideas, bugs, or anything that felt off: I read every message. For anything else, write to hello@reactiive.io.
Send feedback