Advertisement
Guest User

WebGL Cube

a guest
May 23rd, 2021
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const vertexPositions = [
  2.     // Front
  3.     -1, 1, -1,
  4.     -1, -1, -1,
  5.     1, -1, -1,
  6.     1, 1, -1,
  7.  
  8.     // Back
  9.     1, 1, 1,
  10.     1, -1, 1,
  11.     -1, -1, 1,
  12.     -1, 1, 1,
  13.  
  14.     // Left
  15.     -1, 1, 1,
  16.     -1, -1, 1,
  17.     -1, -1, -1,
  18.     -1, 1, -1,
  19.  
  20.     // Right
  21.     1, 1, -1,
  22.     1, -1, -1,
  23.     1, -1, 1,
  24.     1, 1, 1,
  25.  
  26.     // Top
  27.     -1, 1, 1,
  28.     -1, 1, -1,
  29.     1, 1, -1,
  30.     1, 1, 1,
  31.  
  32.     // Bottom
  33.     -1, -1, -1,
  34.     -1, -1, 1,
  35.     1, -1, 1,
  36.     1, -1, -1
  37. ];
  38.  
  39. const textureCoordinates = [
  40.     // Front
  41.     0, 1,
  42.     0, 0,
  43.     1, 0,
  44.     1, 1,
  45.  
  46.     // Back
  47.     0, 1,
  48.     0, 0,
  49.     1, 0,
  50.     1, 1,
  51.  
  52.     // Left
  53.     0, 1,
  54.     0, 0,
  55.     1, 0,
  56.     1, 1,
  57.  
  58.     // Right
  59.     0, 1,
  60.     0, 0,
  61.     1, 0,
  62.     1, 1,
  63.  
  64.     // Bottom
  65.     0, 1,
  66.     0, 0,
  67.     1, 0,
  68.     1, 1,
  69.  
  70.     // Top
  71.     0, 1,
  72.     0, 0,
  73.     1, 0,
  74.     1, 1
  75. ];
  76.  
  77. const indices = [
  78.     // Front
  79.     0, 1, 2,
  80.     2, 3, 0,
  81.  
  82.     // Back
  83.     4, 5, 6,
  84.     6, 7, 4,
  85.  
  86.     // Left
  87.     8, 9, 10,
  88.     10, 11, 8,
  89.  
  90.     // Right
  91.     12, 13, 14,
  92.     14, 15, 12,
  93.  
  94.     // Top
  95.     16, 17, 18,
  96.     18, 19, 16,
  97.  
  98.     // Bottom
  99.     20, 21, 22,
  100.     22, 23, 20
  101. ];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement