# LEGO Electron Microscope

Adapted for My First Microscope from the supplied **LEGO Electron Microscope Set** folder.
The current design represents an aberration-corrected scanning transmission electron microscope (STEM).

## Files

- `index.html` — current 3D model, component explorer, generated parts inventory, and CSV download.
- `brick-stem-v1.html` — earlier model-only design, preserved for reference.
- `three-d-stage.js` — renderer, lighting, orbit controls, reset view, and OBJ/MTL + GLB exports.
- `parts.csv` — inventory generated from the current model, also available without WebGL.
- `vendor/` — pinned Three.js 0.184.0 modules and their MIT license. No CDN connection is required.

## Run locally

Extract the whole ZIP, then serve this folder over HTTP. ES modules do not work reliably by double-clicking the HTML file.

```sh
cd lego-electron-microscope
python3 -m http.server 8000
```

Open `http://localhost:8000/index.html`. A browser with WebGL support is required for the interactive viewer.

## Explore and export

On the website, `/build/lego-tem` opens the viewer as a full-page workspace.
The Build guide link opens the project notes at `/build/lego-tem/guide`; Build returns to the project list.
These website navigation links are not available on a standalone local HTTP server.

- Drag to orbit, scroll or pinch to zoom, and right-drag to pan. On touch screens, use two fingers to pan.
- On phones, use the bottom 3D model / Parts / Components navigation. Tapping a parts row returns to its highlighted location in the 3D view; filters and the current parts page are retained.
- Use the + / − buttons to zoom with one hand. The Downloads menu holds the OBJ + MTL and GLB exports. Swipe the color filters horizontally to see every color.
- The Components view has a View in 3D button after its explanation.
- Select a microscope component to highlight it and read its description.
- In the Parts tab, filter by color or search by part name or design ID. Use Back/Next to browse compact pages.
- Select a parts row to highlight all matching pieces. Select it again to clear, or use the clear-highlight button.
- Each numbered part has a separate design-ID link that opens its BrickLink catalog page in a new tab.
  Links describe the part family; choose and check its color and mold variant on BrickLink.
  The unspecified hose and custom scientist have no exact catalog link.
- The Components tab holds the microscope component explorer.
- Reset view clears highlights and restores the original camera.
- Download parts CSV for a spreadsheet or a printed checklist.
- Download OBJ + MTL for geometry and materials, or GLB for a single binary glTF file.
  Exports clear highlights first and always contain the complete model with its original materials.
  Keep the OBJ and MTL together. These mesh files are not BrickLink Studio or LEGO instruction files.

## Edit the model

The build section in `index.html` uses:

- `rect(name, w, d, hPlates, x, yPlates, z, material, smooth)` — rectangular stack, split into catalog bricks, plates, or tiles.
- `round(name, diameter, hPlates, x, yPlates, z, material)` — vertical round bricks or plates.
- `hround(...)` — sideways round stack.

Horizontal coordinates use studs; vertical coordinates use plates (3 plates = 1 brick).
The parts panel and its CSV download update automatically when the model changes.
Regenerate the separate `parts.csv` from that download after changing the model.
The component explorer matches mesh names; update its matching rules when adding or renaming components.

## Physical-build status

This is a digital educational display-model prototype. It does not magnify or generate an electron beam.
The geometry simplifies real parts. Stud connections, sideways attachments, stability, color availability,
and hose length have not been validated by a physical trial build. The CSV is a planning inventory,
not an order-ready or tested set specification. The scientist is counted as one complete minifigure.

An independent educational model; not affiliated with or endorsed by the LEGO Group.
