Create a static 3D pergola scene using three.js. Use these imports: <script…
- User
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Create a static 3D pergola scene using three.js.
Use these imports:
All dimensions are in feet. Y-axis is up.
Scene Setup:
Pergola Dimensions & Components (Actual lumber dimensions in feet):
Construction:
Posts (4 count):
Main Beams (2 count):
Rafters (7 count):
Purlins (7 count):
Add OrbitControls for ease of viewing. You may add visual embellishments but will be penalized if you add anything distracting from the main pergola design. Output the pergola you designed as a three.js visualization in a single html file
Below is a complete, self-contained HTML file that will create the requested static 3-D pergola scene with tapered beam/rafter overhangs.
Just copy-paste it into a file (e.g. pergola.html) and open it in any modern browser.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>3-D Pergola – three.js</title>
<!-- three.js core -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<!-- OrbitControls (same r128 build) -->
<script src="https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/controls/OrbitControls.js"></script>
<style>
html,body{margin:0;height:100%;overflow:hidden;background:#e0f0ff;}
canvas{display:block;}
</style>
</head>
<body>
<script>
// ------------- helpers & constants -----------------
const FT = 1; // 1 scene unit = 1 foot
const postW = 3.5/12; // 4×4 post real width/depth (ft)
const postH = 8;
const beamLen = 12; // total X length (ft)
const beamH = 7.25/12;
const beamThk = 1.5/12;
const beamOH = 1.5; // over-hang
const beamTaper = 0.35; // 35 %
const rafterLen = 9; // total Z length (ft)
const rafterH = 3.5/12;
const rafterThk = 1.5/12;
const rafterOH = 1.5;
const rafterTaper = 0.35;
const purlinLen = 12;
const purlinH = 1.5/12;
const purlinThk = 1.5/12;
// ----------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xaedba0);
// simple grass-green ground
{
const groundGeo = new THREE.PlaneBufferGeometry(100,100);
const groundMat = new THREE.MeshLambertMaterial({color:0x55aa55});
const ground = new THREE.Mesh(groundGeo, groundMat);
ground.rotation.x = -Math.PI/2;
ground.position.y = -0.01; // prevent z-fighting
scene.add(ground);
}
// lighting
scene.add(new THREE.AmbientLight(0xffffff,0.6));
const dirLight = new THREE.DirectionalLight(0xffffff,0.9);
dirLight.position.set(10,20,10);
scene.add(dirLight);
// renderer
const renderer = new THREE.WebGLRenderer({antialias:true});
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = false;
document.body.appendChild(renderer.domElement);
// camera & controls
const camera = new THREE.PerspectiveCamera(50, window.innerWidth/window.innerHeight, 0.1, 500);
camera.position.set(15,10,15);
const controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.target.set(0,8,0);
controls.update();
// single reusable wood material
const woodMat = new THREE.MeshStandardMaterial({color:0x8B5A2B});
// ============= Geometry builders ===================
/**
* Create a beam (or rafter) that has ruled / tapered bottom on each over-hang,
* flat top, oriented along X. Returned object is a THREE.Group whose local
* origin is dead-center of the overall member.
*/
function createTaperedMemberX(totalLen, height, thickness, overhang, taperK){
const group = new THREE.Group();
const centralLen = totalLen - 2*overhang;
// 1) central rectangular part
const boxG = new THREE.BoxBufferGeometry(centralLen, height, thickness);
const boxM = new THREE.Mesh(boxG, woodMat);
group.add(boxM);
// helper ‑ trapezoid (XY) -> extruded along Z (thickness)
const trapezoidShape = new THREE.Shape();
trapezoidShape.moveTo(0,0); // bottom @ inside
trapezoidShape.lineTo(0,height); // up
trapezoidShape.lineTo(overhang,height); // across top
trapezoidShape.lineTo(overhang,height*taperK); // down to tapered bottom
trapezoidShape.lineTo(0,0); // close
const extrudeOpts = {depth:thickness, bevelEnabled:false};
const sideGeo = new THREE.ExtrudeBufferGeometry(trapezoidShape, extrudeOpts);
sideGeo.translate(0,0,-thickness/2); // center about Z
// 2) right over-hang
const right = new THREE.Mesh(sideGeo, woodMat);
right.position.x = centralLen/2; // 0 at start, spans +overhang
group.add(right);
// 3) left over-hang (same geometry)
const left = new THREE.Mesh(sideGeo, woodMat);
left.position.x = -centralLen/2 - overhang;
group.add(left);
return group;
}
// ============= 1. Posts ============================
(function addPosts(){
const postGeo = new THREE.BoxBufferGeometry(postW, postH, postW);
const offsets = [
[-4.5, -3], [ 4.5,-3],
[-4.5, 3], [ 4.5, 3]
];
offsets.forEach(p=>{
const mesh = new THREE.Mesh(postGeo, woodMat);
mesh.position.set(p[0], postH/2, p[1]);
scene.add(mesh);
});
})();
// ============= 2. Main beams =======================
(function addBeams(){
[-3, 3].forEach(z=>{
const beam = createTaperedMemberX(beamLen, beamH, beamThk, beamOH, beamTaper);
beam.position.set(0, postH + beamH/2, z);
scene.add(beam);
});
})();
// ============= 3. Rafters ==========================
(function addRafters(){
// positions along X: equally spaced, end-to-end
for(let i=0;i<7;i++){
const x = -beamLen/2 + i*(beamLen/6); // -6,-4,…,+6
const rafterGrp = createTaperedMemberX(rafterLen, rafterH, rafterThk,
rafterOH, rafterTaper);
// rotate so length runs along Z
rafterGrp.rotation.y = Math.PI/2;
rafterGrp.position.set(
x,
postH + beamH + rafterH/2, // sits atop beams
0
);
scene.add(rafterGrp);
}
})();
// ============= 4. Purlins ==========================
(function addPurlins(){
const purlinGeo = new THREE.BoxBufferGeometry(purlinLen, purlinH, purlinThk);
for(let i=0;i<7;i++){
const z = -rafterLen/2 + i*(rafterLen/6); // -4.5 … +4.5
const mesh = new THREE.Mesh(purlinGeo, woodMat);
mesh.position.set(
0,
postH + beamH + rafterH + purlinH/2,
z
);
scene.add(mesh);
}
})();
// ============= render loop =========================
function onResize(){
camera.aspect = window.innerWidth/window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
}
window.addEventListener('resize',onResize);
renderer.setAnimationLoop(()=>renderer.render(scene,camera));
</script>
</body>
</html>
What you get
• A grassy ground plane, ambient + directional lighting, and OrbitControls so you can tumble, zoom, and pan around the pergola.
• Four posts forming a 9 ft × 6 ft rectangle, two tapered main beams riding on those posts, seven tapered rafters, and seven purlins on top.
• Each over-hang (beams and rafters) has a 35 % tapered bottom relief while keeping the top faces flat, creating the subtle upward sweep specified.