Skip to content
TheChatArchiveThe Chat Archive
grok-3-preview-02-24· xAIHugging Face LMArena Human Preference 140K

Create a static 3D pergola scene using three.js. Use these imports: <script…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Googlegemma-3n-e4b-it’s answer.
  1. User

    Create a static 3D pergola scene using three.js.

    Use these imports:

    All dimensions are in feet. Y-axis is up.

    Scene Setup:

    1. Ground: grassy plain
    2. Lighting: ambient light and directional light
    3. Material: wood for all pergola parts
    4. 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:

    1. Posts (4 count):

      • Calculate position so as to create a 9ft (X) by 6ft (Z) rectangle.
    2. 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.
    3. Rafters (7 count):

      • Calculate positions so as to ride on top of main beams, with end rafters aligning with the ends of the main beam ends.
      • 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.
    4. Purlins (7 count):

      • Calculate positions so as to ride on top of rafters, with end purlins aligning with the ends of the rafter ends.
      • 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. It is optional to make the scene more pleasing by simple additions but avoid anything distracting from the main pergola design. Output as a single-file html three.js visualization of the pergola you have designed...

  2. Assistant

    Here's a complete HTML file that creates a 3D pergola scene using Three.js according to your specifications:

    <!DOCTYPE html>
    <html>
    <head>
        <title>3D Pergola Visualization</title>
        <style>
            body { margin: 0; overflow: hidden; }
            canvas { width: 100%; height: 100% }
        </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>
            // Initialize scene
            const scene = new THREE.Scene();
            const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
            const renderer = new THREE.WebGLRenderer({ antialias: true });
            renderer.setSize(window.innerWidth, window.innerHeight);
            document.body.appendChild(renderer.domElement);
    
            // Add OrbitControls
            const controls = new THREE.OrbitControls(camera, renderer.domElement);
            controls.enableDamping = true;
            controls.dampingFactor = 0.05;
    
            // Materials
            const woodMaterial = new THREE.MeshStandardMaterial({
                color: 0x8B4513, // Saddle brown
                roughness: 0.7,
                metalness: 0.1
            });
    
            const grassMaterial = new THREE.MeshStandardMaterial({
                color: 0x228B22, // Forest green
                roughness: 0.9
            });
    
            // Lighting
            const ambientLight = new THREE.AmbientLight(0xffffff, 0.5);
            scene.add(ambientLight);
    
            const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8);
            directionalLight.position.set(10, 20, 10);
            directionalLight.castShadow = true;
            scene.add(directionalLight);
    
            // Ground (grassy plain)
            const groundGeometry = new THREE.PlaneGeometry(50, 50);
            const ground = new THREE.Mesh(groundGeometry, grassMaterial);
            ground.rotation.x = -Math.PI / 2;
            ground.position.y = -0.01;
            scene.add(ground);
    
            // Function to create tapered beam/rafter with upward sweep
            function createTaperedBeam(length, height, thickness, overhang, isBeam = true) {
                const shape = new THREE.Shape();
                const fullHeight = height;
                const reducedHeight = height * 0.35;
                
                // Start at bottom left
                shape.moveTo(-length/2, -height/2);
                // Left overhang taper
                shape.lineTo(-length/2 + overhang, -height/2);
                shape.lineTo(-length/2 + overhang, height/2);
                // Top flat
                shape.lineTo(length/2 - overhang, height/2);
                // Right overhang taper
                shape.lineTo(length/2 - overhang, -height/2);
                shape.lineTo(length/2, -height/2 + (height - reducedHeight));
                // Bottom right to left
                shape.lineTo(-length/2, -height/2 + (height - reducedHeight));
                
                const extrudeSettings = {
                    depth: thickness,
                    bevelEnabled: false
                };
                
                const geometry = new THREE.ExtrudeGeometry(shape, extrudeSettings);
                const mesh = new THREE.Mesh(geometry, woodMaterial);
                
                // Rotate for proper orientation
                if (isBeam) {
                    mesh.rotation.y = Math.PI / 2;
                }
                mesh.position.y += height/2;
                
                return mesh;
            }
    
            // Pergola dimensions (in feet)
            const postWidth = 3.5/12;
            const postHeight = 8.0;
            const beamLength = 12.0;
            const beamHeight = 7.25/12;
            const beamThickness = 1.5/12;
            const rafterLength = 9.0;
            const rafterHeight = 3.5/12;
            const rafterThickness = 1.5/12;
            const purlinSize = 1.5/12;
            const overhang = 1.5;
    
            // Create posts (4x4)
            const postGeometry = new THREE.BoxGeometry(postWidth, postHeight, postWidth);
            const postPositions = [
                [-4.5, 0, -3],  // Front left
                [4.5, 0, -3],   // Front right
                [-4.5, 0, 3],   // Back left
                [4.5, 0, 3]     // Back right
            ];
    
            postPositions.forEach(pos => {
                const post = new THREE.Mesh(postGeometry, woodMaterial);
                post.position.set(pos[0], postHeight/2, pos[2]);
                scene.add(post);
            });
    
            // Create main beams (2x8)
            const beamPositions = [
                [0, postHeight, -3],  // Front
                [0, postHeight, 3]    // Back
            ];
    
            beamPositions.forEach(pos => {
                const beam = createTaperedBeam(beamLength, beamHeight, beamThickness, overhang, true);
                beam.position.set(pos[0], pos[1], pos[2]);
                scene.add(beam);
            });
    
            // Create rafters (2x4)
            const rafterCount = 7;
            const rafterSpacing = beamLength / (rafterCount - 1);
            for (let i = 0; i < rafterCount; i++) {
                const xPos = -beamLength/2 + i * rafterSpacing;
                const rafter = createTaperedBeam(rafterLength, rafterHeight, rafterThickness, overhang, false);
                rafter.position.set(xPos, postHeight + beamHeight, 0);
                scene.add(rafter);
            }
    
            // Create purlins (2x2)
            const purlinCount = 7;
            const purlinSpacing = rafterLength / (purlinCount - 1);
            const purlinGeometry = new THREE.BoxGeometry(beamLength, purlinSize, purlinSize);
            for (let i = 0; i < purlinCount; i++) {
                const zPos = -rafterLength/2 + i * purlinSpacing;
                const purlin = new THREE.Mesh(purlinGeometry, woodMaterial);
                purlin.position.set(0, postHeight + beamHeight + rafterHeight, zPos);
                scene.add(purlin);
            });
    
            // Camera setup
            camera.position.set(15, 10, 15);
            camera.lookAt(0, postHeight/2, 0);
    
            // Animation loop
            function animate() {
                requestAnimationFrame(animate);
                controls.update();
                renderer.render(scene, camera);
            }
    
            animate();
    
            // Handle window resize
            window.addEventListener('resize', () => {
                camera.aspect = window.innerWidth / window.innerHeight;
                camera.updateProjectionMatrix();
                renderer.setSize(window.innerWidth, window.innerHeight);
            });
        </script>
    </body>
    </html>
    

    This implementation includes:

    1. A complete scene setup with ground, lighting, and camera
    2. Accurate pergola dimensions converted from feet to Three.js units
    3. Custom shape creation for tapered beams and rafters using THREE.Shape
    4. Proper positioning of all components (posts, beams, rafters, purlins)
    5. Wood material with realistic properties
    6. Grass material for the ground
    7. OrbitControls for interactive viewing
    8. Responsive design with window resize handling

    Key features:

    • The pergola is centered at the origin (0,0,0)
    • Posts form a 9ft x 6ft rectangle
    • Beams and rafters include the specified 1.5ft overhangs with tapered ends
    • All components are properly stacked vertically
    • The camera is positioned for a good overview with orbit controls enabled
    • Simple but effective lighting setup
    • Realistic wood and grass materials

    To use this, simply save it as an HTML file and open it in a web browser. You can rotate, zoom, and pan using the mouse:

    • Left-click and drag to rotate
    • Right-click and drag to pan
    • Scroll wheel to zoom

    The scene is kept simple to focus on the pergola structure while maintaining a pleasing appearance with appropriate materials and lighting.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.