2 Star 2 Fork 1

吴伟/threejs 3D 大屏

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
run.js 1.74 KB
一键复制 编辑 原始数据 按行查看 历史
吴伟 提交于 2024-07-11 19:39 . v1.0.0
function createMap(res) {
res = JSON.parse(res);
res.features.forEach((province) => {
// 省市的物体
let provinceObj = new THREE.Object3D();
if (province.geometry.type === "Polygon") {
province.geometry.coordinates.forEach((polygon) => {
let shape = new THREE.Shape();
let arr = [];
for (let i = 0; i < polygon.length; i++) {
let (x, y) = projection(polygon[i]);
if (i === 0) {
shape.moveTo(x, -y);
} else {
shape.lineTo(x, -y);
}
arr.push(x, -y, 1);
}
let mesh = createPolygon(shape, arr, province);
provinceObj.add(mesh);
});
} else if (province.geometry.type === "MultiPolygon") {
province.geometry.coordinates.forEach((multipolygon) => {
multipolygon.forEach((polygon) => {
let shape = new THREE.Shape();
let arr = [];
for (let i = 0; i < polygon.length; i++) {
let (x, y) = projection(polygon[i]);
if (i === 0) {
shape.moveTo(x, -y);
} else {
shape.lineTo(x, -y);
}
arr.push(x, -y, 1);
}
let mesh = createPolygon(shape, arr, province);
provinceObj.add(mesh);
});
});
}
chinaObj.add(provinceObj);
});
}
function createPolygon(shape, arr, province) {
let extrudeMats = {
steps: 20,
depth: 0.2,
bevelEnabled: false,
bevelThickness: 1,
bevelSize: 1,
bevelOffset: 0,
bevelSegments: 1
}
let geo = new THREE.ExtrudeGeometry(shape);
let mesh = new THREE.Mesh(geo, extrudeMats);
if (province.properties.name) {
mesh.name = province.properties.name;
}
// 其他代码...
return mesh;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wuwei_4356/threejs-3d-bigscreen.git
[email protected]:wuwei_4356/threejs-3d-bigscreen.git
wuwei_4356
threejs-3d-bigscreen
threejs 3D 大屏
master

搜索帮助