Graphics Reference
In-Depth Information
Getting
started
with
the
WebGL
renderer
When you want to create an initial Three.js project that uses WebGL for rendering,
you always have to set up the same couple of variables. You need a
THREE.WebGLRenderer object, a THREE.Scene object, a camera, and some way
to render the scene. In this recipe, we'll provide you with a standard template that you
can use in your own projects to quickly get started with the WebGL renderer.
Getting ready
Make sure that you download the sources for this topic. You can either do this in the
following two ways:
• Firstly, you can do this by cloning the Git repo that you can find at ht-
tps://github.com/josdirksen/threejs-cookbook .
• Alternatively, you can download the sources from Packt Publishing website.
When you extract the ZIP file or clone the repository you'll find a set of direct-
ories; one for each chapter of this topic. For this recipe, you can use 0 as a
reference.
You can directly view the end result of this recipe by opening the previously mentioned
file in your browser. When you open this example in the browser, you'll see the follow-
ing screenshot:
This is a minimal scene, rendered with the THREE.WebGLRenderer object.
Search WWH ::




Custom Search