Three.js 3D Periodic Table (118 Elements)
Interactive 3D periodic table in Three.js with all 118 elements as atlas-textured tiles, category highlighting, hover details, and animated transitions between table, sphere, helix and grid layouts.
Key topics: three.js periodic table, 3d periodic table, chemistry, elements, texture atlas, raycasting, layout animation
Game Over
What this code does
- Texture Atlas: all 118 tiles are drawn once into a 16×8 canvas atlas, and each plane remaps its UVs to its own cell.
- Table Placement: an atomic-number → (group, period) function builds the 18-column layout with the f-block split off below.
- Layout Morphing: every tile lerps its position and slerps its rotation toward a target `Object3D` for smooth transitions.
- Category Colors: alkali, alkaline earth, transition, post-transition, metalloid, nonmetal, halogen, noble gas, lanthanide and actinide.
- Hover Inspect: a `Raycaster` finds the tile under the pointer, enlarges it and shows its name, period and group.
- Controls: layout, category highlight and spin for 3D layouts.
Related Demos
Continue Learning
JavaScript Implementation
const scene = new THREE.Scene()
const camera = new THREE.PerspectiveCamera(50, width / height, 0.1, 200)
camera.position.set(0, -2, 26)
const renderer = new THREE.WebGLRenderer({ antialias: true })
renderer.setSize(width, height)
document.querySelector('#app').appendChild(renderer.domElement)
const symbols = ['H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne', 'Na', 'Mg', 'Al', 'Si', 'P', 'S', 'Cl', 'Ar']
// 18-column positions for the first three periods
function position (z) {
if (z === 1) return [1, 1]
if (z === 2) return [18, 1]
if (z <= 4) return [z - 2, 2]
if (z <= 10) return [z + 8, 2]
if (z <= 12) return [z - 10, 3]
return [z, 3]
}
symbols.forEach((symbol, i) => {
const canvas = document.createElement('canvas')
canvas.width = canvas.height = 128
const g = canvas.getContext('2d')
g.fillStyle = '#0f172a'
g.fillRect(0, 0, 128, 128)
g.fillStyle = '#fff'
g.font = 'bold 56px sans-serif'
g.textAlign = 'center'
g.fillText(symbol, 64, 84)
const tile = new THREE.Mesh(new THREE.PlaneGeometry(1, 1), new THREE.MeshBasicMaterial({ map: new THREE.CanvasTexture(canvas) }))
const [col, row] = position(i + 1)
tile.position.set((col - 9.5) * 1.12, -(row - 2) * 1.12, 0)
scene.add(tile)
})
renderer.render(scene, camera)