poly-extrude 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -2,4 +2,5 @@ import { extrudePolygons } from './src/polygon';
2
2
  import { extrudePolylines, expandLine, leftOnLine, extrudeSlopes } from './src/polyline';
3
3
  import { cylinder } from './src/cylinder';
4
4
  import { expandPaths } from './src/path';
5
- export { extrudePolygons, extrudePolylines, extrudeSlopes, expandLine, leftOnLine, cylinder, expandPaths };
5
+ import { expandTubes } from './src/tube';
6
+ export { extrudePolygons, extrudePolylines, extrudeSlopes, expandLine, leftOnLine, cylinder, expandPaths, expandTubes };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poly-extrude",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "",
5
5
  "main": "dist/poly-extrude.js",
6
6
  "module": "dist/poly-extrude.mjs",
package/readme.md CHANGED
@@ -4,45 +4,37 @@ Extrude polygons/polylines. Born in [maptalks.three](https://github.com/maptalks
4
4
 
5
5
  ## Examples
6
6
 
7
- [building](https://deyihu.github.io/poly-extrude/test/building.html)
8
- <!-- ![](./gallery/building.png)<br> -->
9
- [buildings](https://deyihu.github.io/poly-extrude/test/buildings.html)
10
- <!-- ![](./gallery/buildings.png)<br> -->
11
- [multi-polygon](https://deyihu.github.io/poly-extrude/test/multi-polygon.html)<br>
12
- <!-- ![](./gallery/multi-polygon.png)<br> -->
13
- [street](https://deyihu.github.io/poly-extrude/test/street.html)<br>
14
- <!-- ![](./gallery/street.png)<br> -->
15
- [line-uv](https://deyihu.github.io/poly-extrude/test/line-uv.html)<br>
16
- <!-- ![](./gallery/line-uv.png) -->
17
- [ny-building](https://deyihu.github.io/poly-extrude/test/ny-building.html)<br>
18
- <!-- ![](./gallery/ny-building.png) -->
19
- [cylinder](https://deyihu.github.io/poly-extrude/test/cylinder.html)<br>
20
- <!-- ![](./gallery/cylinder.png) -->
21
- [brige](https://deyihu.github.io/poly-extrude/test/brige.html)<br>
22
- <!-- ![](./gallery/brige.png) -->
23
- [spring](https://deyihu.github.io/poly-extrude/test/spring.html)<br>
24
- <!-- ![](./gallery/spring.png) -->
25
- [expand paths](https://deyihu.github.io/poly-extrude/test/expand-paths-brige.html)<br>
26
- <!-- ![](./gallery/expand-paths-brige.png) -->
27
- [slope](https://deyihu.github.io/poly-extrude/test/slope.html)<br>
7
+ [![](./gallery/building.png)](https://deyihu.github.io/poly-extrude/test/building.html)
28
8
 
29
- ## Install
9
+ [![](./gallery/buildings.png)](https://deyihu.github.io/poly-extrude/test/buildings.html)
30
10
 
31
- ```sh
32
- npm i poly-extrude
11
+ [![](./gallery/multi-polygon.png)](https://deyihu.github.io/poly-extrude/test/multi-polygon.html)<br>
12
+ [![](./gallery/street.png)](https://deyihu.github.io/poly-extrude/test/street.html)<br>
13
+ [![](./gallery/line-uv.png)](https://deyihu.github.io/poly-extrude/test/line-uv.html)<br>
14
+ [![](./gallery/ny-building.png)](https://deyihu.github.io/poly-extrude/test/ny-building.html)<br>
15
+ [![](./gallery/cylinder.png)](https://deyihu.github.io/poly-extrude/test/cylinder.html)<br>
16
+ [![](./gallery/brige.png)](https://deyihu.github.io/poly-extrude/test/brige.html)<br>
17
+ [![](./gallery/spring.png)](https://deyihu.github.io/poly-extrude/test/spring.html)<br>
18
+ [![](./gallery/expand-paths-brige.png)](https://deyihu.github.io/poly-extrude/test/expand-paths-brige.html)<br>
19
+ [![](./gallery/slope.png)](https://deyihu.github.io/poly-extrude/test/slope.html)<br>
33
20
 
34
- # or
21
+ [![](./gallery/tube.png)](https://deyihu.github.io/poly-extrude/test/tube.html)<br>
35
22
 
36
- yarn add poly-extrude
23
+ ## Install
37
24
 
38
- # or
25
+ ### NPM
39
26
 
40
- pnpm i poly-extrude
27
+ ```sh
28
+ npm i poly-extrude
41
29
  ```
42
30
 
43
- ## API
31
+ ### CDN
44
32
 
45
- ### ESM
33
+ ```html
34
+ <script type="text/javascript" src="https://unpkg.com/poly-extrude/dist/poly-extrude.js"></script>
35
+ ```
36
+
37
+ ## Use
46
38
 
47
39
  ```js
48
40
  import {
@@ -50,15 +42,25 @@ pnpm i poly-extrude
50
42
  extrudePolylines,
51
43
  cylinder,
52
44
  expandPaths,
53
- extrudeSlopes
45
+ extrudeSlopes,
46
+ expandTubes
54
47
  } from 'poly-extrude';
48
+
49
+ //if you use cdn,the namespace is polyextrude
50
+
51
+ // const {
52
+ // extrudePolygons,
53
+ // extrudePolylines
54
+ // } = window.polyextrude;
55
+
55
56
  const polygons = [
56
57
  //polygon
57
58
  [
58
59
  //outring
59
60
  [
60
61
  [x, y],
61
- [x, y], ...........
62
+ [x, y],
63
+ ...........
62
64
  ],
63
65
  //holes
64
66
  [
@@ -70,35 +72,25 @@ pnpm i poly-extrude
70
72
  ],
71
73
  //other polygons
72
74
  ......
73
- ]
74
-
75
- const result = extrudePolygons(polygons, {
76
- depth: 2
77
- });
78
- const {
79
- positon,
80
- normal,
81
- uv,
82
- indices
83
- } = result;
84
- //do something
75
+ ];
85
76
 
86
77
  const polylines = [
87
78
  // polyline
88
79
  [
89
80
  [x, y],
90
- [x, y], ...........
81
+ [x, y],
82
+ ...........
91
83
  ],
92
84
  //polyline
93
85
  [
94
86
  [x, y],
95
- [x, y], ...........
87
+ [x, y],
88
+ ...........
96
89
  ],
97
90
  ];
98
91
 
99
- const result = extrudePolylines(polylines, {
100
- depth: 2,
101
- lineWidth: 2
92
+ const result = extrudePolygons(polygons, {
93
+ depth: 2
102
94
  });
103
95
  const {
104
96
  positon,
@@ -107,64 +99,20 @@ pnpm i poly-extrude
107
99
  indices
108
100
  } = result;
109
101
  //do something
102
+ ```
110
103
 
111
- const center = [0, 0];
112
- const result = cylinder(center, {
113
- radius: 1,
114
- height: 2,
115
- radialSegments: 6
116
- });
117
- const {
118
- positon,
119
- normal,
120
- uv,
121
- indices
122
- } = result;
123
- //do something
104
+ ## API
124
105
 
125
- const polylines = [
126
- // polyline
127
- [
128
- [x, y],
129
- [x, y], ...........
130
- ],
131
- //polyline
132
- [
133
- [x, y],
134
- [x, y], ...........
135
- ],
136
- ];
106
+ ![](./img/extrudePolygons.png)
137
107
 
138
- const result = expandPaths(polylines, {
139
- cornerRadius: 0.5,
140
- lineWidth: 2
141
- });
142
- const {
143
- positon,
144
- normal,
145
- uv,
146
- indices
147
- } = result;
148
- //do something
108
+ ### `extrudePolygons(polygons, options)`
149
109
 
150
- const polylines = [
151
- // polyline
152
- [
153
- [x, y],
154
- [x, y], ...........
155
- ],
156
- //polyline
157
- [
158
- [x, y],
159
- [x, y], ...........
160
- ],
161
- ];
110
+ * `polygons`
111
+ * `options.depth`
162
112
 
163
- const result = extrudeSlopes(polylines, {
164
- depth: 1,
165
- side: 'left',
166
- sideDepth: 0,
167
- lineWidth: 2
113
+ ```js
114
+ const result = extrudePolygons(polygons, {
115
+ depth: 2
168
116
  });
169
117
  const {
170
118
  positon,
@@ -175,132 +123,131 @@ pnpm i poly-extrude
175
123
  //do something
176
124
  ```
177
125
 
178
- ### CDN
126
+ ![](./img/extrudePolylines.png)
127
+ ### `extrudePolylines(lines, options)`
179
128
 
180
- ```html
181
- <script src="https://unpkg.com/poly-extrude/dist/poly-extrude.js"></script>
182
-
183
- <script>
184
- const polygons = [
185
- //polygon
186
- [
187
- //outring
188
- [
189
- [x, y],
190
- [x, y], ...........
191
- ],
192
- //holes
193
- [
194
- [x, y],
195
- [x, y], ...........
196
- ],
197
- ........
198
-
199
- ],
200
- //other polygons
201
- ......
202
- ]
203
-
204
- const result = polyextrude.extrudePolygons(polygons, {
205
- depth: 2
206
- })
207
- const {
208
- positon,
209
- normal,
210
- uv,
211
- indices
212
- } = result;
213
- //do something
214
-
215
- const polylines = [
216
- // polyline
217
- [
218
- [x, y],
219
- [x, y], ...........
220
- ],
221
- //polyline
222
- [
223
- [x, y],
224
- [x, y], ...........
225
- ],
226
- ];
227
-
228
- const result = polyextrude.extrudePolylines(polylines, {
229
- depth: 2,
230
- lineWidth: 2
231
- });
232
- const {
233
- positon,
234
- normal,
235
- uv,
236
- indices
237
- } = result;
238
- //do something
239
-
240
- const center = [0, 0];
241
- const result = polyextrude.cylinder(center, {
242
- radius: 1,
243
- height: 2,
244
- radialSegments: 6
245
- });
246
- const {
247
- positon,
248
- normal,
249
- uv,
250
- indices
251
- } = result;
252
- //do something
253
-
254
- const polylines = [
255
- // polyline
256
- [
257
- [x, y],
258
- [x, y], ...........
259
- ],
260
- //polyline
261
- [
262
- [x, y],
263
- [x, y], ...........
264
- ],
265
- ];
266
-
267
- const result = polyextrude.expandPaths(polylines, {
268
- cornerRadius: 0.5,
269
- lineWidth: 2
270
- });
271
- const {
272
- positon,
273
- normal,
274
- uv,
275
- indices
276
- } = result;
277
- //do something
278
-
279
- const polylines = [
280
- // polyline
281
- [
282
- [x, y],
283
- [x, y], ...........
284
- ],
285
- //polyline
286
- [
287
- [x, y],
288
- [x, y], ...........
289
- ],
290
- ];
129
+ * `lines`
130
+ * `options.depth`
131
+ * `options.lineWidth`
132
+ * `options.bottomStickGround` Is the bottom attached to the ground
291
133
 
292
- const result = polyextrude.extrudeSlopes(polylines, {
293
- depth: 1,
294
- side: 'left',
295
- sideDepth: 0,
296
- lineWidth: 2
297
- });
298
- const {
299
- positon,
300
- normal,
301
- uv,
302
- indices
303
- } = result;
304
- //do something
305
- </script>
134
+ ```js
135
+ const result = extrudePolylines(polylines, {
136
+ depth: 2,
137
+ lineWidth: 2
138
+ });
139
+ const {
140
+ positon,
141
+ normal,
142
+ uv,
143
+ indices
144
+ } = result;
145
+ //do something
146
+ ```
147
+
148
+ ![](./img/cylinder.png)
149
+ ### `cylinder(center, options)`
150
+
151
+ * `center`
152
+ * `options.radius`
153
+ * `options.height`
154
+ * `options.radialSegments`
155
+
156
+ ```js
157
+ const center = [0, 0];
158
+ const result = cylinder(center, {
159
+
160
+ radius: 1,
161
+ height: 2,
162
+ radialSegments: 6
163
+
164
+ });
165
+ const {
166
+ positon,
167
+ normal,
168
+ uv,
169
+ indices
170
+
171
+ } = result;
172
+ //do something
173
+ ```
174
+
175
+ ![](./img/expandPaths.png)
176
+ ### `expandPaths(lines, options)`
177
+
178
+ * `lines`
179
+ * `options.lineWidth`
180
+
181
+ ```js
182
+ const result = expandPaths(polylines, {
183
+
184
+ cornerRadius: 0.5,
185
+ lineWidth: 2
186
+
187
+ });
188
+ const {
189
+
190
+ positon,
191
+ normal,
192
+ uv,
193
+ indices
194
+
195
+ } = result;
196
+ //do something
197
+ ```
198
+
199
+ ![](./img/extrudeSlopes.png)
200
+
201
+ ### `extrudeSlopes(lines, options)`
202
+
203
+ * `lines`
204
+ * `options.depth`
205
+ * `options.lineWidth`
206
+ * `options.side` Which side serves as the slope, 'left' or 'right'
207
+ * `options.sideDepth` slope depth
208
+ * `options.bottomStickGround` Is the bottom attached to the ground
209
+
210
+ ```js
211
+ const result = extrudeSlopes(polylines, {
212
+
213
+ depth: 1,
214
+ side: 'left',
215
+ sideDepth: 0,
216
+ lineWidth: 2
217
+
218
+ });
219
+ const {
220
+
221
+ positon,
222
+ normal,
223
+ uv,
224
+ indices
225
+
226
+ } = result;
227
+ //do something
228
+ ```
229
+
230
+ ![](./img/expandTubes.png)
231
+ ### `expandTubes(lines, options)`
232
+
233
+ * `lines`
234
+ * `options.radius`
235
+ * `options.radialSegments`
236
+
237
+ ```js
238
+ const result = expandTubes(polylines, {
239
+
240
+ radius: 1,
241
+ radialSegments: 8
242
+
243
+ });
244
+ const {
245
+
246
+ positon,
247
+ normal,
248
+ uv,
249
+ indices
250
+
251
+ } = result;
252
+ //do something
306
253
  ```