# One-Shot Prompt

**Simulation**: Paper / Receipt
**Theme**: Default
**Generated**: 2026-04-09

## Prompt

Generate a complete, single-file interactive 3D physics simulation of a paper receipt using Three.js and a custom Verlet integration physics engine from scratch.

Technical Requirements:
1. **No Dependencies except Three.js**: Use `<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>`. Do not import Cannon.js, Ammo.js, or OrbitControls. Write the physics and camera controls inline.
2. **Physics Engine**: 
   - Position-based dynamics (Verlet integration) with a fixed timestep accumulator (e.g., 120Hz physics).
   - Use at least 8 substeps per frame for stability.
   - Particle grid of 30 columns by 45 rows.
   - Implement structural (adjacent), shear (diagonal), and strong bending (skip-1 and skip-2) constraints. The bending constraints should have high stiffness to make it behave like paper rather than flowy cloth.
   - Apply gravity and slight air friction (damping).
3. **Rendering & Materials**:
   - `THREE.BufferGeometry` with `Float32Array` attributes updated per frame (`needsUpdate = true`). Compute vertex normals per frame for smooth shading.
   - `THREE.MeshStandardMaterial` with `side: THREE.DoubleSide`.
   - Dynamic canvas texture mapped to the mesh: draw a realistic-looking store receipt using the HTML Canvas API (include store name, itemized lines, total, and a faux barcode).
   - Lighting: Ambient light plus a directional light casting shadows. Add a subtle ground plane to receive shadows.
4. **Interaction**:
   - Mouse and touch grab using `THREE.Raycaster`. Users should be able to click and drag to grab the nearest particle and move it in 3D space, causing the receipt to deform, fold, or crumple.
   - Implement basic orbit camera controls (drag to rotate, scroll to zoom) manually.
   - Pin the top two corners of the receipt initially, but allow them to be grabbed and moved.
5. **UI & Polish**:
   - Add an unobtrusive HTML overlay with the title "Folio" and brief instructions ("Click and drag to interact").
   - Ensure the simulation targets 60fps and works flawlessly on both desktop and mobile.
   - Output everything as a single `index.html` file with NO TRUNCATED CODE.

## Notes

- **Physics approach**: Verlet integration is chosen for its stability in constraint solving, which is critical for the stiff behavior of paper. Bending constraints are doubled up (skip 1 and 2) to resist crumpling and preserve area.
- **Performance**: BufferGeometry with typed arrays avoids garbage collection overhead during per-frame vertex updates.
- **Hosting**: Can be hosted statically anywhere (CodePen, Vercel, Cloudflare Pages).
