poly-extrude 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintignore +12 -0
- package/.eslintrc.js +34 -0
- package/.vscode/settings.json +3 -0
- package/LICENSE +21 -0
- package/babel.config.js +12 -0
- package/dist/poly-extrude.js +1317 -0
- package/dist/poly-extrude.js.map +1 -0
- package/dist/poly-extrude.min.js +4 -0
- package/dist/poly-extrude.mjs +1305 -0
- package/index.js +3 -0
- package/package.json +42 -0
- package/pnpm-lock.yaml +3054 -0
- package/rollup.config.js +108 -0
- package/src/polygon.js +148 -0
- package/src/polyline.js +190 -0
- package/src/util.js +205 -0
- package/test/buildings.html +77 -0
- package/test/data/a.png +0 -0
- package/test/data/building-texture-dark.jpg +0 -0
- package/test/data/building.geojson +1118 -0
- package/test/data/buildings-ny.geojson +2845 -0
- package/test/data/buildings.geojson +1 -0
- package/test/data/free-line.geojson +1 -0
- package/test/data/line.geojson +1 -0
- package/test/data/polygon.geojson +1 -0
- package/test/data/simple-hole.geojson +1 -0
- package/test/data/simple-line.geojson +45 -0
- package/test/data/simple.geojson +1 -0
- package/test/data/street.geojson +1 -0
- package/test/data//345/244/252/346/271/226.geojson +8 -0
- package/test/data//350/210/237/345/261/261/345/270/202.geojson +1 -0
- package/test/data//350/213/217/345/267/236.geojson +1 -0
- package/test/data//351/204/261/351/230/263/346/271/226.geojson +1 -0
- package/test/line-draw.html +100 -0
- package/test/line-uv.html +69 -0
- package/test/line.html +56 -0
- package/test/multi-polygon.html +53 -0
- package/test/ny-building.html +67 -0
- package/test/simple.html +61 -0
- package/test/street.html +52 -0
- package/test/util.js +131 -0
- package/test/uv.html +77 -0
@@ -0,0 +1,77 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<meta charset="UTF-8">
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
5
|
+
<meta name=renderer content=webkit>
|
6
|
+
<script type="text/javascript" src="https://unpkg.com/@maptalks/geojson-bbox@1.0.4/dist/bbox.umd.js"></script>
|
7
|
+
<script type="text/javascript" src="https://unpkg.com/three@0.138.0/build/three.min.js"></script>
|
8
|
+
<script type="text/javascript" src="https://unpkg.com/three@0.142.0/examples/js/controls/OrbitControls.js"></script>
|
9
|
+
<script type="text/javascript" src="./../dist/poly-extrude.js"></script>
|
10
|
+
<script type="text/javascript" src="./util.js"></script>
|
11
|
+
|
12
|
+
<style type="text/css">
|
13
|
+
html,
|
14
|
+
body {
|
15
|
+
margin: 0px;
|
16
|
+
height: 100%;
|
17
|
+
width: 100%;
|
18
|
+
}
|
19
|
+
|
20
|
+
.container {
|
21
|
+
width: 100%;
|
22
|
+
height: 100%;
|
23
|
+
}
|
24
|
+
</style>
|
25
|
+
|
26
|
+
<body>
|
27
|
+
<script>
|
28
|
+
|
29
|
+
|
30
|
+
const scene = createScene();
|
31
|
+
|
32
|
+
function getTexture() {
|
33
|
+
const texture = new THREE.TextureLoader().load('./data/a.png');
|
34
|
+
texture.needsUpdate = true; //使用贴图时进行更新
|
35
|
+
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
|
36
|
+
// texture.repeat.set(0.002, 0.002);
|
37
|
+
texture.repeat.set(1, 2);
|
38
|
+
return texture;
|
39
|
+
}
|
40
|
+
|
41
|
+
const material = new THREE.MeshBasicMaterial({
|
42
|
+
color: '#FFF',
|
43
|
+
wireframe: false,
|
44
|
+
vertexColors: false,
|
45
|
+
map: getTexture()
|
46
|
+
})
|
47
|
+
|
48
|
+
|
49
|
+
function test() {
|
50
|
+
getGeoJSON('./data/buildings.geojson').then(geojson => {
|
51
|
+
flatCoordinates(geojson);
|
52
|
+
geojson.features.forEach(feature => {
|
53
|
+
const { type, coordinates } = feature.geometry;
|
54
|
+
// const time1 = 'time1';
|
55
|
+
// console.time(time1);
|
56
|
+
// const result1 = geometryExtrude.extrudePolygon(type === 'Polygon' ? [coordinates] : coordinates, { depth: 4 });
|
57
|
+
// console.timeEnd(time1);
|
58
|
+
const time = 'time';
|
59
|
+
console.time(time);
|
60
|
+
const result = polyextrude.extrudePolygons(type === 'Polygon' ? [coordinates] : coordinates, { depth: feature.properties.height / 5 });
|
61
|
+
|
62
|
+
console.timeEnd(time);
|
63
|
+
console.log(result);
|
64
|
+
const geometry = createBufferGeometry(result);
|
65
|
+
const mesh = new THREE.Mesh(geometry, material);
|
66
|
+
scene.add(mesh);
|
67
|
+
});
|
68
|
+
})
|
69
|
+
}
|
70
|
+
test();
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
</script>
|
75
|
+
</body>
|
76
|
+
|
77
|
+
</html>
|
package/test/data/a.png
ADDED
Binary file
|
Binary file
|