xr843/insect-world
About
Interactive 3D insect field guide: 63 species across 14 orders, with every body procedurally generated in the browser using TypeScript and Three.js—no model or texture files in the repository. Eight species go through a complete life cycle, and the hovering species beat their wings.
Learning & EducationMeasured star growth
- in 24h
- 0
- in 7 days
- +2
- in 15 days
- +3
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.en.md
OriginalInsect World
简体中文 · English
An interactive 3D insect field guide — rotate, zoom, and click the coloured hotspots to explore the anatomy, life cycle, and ecological role of 63 species.
Live: https://insect-world.pages.dev/en/ · 中文版: https://insect-world.pages.dev

Every insect is generated by code at runtime. There is not a single model file in this repository.
That monarch on the right is eclosing: its wings inflate from a small crumpled pad to full span while lifting out of their droop. No separate animation asset was authored for it — the same code that draws the adult also draws the egg, the grub and the pupa. That is something parametric geometry can do and a scanned model cannot; eight species have full life-cycle models.
63 species across 14 orders: Coleoptera 28, Diptera 5, Lepidoptera 5, Hymenoptera 5, Hemiptera 4, Orthoptera 4; Odonata, Mantodea, Neuroptera, and Blattodea 2 each; Phasmatodea, Dermaptera, Megaloptera, and Trichoptera 1 each. The latest three — house fly, northern house mosquito, and German cockroach — were added after readers pointed out that a guide with 28 beetles had not a single everyday household insect.

Two themes, the same museum by day and by night: "Specimen Table" (default — cool grey-green archival board, bronze nameplates, specimen-label inks) and "Museum at Night" (gallery black with brass accents, specimens lifted out of the dark by spotlight cones — metallic elytra, membrane iridescence, and the firefly's lantern all read better on a deep ground).
| Light — "Specimen Table" (default) | Dark — "Museum at Night" |
|---|---|
![]() |
![]() |
⚠️ About the written content: the summaries, key figures, life cycles, and trivia for all 63 species were written by AI and have not been checked line by line against entomological literature or by a specialist. Treat them as "fun to look at, and a way to learn the shapes" — not as a citable source. Issues are welcome if you spot an error.
The English edition is machine-translated from the Chinese and has not been reviewed by a native speaker or by an entomologist. Scientific names (Linnaean binomials) are identical in both editions and are the only reliable anchor between them.
Why it is worth a look
Reference field guides ship each organ as a ~3.2 MB GLB asset — bought or scanned. No such asset library exists for insects, so this project took another route: every species' geometry is generated by TypeScript in the browser, with no external model files at all.
That is not merely a workaround. Insect morphology is far more regular than viscera: the body divides into head, thorax, and abdomen; the thorax carries three pairs of legs and two pairs of wings; appendages are segmented tapered tubes; wing membranes are supported by radiating veins. Once those structures are parameterised, adding a species means writing a description of its dimensions and colours — not buying another model.
- 13,000–36,000 triangles per species (smallest: northern house mosquito at 13,308; largest: Chinese oak silkmoth at 35,732)
- 30–90 ms to build a species in the browser
- ~424 KB gzipped first-load JS (vendor 340 KB, dominated by three.js, plus an 84 KB main bundle)
- Species code is split per-module and fetched only when selected; the desktop post-processing pipeline (103 KB) is a lazy chunk that phones never download
- Surface micro-detail (punctures, striae, pubescence, hexagonal ommatidia) comes from procedural textures generated at runtime
The trade-off is realism: this will not match a 3D scan. What it buys is zero asset dependencies, unlimited extensibility, and morphology that can be traced back to a reason in the code.
Quick start
Requires Node.js 22.13 or newer; API tests use Node's built-in SQLite.
npm install
npm run dev # main site http://localhost:5178
# model bench http://localhost:5178/preview.html
npm test # 4,000+ tests
npm run build # tsc --noEmit + vite build
npx playwright install chromium # before the first browser check
npm run test:browser # after building: mobile layout, switching, blocked storage
npm run deploy # build and publish to Cloudflare Pages (run npx wrangler login first)
Pages are hosted statically on Cloudflare Pages; language routing and feedback submission use Pages Functions, with feedback stored in D1. public/_headers sets the caching policy: build outputs carry content hashes and are cached immutably for a year, while HTML is revalidated on every request so a new release takes effect immediately.
The root path / also carries a Cloudflare Pages Function (functions/index.ts): it 302-redirects visitors whose Accept-Language has no Chinese tag to /en/ (crawlers are left alone, and an existing language-choice cookie takes precedence; the response carries Vary: Accept-Language, Cookie, User-Agent and Cache-Control: private, no-store). functions/ lives at the repo root, not inside dist/, but the deploy command above needs no change — wrangler pages deploy resolves its functions directory as "the current working directory at invocation time, plus functions", independent of the deployed directory argument (dist), confirmed by reading wrangler 4.x's own source (deploy2()'s functionsDirectory = customFunctionsDirectory || path.join(process.cwd(), "functions")), not assumed from docs. npm run deploy runs from the repo root, so it is auto-discovered and bundled in. Locally, npx wrangler pages dev dist plus curling / with different Accept-Language/Cookie headers reproduces the whole chain.
How to use it
Pick a species in the left column, or step through with ↑ / ↓. Drag to rotate, scroll to zoom, click a coloured dot for a note on that body part.
The toolbar on the left: Focus moves the camera onto the currently selected part, Section cuts along the sagittal plane, Layers makes the exoskeleton translucent, and Compare floats a comparison strip at the base of the stage.
In the right column, the guided walkthrough steps through the anatomy and moves the 3D camera to whichever part is being described; the quiz is genuinely answerable — it marks answers, explains them, and keeps score.

