Three.js implements hello world and the method of drawing lines

小云云
Release: 2018-02-01 13:33:24
Original
1328 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. I hope it can help. Everyone.

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 texture of the line, then use the geometric object or buffer geometric object to generate the vertex coordinates, and finally call Line Method to draw the line.

Related recommendations:

Detailed introduction to HTML5 canvas basic drawing line segment code examples

The above is the detailed content of Three.js implements hello world and the method of drawing 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!