The previous chapter describes adding objects to the scene. In this article, I plan to describe each function point in detail, on the one hand, to deepen my understanding. On the other hand, I hope to be able to
help those in need.
1. When learning WEBGL, you should first understand the steps required to create a WebGL program. Just like making braised pork with pickled vegetables, what steps are needed.
Initialize WebGL drawing context
Initialize shader program
Establish model and data cache
Complete drawing and animation
This is a process-oriented programming. However, three.js is different. It is an object-oriented programming. Mainly construct three objects: scene (scene) camera (camera) renderer (renderer).
What do these three things mean? It doesn't sound like I know what it is at all. To give a small example: take movies as an example. The scene is like the entire layout space, and the camera is like the
shooting period. The renderer is equivalent to converting the filmed movie into film, which is the computer screen.
Scenes and spaces contain 3D and data models, while renderer contains shaders and WebGL drawing contexts.
2. THREE.JS creates scene, camera, renderer
1 2 3 4 5 6 7 8 |
|
The movie, scene, and film are all ready, so how can we display the actors? That is, how to add objects to the scene as mentioned in the above article?
3. Add actors (3D cube).
1 |
|
This way the actor is in the frame.
4. How to make this actor move?
1 2 3 4 5 6 7 |
|
The actor entered the scene and had an impressive effect. The first short story is almost finished.
5. The entire code (originally wanted to be hosted on GitHup). Found it too slow.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
6. Three.js plays an important role in WebGL, but there are really few Chinese APIs. It just accumulates slowly one by one.
The above is the detailed content of How to create a scene in Three.js. For more information, please follow other related articles on the PHP Chinese website!