qwen3-235b-a22b-no-thinking· Alibaba (Qwen) LMArena Human Preference 140K
On random triangles there should be a little cube on the surface. Connect around the…
- User
On random triangles there should be a little cube on the surface. Connect around the sphere these cubes with a line like a graph around the planets surface.
- Assistant
Here's a Three.js HTML example that builds on your request:
✅ What it does:
- Renders an icosahedral sphere (
IcosahedronGeometry). - Places a small cube on the center of each triangle face.
- Connects cubes with lines to form a graph-like structure over the surface of the sphere.
🌐 Features:
- Uses
THREE.IcosahedronGeometry. - Cubes are positioned at face centers and oriented outward.
- Lines connect neighboring cubes based on shared edges between faces.
💡 Notes:
This is a simplified version of a graph network on a triangulated mesh, where each triangle center acts as a node, and connections exist if two triangles share an edge.
✅ Full HTML Code (Copy & Save as
.html):<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>Icosphere with Cubes and Graph Lines</title> <style> body { margin: 0; overflow: hidden; } canvas { display: block; } </style> </head> <body> <!-- Three.js CDN --> <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script> <!-- OrbitControls --> <script src="https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/controls/OrbitControls.js"></script> <script> let scene, camera, renderer, controls; const cubes = []; const lines = []; init(); animate(); function init() { // Scene setup scene = new THREE.Scene(); scene.background = new THREE.Color(0x111111); camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); camera.position.z = 8; renderer = new THREE.WebGLRenderer({ antialias: true }); renderer.setSize(window.innerWidth, window.innerHeight); document.body.appendChild(renderer.domElement); controls = new THREE.OrbitControls(camera, renderer.domElement); controls.enableDamping = true; // Create Icosahedron Sphere Geometry const radius = 3; const detail = 2; const geometry = new THREE.IcosahedronGeometry(radius, detail); // Material for the main sphere const material = new THREE.MeshStandardMaterial({ color: 0x4444ff, wireframe: false, flatShading: true, }); const sphere = new THREE.Mesh(geometry, material); scene.add(sphere); // Add cubes at face centers addCubesAndLines(geometry); // Lighting const ambientLight = new THREE.AmbientLight(0x404040, 1.5); scene.add(ambientLight); const directionalLight = new THREE.DirectionalLight(0xffffff, 1); directionalLight.position.set(5, 5, 5); scene.add(directionalLight); window.addEventListener("resize", onWindowResize, false); } function addCubesAndLines(geometry) { const positionAttr = geometry.attributes.position; const index = geometry.index; const faceCenters = []; // Step 1: Compute face centers for (let i = 0; i < index.count; i += 3) { const a = index.getX(i); const b = index.getX(i + 1); const c = index.getX(i + 2); const vA = new THREE.Vector3().fromBufferAttribute(positionAttr, a); const vB = new THREE.Vector3().fromBufferAttribute(positionAttr, b); const vC = new THREE.Vector3().fromBufferAttribute(positionAttr, c); const center = new THREE.Vector3() .add(vA) .add(vB) .add(vC) .divideScalar(3); center.normalize().multiplyScalar(3.2); // slightly outside the sphere // Store face center faceCenters.push(center.clone()); // Add cube const cubeSize = 0.1; const cubeGeo = new THREE.BoxGeometry(cubeSize, cubeSize, cubeSize); const cubeMat = new THREE.MeshStandardMaterial({ color: 0xffcc00 }); const cube = new THREE.Mesh(cubeGeo, cubeMat); cube.position.copy(center); // Orient cube outward const normal = new THREE.Vector3() .subVectors(center, new THREE.Vector3()) .normalize(); const orientation = new THREE.Quaternion().setFromUnitVectors( new THREE.Vector3(0, 0, 1), normal ); cube.quaternion.copy(orientation); scene.add(cube); cubes.push(cube); } // Step 2: Build adjacency map to find neighbors const vertexToFaceMap = {}; const faceEdges = []; for (let i = 0; i < index.count; i += 3) { const a = index.getX(i); const b = index.getX(i + 1); const c = index.getX(i + 2); const edges = [ [Math.min(a, b), Math.max(a, b)], [Math.min(b, c), Math.max(b, c)], [Math.min(c, a), Math.max(c, a)], ]; edges.forEach(edge => { const key = edge.join(","); if (!vertexToFaceMap[key]) vertexToFaceMap[key] = []; vertexToFaceMap[key].push(Math.floor(i / 3)); }); faceEdges.push(edges.map(e => e.join(","))); } // Step 3: Draw lines between adjacent face centers const lineMaterial = new THREE.LineBasicMaterial({ color: 0xffff00 }); for (const faceIndex in vertexToFaceMap) { const connectedFaces = vertexToFaceMap[faceIndex]; for (let i = 0; i < connectedFaces.length - 1; i++) { for (let j = i + 1; j < connectedFaces.length; j++) { const f1 = connectedFaces[i]; const f2 = connectedFaces[j]; // Avoid duplicate lines const key = [f1, f2].sort().join(","); if (!lines.includes(key)) { const from = faceCenters[f1]; const to = faceCenters[f2]; const points = [from, to]; const geometry = new THREE.BufferGeometry().setFromPoints(points); const line = new THREE.Line(geometry, lineMaterial); scene.add(line); lines.push(key); } } } } } function onWindowResize() { camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); renderer.setSize(window.innerWidth, window.innerHeight); } function animate() { requestAnimationFrame(animate); cubes.forEach((cube, i) => { cube.rotation.y += 0.01; cube.rotation.x += 0.005; }); controls.update(); renderer.render(scene, camera); } </script> </body> </html>
🧪 Try It Out:
- Copy the code above into a file like
icosphere_graph.html. - Open it in any modern browser.
- Use your mouse to orbit around the sphere.
🛠️ Customization Ideas:
- Increase/decrease
detailinIcosahedronGeometryto change density. - Replace cubes with spheres or other geometries.
- Color-code cubes or lines based on distance or angle.
Let me know if you want to make this interactive (e.g., click nodes, highlight paths, etc.)!
- Renders an icosahedral sphere (
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.