Here’s a pure-HTML/CSS/JavaScript solution that fetches the first 100 Pokémon from the PokéAPI and displays each as a continuously rotating 3D “card” (you could easily swap in glTF models & Three.js if you have real 3D assets). This uses CSS 3D transforms for smooth, lightweight animation.
Save the snippet below as index.html, then just open it in your browser (or serve it via a simple HTTP server).
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>3D Rotating Pokémon Gallery (1–100)</title>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<style>
/* page reset & grid */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
background: #F5F5F5;
font-family: sans-serif;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
gap: 16px;
padding: 16px;
}
/* 3D card container */
.pokemon-card {
width: 150px;
height: 150px;
perspective: 600px;
margin: auto;
}
/* the card itself */
.card {
position: relative;
width: 100%;
height: 100%;
transform-style: preserve-3d;
animation: spin 6s linear infinite;
}
/* card faces */
.face {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
border-radius: 12px;
overflow: hidden;
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
display: flex;
align-items: center;
justify-content: center;
background: white;
}
.face img {
max-width: 80%;
max-height: 80%;
}
.front { transform: rotateY( 0deg ) translateZ(75px); }
.right { transform: rotateY( 90deg ) translateZ(75px); }
.back { transform: rotateY( 180deg ) translateZ(75px); }
.left { transform: rotateY(- 90deg ) translateZ(75px); }
@keyframes spin {
from { transform: rotateY(0deg); }
to { transform: rotateY(360deg); }
}
/* simple caption */
.caption {
text-align: center;
margin-top: 4px;
font-size: .9rem;
color: #333;
}
</style>
</head>
<body>
<!-- JS will inject .pokemon-card elements here -->
<script>
const LIMIT = 100;
const container = document.body;
// utility: create the 4 faces of a cube and put the same sprite on each side
function makeCard(name, imgUrl, number) {
const wrapper = document.createElement('div');
wrapper.className = 'pokemon-card';
const card = document.createElement('div');
card.className = 'card';
['front','right','back','left'].forEach(faceName => {
const face = document.createElement('div');
face.className = 'face ' + faceName;
const img = document.createElement('img');
img.src = imgUrl;
img.alt = name;
face.append(img);
card.append(face);
});
wrapper.append(card);
// caption
const caption = document.createElement('div');
caption.className = 'caption';
caption.innerText = `#${number.toString().padStart(3,'0')} ${name}`;
wrapper.append(caption);
return wrapper;
}
// fetch the list of first 100 Pokémon
async function loadPokemon() {
const listRes = await fetch(`https://pokeapi.co/api/v2/pokemon?limit=${LIMIT}`);
const { results } = await listRes.json();
// fetch details in parallel
const detailPromises = results.map((p, idx) =>
fetch(p.url)
.then(r => r.json())
.then(d => ({
name: d.name.charAt(0).toUpperCase() + d.name.slice(1),
img: d.sprites.front_default,
idx: idx + 1
}))
.catch(console.warn)
);
const details = await Promise.all(detailPromises);
details.forEach(({name, img, idx}) => {
if (img) {
container.append(makeCard(name, img, idx));
}
});
}
loadPokemon().catch(console.error);
</script>
</body>
</html>
How this works
- Layout
We use CSS Grid to auto-flow cards into columns, wrapping as needed.
- 3D Animation
Each .pokemon-card has a perspective. Inside we spin a .card (with transform-style: preserve-3d) continuously around the Y-axis.
- Faces
We build four faces (.front, .right, .back, .left) each mapped with the Pokémon’s front sprite. You could expand this to six faces or swap in real 3D glTF models via Three.js if you have them.
- Data Fetch
We call “https://pokeapi.co/api/v2/pokemon?limit=100” then fetch each detail to grab the front_default sprite.
Feel free to:
• Swap the CSS cube for a real Three.js scene with .GLTFLoader & animated rigs
• Lazy-load blocks of 20 at a time to improve initial load
• Add UI controls (pause rotation, filter by type, etc.)
Enjoy your 3D rotating Pokédex! 🎮🔄✨