-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b75e37c
commit 101f5f3
Showing
22 changed files
with
5,614 additions
and
17,700 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title></title> | ||
<style></style> | ||
</head> | ||
<body> | ||
<div style="float: left; position: absolute; top: 0px; left: 0px; z-index: 2;"> | ||
掩膜的设计主要是参考了<a href="https://github.com/hofk/THREEi.js">https://github.com/hofk/THREEi.js</a>这个代码,我将代码改成es module的形式了。 | ||
<p>其他在几何体添加孔洞的方法:</p> | ||
<p>https://github.com/manthrax/THREE-CSGMesh 用于物体求交、减、加。</p> | ||
<p>https://threejs.org/examples/#webgl_geometry_convex 和这个示例。</p> | ||
<p>思路:通过境界经纬度构造ConvexGeometry几何体,然后再使用csg对球体和ConvexGeometry求减。</p> | ||
<p>cesium也有相应的构造掩膜的方法,但我不知道他们怎么做的,哎!汗颜~~~!</p> | ||
<p>如果有其他优雅的方式欢迎各位大佬讨论交流,或者提交pr。</p> | ||
<p>境界服务的数据来自阿里的datav,如果境界有误请及时联系我进行修改删除,谢谢!</p> | ||
</div> | ||
<div id="mapContainer"> | ||
|
||
</div> | ||
<!-- GUI --> | ||
<!-- <div id="mapContainer"> | ||
<div id="map"> | ||
<canvas id="canvas" style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%;"></canvas> | ||
</div> | ||
<div id="layers"> | ||
<div> | ||
<canvas id="canvas1" style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%;"></canvas> | ||
</div> | ||
<div> | ||
<canvas id="canvas2" style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%;"></canvas> | ||
</div> | ||
</div> | ||
</div> --> | ||
|
||
<!-- Code --> | ||
<!-- <script src="./js/wegeo.js"></script> --> | ||
<!-- "three": "../build/three.module.js", --> | ||
<!-- "three/addons/": "../build/jsm/", --> | ||
<!-- <script src="./js/THREEi_ONLY_SphereWithSomeHoles.js"></script> --> | ||
<script type="importmap"> | ||
{ | ||
"imports": { | ||
"three": "../../../build/three.module.js", | ||
"three/addons/": "../../../build/jsm/", | ||
"Geo": "../../../build/wegeo.module.js", | ||
"THREEi":"../../js/createhole.js" | ||
} | ||
} | ||
</script> | ||
|
||
<script type="module"> | ||
// 需要全量构建geo,目前不能把threejs排除在外 | ||
import {WegeoMap,MapView, TianDiTuProvider, Config, BingMapsProvider, AngleUtils} from 'Geo'; | ||
import * as THREE from 'three'; | ||
import * as THREEi from 'THREEi'; | ||
let provider = new BingMapsProvider(); | ||
// 地名服务 | ||
// let nameprovider = new TianDiTuProvider({ | ||
// service:'cva_w', | ||
// token: '588e61bc464868465169f209fe694dd0' | ||
// }); | ||
|
||
// // map.addView(provider); | ||
// let edgeprovider = new TianDiTuProvider({ | ||
// service:'ibo_w', | ||
// token: '588e61bc464868465169f209fe694dd0' | ||
// }); | ||
// Config.outLine.on = true; | ||
const map = new WegeoMap(); | ||
map.addBaseSphereMap({ | ||
providers: [provider] | ||
}); | ||
map.moveToByLL(44.266119,90.139228, 6371008); | ||
window.onresize = () => { map.resize(); } | ||
map.resize(); | ||
map.animate(); | ||
// 解析geojson | ||
// const geojson = await fetch('./examples/data/xinjiang.json').then( res => res.json() ); | ||
let points = []; | ||
await fetch('/examples/data/xinjiang.json').then(res => res.json()) | ||
.then(data => { | ||
let features = data.features; | ||
|
||
features.forEach(feature=>{ | ||
let properties = feature.properties; | ||
let geometry = feature.geometry; | ||
let type = feature.type; | ||
let coordinates = geometry.coordinates; | ||
let typeGeometry = geometry.type; | ||
if (typeGeometry === "MultiPolygon") { // 目前暂时仅仅支持行政区划方向的数据进行解析 | ||
for(let multiPolygon of coordinates){ | ||
const shapePonit = []; | ||
let polygon = multiPolygon[0]; // 每次取第一个图形,geojson里面是这样设置的 | ||
for(let point of polygon){ | ||
// 先维度后经度 | ||
let phi = AngleUtils.degToRad(point[0]); | ||
let theta = AngleUtils.degToRad(90-point[1]); | ||
shapePonit.push(theta); | ||
shapePonit.push(phi); | ||
} | ||
points.push(shapePonit); | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
const g = new THREE.BufferGeometry( ); | ||
const parameters = { | ||
// d: 509680, // rough side length of the triangles, radius calculated from d and div4 | ||
d: 403090, // rough side length of the triangles, radius calculated from d and div4 | ||
div4: 25, // division of the quarter of the great circle (orthodrome) | ||
holes: points | ||
// [ | ||
// // circular hole, 3 elements: [ theta, phi, div4Hole ], div4Hole <= div4 | ||
// // [ 1.57, -0.25, 9 ], | ||
// // [ 0.44, 4.84, 18 ], | ||
// // [ 1.23, 1.62, 11 ], | ||
// // points hole,: array of points theta, phi, ... (last point is connected to first) | ||
// [ 1.7,-1.2, 1.7,-2.1, 2.6,-2.1 ] | ||
// ] | ||
} | ||
|
||
g.createSphereWithHoles = THREEi.createSphereWithHoles; | ||
g.createSphereWithHoles( parameters ); // parameter object | ||
|
||
const material = new THREE.MeshBasicMaterial( { side: THREE.DoubleSide, color: 0x450089, wireframe: false } ); | ||
const mesh = new THREE.Mesh( g, material ); | ||
material.transparent = true; | ||
material.opacity = 0.5; | ||
map.baseMap.add( mesh ); | ||
let scale =0.995; | ||
// let scale =0.9939; | ||
// let scale =0.99385; | ||
mesh.scale.set( scale,scale,scale ); | ||
|
||
|
||
// map.addModelLayer('3dtiles', './s228_checkpoint_3dtiles/tileset.json'); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.