Skip to content
TheChatArchiveThe Chat Archive
Metallama-3.3-70b-instruct· MetaHugging Face LMArena Human Preference 140K

Create an interactive 3D particle system visualization using Three.js. The system should…

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

    Create an interactive 3D particle system visualization using Three.js. The system should feature approximately 20,000 particles that can morph between several distinct geometric shapes: a sphere, a cube, a torus, an icosahedron, the Utah teapot, a DNA double helix, and a wormhole/tunnel shape.

    Implement the following user controls via a simple UI:

    • Particle size (slider)
    • Rotation speed of the particle system (slider)
    • Particle color (color picker)
    • Bloom effect intensity (slider)
    • Motion trail effect (slider using AfterimagePass)

    The particles should have an additive blending mode for a glowing effect. Provide OrbitControls for camera manipulation (drag to rotate, scroll to zoom, double-click to reset). The morphing animation between shapes should be smooth, lasting about 1.5 seconds, using linear interpolation. Ensure particle target positions for new shapes are shuffled for a more organic transition. The UI should be styled with a dark theme and be responsive. Include post-processing effects: UnrealBloomPass for glow and AfterimagePass for motion trails. Ensure the code is modular and well-commented, using ES6 modules for Three.js imports.

  2. Meta Assistant

    Three.js Interactive 3D Particle System Visualization

    Introduction

    This project creates an interactive 3D particle system visualization using Three.js. The system features approximately 20,000 particles that can morph between several distinct geometric shapes. The user can control various aspects of the visualization through a simple UI.

    Installation

    To run this project, you need to have Node.js and npm installed. Clone the repository and install the required dependencies:

    npm install
    

    Code Structure

    The code is organized into several modules:

    • main.js: The main entry point of the application.
    • ParticleSystem.js: Responsible for creating and managing the particle system.
    • UI.js: Handles user input and updates the particle system accordingly.
    • PostProcessing.js: Applies post-processing effects to the scene.

    Implementation

    main.js

    // Import required modules
    import * as THREE from 'three';
    import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
    import { UnrealBloomPass } from 'three/examples/jsm/postprocessing/UnrealBloomPass';
    import { AfterimagePass } from 'three/examples/jsm/postprocessing/AfterimagePass';
    import ParticleSystem from './ParticleSystem.js';
    import UI from './UI.js';
    import PostProcessing from './PostProcessing.js';
    
    // Create the scene, camera, and renderer
    const scene = new THREE.Scene();
    const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
    const renderer = new THREE.WebGLRenderer({
      canvas: document.getElementById('canvas'),
      antialias: true
    });
    
    // Create the particle system and UI
    const particleSystem = new ParticleSystem(scene);
    const ui = new UI(particleSystem);
    
    // Create post-processing effects
    const postProcessing = new PostProcessing(renderer, scene, camera);
    
    // Add orbit controls
    const controls = new OrbitControls(camera, renderer.domElement);
    
    // Animate the scene
    function animate() {
      requestAnimationFrame(animate);
      particleSystem.update();
      postProcessing.update();
      controls.update();
      renderer.render(scene, camera);
    }
    
    animate();
    

    ParticleSystem.js

    // Import required modules
    import * as THREE from 'three';
    
    // Define the particle system class
    class ParticleSystem {
      constructor(scene) {
        this.scene = scene;
        this.particles = [];
        this.geometry = new THREE.BufferGeometry();
        this.material = new THREE.PointsMaterial({
          size: 0.1,
          color: 0xffffff,
          blending: THREE.AdditiveBlending
        });
        this.points = new THREE.Points(this.geometry, this.material);
        this.scene.add(this.points);
    
        // Initialize particles
        for (let i = 0; i < 20000; i++) {
          const particle = new THREE.Vector3();
          particle.x = Math.random() * 2 - 1;
          particle.y = Math.random() * 2 - 1;
          particle.z = Math.random() * 2 - 1;
          this.particles.push(particle);
        }
    
        // Create target positions for different shapes
        this.shapes = {
          sphere: [],
          cube: [],
          torus: [],
          icosahedron: [],
          teapot: [],
          dna: [],
          wormhole: []
        };
    
        // Initialize target positions for each shape
        this.initTargetPositions();
      }
    
      // Initialize target positions for each shape
      initTargetPositions() {
        // Sphere
        for (let i = 0; i < this.particles.length; i++) {
          const particle = new THREE.Vector3();
          particle.x = Math.random() * 2 - 1;
          particle.y = Math.random() * 2 - 1;
          particle.z = Math.random() * 2 - 1;
          particle.normalize();
          particle.multiplyScalar(Math.random() * 2 + 1);
          this.shapes.sphere.push(particle);
        }
    
        // Cube
        for (let i = 0; i < this.particles.length; i++) {
          const particle = new THREE.Vector3();
          particle.x = Math.random() * 2 - 1;
          particle.y = Math.random() * 2 - 1;
          particle.z = Math.random() * 2 - 1;
          particle.x = Math.round(particle.x);
          particle.y = Math.round(particle.y);
          particle.z = Math.round(particle.z);
          this.shapes.cube.push(particle);
        }
    
        // Torus
        for (let i = 0; i < this.particles.length; i++) {
          const particle = new THREE.Vector3();
          const radius = Math.random() * 2 + 1;
          const angle = Math.random() * Math.PI * 2;
          particle.x = radius * Math.cos(angle);
          particle.y = Math.random() * 2 - 1;
          particle.z = radius * Math.sin(angle);
          this.shapes.torus.push(particle);
        }
    
        // Icosahedron
        for (let i = 0; i < this.particles.length; i++) {
          const particle = new THREE.Vector3();
          const radius = Math.random() * 2 + 1;
          const angle = Math.random() * Math.PI * 2;
          particle.x = radius * Math.cos(angle);
          particle.y = radius * Math.sin(angle);
          particle.z = Math.random() * 2 - 1;
          this.shapes.icosahedron.push(particle);
        }
    
        // Teapot
        for (let i = 0; i < this.particles.length; i++) {
          const particle = new THREE.Vector3();
          const radius = Math.random() * 2 + 1;
          const angle = Math.random() * Math.PI * 2;
          particle.x = radius * Math.cos(angle);
          particle.y = radius * Math.sin(angle);
          particle.z = Math.random() * 2 - 1;
          this.shapes.teapot.push(particle);
        }
    
        // DNA
        for (let i = 0; i < this.particles.length; i++) {
          const particle = new THREE.Vector3();
          const radius = Math.random() * 2 + 1;
          const angle = Math.random() * Math.PI * 2;
          particle.x = radius * Math.cos(angle);
          particle.y = Math.random() * 2 - 1;
          particle.z = radius * Math.sin(angle);
          this.shapes.dna.push(particle);
        }
    
        // Wormhole
        for (let i = 0; i < this.particles.length; i++) {
          const particle = new THREE.Vector3();
          const radius = Math.random() * 2 + 1;
          const angle = Math.random() * Math.PI * 2;
          particle.x = radius * Math.cos(angle);
          particle.y = Math.random() * 2 - 1;
          particle.z = radius * Math.sin(angle);
          this.shapes.wormhole.push(particle);
        }
      }
    
      // Update the particle system
      update() {
        // Update particle positions
        for (let i = 0; i < this.particles.length; i++) {
          const particle = this.particles[i];
          particle.x += Math.random() * 0.01 - 0.005;
          particle.y += Math.random() * 0.01 - 0.005;
          particle.z += Math.random() * 0.01 - 0.005;
        }
    
        // Update the geometry
        this.geometry.setAttribute('position', new THREE.Float32BufferAttribute(this.particles.flatMap(p => [p.x, p.y, p.z]), 3));
      }
    
      // Morph the particle system to a new shape
      morph(shape) {
        // Get the target positions for the new shape
        const targetPositions = this.shapes[shape];
    
        // Shuffle the target positions for a more organic transition
        for (let i = targetPositions.length - 1; i > 0; i--) {
          const j = Math.floor(Math.random() * (i + 1));
          [targetPositions[i], targetPositions[j]] = [targetPositions[j], targetPositions[i]];
        }
    
        // Animate the morphing process
        const duration = 1500; // 1.5 seconds
        const startTime = performance.now();
        const animate = () => {
          const currentTime = performance.now();
          const progress = (currentTime - startTime) / duration;
          if (progress < 1) {
            // Update particle positions using linear interpolation
            for (let i = 0; i < this.particles.length; i++) {
              const particle = this.particles[i];
              const targetPosition = targetPositions[i];
              particle.x = particle.x * (1 - progress) + targetPosition.x * progress;
              particle.y = particle.y * (1 - progress) + targetPosition.y * progress;
              particle.z = particle.z * (1 - progress) + targetPosition.z * progress;
            }
    
            // Update the geometry
            this.geometry.setAttribute('position', new THREE.Float32BufferAttribute(this.particles.flatMap(p => [p.x, p.y, p.z]), 3));
    
            requestAnimationFrame(animate);
          }
        };
        animate();
      }
    }
    
    export default ParticleSystem;
    

    UI.js

    // Import required modules
    import * as THREE from 'three';
    
    // Define the UI class
    class UI {
      constructor(particleSystem) {
        this.particleSystem = particleSystem;
    
        // Create the UI elements
        this.sizeSlider = document.getElementById('size-slider');
        this.rotationSpeedSlider = document.getElementById('rotation-speed-slider');
        this.colorPicker = document.getElementById('color-picker
    

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