Basic 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.normalBuffer = gl.createBuffer();
50 gl.bindBuffer(gl.ARRAY_BUFFER, this.normalBuffer);
51 var normals = [// font face
81 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(normals), gl.STATIC_DRAW);
82 this.normalBuffer.itemSize = 3;
83 this.normalBuffer.numItems = 24;
85 this.colourBuffer = gl.createBuffer();
86 gl.bindBuffer(gl.ARRAY_BUFFER, this.colourBuffer);
88 var uni = [1.0, 1.0, 1.0, alpha];
89 var colours = [[0.0, 0.0, 0.0, alpha],
90 [0.0, 0.0, 0.0, alpha],
91 [0.0, 0.0, 0.0, alpha],
92 [0.0, 0.0, 0.0, alpha],
93 [0.0, 0.0, 0.0, alpha],
94 [0.0, 0.0, 0.0, alpha]];
95 var unpackedColours = [];
96 for (var i in colours)
98 var colour = uni;//colours[i];
99 for (var j = 0; j < 4; j++)
101 unpackedColours = unpackedColours.concat(colour);
103 //colours = colours.concat([0.5, 0.5, 1.0, 1.0]);
105 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(unpackedColours), gl.STATIC_DRAW);
106 this.colourBuffer.itemSize = 4;
107 this.colourBuffer.numItems = 24;
109 this.indexBuffer = gl.createBuffer();
110 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
111 var indices = [0, 1, 2, 0, 2, 3,
114 12, 13, 14, 12, 14, 15,
115 16, 17, 18, 16, 18, 19,
116 20, 21, 22, 20, 22, 23];
117 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices), gl.STATIC_DRAW);
118 this.indexBuffer.itemSize = 1;
119 this.indexBuffer.numItems = 36;