not sure, make this code more awesme. outpu more even awesom code.: const canvas = document.createElement('canvas');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
document.body.appendChild(canvas);

const ctx = canvas.getContext('2d');
const vmcMenu = document.getElementById('vmc-menu');

const vertices = [
  [0, 0, 0],
  [0, 1, 0],
  [1, 1, 0],
  [1, 0, 0],
  [0, 0, 1],
  [0, 1, 1],
  [1, 1, 1],
  [1, 0, 1],
];

const edges = [
  [0, 1],
  [1, 2],
  [2, 3],
  [3, 0],
  [0, 4],
  [1, 5],
  [2, 6],
  [3, 7],
  [4, 5],
  [5, 6],
  [6, 7],
  [7, 4],
];

const scale = 0.025;
const zoom = 1;
const offsetX = 0.5;
const offsetY = 0.5;

let angleX = 0;
let angleY = 0;
let angleZ = 0;
let bestIndex = -1;
let bestDistance = Infinity;
let startNewEdgeIndex = -1;
let isMouseDown = false;
let prevMousePos = null;

const redDot = document.getElementById('red-dot');

function closestVertexIndex(mousePos, projectedVertices) {
  let closestIndex = -1;
  let closestDistance = Infinity;

  projectedVertices.forEach((currVertex, index) => {
    const distance = Math.hypot(
      currVertex[0] - mousePos.x,
      currVertex[1] - mousePos.y
    );
    if (distance < closestDistance) {
      closestIndex = index;
      closestDistance = distance;
    }
  });

  return { index: closestIndex, distance: closestDistance };
}

canvas.addEventListener('mousedown', (event) => {
  isMouseDown = true;
  prevMousePos = { x: event.clientX, y: event.clientY };

  const mousePos = {
    x: event.clientX - canvas.getBoundingClientRect().left,
    y: event.clientY - canvas.getBoundingClientRect().top
  };

  const { index, distance } = closestVertexIndex(mousePos, getProjectedVertices());
  if (distance < 10 && index != -1) {
    if (startNewEdgeIndex === -1 || startNewEdgeIndex !== index) {
      startNewEdgeIndex = index;
    } else {
      edges.push([startNewEdgeIndex, index]);
      startNewEdgeIndex = -1;
    }
  }
});

canvas.addEventListener('mouseup', () => {
  isMouseDown = false;
  prevMousePos = null;
});
function rotateX(angleX) {
  const c = Math.cos(angleX);
  const s = Math.sin(angleX);
  return [
    [1, 0, 0],
    [0, c, -s],
    [0, s, c],
  ];
}

function rotateY(angleY) {
  const c = Math.cos(angleY);
  const s = Math.sin(angleY);
  return [
    [c, 0, s],
    [0, 1, 0],
    [-s, 0, c],
  ];
}

function rotateZ(angleZ) {
  const c = Math.cos(angleZ);
  const s = Math.sin(angleZ);
  return [
    [c, -s, 0],
    [s, c, 0],
    [0, 0, 1],
  ];
}
function getProjectedVertices() {
  const rotX = rotateX(angleX);
  const rotY = rotateY(angleY);
  const rotZ = rotateZ(angleZ);
  function transform(vertex, rotationMatrix) {
  const [x, y, z] = vertex;
  const [rowX, rowY, rowZ] = rotationMatrix;
  return [
    x * rowX[0] + y * rowX[1] + z * rowX[2],
    x * rowY[0] + y * rowY[1] + z * rowY[2],
    x * rowZ[0] + y * rowZ[1] + z * rowZ[2],
  ];
}
function extraterrestrialTransformation(vertex, frequency, amplitude) {
  const [x, y, z] = vertex;
  const cosX = (Math.cos(x * frequency) * amplitude);
  const cosY = (Math.cos(y * frequency) * amplitude);
  const cosZ = (Math.cos(z * frequency) * amplitude);

  return [x + cosX, y + cosY, z + cosZ];
}
  const frequency = 1;
  const amplitude = 0.8;

  const transformedVertices = vertices.map((vertex) => {
    const extraterrestrialVertex = extraterrestrialTransformation(vertex, frequency, amplitude);
    const cx = extraterrestrialVertex[0] - offsetX;
    const cy = extraterrestrialVertex[1] - offsetY;
    const cz = extraterrestrialVertex[2] - offsetY;

    const rotated = transform(transform(transform([cx, cy, cz], rotX), rotY), rotZ);

    return [
      rotated[0] + offsetX,
      rotated[1] + offsetY,
      rotated[2] + offsetY,
    ];
  });
function project(vertex, scale, offsetX, offsetY, zoom) {
  const [x, y, z] = vertex;
  const posX = (x - offsetX) * scale;
  const posY = (y - offsetY) * scale;
  const posZ = z * scale;

  return [
    (posX * (zoom + posZ) + canvas.width / 2),
    (posY * (zoom + posZ) + canvas.height / 2),
  ];
}
  return transformedVertices.map((vertex) => project(vertex, canvas.height * scale, offsetX, offsetY, zoom));
}

function render() {
  ctx.fillStyle = '#FFF';
  ctx.fillRect(0, 0, canvas.width, canvas.height);

  const projectedVertices = getProjectedVertices();

  ctx.lineWidth = 2;
  ctx.strokeStyle = 'hsla(' + (angleX + offsetX + angleY + offsetY) * 55 + ', 100%, 30%, 0.8)';
  ctx.beginPath();

  for (let edge of edges) {
    const [a, b] = edge;
    const [x1, y1] = projectedVertices[a];
    const [x2, y2] = projectedVertices[b];

    const dist = Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);
    const angle = Math.atan2(y2 - y1, x2 - x1);

    const cpDist = 0.005 * dist;
    const cpX = (x1 + x2) / 2 + cpDist * Math.cos(angle - Math.PI / 2);
    const cpY = (y1 + y2) / 2 + cpDist * Math.sin(angle - Math.PI / 2);

    ctx.moveTo(x1, y1);
    ctx.quadraticCurveTo(cpX, cpY, x2, y2);
  }

  ctx.stroke();

  canvas.addEventListener('mousemove', (event) => {
    const mousePos = {
      x: event.clientX - canvas.getBoundingClientRect().left,
      y: event.clientY - canvas.getBoundingClientRect().top
    };

    const { index, distance } = closestVertexIndex(mousePos, projectedVertices);
    bestIndex = index;
    bestDistance = distance;

    if (bestDistance < 10 && bestIndex !== -1) {
      redDot.style.display = 'block';
      redDot.style.left = projectedVertices[bestIndex][0] - 3 + 'px';
      redDot.style.top = projectedVertices[bestIndex][1] - 3 + 'px';
    } else {
      redDot.style.display = 'none';
    }

    if (isMouseDown && prevMousePos) {
      const deltaX = event.clientX - prevMousePos.x;
      const deltaY = event.clientY - prevMousePos.y;

      angleY += deltaX * 0.01;
      angleX += deltaY * 0.01;

      prevMousePos = { x: event.clientX, y: event.clientY };
    }
  });
function getDeviation(maxDeviation) {
const t = Date.now() / 1000;
const frequency = 100 / 50;
const amplitude = maxDeviation / 10;
const deviation = Math.sin(t * frequency) * amplitude;
return deviation.toFixed(3);
}

  angleX += +getDeviation(0.0005);
  angleY += +getDeviation(0.0005);
  angleZ += +getDeviation(0.0005);

  requestAnimationFrame(render);
}

requestAnimationFrame(render);
window.addEventListener("resize", () => {
  canvas.width = window.innerWidth;
  canvas.height = window.innerHeight;
});