Make a 3D visual simulation wave function of schirondinger equation that show the…
- User
Make a 3D visual simulation wave function of schirondinger equation that show the colapse of the wave function when I touch my mobile screen (peak more high and narrowed with color gradually turn from blue to yellow), after that the wave will envolving smooth, make it using tree.js or better mode aproach. Put all code in wave.html for I will run on my Brouser. After screen touch the peak will return smoothing spreaded again. And surface plane will oscillating low smoothing again.
Assistant
I'll create an interactive 3D wave function visualization that demonstrates quantum wave function collapse when you touch the screen. This uses Three.js with a custom shader for smooth, realistic wave behavior.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Quantum Wave Function Collapse Visualization</title> <style> body { margin: 0; padding: 0; overflow: hidden; font-family: Arial, sans-serif; background: #000; } canvas { display: block; } #info { position: absolute; top: 10px; left: 10px; color: white; background: rgba(0,0,0,0.7); padding: 10px; border-radius: 5px; font-size: 14px; } </style> </head> <body> <div id="info">Touch/Click to collapse the wave function</div> <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script> <script> // Scene setup const scene = new THREE.Scene(); scene.background = new THREE.Color(0x000000); const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); camera.position.set(30, 20, 30); camera.lookAt(0, 0, 0); const renderer = new THREE.WebGLRenderer({ antialias: true }); renderer.setSize(window.innerWidth, window.innerHeight); document.body.appendChild(renderer.domElement); // Lighting const ambientLight = new THREE.AmbientLight(0x404040); scene.add(ambientLight); const directionalLight = new THREE.DirectionalLight(0xffffff, 0.5); directionalLight.position.set(10, 10, 10); scene.add(directionalLight); // Wave parameters const waveParams = { amplitude: 3, frequency: 0.5, speed: 0.5, collapse: 0, collapseX: 0, collapseZ: 0, time: 0 }; // Custom shader for wave function const vertexShader = ` uniform float time; uniform float amplitude; uniform float frequency; uniform float collapse; uniform vec2 collapsePoint; varying vec3 vPosition; varying float vHeight; void main() { vPosition = position; float dist = distance(position.xz, collapsePoint); float gaussian = exp(-dist * dist * collapse * 0.5); // Wave equation with collapse effect float wave = amplitude * (1.0 + collapse * gaussian * 2.0) * sin(frequency * (position.x + position.z) - time) * exp(-dist * dist * 0.01 * (1.0 - collapse)); // Add localized oscillation wave += amplitude * 0.3 * sin(frequency * 3.0 * dist - time * 2.0) * (1.0 - collapse) * exp(-dist * dist * 0.02); vec3 newPosition = position; newPosition.y = wave; vHeight = wave; gl_Position = projectionMatrix * modelViewMatrix * vec4(newPosition, 1.0); } `; const fragmentShader = ` uniform float collapse; varying vec3 vPosition; varying float vHeight; void main() { // Color gradient from blue to yellow based on height and collapse float normalizedHeight = (vHeight + 3.0) / 6.0; normalizedHeight = clamp(normalizedHeight + collapse * 0.5, 0.0, 1.0); vec3 blue = vec3(0.0, 0.3, 1.0); vec3 cyan = vec3(0.0, 0.8, 1.0); vec3 yellow = vec3(1.0, 1.0, 0.0); vec3 orange = vec3(1.0, 0.5, 0.0); vec3 color; if (normalizedHeight < 0.5) { color = mix(blue, cyan, normalizedHeight * 2.0); } else { color = mix(cyan, yellow, (normalizedHeight - 0.5) * 2.0); } // Add intensity based on collapse color = mix(color, orange, collapse * 0.5); gl_FragColor = vec4(color, 0.9); } `; // Create wave mesh const geometry = new THREE.PlaneGeometry(50, 50, 100, 100); geometry.rotateX(-Math.PI / 2); const material = new THREE.ShaderMaterial({ uniforms: { time: { value: 0 }, amplitude: { value: waveParams.amplitude }, frequency: { value: waveParams.frequency }, collapse: { value: 0 }, collapsePoint: { value: new THREE.Vector2(0, 0) } }, vertexShader: vertexShader, fragmentShader: fragmentShader, wireframe: false, transparent: true, side: THREE.DoubleSide }); const waveMesh = new THREE.Mesh(geometry, material); scene.add(waveMesh); // Add grid for reference const gridHelper = new THREE.GridHelper(50, 50, 0x444444, 0x222222); scene.add(gridHelper); // Mouse/Touch interaction const raycaster = new THREE.Raycaster(); const mouse = new THREE.Vector2(); function onInteraction(event) { let clientX, clientY; if (event.type === 'touchstart') { clientX = event.touches[0].clientX; clientY = event.touches[0].clientY; } else { clientX = event.clientX; clientY = event.clientY; } mouse.x = (clientX / window.innerWidth) * 2 - 1; mouse.y = -(clientY / window.innerHeight) * 2 + 1; raycaster.setFromCamera(mouse, camera); const intersects = raycaster.intersectObject(waveMesh); if (intersects.length > 0) { const point = intersects[0].point; waveParams.collapseX = point.x; waveParams.collapseZ = point.z; waveParams.collapse = 1; material.uniforms.collapsePoint.value.set(point.x, point.z); } } renderer.domElement.addEventListener('click', onInteraction); renderer.domElement.addEventListener('touchstart', onInteraction); // Camera controls let mouseX = 0, mouseY = 0; let targetX = 0, targetY = 0; document.addEventListener('mousemove', (event) => { mouseX = (event.clientX - window.innerWidth / 2) / 100; mouseY = (event.clientY - window.innerHeight / 2) / 100; }); // Animation loop function animate() { requestAnimationFrame(animate); // Update time waveParams.time += waveParams.speed * 0.05; material.uniforms.time.value = waveParams.time; // Smooth collapse decay if (waveParams.collapse > 0) { waveParams.collapse *= 0.98; if (waveParams.collapse < 0.01) { waveParams.collapse = 0; } material.uniforms.collapse.value = waveParams.collapse; } // Smooth camera movement targetX += (mouseX - targetX) * 0.05; targetY += (mouseY - targetY) * 0.05; camera.position.x = 30 * Math.cos(targetX * 0.1); camera.position.z = 30 * Math.sin(targetX * 0.1); camera.position.y = 20 + targetY; camera.lookAt(0, 0, 0); renderer.render(scene, camera); } // Handle window resize window.addEventListener('resize', () => { camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); renderer.setSize(window.innerWidth, window.innerHeight); }); animate(); </script> </body> </html>This visualization creates a 3D quantum wave function with the following features:
-
Wave Function Display: A continuously oscillating 3D surface representing the probability amplitude of a quantum particle
-
Interactive Collapse: When you touch/click the screen, the wave function collapses at that point, creating a sharp peak (representing localized probability)
-
Color Gradient: The wave smoothly transitions from blue (low amplitude) through cyan to yellow (high amplitude), with orange highlights during collapse
-
Smooth Evolution: After collapse, the wave function gradually spreads out again, simulating the natural evolution of a quantum system
-
Camera Movement: Move your mouse to orbit around the wave for different viewing angles
The visualization uses custom GLSL shaders for smooth, efficient rendering of the wave dynamics. The collapse effect uses a Gaussian function to create a realistic localized peak that gradually disperses back into the general wave pattern.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.