]> git.r.bdr.sh - rbdr/flower/blobdiff - lib/flower.js
Fix linter warnings
[rbdr/flower] / lib / flower.js
index 319d436b4ff23390aaefdfc543c47b86600352cd..69802d7ffee3f6638226b49a71978a78cfbe3c0e 100644 (file)
@@ -1,3 +1,5 @@
+/* globals window document mat4 */
+
 const internals = {
 
   // Constants
 const internals = {
 
   // Constants
@@ -53,7 +55,7 @@ const internals = {
 
 
     const canvas = internals.initializeCanvas();
 
 
     const canvas = internals.initializeCanvas();
-    const {gl, programInfo, buffers} = internals.initializeWebGL(canvas);
+    const { gl, programInfo, buffers } = internals.initializeWebGL(canvas);
 
     window.requestAnimationFrame(internals.animate.bind(this, gl, programInfo, buffers));
   },
 
     window.requestAnimationFrame(internals.animate.bind(this, gl, programInfo, buffers));
   },
@@ -92,7 +94,7 @@ const internals = {
 
     const buffers = internals.initializeBuffers(gl);
 
 
     const buffers = internals.initializeBuffers(gl);
 
-    return { gl, programInfo, buffers};
+    return { gl, programInfo, buffers };
   },
 
   // Methods: Canvas
   },
 
   // Methods: Canvas
@@ -112,7 +114,7 @@ const internals = {
     canvas.style.height = `${height}px`;
 
     canvas.width = internals.kTargetVerticalResolution * internals.kWidthRatio;
     canvas.style.height = `${height}px`;
 
     canvas.width = internals.kTargetVerticalResolution * internals.kWidthRatio;
-    canvas.height = internals.kTargetVerticalResolution;  
+    canvas.height = internals.kTargetVerticalResolution;
   },
 
   // Methods: Shader / GL Related
   },
 
   // Methods: Shader / GL Related
@@ -129,7 +131,7 @@ const internals = {
     gl.linkProgram(shaderProgram);
 
     if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
     gl.linkProgram(shaderProgram);
 
     if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
-      alert(`Unable to initialize shader program: ${gl.getProgramInfoLog(shaderProgram)}`);
+      console.error(`Unable to initialize shader program: ${gl.getProgramInfoLog(shaderProgram)}`);
       return null;
     }
 
       return null;
     }
 
@@ -143,7 +145,7 @@ const internals = {
     gl.compileShader(shader);
 
     if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
     gl.compileShader(shader);
 
     if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
-      alert(`Unable to compile shader: ${gl.getShaderInfoLog(shader)}`);
+      console.error(`Unable to compile shader: ${gl.getShaderInfoLog(shader)}`);
       gl.deleteShader(shader);
       return null;
     }
       gl.deleteShader(shader);
       return null;
     }
@@ -175,12 +177,12 @@ const internals = {
     ];
 
     gl.bufferData(gl.ARRAY_BUFFER,
     ];
 
     gl.bufferData(gl.ARRAY_BUFFER,
-        new Float32Array(positions),
-        gl.STATIC_DRAW);
+      new Float32Array(positions),
+      gl.STATIC_DRAW);
 
     return {
       position: positionBuffer
 
     return {
       position: positionBuffer
-    }
+    };
   },
 
   // Methods: Utility
   },
 
   // Methods: Utility
@@ -190,9 +192,9 @@ const internals = {
     const matrix = mat4.create();
 
     mat4.translate(
     const matrix = mat4.create();
 
     mat4.translate(
-        matrix,
-        matrix,
-        [-0.0, 0.0, -6.0]
+      matrix,
+      matrix,
+      [-0.0, 0.0, -6.0]
     );
 
     return matrix;
     );
 
     return matrix;
@@ -219,11 +221,11 @@ const internals = {
     const projectionMatrix = mat4.create();
 
     mat4.perspective(
     const projectionMatrix = mat4.create();
 
     mat4.perspective(
-        projectionMatrix,
-        fieldOfView,
-        aspectRatio,
-        internals.kNearLimit,
-        internals.kFarLimit
+      projectionMatrix,
+      fieldOfView,
+      aspectRatio,
+      internals.kNearLimit,
+      internals.kFarLimit
     );
 
     internals.modelViewMatrix = internals.modelViewMatrix || internals.createMatrix();
     );
 
     internals.modelViewMatrix = internals.modelViewMatrix || internals.createMatrix();
@@ -239,12 +241,12 @@ const internals = {
 
       gl.bindBuffer(gl.ARRAY_BUFFER, buffers.position);
       gl.vertexAttribPointer(
 
       gl.bindBuffer(gl.ARRAY_BUFFER, buffers.position);
       gl.vertexAttribPointer(
-          programInfo.attribLocations.vertexPosition,
-          numberOfComponents,
-          type,
-          normalize,
-          stride,
-          offset
+        programInfo.attribLocations.vertexPosition,
+        numberOfComponents,
+        type,
+        normalize,
+        stride,
+        offset
       );
       gl.enableVertexAttribArray(programInfo.attribLocations.vertexPosition);
     }
       );
       gl.enableVertexAttribArray(programInfo.attribLocations.vertexPosition);
     }
@@ -274,8 +276,8 @@ const internals = {
       ];
 
       gl.bufferData(gl.ARRAY_BUFFER,
       ];
 
       gl.bufferData(gl.ARRAY_BUFFER,
-          new Float32Array(colors),
-          gl.STATIC_DRAW);
+        new Float32Array(colors),
+        gl.STATIC_DRAW);
 
       const numberOfComponents = 4;
       const type = gl.FLOAT;
 
       const numberOfComponents = 4;
       const type = gl.FLOAT;
@@ -285,12 +287,12 @@ const internals = {
 
       gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer);
       gl.vertexAttribPointer(
 
       gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer);
       gl.vertexAttribPointer(
-          programInfo.attribLocations.vertexColor,
-          numberOfComponents,
-          type,
-          normalize,
-          stride,
-          offset
+        programInfo.attribLocations.vertexColor,
+        numberOfComponents,
+        type,
+        normalize,
+        stride,
+        offset
       );
       gl.enableVertexAttribArray(programInfo.attribLocations.vertexColor);
 
       );
       gl.enableVertexAttribArray(programInfo.attribLocations.vertexColor);
 
@@ -300,14 +302,14 @@ const internals = {
     gl.useProgram(programInfo.program);
 
     gl.uniformMatrix4fv(
     gl.useProgram(programInfo.program);
 
     gl.uniformMatrix4fv(
-        programInfo.uniformLocations.projectionMatrix,
-        false,
-        projectionMatrix
+      programInfo.uniformLocations.projectionMatrix,
+      false,
+      projectionMatrix
     );
     gl.uniformMatrix4fv(
     );
     gl.uniformMatrix4fv(
-        programInfo.uniformLocations.modelViewMatrix,
-        false,
-        internals.modelViewMatrix
+      programInfo.uniformLocations.modelViewMatrix,
+      false,
+      internals.modelViewMatrix
     );
 
     {
     );
 
     {