Three.js Scroll Article Starter

A copyable Vite and TypeScript project template. It is free and MIT licensed. The story stays in ordinary HTML, and the scroll position directs the 3D scene behind it. This page is the live demo of the starter.

What you can do on this page

  • Scroll down to try the three-chapter demo.
  • Take the same source code through GitHub Template or ZIP.
  • Read the notes below before you adapt it for your own article.

What is in the starter

The starter shows one idea: as the reader scrolls, the 3D scene in the background moves with them.

The scene uses only geometry built into Three.js: a faceted core, a thin ring, a wireframe torus knot, and 240 small particles. You do not need to download or prepare any 3D model files.

How it works

  • The article text is ordinary HTML. A single fixed canvas sits behind it.
  • The code converts the scroll position into a progress value from 0 to 1.
  • That value sets the camera position, the rotation of the scene, and the core color.
  • The core color moves through four color steps.
  • The page has three chapters. The chapter number changes as you reach each chapter.
  • The scene redraws only after a scroll or a window resize. It does not run when nothing changes.

How it handles different devices

  • If the reader's system uses reduced motion, the camera jumps to a fixed position for each chapter. It does not rotate continuously.
  • If the device does not support WebGL, the browser's 3D drawing feature, the page shows a CSS shape instead. A short note appears. The article and the downloads still work.
  • The pixel ratio is capped at 2 to limit the load on high-resolution screens.

How to use it

  1. Create your own repository with the GitHub Template feature, or download the ZIP.
  2. Run npm install in the project folder.
  3. Replace the three chapters with your own story.

The code uses the MIT license. You can use it in personal and commercial work.

Notes

  • The template shows three chapters. You can change their number and content.
  • If you are new to Three.js, start with the introduction article on this site.

Related links