oneshotlm
Compare all models on this prompt →

3D solar system · gpt-5-nano

Using the pre-provided three.min.js (global THREE), build a 3D solar system with the sun and orbiting planets at varied speeds and sizes, orbit-drag camera controls, and a starfield.

⛨ sandboxed Open in new tab ↗
transcript · 4 messages
user

Using the pre-provided three.min.js (global THREE), build a 3D solar system with the sun and orbiting planets at varied speeds and sizes, orbit-drag camera controls, and a starfield.

assistant
thinking
**Implementing planet rotation**

I'm considering how to add planets as spheres with varying radii and orbital paths around the sun. I need to create an Object3D as an orbital pivot and make the planet meshes children of that pivot, allowing it to rotate around the Y-axis. For camera controls, I should explore implementing orbit controls, but notice that THREE.OrbitControls isn't included in three.js core. So instead, I could create mouse listeners to adjust spherical coordinates, simplifying the process by repositioning the camera based on mouse drag.**Implementing orbital motion class**

I’m planning to create a class that handles the orbital motion of planets. Each planet will have an Object3D pivot at the Sun's location, with a mesh placed at an orbit radius along the X-axis. To achieve rotation, I’ll rotate the pivot around the Y-axis based on a speed multiplied by the deltaTime.

For travel speeds, I'm considering varied rates: Mercury at 0.04 rad/s, Venus at 0.03, and so on, with distances between the Sun and each planet set accordingly. Additionally, I’ll scale the planets, with Mercury being 0.4 and Jupiter at 2.4. Lastly, I’ll use a large sphere for the Sun, applying an emissive material to add a glow.**Setting up lighting and camera controls**

I’m deciding to skip heavy glow and work on the lighting setup, which will include ambient light and a point light at the Sun. For the star field, I’ll create a BufferGeometry filled with randomly positioned stars, distributed in a sphere or cube beyond the visible distance, using small white points.

For camera controls, I’ll implement drag features with event listeners: when the mouse is down, dragging will be true, and on mouse move, I’ll adjust azimuth and elevation angles. After releasing the mouse, dragging will stop. I'll also allow zooming with the mouse wheel, starting with an initial camera distance of 40, using standard spherical coordinates.**Calculating camera position**

I’m planning to implement the following calculations for the camera position: 

x = distance * Math.sin(phi) * Math.cos(theta)  
y = distance * Math.cos(phi)  
z = distance * Math.sin(phi) * Math.sin(theta)

I’ll set phi to range between [0.1, PI - 0.1] for easier adjustments, starting with theta at 0 and phi at Math.PI/4. The camera position will be updated to center plus the calculated offset, and I’ll ensure the camera looks at the center.

I’m also considering allowing right-button dragging, but I may stick to just the left button. I want to ensure the script runs when the HTML loads, so I'll write a minimal index.html that includes a style tag and a script tag with the necessary code using THREE from three.min.js, avoiding any network calls. Finally, I’ll provide the relevant code snippet and describe what I created in the response.**Creating a self-contained web app**

I’m going to build a single-page web app in one self-contained file, named index.html. For this, I'll write the content directly into /tmp/ws/index.html. I will embed everything from scratch, relying on three.min.js.

I’ll set up the scene with a sun, planets, starfield, and proper lighting, ensuring the renderer responds to window resizing. Animations will be handled via requestAnimationFrame. For planets, I'll define their properties and create an orbit for each using Object3D. I'll also implement camera controls for dragging and zooming, ensuring everything runs smoothly without network calls. Finally, I’ll write the HTML and a minimal CSS for styling.**Implementing a 3D scene**

I’m setting up a 3D scene using Three.js, starting with a black background and configuring the camera. After initializing the renderer, I’ll add a glowing sun sphere and create a starfield of 4000 stars with random positions.

Then, I'll configure the planets, each with defined orbits, colors, and speeds, placing them in orbit around the sun. I'll animate the scene using `requestAnimationFrame`, handling camera updates based on distance. Finally, I'll ensure all scripts are included correctly in index.html and prepare everything for writing as a single string for the tool.**Preparing HTML content**

