var nothingness = (window.localStorage.getItem('nothings') || 1) * 1, nGain = 0.003; var getBonus = 0; var mx = 0, my = 0; let clicking = false; let counts = JSON.parse(window.localStorage.getItem('counts')) || {}; var cubePos = []; window.addEventListener('mousemove', (e) => { mx = e.pageX; my = e.pageY; }); document.querySelector('canvas').addEventListener('click', (e) => { let p1 = MDN.perspectiveMatrix(Math.PI * 100 / 180, ratio, 0.01, 1000); for (let cubieI in cubePos) { let cubie = cubePos[cubieI]; let p2 = MDN.multiplyPoint(p1, [cubie[0], cubie[1], cubie[2], 0]); p2[0] /= p2[3]; p2[1] /= p2[3]; p2[0] -= (mx - width / 2) / width * 2; p2[1] += (my - height / 2) / height * 2; let b = 1 / (Math.sqrt(p2[0] ** 2 + p2[1] ** 2) + .03); b = (b * b) * 0.0001; getBonus += b; } }); setInterval(function () { nothingness += nGain + getBonus; getBonus += 0.0001 * cubePos.length; getBonus *= 0.93; for (let a of cubePos) { let f = (nGain + getBonus * 100 + 10) / (nothingness + 10); f *= 50; if (f > 100) f = 100; a[0] = a[0] * 0.9 + a[3] * .4 * f; a[1] = a[1] * 0.9 + a[4] * .4 * f; f /= Math.sqrt(a[0] * a[0] + a[1] * a[1]) / 0.3; if (f > 0.3) f = 0.3; let a3 = a[3], a4 = a[4]; a[3] = Math.sin(f) * a4 + Math.cos(f) * a3; a[4] = -Math.sin(f) * a3 + Math.cos(f) * a4; let d = Math.sqrt(a[3] * a[3] + a[4] * a[4]) a[3] /= d / 2; a[4] /= d / 2; } }, 1000 / 60) document.querySelector('canvas').addEventListener('click', async (e) => { if (clicking) return; clicking = true; getBonus += 0.01; clicking = false; }) setInterval(function () { window.localStorage.setItem('nothings', nothingness); window.localStorage.setItem('counts', JSON.stringify(counts)); }, 1000)