"Three.js Getting Started Guide" 3.1.1 - basic geometric shapes - round (CircleGeometry)

3.1 basic geometry

Circular (CircleGeometry)

Description:

Circular or sector can be created

Constructor:

 THREE.CircleGeometry(radius, segments, thetaStart, thetaLength) 

radius: radius;

segments: the number of slices to a point as the center (cut the cake?);

thetaStart: starting position;

thetaLength: fan span;

A complete code example and demo effects:

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 
 4 <head>
 5     <meta charset="UTF-8">
 6     <meta name="viewport" content="width=device-width, initial-scale=1.0">
 7     <meta http-equiv="X-UA-Compatible" content="ie=edge">
 8     <script type="text/javascript" src="./three.js"></script>
 9     <title>Document</title>
10 </head>
11 
12 <body onload="init()">
13     <script>
14         function init() {
15             var renderer = new THREE.WebGLRenderer();
16             renderer.setSize(800, 600);
17             document.getElementsByTagName('body')[0].appendChild(renderer.domElement);
18 
19             renderer.setClearColor(0x00000);
20             var scene = new THREE.Scene();
21             var aspect = window.innerWidth / window.innerHeight;
22             var camera = new THREE.OrthographicCamera(-4 * aspect, 4 * aspect, -3 * aspect, 3 * aspect, 1, 500);
23             camera.position.set ( 0 , 0 , 200 is );
 24              camera.lookAt ( new new THREE.Vector3 ( 0 , 0 , 0 ));
 25              scene.add (Camera);
 26 is  
27              var Circle =  new new THREE.Mesh ( new new THREE.CircleGeometry ( 3 , 50 , Math.PI, Math.PI /  3  *  4 ),
 28                  // Math.PI / 3 * 4) how come? : Math.PI * 2 is a full circle (360 degrees projection plane), then Math.PI * 2 * 2/3 to 2/3 can draw a circle (a sector region) 
29                 new THREE.MeshBasicMaterial({
30                     color: 0xff0000,
31                     wireframe: true
32                 })
33             )
34             scene.add(circle)
35 
36 
37             renderer.render(scene, camera);
38         }
39     </script>
40 </body>
41 
42 </html>

Guess you like

Origin www.cnblogs.com/jaycethanks/p/12032969.html