Broken light.
1 function Cube(size, context)
5 this.rotation = {'x': 0.0, 'y': 0.0, 'z': 0.0};
7 this.positionBuffer = gl.createBuffer();
8 gl.bindBuffer(gl.ARRAY_BUFFER, this.positionBuffer);
45 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW);
46 this.positionBuffer.itemSize = 3;
47 this.positionBuffer.numItems = 24;
49 this.colourBuffer = gl.createBuffer();
50 gl.bindBuffer(gl.ARRAY_BUFFER, this.colourBuffer);
52 var colours = [[1.0, 0.0, 0.0, alpha],
53 [0.0, 1.0, 0.0, alpha],
54 [0.0, 0.0, 1.0, alpha],
55 [1.0, 0.0, 1.0, alpha],
56 [1.0, 1.0, 0.0, alpha],
57 [0.0, 1.0, 1.0, alpha]];
58 var unpackedColours = [];
59 for (var i in colours)
61 var colour = colours[i];
62 for (var j = 0; j < 4; j++)
64 unpackedColours = unpackedColours.concat(colour);
66 //colours = colours.concat([0.5, 0.5, 1.0, 1.0]);
68 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(unpackedColours), gl.STATIC_DRAW);
69 this.colourBuffer.itemSize = 4;
70 this.colourBuffer.numItems = 24;
72 this.indexBuffer = gl.createBuffer();
73 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
74 var indices = [0, 1, 2, 0, 2, 3,
77 12, 13, 14, 12, 14, 15,
78 16, 17, 18, 16, 18, 19,
79 20, 21, 22, 20, 22, 23];
80 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices), gl.STATIC_DRAW);
81 this.indexBuffer.itemSize = 1;
82 this.indexBuffer.numItems = 36;
84 this.normalBuffer = gl.createBuffer();
85 gl.bindBuffer(gl.ARRAY_BUFFER, this.normalBuffer);
86 var normals = [// font face
115 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(normals), gl.STATIC_DRAW);
116 this.normalBuffer.itemSize = 3;
117 this.normalBuffer.numItems = 24;