poly-extrude
v0.22.2
Published
extrude polyline/polygon etc
Readme
poly-extrude
Extrude polygons/polylines. Born in maptalks.three project
Install
NPM
npm i poly-extrudeCDN
<script type="text/javascript" src="https://unpkg.com/poly-extrude/dist/poly-extrude.js"></script>Use
import {
polygons,
extrudePolygons,
extrudePolygonsOnPath,
extrudePolylines,
cylinder,
expandPaths,
extrudeSlopes,
expandTubes,
plane
} from 'poly-extrude';
//if you use cdn,the namespace is polyextrude
// const {
// extrudePolygons,
// extrudePolylines
// } = window.polyextrude;
const polygons = [
//polygon
[
//outring
[
[x, y],
[x, y],
...........
],
//holes
[
[x, y],
[x, y], ...........
],
........
],
//other polygons
......
];
const polylines = [
// polyline
[
[x, y],
[x, y],
...........
],
//polyline
[
[x, y],
[x, y],
...........
],
];
const result = extrudePolygons(polygons, {
depth: 2
});
const {
positon,
normal,
uv,
indices
} = result;
//do somethingAPI

extrudePolygons(polygons, options)
polygonsoptions.depthoptions.topWhether to display the top
const result = extrudePolygons(polygons, {
depth: 2
});
const {
positon,
normal,
uv,
indices
} = result;
//do somethingbuilding
buildings
china
muti polygon
ny buildings
custom shape

extrudePolygonsOnPath(polygons, options)
polygonsoptions.extrudePathis lineoptions.openEndoptions.openEndUVoptions.polygonRotation
const result = extrudePolygonsOnPath(polygons, {
extrudePath: [
[0, 0],
[100, 0]
]
});
const {
positon,
normal,
uv,
indices
} = result;
//do somethingbase demo
wireframe demo
with holes
with holes by custom shape
polygonRotation
extrude along spring
extrude taihu lake
extrude by curve

extrudePolylines(lines, options)
linesoptions.depthoptions.lineWidthoptions.bottomStickGroundIs the bottom attached to the groundoptions.pathUVgenerate Path UV
const result = extrudePolylines(polylines, {
depth: 2,
lineWidth: 2
});
const {
positon,
normal,
uv,
indices
} = result;
//do somethingline
line uv
line pathUV
line cutcorner
brige
brige bottomStickGround
extrude brige
spring
wall
street

cylinder(center, options)
centeroptions.radiusoptions.heightoptions.radialSegments
const center = [0, 0];
const result = cylinder(center, {
radius: 1,
height: 2,
radialSegments: 6
});
const {
positon,
normal,
uv,
indices
} = result;
//do something
expandPaths(lines, options)
linesoptions.lineWidth
const result = expandPaths(polylines, {
cornerRadius: 0.5,
lineWidth: 2
});
const {
positon,
normal,
uv,
indices
} = result;
//do something
extrudeSlopes(lines, options)
linesoptions.depthoptions.lineWidthoptions.sideWhich side serves as the slope, 'left' or 'right'options.sideDepthslope depthoptions.bottomStickGroundIs the bottom attached to the groundoptions.pathUVgenerate Path UV
const result = extrudeSlopes(polylines, {
depth: 1,
side: 'left',
sideDepth: 0,
lineWidth: 2
});
const {
positon,
normal,
uv,
indices
} = result;
//do somethingslope
extrudeSlopes pathUV demo

expandTubes(lines, options)
linesoptions.radiusoptions.radialSegments
const result = expandTubes(polylines, {
radius: 1,
radialSegments: 8
});
const {
positon,
normal,
uv,
indices
} = result;
//do something
plane(width, height,devideW,devideH)
widthheightdevideWdevideH
const result = plane(100, 100, 10, 10);
const {
positon,
normal,
uv,
indices
} = result;
//do something
polygons(polygons, options)
polygons
const result = polygons(polygons, {
});
const {
positon,
normal,
uv,
indices
} = result;
//do something