mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-01-25 15:08:11 +00:00
修复bug。
This commit is contained in:
parent
212f0954d4
commit
95c5ec4bbf
@ -233,7 +233,9 @@ ScenePanel.prototype.onLoad = function (data) {
|
||||
if (this.app.editor.gis) {
|
||||
this.app.editor.gis.stop();
|
||||
}
|
||||
this.app.editor.gis = new GISScene(this.app);
|
||||
this.app.editor.gis = new GISScene(this.app, {
|
||||
useCameraPosition: true,
|
||||
});
|
||||
this.app.editor.gis.start();
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,16 +14,15 @@ import WGS84 from './core/WGS84';
|
||||
* @param {THREE.WebGLRenderer} renderer 渲染器
|
||||
* @param {Object} options 配置
|
||||
* @param {String} options.server 服务端配置
|
||||
* @param {Boolean} options.useCameraPosition 是否使用相机位置
|
||||
* @param {Number} options.maxThread 最大工作线程数,避免任务创建过多,导致地图卡顿
|
||||
*/
|
||||
function Globe(camera, renderer, options = {}) {
|
||||
THREE.Object3D.call(this);
|
||||
|
||||
options.server = options.server || location.origin;
|
||||
options.useCameraPosition = options.useCameraPosition || false;
|
||||
options.maxThread = options.maxThread || 10;
|
||||
options.lon = options.lon || 0;
|
||||
options.lat = options.lat || 0;
|
||||
options.zoom = options.zoom || 2;
|
||||
|
||||
this.name = L_GLOBE;
|
||||
|
||||
@ -50,8 +49,10 @@ function Globe(camera, renderer, options = {}) {
|
||||
this.renderers = new Renderers(this);
|
||||
this.viewer = new OrbitViewer(this.camera, this.renderer.domElement);
|
||||
|
||||
// 相机位置
|
||||
this.viewer.setPosition(options.lon, options.lat, GeoUtils.zoomToAlt(options.zoom));
|
||||
// 如果不使用相机位置,则设置默认中心点
|
||||
if (!this.options.useCameraPosition) {
|
||||
this.viewer.setPosition(0, 0, GeoUtils.zoomToAlt(2));
|
||||
}
|
||||
}
|
||||
|
||||
Globe.prototype = Object.create(THREE.Object3D.prototype);
|
||||
|
||||
@ -3,10 +3,14 @@ import Globe from './Globe';
|
||||
/**
|
||||
* GIS场景
|
||||
* @author tengge / https://github.com/tengge1
|
||||
* @param {*} app
|
||||
* @param {*} app 应用程序
|
||||
* @param {Object} options 配置
|
||||
* @param {Boolean} options.useCameraPosition 是否使用相机位置
|
||||
*/
|
||||
function Scene(app) {
|
||||
function Scene(app, options = {}) {
|
||||
this.app = app;
|
||||
this.options = options;
|
||||
this.options.useCameraPosition = this.options.useCameraPosition || false;
|
||||
}
|
||||
|
||||
Scene.prototype.start = function () {
|
||||
@ -24,6 +28,7 @@ Scene.prototype.start = function () {
|
||||
|
||||
this.globe = new Globe(editor.camera, editor.renderer, {
|
||||
server: this.app.options.server,
|
||||
useCameraPosition: this.options.useCameraPosition,
|
||||
});
|
||||
editor.scene.add(this.globe);
|
||||
this.oldSceneBeforeRender = editor.scene.onBeforeRender;
|
||||
|
||||
@ -135,15 +135,15 @@ OrbitViewer.prototype.onMouseWheel = function () {
|
||||
|
||||
var d = delta * (distance - WGS84.a) / 1000;
|
||||
|
||||
var d_1 = GeoUtils.zoomToAlt(-1) + WGS84.a;
|
||||
var d_1 = GeoUtils.zoomToAlt(2) + WGS84.a;
|
||||
|
||||
if (distance + d >= d_1) { // 最远0层级距离
|
||||
if (distance + d >= d_1) { // 最远2层级距离
|
||||
d = 0;
|
||||
}
|
||||
|
||||
var d_2 = GeoUtils.zoomToAlt(18) + WGS84.a;
|
||||
|
||||
if (distance + d <= d_2) { // 最近16层级
|
||||
if (distance + d <= d_2) { // 最近18层级
|
||||
d = 0;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user