Record the rotation by updating the transformation matrix (function remx()).
Use the matrix to calculate the coordinates of the rotated cube vertices,
Convert the spatial coordinates of each vertex into plane coordinates according to "near large, far small" (function p2d()),
Use the z coordinate of the normal vector of each face of the cube to determine whether the face is visible,
Use a div layer with a height of 1px to simulate drawing a quadrilateral (function gra2htm()).
Drag the mouse The code is modified with someone else’s code.