A simple, interactive 3D text sphere generator built with Next.js and Three.js.
- Add and remove words to display in a 3D sphere
- Adjust sphere radius, font size, and word density
- Customize text and background colors
- Interactive rotation with mouse/touch controls
- Text always faces the camera (no reversed text)
- Evenly distributed text using Fibonacci algorithm
git clone https://github.com/yourusername/3d-text-sphere.git
cd 3d-text-sphereUsing Bun (recommended):
bun installUsing npm:
npm installUsing Bun:
bun devUsing npm:
npm run devOpen http://localhost:3000 in your browser to see the application.
3d-text-sphere/
├── public/ # Static assets
├── src/
│ ├── app/
│ │ └── page.tsx # Main application page
│ └── components/
│ └── TextSphere.tsx # 3D Text Sphere component
├── package.json # Project dependencies
└── README.md # Documentation
- Copy the
TextSphere.tsxfile to your project's components directory - Install the required dependencies:
bun add three @react-three/fiber @react-three/drei
# or
npm install three @react-three/fiber @react-three/drei- Import and use the component:
import { TextSphere } from '@/components/TextSphere';
export default function MyPage() {
return (
<div style={{ height: '500px', position: 'relative' }}>
<TextSphere config={{
words: ['Next.js', 'React', 'Three.js'],
radius: 3,
fontSize: 0.2,
density: 5,
color: '#000000',
backgroundColor: '#ffffff'
}} />
</div>
);
}The application provides a simple interface to:
- Add words individually or in batches (comma-separated)
- Choose from sample word sets (Tech, Nature, Colors)
- Adjust the sphere radius, font size, and word density
- Customize text and background colors
The sphere automatically rotates, and you can also interact with it using your mouse or touch.
| Property | Type | Default | Description |
|---|---|---|---|
words |
string[] |
['Next.js', 'React', 'Three.js', 'TypeScript'] |
Words to display |
radius |
number |
3 |
Radius of the sphere |
fontSize |
number |
0.2 |
Size of the text |
density |
number |
5 |
Word density (1-10) |
color |
string |
'#000000' |
Text color |
backgroundColor |
string |
'#ffffff' |
Background color |
- Next.js - React framework
- React - UI library
- Three.js - 3D library
- React Three Fiber - React renderer for Three.js
- Drei - Useful helpers for React Three Fiber
-
Text appears too small or too large
- Adjust the font size slider to find the right balance
- For many words, use a smaller font size
-
Performance issues
- Reduce the density if the animation becomes slow
- Try using fewer unique words
-
Text overlapping
- Increase the sphere radius
- Decrease the font size
- Reduce the density
MIT