Having an issue getting my html page to load properly











up vote
0
down vote

favorite












I'm trying to make a canvas displaying a 3-dimensional space with normals and a light source. A slider will also be implemented to be able to change the x and the y of the light source. When I run the HTML file in Chrome, all i get is a blank canvas. What i should be getting is a canvas showing rows of block normals with spheres on top. The error I'm guessing is most likely in this implementation of the normals. The code I included consists of the code involving the normals in my .js file.



    get normals(){
return[[0,1,0,0],[0,1,0,0],[0,1,0,0],[0,1,0,0],[0,1,0,0],[0,1,0,0], ];
}

window.addEventListener("load", function init()
{
let canvas = document.getElementById( "gl-canvas" );

let gl = WebGLUtils.setupWebGL(canvas);
if ( !gl ) { alert( "WebGL isn't available" ); }
gl.enable(gl.DEPTH_TEST);
gl.viewport( 0, 0, canvas.width, canvas.height );
gl.clearColor(...X11.AliceBlue);


let program = initShaders( gl, vertex_shader, fragment_shader);
gl.useProgram( program );


let vertices = ;
let normals = ;

const extent = 3;
const minX = -extent;
const maxX = extent;
const minZ = -extent;
const maxZ = extent;

let ground = new Ground(minX, maxX, minZ, maxZ);
vertices = vertices.concat(ground.points);
colors = colors.concat(ground.color_scheme);
normals = normals.concat(ground.normals);

const pillarRows = 5;
const pillarColumns = 6;
const pillarRadius = .05;
const pillarHeight = .5;
const pillarSchemeColors = [X11.LightSkyBlue1, X11.LightSkyBlue2];


const pMaxX = maxX - pillarRadius;
const pMinX = minX + pillarRadius;
const pMaxZ = maxZ - pillarRadius;
const pMinZ = minZ + pillarRadius;

const xDelta = (pMaxX - pMinX) / (pillarColumns - 1);
const zDelta = (pMaxZ - pMinZ) / (pillarRows - 1);

for(let r = 0; r < pillarRows; r++ ) {
for(let c = 0; c < pillarColumns; c++) {

const baseX = pMinX + c * xDelta;
const baseY = 0;
const baseZ = pMinZ + r * zDelta;

let box = new cs4722_objects.Block();
box.width = Math.sqrt(2) * pillarRadius;
box.depth = box.width;
box.center = [baseX, baseY + pillarHeight/2, baseZ];
box.height = pillarHeight;

vertices = vertices.concat(box.points);
normals = normals.concat(box.normals);

//creates the box normals and their parameters
let sph = new cs4722_objects.Sphere();
sph.radius = .1;
sph.center = [baseX, (baseY + pillarHeight) + .1, baseZ];
vertices = vertices.concat(sph.points);
normals = normals.concat(sph.normals);

//light effects
let objAmbient = X11.Yellow;
let objDiffuse = vec4(1.0, 0.8, 0.0, 1.0);
let objSpecular = X11.DarkMagenta;
let objShininess = 120;

//position of light
let lightPosition = [1,1,3,1];
let lightAmbient = [1,1,1,1];
let lightDiffuse = [1,1,1,1];
let lightSpecular = [1,1,1,1];

//combines the objects effects with the lights position
let ambientProduct = mult(objAmbient, lightAmbient);
let diffuseProduct = mult(objDiffuse, lightDiffuse);
let specularProduct = mult(objSpecular, lightSpecular);
let shininess = objShininess
}

document.getElementById("Y-axis").value = 50;

listenerSetup();









share|improve this question


























    up vote
    0
    down vote

    favorite












    I'm trying to make a canvas displaying a 3-dimensional space with normals and a light source. A slider will also be implemented to be able to change the x and the y of the light source. When I run the HTML file in Chrome, all i get is a blank canvas. What i should be getting is a canvas showing rows of block normals with spheres on top. The error I'm guessing is most likely in this implementation of the normals. The code I included consists of the code involving the normals in my .js file.



        get normals(){
    return[[0,1,0,0],[0,1,0,0],[0,1,0,0],[0,1,0,0],[0,1,0,0],[0,1,0,0], ];
    }

    window.addEventListener("load", function init()
    {
    let canvas = document.getElementById( "gl-canvas" );

    let gl = WebGLUtils.setupWebGL(canvas);
    if ( !gl ) { alert( "WebGL isn't available" ); }
    gl.enable(gl.DEPTH_TEST);
    gl.viewport( 0, 0, canvas.width, canvas.height );
    gl.clearColor(...X11.AliceBlue);


    let program = initShaders( gl, vertex_shader, fragment_shader);
    gl.useProgram( program );


    let vertices = ;
    let normals = ;

    const extent = 3;
    const minX = -extent;
    const maxX = extent;
    const minZ = -extent;
    const maxZ = extent;

    let ground = new Ground(minX, maxX, minZ, maxZ);
    vertices = vertices.concat(ground.points);
    colors = colors.concat(ground.color_scheme);
    normals = normals.concat(ground.normals);

    const pillarRows = 5;
    const pillarColumns = 6;
    const pillarRadius = .05;
    const pillarHeight = .5;
    const pillarSchemeColors = [X11.LightSkyBlue1, X11.LightSkyBlue2];


    const pMaxX = maxX - pillarRadius;
    const pMinX = minX + pillarRadius;
    const pMaxZ = maxZ - pillarRadius;
    const pMinZ = minZ + pillarRadius;

    const xDelta = (pMaxX - pMinX) / (pillarColumns - 1);
    const zDelta = (pMaxZ - pMinZ) / (pillarRows - 1);

    for(let r = 0; r < pillarRows; r++ ) {
    for(let c = 0; c < pillarColumns; c++) {

    const baseX = pMinX + c * xDelta;
    const baseY = 0;
    const baseZ = pMinZ + r * zDelta;

    let box = new cs4722_objects.Block();
    box.width = Math.sqrt(2) * pillarRadius;
    box.depth = box.width;
    box.center = [baseX, baseY + pillarHeight/2, baseZ];
    box.height = pillarHeight;

    vertices = vertices.concat(box.points);
    normals = normals.concat(box.normals);

    //creates the box normals and their parameters
    let sph = new cs4722_objects.Sphere();
    sph.radius = .1;
    sph.center = [baseX, (baseY + pillarHeight) + .1, baseZ];
    vertices = vertices.concat(sph.points);
    normals = normals.concat(sph.normals);

    //light effects
    let objAmbient = X11.Yellow;
    let objDiffuse = vec4(1.0, 0.8, 0.0, 1.0);
    let objSpecular = X11.DarkMagenta;
    let objShininess = 120;

    //position of light
    let lightPosition = [1,1,3,1];
    let lightAmbient = [1,1,1,1];
    let lightDiffuse = [1,1,1,1];
    let lightSpecular = [1,1,1,1];

    //combines the objects effects with the lights position
    let ambientProduct = mult(objAmbient, lightAmbient);
    let diffuseProduct = mult(objDiffuse, lightDiffuse);
    let specularProduct = mult(objSpecular, lightSpecular);
    let shininess = objShininess
    }

    document.getElementById("Y-axis").value = 50;

    listenerSetup();









    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm trying to make a canvas displaying a 3-dimensional space with normals and a light source. A slider will also be implemented to be able to change the x and the y of the light source. When I run the HTML file in Chrome, all i get is a blank canvas. What i should be getting is a canvas showing rows of block normals with spheres on top. The error I'm guessing is most likely in this implementation of the normals. The code I included consists of the code involving the normals in my .js file.



          get normals(){
      return[[0,1,0,0],[0,1,0,0],[0,1,0,0],[0,1,0,0],[0,1,0,0],[0,1,0,0], ];
      }

      window.addEventListener("load", function init()
      {
      let canvas = document.getElementById( "gl-canvas" );

      let gl = WebGLUtils.setupWebGL(canvas);
      if ( !gl ) { alert( "WebGL isn't available" ); }
      gl.enable(gl.DEPTH_TEST);
      gl.viewport( 0, 0, canvas.width, canvas.height );
      gl.clearColor(...X11.AliceBlue);


      let program = initShaders( gl, vertex_shader, fragment_shader);
      gl.useProgram( program );


      let vertices = ;
      let normals = ;

      const extent = 3;
      const minX = -extent;
      const maxX = extent;
      const minZ = -extent;
      const maxZ = extent;

      let ground = new Ground(minX, maxX, minZ, maxZ);
      vertices = vertices.concat(ground.points);
      colors = colors.concat(ground.color_scheme);
      normals = normals.concat(ground.normals);

      const pillarRows = 5;
      const pillarColumns = 6;
      const pillarRadius = .05;
      const pillarHeight = .5;
      const pillarSchemeColors = [X11.LightSkyBlue1, X11.LightSkyBlue2];


      const pMaxX = maxX - pillarRadius;
      const pMinX = minX + pillarRadius;
      const pMaxZ = maxZ - pillarRadius;
      const pMinZ = minZ + pillarRadius;

      const xDelta = (pMaxX - pMinX) / (pillarColumns - 1);
      const zDelta = (pMaxZ - pMinZ) / (pillarRows - 1);

      for(let r = 0; r < pillarRows; r++ ) {
      for(let c = 0; c < pillarColumns; c++) {

      const baseX = pMinX + c * xDelta;
      const baseY = 0;
      const baseZ = pMinZ + r * zDelta;

      let box = new cs4722_objects.Block();
      box.width = Math.sqrt(2) * pillarRadius;
      box.depth = box.width;
      box.center = [baseX, baseY + pillarHeight/2, baseZ];
      box.height = pillarHeight;

      vertices = vertices.concat(box.points);
      normals = normals.concat(box.normals);

      //creates the box normals and their parameters
      let sph = new cs4722_objects.Sphere();
      sph.radius = .1;
      sph.center = [baseX, (baseY + pillarHeight) + .1, baseZ];
      vertices = vertices.concat(sph.points);
      normals = normals.concat(sph.normals);

      //light effects
      let objAmbient = X11.Yellow;
      let objDiffuse = vec4(1.0, 0.8, 0.0, 1.0);
      let objSpecular = X11.DarkMagenta;
      let objShininess = 120;

      //position of light
      let lightPosition = [1,1,3,1];
      let lightAmbient = [1,1,1,1];
      let lightDiffuse = [1,1,1,1];
      let lightSpecular = [1,1,1,1];

      //combines the objects effects with the lights position
      let ambientProduct = mult(objAmbient, lightAmbient);
      let diffuseProduct = mult(objDiffuse, lightDiffuse);
      let specularProduct = mult(objSpecular, lightSpecular);
      let shininess = objShininess
      }

      document.getElementById("Y-axis").value = 50;

      listenerSetup();









      share|improve this question













      I'm trying to make a canvas displaying a 3-dimensional space with normals and a light source. A slider will also be implemented to be able to change the x and the y of the light source. When I run the HTML file in Chrome, all i get is a blank canvas. What i should be getting is a canvas showing rows of block normals with spheres on top. The error I'm guessing is most likely in this implementation of the normals. The code I included consists of the code involving the normals in my .js file.



          get normals(){
      return[[0,1,0,0],[0,1,0,0],[0,1,0,0],[0,1,0,0],[0,1,0,0],[0,1,0,0], ];
      }

      window.addEventListener("load", function init()
      {
      let canvas = document.getElementById( "gl-canvas" );

      let gl = WebGLUtils.setupWebGL(canvas);
      if ( !gl ) { alert( "WebGL isn't available" ); }
      gl.enable(gl.DEPTH_TEST);
      gl.viewport( 0, 0, canvas.width, canvas.height );
      gl.clearColor(...X11.AliceBlue);


      let program = initShaders( gl, vertex_shader, fragment_shader);
      gl.useProgram( program );


      let vertices = ;
      let normals = ;

      const extent = 3;
      const minX = -extent;
      const maxX = extent;
      const minZ = -extent;
      const maxZ = extent;

      let ground = new Ground(minX, maxX, minZ, maxZ);
      vertices = vertices.concat(ground.points);
      colors = colors.concat(ground.color_scheme);
      normals = normals.concat(ground.normals);

      const pillarRows = 5;
      const pillarColumns = 6;
      const pillarRadius = .05;
      const pillarHeight = .5;
      const pillarSchemeColors = [X11.LightSkyBlue1, X11.LightSkyBlue2];


      const pMaxX = maxX - pillarRadius;
      const pMinX = minX + pillarRadius;
      const pMaxZ = maxZ - pillarRadius;
      const pMinZ = minZ + pillarRadius;

      const xDelta = (pMaxX - pMinX) / (pillarColumns - 1);
      const zDelta = (pMaxZ - pMinZ) / (pillarRows - 1);

      for(let r = 0; r < pillarRows; r++ ) {
      for(let c = 0; c < pillarColumns; c++) {

      const baseX = pMinX + c * xDelta;
      const baseY = 0;
      const baseZ = pMinZ + r * zDelta;

      let box = new cs4722_objects.Block();
      box.width = Math.sqrt(2) * pillarRadius;
      box.depth = box.width;
      box.center = [baseX, baseY + pillarHeight/2, baseZ];
      box.height = pillarHeight;

      vertices = vertices.concat(box.points);
      normals = normals.concat(box.normals);

      //creates the box normals and their parameters
      let sph = new cs4722_objects.Sphere();
      sph.radius = .1;
      sph.center = [baseX, (baseY + pillarHeight) + .1, baseZ];
      vertices = vertices.concat(sph.points);
      normals = normals.concat(sph.normals);

      //light effects
      let objAmbient = X11.Yellow;
      let objDiffuse = vec4(1.0, 0.8, 0.0, 1.0);
      let objSpecular = X11.DarkMagenta;
      let objShininess = 120;

      //position of light
      let lightPosition = [1,1,3,1];
      let lightAmbient = [1,1,1,1];
      let lightDiffuse = [1,1,1,1];
      let lightSpecular = [1,1,1,1];

      //combines the objects effects with the lights position
      let ambientProduct = mult(objAmbient, lightAmbient);
      let diffuseProduct = mult(objDiffuse, lightDiffuse);
      let specularProduct = mult(objSpecular, lightSpecular);
      let shininess = objShininess
      }

      document.getElementById("Y-axis").value = 50;

      listenerSetup();






      javascript webgl normals






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 8 at 19:37









      Matthew Keller

      63




      63





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53214951%2fhaving-an-issue-getting-my-html-page-to-load-properly%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53214951%2fhaving-an-issue-getting-my-html-page-to-load-properly%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Schultheiß

          Liste der Kulturdenkmale in Wilsdruff

          Android Play Services Check