CALIBRATING DRONES...
🎓 AI Educational Architect
The following prompt ensures high-performance code that labels and
explains physics concepts.
Act as a Computational Physics Teacher & WebGL Expert. Write the
JavaScript **function body** that runs for **EACH PARTICLE** in a 3D Drone Swarm.
Context:
- The function runs 20,000 times per frame.
- Input Vars: `i` (index), `count`, `target` (Vector3), `color` (Color), `time`, `THREE`.
- Helper: `addControl(id, label, min, max, initial)` -> Returns float.
- Helper: `setInfo(title, educational_text)` -> Displays HUD info (run only once).
- Helper: `annotate(id, vector, label)` -> Draws a 2D label on a 3D point.
**EDUCATIONAL RULES:**
1. **EXPLAIN IT:** You MUST call `setInfo` (if i===0) to explain the math or physics concept being
visualized.
2. **LABEL IT:** Use `annotate` to highlight singularities, attractors, or poles (e.g., if i===0 or
i===count/2).
3. **NO ALLOCATION:** Do NOT use `new Vector3()`. Write directly to `target.x`, `target.y`, `target.z`.
4. **ANNOTATION SAFETY:** When calling annotate, the second argument MUST be a THREE.Vector3 (e.g., target
or new THREE.Vector3(x,y,z)). Do NOT pass plain objects like {x:0, y:0, z:0} or the system will crash with
vector.clone is not a function. Allocation inside if(i===0) is permitted.
**Task:** Create a [INSERT IDEA HERE, e.g., "Lorenz Attractor" or "Quantum Orbital"]
**Example Code Structure (Use this):**
const scale = addControl("s", "Scale", 5, 50, 20);
const t = time * 0.5;
// Math Logic (e.g., Parametric Torus)
const u = (i / count) * Math.PI * 2;
const v = (i / count) * Math.PI * 10 + t;
const x = (scale + 5 * Math.cos(v)) * Math.cos(u);
const y = (scale + 5 * Math.cos(v)) * Math.sin(u);
const z = 5 * Math.sin(v);
target.set(x, y, z); // Direct assignment
color.setHSL((i / count), 1, 0.5);
// Educational Annotation & Info
if(i === 0) {
setInfo("Toroidal Field", "A torus is a surface of revolution generated by revolving a circle in
three-dimensional space about an axis that is coplanar with the circle.");
annotate("pole", target, "North Pole");
}