Science Visualiser
ASecurityBuild scientifically accurate, interactive 3D explainers of how a mechanism or machine works — firearms, engines, gearboxes, clocks and escapements, pumps, locks, cameras, valves, turbines, sewing machines, typewriters — as a three.js project with a Blender-scripted model, a physics simulation that drives the animation, cutaway / x-ray / exploded views, a guided slow-motion timeline with captions, live physics charts and a sourced spec sheet. Use this whenever the user wants an educational or...
- 2 stars
- 0 votes
- 0 copies
- 1 view
- Added November 7, 2026
Works with
Security analysis
100/100Pro scans all 20 files and shows the line behind each finding
npx -y skills add joonsp/threejs-skills --skill science-visualiser --agent claude-codeAre you the author of Science Visualiser?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/joonsp-science-visualiser)---
name: science-visualiser
description: Build scientifically accurate, interactive 3D explainers of how a mechanism or machine works — firearms, engines, gearboxes, clocks and escapements, pumps, locks, cameras, valves, turbines, sewing machines, typewriters — as a three.js project with a Blender-scripted model, a physics simulation that drives the animation, cutaway / x-ray / exploded views, a guided slow-motion timeline with captions, live physics charts and a sourced spec sheet. Use this whenever the user wants an educational or scientific 3D model, animation or "how it works" visualisation of a device, its parts or its operating cycle, even if they never mention three.js, Blender or simulation.
---
# Science visualiser: mechanism explainers
The end product is a local Vite + TypeScript + three.js app where a viewer can:
- see the device, pick any part to read what it does, and switch between solid, cutaway (capped, hatched sections), x-ray and exploded views;
- run the operating cycle in guided slow motion, which gives a 1 ms event as much screen time as a 50 ms one;
- follow captions for each phase, and see live charts of the governing quantities;
- open a Sources tab listing every number, with its provenance.
It was distilled from two builds, both in `assets/examples/`; reuse their structure, not their numbers:
- a Finnish RK 62 rifle: an event-driven machine, shooting;
- a single-cylinder four-stroke engine: a periodic machine, running at operating points.
## Why it is built this way
- **Physics drives the animation; nothing is hand-keyed.** A simulation integrates the real mechanics (forces, springs, gas or heat, impacts, latches). It is calibrated to published figures such as rate, speed, pressure or rpm. Timing, graphs and motion then agree with each other and with reality. Hand-keyed animation looks plausible but teaches wrong timings.
- **One spec file is the source of truth** (`specs/<device>.json`).
- It holds every dimension, pivot, travel and mass, each tagged `src` (a citation) or `est` (with the reasoning).
- The Blender build and the TypeScript simulation both read it. That stops geometry and kinematics drifting apart; drift shows up as parts clipping through each other.
- **Honesty about estimates.** Many internal dimensions are never published. Estimating them is fine, but the UI must say which values are estimates. A science explainer that hides its guesses is worse than one with visible error bars.
- **Blender, headless and scripted**, not an MCP session or manual modelling. The model stays reproducible and diffable:
- bevels with hardened normals, exact booleans for cuts and holes, curves for springs;
- each part's origin placed at its real pivot;
- pre-cut, capped "cutaway twins" of the housings.
If Blender isn't installed, do the geometry in three.js directly (`ExtrudeGeometry`, `LatheGeometry`, `TubeGeometry`, `three-bvh-csg`) and keep everything else the same.
## Workflow
This is a big job: from about half an hour for a first working build, to a few hours for a polished one. Plan it, then execute phase by phase. Give the user a one-line status at each phase boundary. Verify visually (screenshots) before claiming a phase is done.
### 0. Clarify, briefly
Ask only what changes the build, and offer recommended defaults:
- **Variant or scope:** e.g. "RK 62 classic milled receiver, not the M-upgrades".
- **Language:** one, or bilingual with a toggle. If the user or the device has a non-English context, offer that language plus English, using the official terminology from the primary source.
- **Features:** timeline and slow motion, cutaway / x-ray, exploded view, the control logic of the mechanism (modes, safeties), physics charts.
- **Delivery:** a local Vite project is the default.
### 1. Research — see `references/research.md`
- Run 2–3 research agents in parallel: specs and parts (with native part names); the operating cycle's physics and timing; part geometry and technical drawings.
- Then open the primary documents yourself. Official manuals and technical drawings beat encyclopedias. Download them into `research/`, render their figures to PNG and look at them.
- Calibrate scale from a clean side-view drawing by overlaying a pixel grid, and write down the key coordinates. If no usable drawing exists, build from published dimensions instead.
### 2. Spec file — see `references/specs.md`
Pick the coordinate frame (e.g. x = forward, y = up, z = viewer side; origin at a meaningful datum). Write `specs/<device>.json` with values and provenance, the parts list (id, names in each language, material, group, whether it gets a cut twin, explode vector) and outline geometry.
### 3. Blender model — see `references/blender.md`
- Copy `scripts/blender_lib.py` → `blender/lib.py`, `scripts/blender_run.sh` → `blender/run.sh`, and `scripts/render_previews.py` → `blender/render_previews.py`.
- Write `blender/build_model.py`: one function per part; origins at pivots; nested parts parented (e.g. firing pin inside bolt); cut twins; GLB export.
- Render previews and compare them with the reference drawing before moving on.
### 4. Simulation — see `references/simulation.md`
- **Pick the archetype first:**
- **Event-driven:** a user action produces a transient from the current state, then everything comes to rest (firearms, locks, shutters).
- **Periodic:** run until the cycle repeats itself, record one period, and offer operating points (engines, clocks, pumps).
- Write a time-domain integrator with discrete events: latches, catches, impacts, valve events, state changes.
- Calibrate unpublished constants against published behaviour, and record the calibration in tests.
- Output a `Recording`: tracks, events, non-overlapping phases (for captions and the timeline), and entity lifecycles.
### 5. Kinematics and viewer — see `references/viewer.md`
- **Kinematics:** a pure function `poseAt(recording, t)` gives every part's transform. Shared geometry helpers live in `src/mechanism.ts` and are used by both the simulation and the kinematics: cam curves, linkage angles, contact limits, feed paths.
- **Viewer:** copy `assets/viewer/` and adapt it. The app glue in `main.example.ts` was the biggest hand-written piece in testing, so start from it.
- `index.html` and `style.css`: page skeleton and dark app shell;
- `specs.ts`: typed spec access;
- `main.example.ts` and `i18n.example.ts`: complete app glue;
- `player.ts`: guided time warp, with `'auto'` rates and looping;
- `chart.ts`: accessible single-series charts;
- `viewer.ts`: renderer, camera presets, fly-to;
- `materials.ts`: PBR materials, hatched section faces, x-ray;
- `surface.ts`: procedural texture and edge wear;
- `model-registry.example.ts`: GLB part registry, explode wrappers, view modes.
- If the charts matter, load the `dataviz` skill.
### 6. Surfaces — see `references/surfaces.md`
Use procedural, UV-free micro-relief per material, plus edge wear detected from the hardened bevels, plus decals for markings the sources document.
### 7. QA — see `references/qa.md`
- Run `node scripts/shoot.mjs steps.json out/` for scripted headless screenshots of key moments in every view mode.
- Look at every screenshot and read the console output.
- Write unit tests for calibration and invariants. Examples: "the latch only releases when locked"; "semi-auto fires once per trigger pull"; "the fed part ends exactly at its seat".
### 8. Deliver
- **README:** how to run it, how to rebuild the model, the layout, and accuracy notes.
- **Research notes:** `research/notes.md` with a source table, the conflicts and choices, and the list of estimates.
- **Final report to the user:** the calibration table (model output vs. published figure), what is sourced vs. estimated, and known simplifications.
## Project layout
```
specs/<device>.json single source of truth (values + provenance, parts, geometry)
research/ downloaded sources, rendered figures, gridded drawings, notes.md
blender/ build_model.py, lib.py, render_previews.py, run.sh, previews/
public/models/<device>.glb
src/specs.ts typed access to the spec (val(key), PARTS, SOURCES)
src/mechanism.ts pure geometry shared by sim + animation
src/sim/ domain physics (e.g. ballistics.ts, thermo.ts) + engine.ts (time-domain, events → Recording)
src/anim/ kinematics.ts (Recording + t → Pose), player.ts (guided warp)
src/model/ GLB registry: pivots, explode wrappers, view modes, applyPose
src/scene/ viewer.ts, materials.ts, surface.ts, fx.ts
src/content/ per-language phase captions and part descriptions
src/ui/, src/i18n.ts, src/main.ts, index.html, tests/
```
## Pitfalls that cost real time
Each is explained in the linked reference.
- **Blender picks up the wrong Python.** Under a version manager (mise, pyenv, asdf), headless Blender fails with "No module named 'math'". Run it through `blender/run.sh`. (blender.md)
- **Exact booleans return an empty mesh** if concave caps were pre-triangulated, or after near-coplanar unions. Leave the caps as n-gons, overlap unions by at least 0.5 mm, and pass `robust=True` (`use_self`, `use_hole_tolerant`) for cut twins of merged objects. Check each part's volume and non-manifold count. (blender.md)
- **`Mesh.shade_smooth()` takes no arguments in Blender 5.x.** A failed call leaves everything flat-shaded. (blender.md)
- **Screen-space AO (GTAO) turns nested thin parts black** (a tube over a rod). Leave it off. (viewer.md)
- **Exploded offsets along the viewing axis are invisible** in a side view. Explode mostly in the view plane, fly the camera to an oblique angle, and suppress overlapping labels. (viewer.md)
- **Transparent ghosting needs `material.needsUpdate = true`.** (viewer.md)
- **External parts on the cut side hide the internals** in the cutaway (e.g. a lever). Ghost them. (viewer.md)
- **Guarded bump mapping.** Bump mapping from screen derivatives produces NaN black specks on degenerate quads. Guard it, and fade detail by pixel footprint. (surfaces.md)
- **The Chrome extension may be disconnected.** Use `scripts/shoot.mjs` (headless Playwright on the host GPU; `SW=1` for SwiftShader) rather than asking the user. (qa.md)
- **Stiff dynamics need small time steps.** Use an adaptive step: fine while gas, impacts or free fall are active, coarse otherwise. (simulation.md)
- **Captions that quote numbers go stale** when the operating point or mode changes. Fill the numbers in from the recording. (simulation.md)
- **A moving part's cut twin freezes** unless its transform is synced every frame. (viewer.md)
- **Calibration scan scripts print NaN** if they build parameters without spreading the defaults, while the tests stay green. (simulation.md)
- **Visual effects should be physically modest.** Scale flashes, jets and smoke to reality, e.g. a flash hider suppresses the flash. (viewer.md)
Files in this skill
- SKILL.md
- assets/examples/engine/engine-cycle.example.ts
- assets/examples/engine/mechanism.example.ts
- assets/examples/engine/sim.test.example.ts
- assets/examples/engine/thermo.example.ts
- assets/examples/rifle/ballistics.example.ts
- assets/examples/rifle/engine-events.example.ts
- assets/examples/rifle/fx.example.ts
- assets/examples/rifle/mechanism.example.ts
- assets/examples/rifle/sim.test.example.ts
- assets/viewer/chart.ts
- assets/viewer/i18n.example.ts
- assets/viewer/index.html
- assets/viewer/main.example.ts
- assets/viewer/materials.ts
- assets/viewer/model-registry.example.ts
- assets/viewer/player.ts
- assets/viewer/specs.ts
- assets/viewer/style.css
- assets/viewer/surface.ts
Attribution
Related skills
View all in ai-agents →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.