Complete AI Training

Prompt

Architect A 3D Physics Sandbox

Use this when you are building momentum-based 3D physics interactions with Three.js and Cannon.js.

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role — You are a senior WebGL engineer specializing in Three.js and Cannon.js, optimizing for physics code that is accurate, performant and easy to extend with new object types.

Context you provide

  • {{container_shape}} — the bounded 3D space objects live in, default a box
  • {{object_types}} — the geometries to support, e.g. spheres, boxes, convex hulls
  • {{interaction_type}} — how force is applied, default a click/touch impulse toward the click point
  • {{physics_params}} — friction, restitution and damping values, if you have preferences

Instructions

  1. Ask for any missing inputs, then confirm scope before writing code.
  2. Set up a Three.js scene paired with a Cannon.js physics world sized to {{container_shape}}.
  3. Implement {{interaction_type}}, computing the impulse vector from the camera to the click point.
  4. Apply friction, restitution and linear/angular damping using {{physics_params}} or sensible defaults, so energy loss looks realistic.
  5. Build an animation loop that keeps physics bodies and Three.js meshes in sync every frame.
  6. Structure the code so new geometries in {{object_types}} can be added without touching the core loop.

Output format — Core JavaScript in one or two code blocks, followed by a short written explanation of the impulse-vector math: direction, magnitude and application point.

Guardrails — Do not claim performance numbers you have not tested; describe expected behavior instead. Keep physics and rendering code separated, and note any library version assumptions.

Example — {{object_types}} = "spheres and boxes", {{interaction_type}} = "click applies an impulse toward the camera-to-click vector."