OSDN Git Service

three.jsをThirdPartyに追加
[webglgame/webgl_framework.git] / webglFramework / Thirdparty / three.js-master / src / extras / core / Shape.js
1 import { PathPrototype } from './PathPrototype';
2 import { Path } from './Path';
3
4 /**
5  * @author zz85 / http://www.lab4games.net/zz85/blog
6  * Defines a 2d shape plane using paths.
7  **/
8
9 // STEP 1 Create a path.
10 // STEP 2 Turn path into shape.
11 // STEP 3 ExtrudeGeometry takes in Shape/Shapes
12 // STEP 3a - Extract points from each shape, turn to vertices
13 // STEP 3b - Triangulate each shape, add faces.
14
15 function Shape() {
16
17         Path.apply( this, arguments );
18
19         this.holes = [];
20
21 }
22
23 Shape.prototype = Object.assign( Object.create( PathPrototype ), {
24
25         constructor: Shape,
26
27         getPointsHoles: function ( divisions ) {
28
29                 var holesPts = [];
30
31                 for ( var i = 0, l = this.holes.length; i < l; i ++ ) {
32
33                         holesPts[ i ] = this.holes[ i ].getPoints( divisions );
34
35                 }
36
37                 return holesPts;
38
39         },
40
41         // Get points of shape and holes (keypoints based on segments parameter)
42
43         extractAllPoints: function ( divisions ) {
44
45                 return {
46
47                         shape: this.getPoints( divisions ),
48                         holes: this.getPointsHoles( divisions )
49
50                 };
51
52         },
53
54         extractPoints: function ( divisions ) {
55
56                 return this.extractAllPoints( divisions );
57
58         }
59
60 } );
61
62
63 export { Shape };