They are alive
Idle insects make very small postural adjustments (about 1.7°, the six legs phase-offset by where they attach). The eight species that genuinely hover — dragonfly, damselfly, honeybee, bumblebee, hoverfly, lacewing, hawk-moth and crane-fly — beat their wings in place; in Odonata the fore and hind wings beat in antiphase, which is part of why they can hover and is the dead giveaway that you are looking at a dragonfly.
Wingbeat frequencies are compressed, deliberately and openly: a honeybee really beats at 230 Hz and a hoverfly at 200 Hz, while a 60 fps screen tops out at 30 Hz by Nyquist. Driving the real numbers does not look "fast", it aliases — the wings appear to drift slowly backwards. A log compression maps them into 4–12 Hz and preserves the ordering between species; the real frequencies stay in the data table with the compression function right next to them.
There is no full walk cycle, and the reason is in the code: the stand is a turntable with the insect at its centre, so legs that stride while the body stays put read as a treadmill, not as walking. Hovering has no such problem — hovering really is stationary.
A whole life
The life cycle card at the bottom steps the stand through egg, larva and pupa as you page through the panel. Twenty-eight species so far, 74 stage models. Complete metamorphosis: Japanese rhinoceros beetle (a creamy white grub → a pupa that already carries the beginnings of the horn → the glossy black adult — the sharpest contrast of the set), monarch, Chinese oak silkmoth (the caterpillar plus a longitudinally half-sectioned cocoon), western honeybee (everything happens inside hexagonal wax cells; the pupa's compound eyes darken before its body), Chinese firefly (egg, larva and pupa all glow) and the sacred dung beetle (egg and larva both inside a brood pear), the seven-spot ladybird (a standing clutch of eggs, a slate-blue larva studded with orange-patched tubercles, and a naked pupa that still trails its shed larval skin), the Japanese carpenter ant (all of it inside the nest; a window in the side of the cocoon shows the pupa curled up within) and the starry sky longhorn beetle (the egg tucked into a chevron-shaped slit chewed through the bark; a ramrod straight grub under a broad shield-like pronotum; a pupa whose enormous antennae are already coiled along its flanks), the Chinese stag beetle (an egg sunk into a shallow pit in rotting wood; a milk-white grub with an orange head capsule and big black mandibles, kept distinct from the rhinoceros grub; a male pupa that already carries the pair of great jaws), the Chinese tiger beetle (the larva is a burrow ambusher — its metallic head shield plugs the hole and a hooked hump on its back anchors it to the wall; the pupa lies on its back on dorsal spines) and the common Mormon swallowtail (a smooth round egg; a final-instar caterpillar with false eyespots and an orange osmeterium; a girdled pupa slung from a twig by a silk belt, against the monarch's hanging one), the house fly (a banana-shaped egg; a legless, headless maggot showing only the tips of its black mouth hooks and a pair of D-shaped spiracular plates on its blunt rear; a dark reddish-brown puparium — the hardened skin of the last larval instar, with no legs or wings visible), the jewel beetle (a flat disc-shaped egg in a bark crevice; a classic flat-headed borer with a broad hammer-like prothorax marked by a Y-shaped groove; a pale exarate pupa lying on its back) the bamboo weevil (an egg set in a hole chewed into a bamboo-shoot wall; a brown-headed, legless C-shaped grub; a supine pupa with its long snout pressed along the midline of its belly), the rove beetle (a spherical egg; a slender campodeiform larva with three pairs of thoracic legs and tail processes), the giant hornet (everything inside grey-brown paper hexagonal cells that open downward — against the honeybee's wax — with a pale silk cap over the pupa) and the crane fly (a black elongate egg; a grey-brown "leatherjacket" whose tail end carries a ring of fleshy lobes around two spiracles; a pupa with breathing horns and rows of abdominal spines). Incomplete metamorphosis, as the contrast: the black cicada (fossorial forelegs plus wing pads), the emperor dragonfly nymph (the hinged, mask-like labium plus four wing pads), the Chinese mantis (an ootheca lashed to a twig, with the hatching band running along its crest) and the migratory locust (an egg pod standing in the soil under a plug of hardened foam; the hopper's wing pads are reversed — front and back swapped relative to the adult), the German cockroach (a ribbed, purse-shaped ootheca; a dark nymph with a pale stripe down its back) and the stick insect (seed-like eggs with a lid and a micropylar plate; the nymph is a smaller, greener twig — the adult is wingless, so there are no wing pads), the oriental mole cricket (a greyish oval egg; a nymph already armed with shovel-like digging forelegs and small wing pads lying flat on its back) the water strider (elongate eggs glued in a row along a water-plant stem; a wingless nymph with enormously long middle and hind legs), the damselfly (eggs inserted into a water-plant stem; a nymph with three leaf-like caudal gills that set it apart from the dragonfly's) and the shore earwig (a clutch of white eggs in a soil chamber; a pale nymph with short, straight forceps).
Those wing pads are the visible evidence that the wings are still "buds" — the difference between complete and incomplete metamorphosis is the first thing anyone is taught about insects, and it is the whole reason this feature exists.

All four panels share one camera and one crop box, so the size difference — a small clutch of eggs against a fat C-shaped grub — is the models' own, not a layout trick. Rendered from the same code that runs the site by scripts/make-lifecycle-strip.mjs.
Stages do not morph into one another. A caterpillar turning into a butterfly is not a continuous deformation in the first place (tissue histolysis plus imaginal discs), so a smooth morph would look good and be wrong. The one thing that is animated continuously is wing expansion at emergence — because that really is continuous: a freshly eclosed wing is a small crumpled pad of soft tissue that haemolymph pressure inflates and then hardens.
(The monarch eclosing at the top of this page is this animation.)
It is a recording, not a hand-tuned animation: scripts/make-emerge-gif.mjs opens the life cycle on the live site, steps to the pupa, steps once more, and collects the frames the browser's compositor pushes out. The curve is 1-(1-u)³ — fast then slow, because haemolymph pressure is highest at the start — and the wings lift out of their droop as they expand.
Project layout
src/
three/
builders/
kit.ts modelling toolkit — the foundation for every species
surface.ts procedural surface micro-texture (runtime CanvasTexture)
eyes.ts hexagonal ommatidia normal map for compound eyes
venation.ts parametric wing venation (longitudinal + cross veins)
<id>.ts one file per species, exporting build<Name>(): InsectModel
registry.ts dynamic per-id species loading (Vite code splitting + LRU VRAM eviction)
InsectCanvas.tsx the 3D stage: studio lighting, on-demand rendering, antenna sway
PostFX.tsx desktop post-processing (N8AO + Bloom + ACES), lazy chunk
components/
TopBar / LibraryPanel / Stage / DetailPanel / BottomCards the three-column workbench
Discovery.tsx guided panel (walkthrough / motion / quiz / habitat)
CompareBar.tsx inline comparison strip
Gallery.tsx full species overview grouped by order
InsectGlyph.tsx 63 hand-written SVG silhouettes
data/
types.ts data contract
insects.zh.ts / insects.en.ts field-guide data for 63 species
guides.zh.ts / guides.en.ts walkthroughs and quizzes
preview.tsx model bench (/preview.html)
Model-local coordinates: +X forward (towards the head), +Y up (dorsal), +Z to the right; 1 unit = 1 cm of real body length.
anchors keys are the single coupling point between the modelling layer and the data layer: every hotspot.anchor in the insect data and every LessonStep.anchor in the guides must resolve against that species' anchors, or the hotspot disappears silently — no page error, and both sides' own tests still pass. three/__tests__/integration.test.ts exists to pin that seam.
Adding a species
The registry scans the directory with import.meta.glob('./builders/*.ts'), treats the filename as the id, and finds the exported buildXxx() by its build prefix. Dropping a new file in registers it automatically — no existing code needs to change.
The content still has to be written by hand, and the id must match in all four places:
| What | Where | Size |
|---|---|---|
| 3D geometry code | src/three/builders/<id>.ts |
200–400 lines, the bulk of the work |
| Field-guide data (scientific name, 6 key figures, 5–6 hotspots, ecology, trivia…) | src/data/insects.zh.ts + insects.en.ts |
one record each |
| Walkthrough and quiz (3–4 steps + 2 questions) | src/data/guides.zh.ts + guides.en.ts |
one record each |
| 24×24 silhouette icon | src/components/InsectGlyph.tsx |
one small component |
Miss one and the tests will catch it: a data record with no builder file fails the integration test; an anchor that does not exist on the model fails the seam test.
Tests
npm test # 4,000+ tests across 50+ files
One self-check when writing a morphology assertion: if I revert the code to the broken version, does this assertion fail? If not, it is not really an assertion.
There is a harder failure mode the self-check does not cover: assertions measure numbers, people look at shapes, and the two can be unrelated. The orchid mantis's petal-like femora asserted "width ≥ 3.5× thickness" and measured 5.75 — green — yet rendered as a few thin plates seen edge-on, making the whole insect look like a pale shrimp, because the quaternion fixing their orientation constrained only the long axis and left roll free. The width-to-thickness number was entirely unaffected. Assertions that pin this class of bug have to measure the quantity the user actually sees.
The audit methodology that catches what tests cannot — render-size requirements, the silhouette-diff sweep for backface culling, ID-map pixel attribution — is written up in docs/model-audit-notes.md (Chinese). The Chinese README documents these lessons in full, including a long list of bugs that only surface at runtime and are caught by neither type-checking nor NaN checks — <Environment> suspending an entire subtree, inline callbacks causing infinite reloads, legPair not actually mirroring, and the counter-intuitive spread semantics in wing().
Known limitations
- Realism is capped below what a 3D scan achieves. Surface micro-detail is covered by procedural textures, but there are no hand-painted textures and no real fur physics. In exchange: zero asset files and a consistent style across the whole library.
- Observation notes live only in the browser (localStorage) and are lost when you switch devices or clear the cache. "Copy as Markdown" in the avatar menu is currently the only way to take them with you.
- Section and layer views are generic (clipping plane / reduced exoskeleton opacity) rather than per-species anatomical layers.
- Some "related species" lists were written from common names and have not been checked against taxonomic literature one by one.
- The entire English edition is machine-translated, as noted above.
Credits and licence
The information architecture is learned from Anatomy Atelier (source at thebuggeddev/anatomy) — the three-column workbench, the coloured hotspots on the model, the expandable cards along the bottom, the placement of the guided walkthrough, and some of the interaction feel all come from it. This project contains none of its code; everything here is written from scratch. Thanks to it for building this interaction pattern in the first place.
The 3D modelling code, field-guide text, walkthroughs and quizzes, both visual themes, and all implementation in this repository are original work, released under the MIT licence — see LICENSE.
⚠️ Once more: the field-guide text is AI-written and has not been professionally reviewed. It is not suitable as an academic or teaching citation.
The Chinese README is the source of truth and goes deeper — the full pitfalls section, the per-file test breakdown, and the complete kit.ts API table live there.
Explore related projects
Loading…

