Time for action – loading a cone with AJAX + JSON
Follow the given steps:
Make sure that your web server is running and access the file
ch2_AJAXJSON.html
using your web server.Note
You know you are using the web server if the URL in the address bar starts with
localhost/…
instead offile://...
The folder where you have the code for this chapter should look like this:
Click on
ch2_AjaxJSON.html
.The example will load in your browser and you will see something similar to this:
When you click on the JavaScript alert, you will see:
As the page says, please review the functions
loadModel
andhandleLoadedModel
to better understand the use of AJAX and JSON in the application.What does the
modelLoaded
variable do? (check the source code).See what happens when you change the color in the file
models/cone.json
and reload the page.Modify the coordinates of the cone in the file
models/cone.json
and reload the page. Here you can verify that WebGL reads and renders the coordinates from the file. If you modify...