diff --git a/files/en-us/learn/javascript/client-side_web_apis/drawing_graphics/index.html b/files/en-us/learn/javascript/client-side_web_apis/drawing_graphics/index.html index 65d767ca45c825c..a1b088af5cd8e43 100644 --- a/files/en-us/learn/javascript/client-side_web_apis/drawing_graphics/index.html +++ b/files/en-us/learn/javascript/client-side_web_apis/drawing_graphics/index.html @@ -744,7 +744,7 @@
const scene = new THREE.Scene();-
The Scene()
constructor creates a new scene, which represents the whole 3D world we are trying to display.
The Scene()
constructor creates a new scene, which represents the whole 3D world we are trying to display.
Next, we need a camera so we can see the scene. In 3D imagery terms, the camera represents a viewer's position in the world. To create a camera, add the following lines next:
@@ -753,7 +753,7 @@The PerspectiveCamera()
constructor takes four arguments:
The PerspectiveCamera()
constructor takes four arguments:
We also set the camera's position to be 5 distance units out of the Z axis, which, like in CSS, is out of the screen towards you, the viewer.
The third vital ingredient is a renderer. This is an object that renders a given scene, as viewed through a given camera. We'll create one for now using the WebGLRenderer()
constructor, but we'll not use it till later. Add the following lines next:
The third vital ingredient is a renderer. This is an object that renders a given scene, as viewed through a given camera. We'll create one for now using the WebGLRenderer()
constructor, but we'll not use it till later. Add the following lines next:
const renderer = new THREE.WebGLRenderer(); renderer.setSize(window.innerWidth, window.innerHeight); @@ -797,8 +797,8 @@Recreating our cube
cube
global variable so we can access our cube from anywhere in the code.TextureLoader
object, then call load()
on it. load()
takes two parameters in this case (although it can take more): the texture we want to load (our PNG), and a function that will run when the texture has loaded.texture
object to specify that we want a 2 x 2 repeat of the image wrapped around all sides of the cube. Next, we create a new BoxGeometry
object and a new MeshLambertMaterial
object, and bring them together in a Mesh
to create our cube. An object typically requires a geometry (what shape it is) and a material (what its surface looks like).TextureLoader
object, then call load()
on it. load()
takes two parameters in this case (although it can take more): the texture we want to load (our PNG), and a function that will run when the texture has loaded.texture
object to specify that we want a 2 x 2 repeat of the image wrapped around all sides of the cube. Next, we create a new BoxGeometry
object and a new MeshLambertMaterial
object, and bring them together in a Mesh
to create our cube. An object typically requires a geometry (what shape it is) and a material (what its surface looks like).draw()
function to start off the animation.An AmbientLight
object is a kind of soft light that lightens the whole scene a bit, like the sun when you are outside. The SpotLight
object, on the other hand, is a directional beam of light, more like a flashlight/torch (or a spotlight, in fact).
An AmbientLight
object is a kind of soft light that lightens the whole scene a bit, like the sun when you are outside. The SpotLight
object, on the other hand, is a directional beam of light, more like a flashlight/torch (or a spotlight, in fact).
Last of all, let's add our draw()
function to the bottom of the code: