| 2 | window.runDNA=(()=>{let e,n,t;const{sin:a,cos:o}=Math;let r=[];const c=[],s=()=>20*Math.random()-10,i=e=>Array(e).fill(0).map((e,n)=>n),m=(e,n,t,a,o)=>((e,n,t)=>(t-n)*e+n)(((e,n,t)=>(e-n)/(t-n))(e,n,t),a,o),E=e=>{const{x:n,y:t,z:a}=e;return i(10).map(()=>({x:n+s(),y:t+s(),z:a+s()}))},d=e=>{const n=(e=>e/180*Math.PI)(e);return{x:130*a(n),z:130*o(n)}};(()=>{e=new THREE.WebGLRenderer({alpha:!0}),document.getElementById("dnaContainer").appendChild(e.domElement),e.setSize($("#dnaContainer").width(),$("#dnaContainer").height()),camera=new THREE.PerspectiveCamera(15,2,1,5e3),camera.position.z=1200,n=new THREE.Scene;const t=new THREE.OrbitControls(camera,e.domElement);t.minDistance=10,t.maxDistance=1200})(),i(360).forEach(e=>{const n={...d(e),y:1.5*(e-180)},t={...d(e+120),y:1.5*(e-180)};r=(r=r.concat(E(n))).concat(E(t)),e%36==0&&c.push({pa:n,pb:t})}),c.map(e=>(({pa:e,pb:n})=>{const t=i(100).reduce((t,a)=>[...t,...E({x:m(a,0,100,e.x,n.x),y:e.y,z:m(a,0,100,e.z,n.z)})],[]);r=r.concat(t)})(e)),(e=>{const a=new THREE.Geometry;e.forEach(e=>{a.vertices.push(e)});const o=new THREE.PointsMaterial({size:.2,opacity:.9,alphaTest:.4,transparent:!0});o.color.setHex("0x"+color.substring(1)),t=new THREE.Points(a,o),n.add(t)})(r),t.rotation.z=Math.PI/2;const p=()=>{t.rotation.x+=.01,requestAnimationFrame(p),e.render(n,camera)};p()}); |