O'Reilly logo

WebGL Beginner's Guide by Brandon Jones, Diego Cantor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — JSON encoding and decoding

Let's create a simple model: a 3D line. Here we will be focusing on how we do JSON encoding and decoding. Follow the given steps:

  1. Go to your Internet browser and open the interactive JavaScript console. Use the following table for assistance:

    Web browser

    Menu option

    Shortcut keys (PC / Mac)

    Firefox

    Tools | Web Developer | Web Console

    Ctrl + Shift + K / Command + Alt + K

    Safari

    Develop | Show Web Inspector

    Ctrl + Shift + C / Command + Alt + C

    Chrome

    Tools | JavaScript Console

    Ctrl + Shift + J / Command + Alt + Js

  2. Create a JSON object by typing:
    var model = {"vertices":[0,0,0,1,1,1], "indices":[0,1]};
    
  3. Verify that the model is an object by writing:
    typeof(model)
    
  4. Now, let's print the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required