Creating the HTML skeleton
The first thing we need to do is create an empty skeleton page that we can use as the base for all our examples, as follows:
<!DOCTYPE html> <html> <head> <title>Example 01.01 - Basic skeleton</title> <script src="../libs/three.js"></script> <style> body{ /* set margin to 0 and overflow to hidden, to use the complete page */ margin: 0; overflow: hidden; } </style> </head> <body> <!-- Div which will hold the Output --> <div id="WebGL-output"> </div> <!-- Javascript code that runs our Three.js examples --> <script> // once everything is loaded, we run our Three.js stuff. function init() { // here we'll put the Three.js stuff }; window.onload = init; </script> </body> </html>
Tip
Downloading the example code
You can download ...
Get Learning Three.js – the JavaScript 3D Library for WebGL - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.