Skip to content

Commit 58a8cfc

Browse files
authored
Merge pull request #129 from MapGIS/ljy
Ljy
2 parents 3343f92 + 7344c35 commit 58a8cfc

File tree

4 files changed

+66
-15
lines changed

4 files changed

+66
-15
lines changed

src/cesiumjs/layer/TilesLayer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ export default class TilesLayer extends BaseLayer {
7171
* @param {Rectangle} [optionsParam.tileRange=Rectangle.fromDegrees(-180,-90,180,90)] 默认范围为全球范围
7272
* @param {Number} [optionsParam.colNum=2] 瓦片初始级的列数 默认为2
7373
* @param {Number} [optionsParam.rowNum=1] 瓦片初始级的列数 默认为1
74-
* @param {Number} [optionsParam.maxLevel=19] 瓦片最大显示级数 默认为19
74+
* @param {Number} [options.minimumLevel=0] 瓦片最小级别
75+
* @param {Number} [options.maximumLevel=19] 瓦片最大级别
7576
* @param {String} [optionsParam.proxy] 转发代理
7677
* @param {Array} [options.gdbps] gdbps地址数组
7778
* @param {String} [options.layers] layers参数,用于过滤图层

src/cesiumjs/manager/CommonDataManager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export default class CommonDataManager extends LayerManager {
111111
* @returns {Object} model 移除通过 removeModel()
112112
* @example
113113
* let modelUrl = '../../../../../../static/data/CesiumAir/Cesium_Air.gltf';
114-
cesiumFun.appendModels('1', modelUrl, 114, 28, 200, 100000, {
114+
cesiumFun.appendModel('1', modelUrl, 114, 28, 200, 100000, {
115115
color: Cesium.Color.RED,
116116
colorBlendMode: Cesium.ColorBlendMode.MIX,// MIX是混合 Cesium.ColorBlendMode.HIGHLIGHT, HIGHLIGHT是高亮
117117
colorBlendAmount: 0.4 //这个是程度
@@ -160,7 +160,7 @@ export default class CommonDataManager extends LayerManager {
160160

161161
/**
162162
* 通过文件批量添加模型
163-
* @function module:客户端公共方法.CommonDataManager.prototype.appendModels
163+
* @function module:客户端公共方法.CommonDataManager.prototype.appendModelsByFile
164164
* @param {String} filePath 模型组织文件
165165
* @param {Function} successCall 成功后的回调
166166
* @returns {Object} 模型层对象

src/cesiumjs/manager/CommonFuncManager.js

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,16 @@ export default class CommonFuncManager {
138138
* //res.toPng();
139139
*/
140140
outputImageObj() {
141+
let isAn = true;
142+
if (this.viewer.shouldAnimate === false) {
143+
this.viewer.shouldAnimate === true;
144+
isAn = false;
145+
}
141146
this.viewer.render();
142-
return Cesium.reimg.fromCanvas(this.viewer.canvas);
147+
if (!isAn) {
148+
this.viewer.shouldAnimate === false;
149+
}
150+
return Cesium.ReImg.fromCanvas(this.viewer.canvas);
143151
}
144152

145153
/**
@@ -153,7 +161,7 @@ export default class CommonFuncManager {
153161
*/
154162
outputImageFile(fileName) {
155163
this.viewer.render();
156-
Cesium.reimg.fromCanvas(this.viewer.canvas).downloadPng(fileName);
164+
Cesium.ReImg.fromCanvas(this.viewer.canvas).downloadPng(fileName);
157165
}
158166

159167
/**
@@ -195,6 +203,13 @@ export default class CommonFuncManager {
195203
* @function module:客户端公共方法.CommonFuncManager.prototype.getSceneRange
196204
* @param {String} 视图元素ID
197205
* @returns {Array[]} 场景范围(单位:经纬度)Array<[lon,lat]>
206+
* @example
207+
* var viewer = new Cesium.Viewer('GlobeView1', {
208+
* terrainExaggeration: 1,
209+
* requestRenderMode: true
210+
* });
211+
* let id = 'GlobeView1';
212+
* cfm.getSceneRange(id);
198213
*/
199214
getSceneRange(elementID) {
200215
const controlDiv = document.getElementById(elementID);
@@ -442,15 +457,33 @@ export default class CommonFuncManager {
442457
let carCenter = new Cesium.Cartographic();
443458
carCenter = Cesium.Cartographic.fromCartesian(center, this.ellipsoid, carCenter);
444459
carCenter.height = 0;
445-
const centerUse = Cesium.Cartesian3.fromRadians(carCenter.longitude, carCenter.latitude, carCenter.height, this.ellipsoid, new Cesium.Cartesian3());
446-
const centerUseEx = Cesium.Cartesian3.fromRadians(carCenter.longitude, carCenter.latitude + 0.1, carCenter.height, this.ellipsoid, new Cesium.Cartesian3());
460+
const centerUse = Cesium.Cartesian3.fromRadians(
461+
carCenter.longitude,
462+
carCenter.latitude,
463+
carCenter.height,
464+
this.ellipsoid,
465+
new Cesium.Cartesian3()
466+
);
467+
const centerUseEx = Cesium.Cartesian3.fromRadians(
468+
carCenter.longitude,
469+
carCenter.latitude + 0.1,
470+
carCenter.height,
471+
this.ellipsoid,
472+
new Cesium.Cartesian3()
473+
);
447474
let tempdir = Cesium.Cartesian3.subtract(centerUseEx, centerUse, new Cesium.Cartesian3());
448475
tempdir = Cesium.Cartesian3.normalize(tempdir, tempdir);
449476

450477
let carTarget = new Cesium.Cartographic();
451478
carTarget = Cesium.Cartographic.fromCartesian(target, this.ellipsoid, carTarget);
452479
carTarget.height = 0;
453-
const targetUse = Cesium.Cartesian3.fromRadians(carTarget.longitude, carTarget.latitude, carTarget.height, this.ellipsoid, new Cesium.Cartesian3());
480+
const targetUse = Cesium.Cartesian3.fromRadians(
481+
carTarget.longitude,
482+
carTarget.latitude,
483+
carTarget.height,
484+
this.ellipsoid,
485+
new Cesium.Cartesian3()
486+
);
454487

455488
let tarDir = Cesium.Cartesian3.subtract(targetUse, centerUse, new Cesium.Cartesian3());
456489
tarDir = Cesium.Cartesian3.normalize(tarDir, tarDir);
@@ -496,8 +529,8 @@ export default class CommonFuncManager {
496529
* let drawElement = new Cesium.DrawElement(viewer);
497530
* let commfun = new CommonFun({viewer:viewer});
498531
* drawElement.startDrawingPolyline({
499-
* callback: function(positions){
500-
* let simplify = commfun.simplifyLine(positions);
532+
* callback: function(result){
533+
* let simplify = commfun.simplifyLine(result.positions);
501534
* polyline = new Cesium.DrawElement.PolylinePrimitive({
502535
* positions: simplify,
503536
* width: 1,
@@ -520,7 +553,11 @@ export default class CommonFuncManager {
520553
}
521554
for (let i = 0; i <= posCopy.length - 3; i += 1) {
522555
const isVertice = !((posCopy[i].z - posCopy[i + 1].z) * (posCopy[i + 1].z - posCopy[i + 2].z) > 0);
523-
const angle = calAngleOf3Pnt([posCopy[i].x, posCopy[i].y, posCopy[i].z], [posCopy[i + 1].x, posCopy[i + 1].y, posCopy[i + 1].z], [posCopy[i + 2].x, posCopy[i + 2].y, posCopy[i + 2].z]);
556+
const angle = calAngleOf3Pnt(
557+
[posCopy[i].x, posCopy[i].y, posCopy[i].z],
558+
[posCopy[i + 1].x, posCopy[i + 1].y, posCopy[i + 1].z],
559+
[posCopy[i + 2].x, posCopy[i + 2].y, posCopy[i + 2].z]
560+
);
524561

525562
if (angle > 175 && !isVertice) {
526563
posCopy = posCopy.slice(0, i + 1).concat(posCopy.slice(i + 2));
@@ -555,7 +592,10 @@ export default class CommonFuncManager {
555592
static calcParabola(options) {
556593
// 方程 y=-(4h/L^2)*x^2+h h:顶点高度 L:横纵间距较大者
557594
const h = options.height && options.height > 5000 ? options.height : 5000;
558-
const L = Math.abs(options.position1.lon - options.position2.lon) > Math.abs(options.position1.lat - options.position2.lat) ? Math.abs(options.position1.lon - options.position2.lon) : Math.abs(options.position1.lat - options.position2.lat);
595+
const L =
596+
Math.abs(options.position1.lon - options.position2.lon) > Math.abs(options.position1.lat - options.position2.lat)
597+
? Math.abs(options.position1.lon - options.position2.lon)
598+
: Math.abs(options.position1.lat - options.position2.lat);
559599
const num = options.num && options.num > 50 ? options.num : 50;
560600
const result = [];
561601
let dlt = L / num;
@@ -713,7 +753,7 @@ export default class CommonFuncManager {
713753
});
714754
*/
715755
createNavigationTool(options) {
716-
this.viewer.extend(Cesium.viewerCesiumNavigationMixin, options);
756+
this.viewer.extend(Cesium.NavigationTool, options);
717757
return this.viewer.cesiumNavigation;
718758
}
719759
}

src/cesiumjs/manager/EntityController.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,12 +422,22 @@ export default class EntityController extends BaseLayer {
422422
positions: simplifyPnts,
423423
width: 1,
424424
geodesic: true,
425-
id: name
425+
id: name,
426+
vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT,
426427
};
428+
var color = Cesium.defaultValue(options.color,Cesium.Color.BLUE);
427429
if (Cesium.defined(options)) {
428430
Object.extend(para, options);
429431
}
430-
const polyline = new Cesium.PathTool.PolylinePrimitive(para);
432+
var polyline = new Cesium.Primitive({
433+
geometryInstances : new Cesium.GeometryInstance({
434+
geometry : new Cesium.PolylineGeometry(para),
435+
attributes: {
436+
color: Cesium.ColorGeometryInstanceAttribute.fromColor(color)
437+
}
438+
}),
439+
appearance: new Cesium.PolylineColorAppearance()
440+
})
431441
this.scene.primitives.add(polyline);
432442
if (typeof callback === 'function') {
433443
callback(polyline);

0 commit comments

Comments
 (0)