Time for Action: Loading a Cone with AJAX

Follow the given steps:

  1. Make sure that your web server is running and access the ch02_07_ajax-cone.html file using your web server.
Web Server Address

You know that you are using the web server if the URL in the address bar starts with localhost/ or 127.0.0.1/ instead of file://.
  1. The folder containing the code for this chapter should look like this:

  1. Click on ch02_07_ajax-cone.html.
  2. The example will load in your browser and you will see something similar to this:

  1. Please review the load functions to better understand the use of AJAX and JSON in the application.
  2. How is the global model variable used? (Check the source code.)
  3. Check what happens when you change the color in the common/models/geometries/cone.json file and reload the page.
  4. Modify the coordinates of the cone in the common/models/geometries/cone.json file and reload the page. Here, you can verify that WebGL reads and renders the coordinates from the file. If you modify them in the file, the geometry will be updated on the screen.

What just happened?

You learned how to use AJAX and JSON to load geometries from a remote location (web server) instead of specifying these geometries (using JavaScript arrays) inside the web page.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.17.20