Introduction to Three.js hello world and how to draw lines

巴扎黑
Release: 2017-09-26 09:39:19
Original
1399 people have browsed it

This article mainly introduces you to the relevant information about hello world for getting started with Three.js and how to draw lines. The article introduces it in great detail through sample code. It has certain reference learning value for everyone's study or work. It needs Friends, please follow the editor to learn together.

Preface

This article is an introductory tutorial for learning Three.js. It introduces the implementation of hello world and lines through examples. The following is not Enough said, let’s take a look at the detailed introduction.

hello world

First of all, we use three.js to create a cube hello world type case.


      Document   
Copy after login

Analysis of the above code case:

(1) First introduce the three.js library file, Just like introducing jq.

(2) Create scene (line 17)

(3) Create camera and set field of view, display aspect ratio, near clipping plane, far clipping plane (Line 19)

(4) Create a renderer, set attributes, and place it in the dom (Lines 21-25)

(5) Create a cube model , and put it into the scene (28-34)

(6) Set the camera position (line 36)

(7) Set an animation function and use The renderer renders the scene and camera at 60 frames per second, displays it, and turns it into an animation.

Use Three.js to draw lines

The above is the effect displayed after the drawing is completed.


      Document   
Copy after login

Compared with the previous section, there is only a difference in the model. Here, we first use the line texture method to set the line texture, and then use geometric objects or buffers. The geometric object generates vertex coordinates, and finally calls the Line method to draw the line.

The above is the detailed content of Introduction to Three.js hello world and how to draw lines. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!