Change background color
This commit is contained in:
parent
ed80030d3d
commit
0a357f0109
|
@ -6,6 +6,7 @@ import vertexSource from "./shaders/vertices.glsl";
|
||||||
import fragmentSource from "./shaders/fragments.glsl";
|
import fragmentSource from "./shaders/fragments.glsl";
|
||||||
|
|
||||||
const ROTATION_SPEED = 0.0005;
|
const ROTATION_SPEED = 0.0005;
|
||||||
|
const BACKGROUND_COLOR = [0.0588235294118, 0.0588235294118, 0.0588235294118];
|
||||||
|
|
||||||
class RendererError extends Error {}
|
class RendererError extends Error {}
|
||||||
|
|
||||||
|
@ -148,7 +149,12 @@ class Renderer {
|
||||||
|
|
||||||
initGL(gl: WebGLRenderingContext, shader: Shader) {
|
initGL(gl: WebGLRenderingContext, shader: Shader) {
|
||||||
gl.useProgram(shader.program);
|
gl.useProgram(shader.program);
|
||||||
gl.clearColor(0.0, 0.0, 0.0, 1.0);
|
gl.clearColor(
|
||||||
|
BACKGROUND_COLOR[0],
|
||||||
|
BACKGROUND_COLOR[1],
|
||||||
|
BACKGROUND_COLOR[2],
|
||||||
|
1.0
|
||||||
|
);
|
||||||
gl.clearDepth(1.0);
|
gl.clearDepth(1.0);
|
||||||
gl.enable(gl.DEPTH_TEST);
|
gl.enable(gl.DEPTH_TEST);
|
||||||
gl.depthFunc(gl.LESS);
|
gl.depthFunc(gl.LESS);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
// Takes vertices of a unit cube, scales them up along Y according to
|
// Takes vertices of a unit cube, scales them up along Y according to
|
||||||
// aHeight, and colors them with basic diffuse shading.
|
// aHeight, and colors them with basic diffuse shading.
|
||||||
|
|
||||||
#define CLEAR_COLOR vec4(0.0, 0.0, 0.0, 1.0)
|
#define CLEAR_COLOR vec4(0.0588235294118, 0.0588235294118, 0.0588235294118, 1.0)
|
||||||
#define BASE_COLOR vec3(0.6, 0.819607843137, 0.807843137255)
|
#define BASE_COLOR vec3(0.6, 0.819607843137, 0.807843137255)
|
||||||
#define AMBIENT_LIGHT vec3(0.3, 0.3, 0.3)
|
#define AMBIENT_LIGHT vec3(0.3, 0.3, 0.3)
|
||||||
#define LIGHT_DIRECTION normalize(vec3(0.85, 0.8, 0.75))
|
#define LIGHT_DIRECTION normalize(vec3(0.85, 0.8, 0.75))
|
||||||
|
|
Reference in a new issue