Create a static 3D pergola scene using three.js. Use these imports: <script…
- User
Create a static 3D pergola scene using three.js.
Use these imports:
All dimensions are in feet. Y-axis is up.
Scene Setup:
- Ground: grassy plain
- Lighting: ambient light and directional light
- Material: wood for all pergola parts
- Camera: Position for a good overview
Pergola Dimensions & Components (Actual lumber dimensions in feet):
- Post dimensions (nominal 4x4): width/depth = 3.5/12, height = 8.0.
- Main Beam dimensions (nominal 2x8): thickness (Z-axis for beam along X) = 1.5/12, height (Y-axis) = 7.25/12. Overhang = 1.5.
- Rafter dimensions (nominal 2x4): thickness (X-axis for rafter along Z) = 1.5/12, height (Y-axis) = 3.5/12. Overhang = 1.5.
- Purlin dimensions (nominal 2x2): width/height/depth = 1.5/12.
Construction:
-
Posts (4 count):
- Calculate position so as to create a 9ft (X) by 6ft (Z) rectangle.
-
Main Beams (2 count):
- Calculate position so as to ride on top of posts
- Total Length: 9.0 (post span) + 2 * 1.5 (overhangs) = 12.0.
- Height: 7.25/12. Thickness: 1.5/12. Overhang: 1.5.
- Cut a tapered relief on the bottom face of each 1.5 overhang, reducing the lumber height to 35% of original by the end of each overhang to create an upward sweep profile, keeping the top face flat.
-
Rafters (7 count):
- Calculate positions so as to ride on top of main beams
- Spacing: Distribute 7 rafters evenly along the 12.0 ft X-length of main beams
- Total Length: 6.0 (main beam span based on post Z-centers) + 2 * 1.5 (overhangs) = 9.0.
- Height: 3.5/12. Thickness: 1.5/12. Overhang: 1.5.
- Cut a tapered relief on the bottom face of each 1.5 overhang, reducing the lumber height to 35% of original by the end of each overhang to create an upward sweep profile, keeping the top face flat.
-
Purlins (7 count):
- Calculate positions so as to ride on top of rafters
- Spacing: Distribute 7 purlins evenly along the 9.0 ft Z-length of rafters.
- Dimensions: Length = 12.0. Height = 1.5/12. Depth = 1.5/12.
Add OrbitControls for ease of viewing. Output as a pleasing single-file html three.js visualization.
- Assistant
Here’s a single‐file HTML example that builds a simple “static” 3D pergola in Three.js r128. All dimensions are in feet, Y‐axis is up. Main beams and rafters have a little “upward sweep” relief on the bottom overhangs (bottom face tapers from full depth to 35% depth over the 1.5 ft overhang), while posts and purlins are simple boxes. You can orbit/pan/zoom with your mouse.
Save this as
index.htmland open in your browser:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>Three.js Pergola</title> <style> body { margin: 0; overflow: hidden; } canvas { display: block; } </style> </head> <body> <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/controls/OrbitControls.js"></script> <script> // -------------------------------- // Scene, Renderer, Camera, Controls // -------------------------------- const scene = new THREE.Scene(); scene.background = new THREE.Color(0xbfd1e5); const renderer = new THREE.WebGLRenderer({ antialias: true }); renderer.setSize(window.innerWidth, window.innerHeight); document.body.appendChild(renderer.domElement); const camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 0.1, 1000 ); camera.position.set(15, 10, 15); const controls = new THREE.OrbitControls(camera, renderer.domElement); controls.target.set(0, 4, 0); controls.update(); // ---------------- // Lights + Ground // ---------------- scene.add(new THREE.AmbientLight(0x404040, 1.0)); const dir = new THREE.DirectionalLight(0xffffff, 0.8); dir.position.set(10, 20, 10); scene.add(dir); // simple grassy ground const groundMat = new THREE.MeshLambertMaterial({ color: 0x228b22 }); const ground = new THREE.Mesh( new THREE.PlaneGeometry(100, 100), groundMat ); ground.rotateX(-Math.PI / 2); scene.add(ground); // ------------- // Wood material // ------------- const woodMat = new THREE.MeshStandardMaterial({ color: 0x8b4513, roughness: 0.6, metalness: 0.1 }); // ------------------- // DIMENSIONS (feet) // ------------------- const postW = 3.5 / 12, postD = postW, postH = 8.0; const beamSpan = 9.0, beamOver = 1.5, beamL = beamSpan + 2 * beamOver; const beamD = 1.5 / 12, beamH = 7.25 / 12; const rafSpan = 6.0, rafOver = 1.5, rafL = rafSpan + 2 * rafOver; const rD = 1.5 / 12, rH = 3.5 / 12; const pW = beamL, pH = 1.5 / 12, pD = 1.5 / 12; // ------------- // POSTS (4) // ------------- const postGeo = new THREE.BoxGeometry(postW, postH, postD); for (let x of [-beamSpan/2, +beamSpan/2]) { for (let z of [-rafSpan/2, +rafSpan/2]) { const post = new THREE.Mesh(postGeo, woodMat); post.position.set(x, postH / 2, z); scene.add(post); } } // ------------------------------------------------- // FUNCTION to build a BEAM with bottom overhang sweep // ------------------------------------------------- function makeSweepBox(length, height, depth, span, overhang) { // 1) build a centered box const geo = new THREE.BoxGeometry(length, height, depth); // 2) shift it so top face == y=0, bottom == y=-height geo.translate(0, -height / 2, 0); // 3) taper the bottom vertices in each overhang const pos = geo.attributes.position; for (let i = 0; i < pos.count; i++) { const x = pos.getX(i), y = pos.getY(i); // modify only bottom-half verts in the overhang region if (y < 0 && Math.abs(x) > span / 2) { // t ∈ [0..1] across that 1.5 ft overhang let t = (Math.abs(x) - span / 2) / overhang; t = THREE.MathUtils.clamp(t, 0, 1); // bottom is originally y = -height; we lift it by 65% * t const dy = 0.65 * height * t; pos.setY(i, y + dy); } } geo.computeVertexNormals(); return geo; } // -------------- // MAIN BEAMS (2) // -------------- const beamGeo = makeSweepBox(beamL, beamH, beamD, beamSpan, beamOver); for (let z of [-rafSpan / 2, +rafSpan / 2]) { const beam = new THREE.Mesh(beamGeo, woodMat); // bottom-of-geometry sits at y = postH ⇒ meshY = postH + beamH beam.position.set(0, postH + beamH, z); scene.add(beam); } // ------------- // RAFTERS (7) // ------------- const rafGeo = makeSweepBox(rD, rH, rafL, rafSpan, rafOver); for (let i = 0; i < 7; i++) { // spread 7 rafters evenly over the 12-ft beam length const x = -beamL / 2 + (i * beamL) / (7 - 1); const raf = new THREE.Mesh(rafGeo, woodMat); // rafter bottom → beam top @ y = postH + beamH // geometry bottom is at -rH, so meshY = postH+beamH + rH raf.position.set(x, postH + beamH + rH, 0); scene.add(raf); } // ------------- // PURLINS (7) // ------------- const pGeo = new THREE.BoxGeometry(pW, pH, pD); // shift so top face y=0, bottom y=-pH pGeo.translate(0, -pH / 2, 0); for (let i = 0; i < 7; i++) { // distribute along rafL = 9ft in Z const z = -rafL / 2 + (i * rafL) / (7 - 1); const p = new THREE.Mesh(pGeo, woodMat); // bottom of purlin @ rafter top (postH+beamH+rH) p.position.set(0, postH + beamH + rH + pH, z); scene.add(p); } // ---------- // render loop // ---------- function animate() { requestAnimationFrame(animate); renderer.render(scene, camera); } animate(); // handle resize window.addEventListener('resize', () => { const w = window.innerWidth, h = window.innerHeight; renderer.setSize(w, h); camera.aspect = w / h; camera.updateProjectionMatrix(); }); </script> </body> </html>Explanation of the key bits:
• All lengths are in feet.
• Posts: simple 4×4 (3.5″×3.5″) boxes, 8 ft tall, at the corners of a 9 × 6 ft rectangle.
• Main beams: 2″×8″ nominal (7.25″ tall, 1.5″ thick) boxes, 12 ft long (9 ft span + 2×1.5 ft overhang), with a little bottom‐face taper over each 1.5 ft overhang, lifting the bottom from full height to 35% of height.
• Rafters: same trick as beams, but 2″×4″ nominal (3.5″ tall, 1.5″ thick), 9 ft long overhanging 1.5 ft each side, spaced evenly along the 12 ft beams.
• Purlins: 2″×2″ nominal (1.5″ square) 12 ft long, spaced evenly along the 9 ft rafters.
• Ground plane, ambient + directional lights, OrbitControls for easy viewing.Feel free to tweak colors, spacing, camera angles or add textures for a more photo‐real look!
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-3-5-haiku-20241022Compare side by side →
- o3-miniCompare side by side →
amazon.nova-pro-v1:0Compare side by side →
gemini-2.5-proCompare side by side →
claude-sonnet-4-20250514Compare side by side →
claude-opus-4-20250514Compare side by side →
- chatgpt-4o-latest-20250326Compare side by side →
mistral-medium-2505Compare side by side →
llama-4-maverick-03-26-experimentalCompare side by side →