I’m crafting the HTML content for a Three.js solar system scene. The structure starts with the basic HTML boilerplate, meta tags, and a title. I'm setting up the scene, lights (ambient and point light for the sun), a sun mesh, and a starfield of 4000 stars.

I’ll also configure the planets using their respective properties and implement camera controls to allow dragging and zooming. Lastly, I need to write this content to an HTML file while ensuring everything is properly formatted, including the CSS styles for the layout.**Finalizing content response**

I'm ready to finalize my response! I want to let the user know that I've created the HTML file, and it's located at /tmp/ws/index.html. I could also offer to make any enhancements if they're interested. It's always good to check in and see if they have any additional requests. Let me put this together in a concise message.
write /tmp/ws/index.html (5678 bytes)
toolResult

Successfully wrote 5678 bytes to /tmp/ws/index.html

assistant
thinking
**Evaluating orbit distances**

I should make sure the orbit distances are consistent in the code, especially since we set the mesh position to the orbit value. The rotation of the orbitGroup around Y affects the planet's movement, assuming the orbit center is at the origin where the sun is placed. It seems fine even though the orbitGroup itself isn’t a child of the sun. The planet's rotation may not be needed, and I’ve handled the starField in the animation loop as defined earlier.**Confirming features and setup**

I've added a subtle spin feature and included functionality for window resizing, camera dragging, and zooming. I also added a sun light as a PointLight at the origin along with ambient light. I need to check if the correct version of three.js is loaded in this environment. I confirmed the index.html is created at /tmp/ws/index.html, which includes the code. To run it, simply open it in a browser, drag to orbit the camera, and scroll to zoom. Plus, you can tweak planet speeds in the config!**Providing server instructions**

The planets in the simulation have varied speeds and sizes, with a starfield and the sun at the center. The code relies on THREE from three.min.js. To view the simulation, you'll need to run a local server, especially since some browsers block file:// due to CORS restrictions. You can easily set up a server with `python -m http.server 8000` from the /tmp/ws directory, then access it at http://localhost:8000/index.html. Great news—we've successfully written the file! You can also adjust the planet configs array to modify their speeds or sizes.

All set. I created index.html in /tmp/ws that builds a self-contained 3D solar system using the pre-provided three.min.js (global THREE). What you get - A sun at the center with basic lighting - Eight planets with varied sizes and orbit speeds - Orbits implemented by rotating each planet’s parent group around the sun - A starfield background - Orbit-drag camera controls (click+drag to rotate, wheel to zoom) - Responsive resizing How to view - Open the file directly in a browser (file:// may work in some browsers). - For reliability, run a tiny static server from the folder: - python -m http.server 8000 - Then browse to http://localhost:8000/index.html Notes - You can tweak the planets by editing the planetConfigs array in the script: - orbit (distance from sun) - radius (planet size) - color - speed (orbit speed; in the code it’s scaled for visible motion) - The starfield is a simple random distribution; you can increase STAR_COUNT or tweak spread as needed.

TAKE IT TO CODE

A single self-contained HTML file — copy it and open in any browser, or reuse the prompt with your own pi-agent run.

RUN

modelgpt-5-nano
vendorOpenAI
harnesspi-agent
generated2026-08-01

EVALUATION

3/5 working

3D solar system with sun, planets, and starfield; orbit-drag camera responds but planets appear oddly huge and close, occluding view.

Vision grade · anthropic/claude-sonnet-5

MEASUREMENTS

Raw readings from the capture, not a verdict — the grade above is the only judgement. Percentages are how much of the screen changed; the measure under-reports sparse motion on a dark background.

idle motion4.5%
on click5.0%
on drag6.3%
on wheel8.3%
on enter + space20.1%
on arrow keys21.5%
on w/a/s/d18.1%
frame spread45.8 / 255
console errors0
js errors none

METRICS

runtime63.4s
tokens in4.3k
tokens out8.5k
cached2.0k
cost / run$0.0035