poly-extrude 0.6.0 → 0.7.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.7.0",
4
4
  "description": "",
5
5
  "main": "dist/poly-extrude.js",
6
6
  "module": "dist/poly-extrude.mjs",
package/readme.md CHANGED
@@ -26,23 +26,24 @@ Extrude polygons/polylines. Born in [maptalks.three](https://github.com/maptalks
26
26
  <!-- ![](./gallery/expand-paths-brige.png) -->
27
27
  [slope](https://deyihu.github.io/poly-extrude/test/slope.html)<br>
28
28
 
29
+ [tube](https://deyihu.github.io/poly-extrude/test/tube.html)<br>
30
+
29
31
  ## Install
30
32
 
33
+ ### NPM
34
+
31
35
  ```sh
32
36
  npm i poly-extrude
33
37
 
34
- # or
35
-
36
- yarn add poly-extrude
38
+ ```
37
39
 
38
- # or
40
+ ### CDN
39
41
 
40
- pnpm i poly-extrude
42
+ ```html
43
+ <script type="text/javascript" src="https://unpkg.com/poly-extrude/dist/poly-extrude.js"></script>
41
44
  ```
42
45
 
43
- ## API
44
-
45
- ### ESM
46
+ ## Use
46
47
 
47
48
  ```js
48
49
  import {
@@ -50,15 +51,25 @@ pnpm i poly-extrude
50
51
  extrudePolylines,
51
52
  cylinder,
52
53
  expandPaths,
53
- extrudeSlopes
54
+ extrudeSlopes,
55
+ expandTubes
54
56
  } from 'poly-extrude';
57
+
58
+ //if you use cdn
59
+
60
+ // const {
61
+ // extrudePolygons,
62
+ // extrudePolylines
63
+ // } = window.polyextrude;
64
+
55
65
  const polygons = [
56
66
  //polygon
57
67
  [
58
68
  //outring
59
69
  [
60
70
  [x, y],
61
- [x, y], ...........
71
+ [x, y],
72
+ ...........
62
73
  ],
63
74
  //holes
64
75
  [
@@ -70,35 +81,25 @@ pnpm i poly-extrude
70
81
  ],
71
82
  //other polygons
72
83
  ......
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
84
+ ];
85
85
 
86
86
  const polylines = [
87
87
  // polyline
88
88
  [
89
89
  [x, y],
90
- [x, y], ...........
90
+ [x, y],
91
+ ...........
91
92
  ],
92
93
  //polyline
93
94
  [
94
95
  [x, y],
95
- [x, y], ...........
96
+ [x, y],
97
+ ...........
96
98
  ],
97
99
  ];
98
100
 
99
- const result = extrudePolylines(polylines, {
100
- depth: 2,
101
- lineWidth: 2
101
+ const result = extrudePolygons(polygons, {
102
+ depth: 2
102
103
  });
103
104
  const {
104
105
  positon,
@@ -107,64 +108,20 @@ pnpm i poly-extrude
107
108
  indices
108
109
  } = result;
109
110
  //do something
111
+ ```
110
112
 
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
113
+ ## API
124
114
 
125
- const polylines = [
126
- // polyline
127
- [
128
- [x, y],
129
- [x, y], ...........
130
- ],
131
- //polyline
132
- [
133
- [x, y],
134
- [x, y], ...........
135
- ],
136
- ];
115
+ ![](./img/extrudePolygons.png)
137
116
 
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
117
+ ### `extrudePolygons(polygons, options)`
149
118
 
150
- const polylines = [
151
- // polyline
152
- [
153
- [x, y],
154
- [x, y], ...........
155
- ],
156
- //polyline
157
- [
158
- [x, y],
159
- [x, y], ...........
160
- ],
161
- ];
119
+ * `polygons`
120
+ * `options.depth`
162
121
 
163
- const result = extrudeSlopes(polylines, {
164
- depth: 1,
165
- side: 'left',
166
- sideDepth: 0,
167
- lineWidth: 2
122
+ ```js
123
+ const result = extrudePolygons(polygons, {
124
+ depth: 2
168
125
  });
169
126
  const {
170
127
  positon,
@@ -175,132 +132,126 @@ pnpm i poly-extrude
175
132
  //do something
176
133
  ```
177
134
 
178
- ### CDN
179
135
 
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
- ];
136
+ ### `extrudePolylines(lines, options)`
291
137
 
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>
138
+ * `lines`
139
+ * `options.depth`
140
+ * `options.lineWidth`
141
+ * `options.bottomStickGround` Is the bottom attached to the ground
142
+
143
+ ```js
144
+ const result = extrudePolylines(polylines, {
145
+ depth: 2,
146
+ lineWidth: 2
147
+ });
148
+ const {
149
+ positon,
150
+ normal,
151
+ uv,
152
+ indices
153
+ } = result;
154
+ //do something
155
+ ```
156
+
157
+ ### `cylinder(center, options)`
158
+
159
+ * `center`
160
+ * `options.radius`
161
+ * `options.height`
162
+ * `options.radialSegments`
163
+
164
+ ```js
165
+ const center = [0, 0];
166
+ const result = cylinder(center, {
167
+
168
+ radius: 1,
169
+ height: 2,
170
+ radialSegments: 6
171
+
172
+ });
173
+ const {
174
+ positon,
175
+ normal,
176
+ uv,
177
+ indices
178
+
179
+ } = result;
180
+ //do something
181
+ ```
182
+
183
+ ### `expandPaths(lines, options)`
184
+
185
+ * `lines`
186
+ * `options.lineWidth`
187
+
188
+ ```js
189
+ const result = expandPaths(polylines, {
190
+
191
+ cornerRadius: 0.5,
192
+ lineWidth: 2
193
+
194
+ });
195
+ const {
196
+
197
+ positon,
198
+ normal,
199
+ uv,
200
+ indices
201
+
202
+ } = result;
203
+ //do something
204
+ ```
205
+
206
+ ### `extrudeSlopes(lines, options)`
207
+
208
+ * `lines`
209
+ * `options.depth`
210
+ * `options.lineWidth`
211
+ * `options.side` Which side serves as the slope, 'left' or 'right'
212
+ * `options.sideDepth` slope depth
213
+ * `options.bottomStickGround` Is the bottom attached to the ground
214
+
215
+ ```js
216
+ const result = extrudeSlopes(polylines, {
217
+
218
+ depth: 1,
219
+ side: 'left',
220
+ sideDepth: 0,
221
+ lineWidth: 2
222
+
223
+ });
224
+ const {
225
+
226
+ positon,
227
+ normal,
228
+ uv,
229
+ indices
230
+
231
+ } = result;
232
+ //do something
233
+ ```
234
+
235
+ ### `expandTubes(lines, options)`
236
+
237
+ * `lines`
238
+ * `options.radius`
239
+ * `options.radialSegments`
240
+
241
+ ```js
242
+ const result = expandTubes(polylines, {
243
+
244
+ radius: 1,
245
+ radialSegments: 8
246
+
247
+ });
248
+ const {
249
+
250
+ positon,
251
+ normal,
252
+ uv,
253
+ indices
254
+
255
+ } = result;
256
+ //do something
306
257
  ```