Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-opus-4-20250514-thinking-16k· AnthropicHugging Face LMArena Human Preference 140K

setup me a html file with three.js 0.178.0 and ammo.js and wasm and orbitcontrol and…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Geminigemini-2.5-flash-lite-preview-06-17-thinking’s answer.
  1. User

    setup me a html file with three.js 0.178.0 and ammo.js and wasm and orbitcontrol and gltfloader, with a simple scene

  2. Claude Assistant

    Here's a complete HTML file with Three.js 0.178.0, Ammo.js (WASM), OrbitControls, and GLTFLoader set up with a simple physics-enabled scene:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Three.js + Ammo.js Scene</title>
        <style>
            body {
                margin: 0;
                padding: 0;
                overflow: hidden;
                font-family: Arial, sans-serif;
            }
            #canvas-container {
                width: 100vw;
                height: 100vh;
            }
            #loading {
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);
                color: white;
                font-size: 24px;
                text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
            }
        </style>
    </head>
    <body>
        <div id="canvas-container">
            <div id="loading">Loading Ammo.js...</div>
        </div>
    
        <!-- Three.js 0.178.0 -->
        <script src="https://cdn.jsdelivr.net/npm/three@0.178.0/build/three.min.js"></script>
        
        <!-- Three.js modules -->
        <script src="https://cdn.jsdelivr.net/npm/three@0.178.0/examples/js/controls/OrbitControls.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/three@0.178.0/examples/js/loaders/GLTFLoader.js"></script>
        
        <!-- Ammo.js WASM -->
        <script src="https://cdn.jsdelivr.net/gh/kripken/ammo.js@HEAD/builds/ammo.wasm.js"></script>
    
        <script>
            // Global variables
            let scene, camera, renderer, controls;
            let physicsWorld;
            let rigidBodies = [];
            let tmpTrans;
            
            // Initialize Ammo.js
            Ammo().then(function() {
                // Remove loading message
                document.getElementById('loading').style.display = 'none';
                
                // Start the application
                init();
                animate();
            });
    
            function init() {
                // Scene setup
                scene = new THREE.Scene();
                scene.background = new THREE.Color(0x87CEEB); // Sky blue
                scene.fog = new THREE.Fog(0x87CEEB, 50, 200);
    
                // Camera setup
                camera = new THREE.PerspectiveCamera(
                    75,
                    window.innerWidth / window.innerHeight,
                    0.1,
                    1000
                );
                camera.position.set(10, 10, 20);
    
                // Renderer setup
                renderer = new THREE.WebGLRenderer({ antialias: true });
                renderer.setSize(window.innerWidth, window.innerHeight);
                renderer.shadowMap.enabled = true;
                renderer.shadowMap.type = THREE.PCFSoftShadowMap;
                document.getElementById('canvas-container').appendChild(renderer.domElement);
    
                // Controls setup
                controls = new THREE.OrbitControls(camera, renderer.domElement);
                controls.enableDamping = true;
                controls.dampingFactor = 0.05;
                controls.target.set(0, 0, 0);
    
                // Lighting
                const ambientLight = new THREE.AmbientLight(0xffffff, 0.6);
                scene.add(ambientLight);
    
                const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8);
                directionalLight.position.set(10, 20, 5);
                directionalLight.castShadow = true;
                directionalLight.shadow.camera.left = -20;
                directionalLight.shadow.camera.right = 20;
                directionalLight.shadow.camera.top = 20;
                directionalLight.shadow.camera.bottom = -20;
                directionalLight.shadow.camera.near = 0.1;
                directionalLight.shadow.camera.far = 50;
                directionalLight.shadow.mapSize.width = 2048;
                directionalLight.shadow.mapSize.height = 2048;
                scene.add(directionalLight);
    
                // Initialize physics
                setupPhysicsWorld();
    
                // Create ground
                createGround();
    
                // Create some physics objects
                createBox(0, 10, 0, 2, 2, 2, 0xff0000, 5);
                createBox(-3, 15, 0, 1, 1, 1, 0x00ff00, 1);
                createBox(3, 20, 0, 1.5, 1.5, 1.5, 0x0000ff, 3);
    
                // Create static decorative objects
                createStaticBox(5, 1, 5, 2, 2, 2, 0xff00ff);
                createStaticBox(-5, 1, -5, 2, 2, 2, 0xffff00);
    
                // Example GLTF loader setup (won't load anything without a model)
                const gltfLoader = new THREE.GLTFLoader();
                // Uncomment and provide a model URL to load a GLTF model
                // gltfLoader.load('path/to/model.gltf', function(gltf) {
                //     scene.add(gltf.scene);
                // });
    
                // Handle window resize
                window.addEventListener('resize', onWindowResize, false);
            }
    
            function setupPhysicsWorld() {
                // Physics configuration
                const collisionConfiguration = new Ammo.btDefaultCollisionConfiguration();
                const dispatcher = new Ammo.btCollisionDispatcher(collisionConfiguration);
                const overlappingPairCache = new Ammo.btDbvtBroadphase();
                const solver = new Ammo.btSequentialImpulseConstraintSolver();
    
                physicsWorld = new Ammo.btDiscreteDynamicsWorld(
                    dispatcher,
                    overlappingPairCache,
                    solver,
                    collisionConfiguration
                );
                physicsWorld.setGravity(new Ammo.btVector3(0, -9.81, 0));
    
                tmpTrans = new Ammo.btTransform();
            }
    
            function createGround() {
                // Three.js ground
                const groundGeometry = new THREE.BoxGeometry(50, 1, 50);
                const groundMaterial = new THREE.MeshPhongMaterial({ 
                    color: 0x808080,
                    side: THREE.DoubleSide
                });
                const groundMesh = new THREE.Mesh(groundGeometry, groundMaterial);
                groundMesh.receiveShadow = true;
                groundMesh.position.y = -0.5;
                scene.add(groundMesh);
    
                // Physics ground
                const groundShape = new Ammo.btBoxShape(new Ammo.btVector3(25, 0.5, 25));
                const groundTransform = new Ammo.btTransform();
                groundTransform.setIdentity();
                groundTransform.setOrigin(new Ammo.btVector3(0, -0.5, 0));
                
                const mass = 0; // Static object
                const localInertia = new Ammo.btVector3(0, 0, 0);
                const motionState = new Ammo.btDefaultMotionState(groundTransform);
                const rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, motionState, groundShape, localInertia);
                const body = new Ammo.btRigidBody(rbInfo);
                
                physicsWorld.addRigidBody(body);
            }
    
            function createBox(x, y, z, width, height, depth, color, mass) {
                // Three.js box
                const boxGeometry = new THREE.BoxGeometry(width, height, depth);
                const boxMaterial = new THREE.MeshPhongMaterial({ color: color });
                const boxMesh = new THREE.Mesh(boxGeometry, boxMaterial);
                boxMesh.castShadow = true;
                boxMesh.receiveShadow = true;
                boxMesh.position.set(x, y, z);
                scene.add(boxMesh);
    
                // Physics box
                const boxShape = new Ammo.btBoxShape(new Ammo.btVector3(width/2, height/2, depth/2));
                const boxTransform = new Ammo.btTransform();
                boxTransform.setIdentity();
                boxTransform.setOrigin(new Ammo.btVector3(x, y, z));
                
                const localInertia = new Ammo.btVector3(0, 0, 0);
                boxShape.calculateLocalInertia(mass, localInertia);
                
                const motionState = new Ammo.btDefaultMotionState(boxTransform);
                const rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, motionState, boxShape, localInertia);
                const body = new Ammo.btRigidBody(rbInfo);
                
                physicsWorld.addRigidBody(body);
                
                boxMesh.userData.physicsBody = body;
                rigidBodies.push(boxMesh);
            }
    
            function createStaticBox(x, y, z, width, height, depth, color) {
                const boxGeometry = new THREE.BoxGeometry(width, height, depth);
                const boxMaterial = new THREE.MeshPhongMaterial({ color: color });
                const boxMesh = new THREE.Mesh(boxGeometry, boxMaterial);
                boxMesh.castShadow = true;
                boxMesh.receiveShadow = true;
                boxMesh.position.set(x, y, z);
                scene.add(boxMesh);
            }
    
            function updatePhysics(deltaTime) {
                // Step physics world
                physicsWorld.stepSimulation(deltaTime, 10);
    
                // Update rigid bodies
                for (let i = 0; i < rigidBodies.length; i++) {
                    const objThree = rigidBodies[i];
                    const objAmmo = objThree.userData.physicsBody;
                    const ms = objAmmo.getMotionState();
                    
                    if (ms) {
                        ms.getWorldTransform(tmpTrans);
                        const p = tmpTrans.getOrigin();
                        const q = tmpTrans.getRotation();
                        objThree.position.set(p.x(), p.y(), p.z());
                        objThree.quaternion.set(q.x(), q.y(), q.z(), q.w());
                    }
                }
            }
    
            function animate() {
                requestAnimationFrame(animate);
    
                const deltaTime = 1/60;
                updatePhysics(deltaTime);
    
                controls.update();
                renderer.render(scene, camera);
            }
    
            function onWindowResize() {
                camera.aspect = window.innerWidth / window.innerHeight;
                camera.updateProjectionMatrix();
                renderer.setSize(window.innerWidth, window.innerHeight);
            }
        </script>
    </body>
    </html>
    

    This HTML file includes:

    • Three.js 0.178.0 with OrbitControls and GLTFLoader
    • Ammo.js WASM physics engine
    • A simple scene with:
      • Sky blue background with fog
      • Directional and ambient lighting with shadows
      • A physics-enabled ground plane
      • Three colored boxes that fall with physics
      • Two static decorative boxes
      • OrbitControls for camera movement (click and drag to rotate, scroll to zoom)

    The scene demonstrates:

    • Physics simulation with falling boxes
    • Shadow rendering
    • Basic lighting setup
    • Camera controls

    To use the GLTFLoader, uncomment the example code and provide a path to your GLTF/GLB model file. The physics world is fully set up and ready to handle additional rigid bodies and constraints as needed.

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