Making Boxes with the Cube Shape
Next weâll make a cube, which is another name for a box. In 3D programming, the sides of a cube donât have to be the same size. We can control the width, the height, and the depth.
Size: CubeGeometry(300, 100, 20)
To create a box, weâll write more JavaScript below everything that we used to create our ball. Type the following (maybe add a blank line first):
â | âvarâ shape = ânewâ THREE.CubeGeometry(100, 100, 100); |
â | âvarâ cover = ânewâ THREE.MeshNormalMaterial(flat); |
â | âvarâ box = ânewâ THREE.Mesh(shape, cover); |
â | scene.add(box); |
If you have everything correct, you should see⦠a square?
Well, thatâs boring. Why do we see a square instead of a box? The answer is that our ...
Get 3D Game Programming for Kids, 2nd 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.