98 lines
2.7 KiB
JavaScript
98 lines
2.7 KiB
JavaScript
|
/* 2017-12-4 08:27:25 | 修改 木遥(微信: http://marsgis.cn/weixin.html ) */
|
|||
|
//模块:
|
|||
|
mars3d.widget.bindClass(mars3d.widget.BaseWidget.extend({
|
|||
|
options: {
|
|||
|
//弹窗
|
|||
|
view: {
|
|||
|
type: "window",
|
|||
|
url: "view.html",
|
|||
|
windowOptions: {
|
|||
|
width: 270,
|
|||
|
height: 500,
|
|||
|
"position": {
|
|||
|
"top": 70,
|
|||
|
"bottom": 40,
|
|||
|
"left": 15
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
},
|
|||
|
//初始化[仅执行1次]
|
|||
|
create: function () {
|
|||
|
|
|||
|
|
|||
|
},
|
|||
|
viewWindow: null,
|
|||
|
//每个窗口创建完成后调用
|
|||
|
winCreateOK: function (opt, result) {
|
|||
|
this.viewWindow = result;
|
|||
|
},
|
|||
|
//打开激活
|
|||
|
activate: function () {
|
|||
|
|
|||
|
|
|||
|
},
|
|||
|
//关闭释放
|
|||
|
disable: function () {
|
|||
|
this.viewWindow = null;
|
|||
|
this.resetStyle();
|
|||
|
},
|
|||
|
getTreeUrl: function () {
|
|||
|
var url = this.config.layerCfg.url;
|
|||
|
url = url.substring(0, url.lastIndexOf('/') + 1) + this.config.layerCfg.scenetree;
|
|||
|
|
|||
|
var that = this;
|
|||
|
$.ajax({
|
|||
|
url: url,
|
|||
|
dataType: 'json',
|
|||
|
success: function (scene) {
|
|||
|
that.viewWindow.initSceneTree(scene);
|
|||
|
}
|
|||
|
});
|
|||
|
},
|
|||
|
resetStyle: function () {
|
|||
|
var layerWork = this.viewer.mars.getLayer(this.config.layerCfg);
|
|||
|
if (!layerWork) return;
|
|||
|
var tileset = layerWork.model;
|
|||
|
if (!tileset) return;
|
|||
|
tileset.style = undefined;
|
|||
|
},
|
|||
|
//定位
|
|||
|
locateNode: function (nodeid, nodesphere) {
|
|||
|
if (nodesphere[3] <= 0)
|
|||
|
return;
|
|||
|
|
|||
|
|
|||
|
var layerWork = this.viewer.mars.getLayer(this.config.layerCfg);
|
|||
|
var tileset = layerWork.model;
|
|||
|
var orginMatrixInverse = layerWork.orginMatrixInverse;
|
|||
|
|
|||
|
//飞行过去
|
|||
|
var center = new Cesium.Cartesian3(nodesphere[0], nodesphere[1], nodesphere[2]);
|
|||
|
if (orginMatrixInverse && tileset._root.transform) {
|
|||
|
var mat = Cesium.Matrix4.multiply(tileset._root.transform, orginMatrixInverse, new Cesium.Matrix4());
|
|||
|
center = Cesium.Matrix4.multiplyByPoint(mat, center, new Cesium.Cartesian3());
|
|||
|
}
|
|||
|
|
|||
|
var sphere = new Cesium.BoundingSphere(center, nodesphere[3]);
|
|||
|
this.viewer.camera.flyToBoundingSphere(sphere, {
|
|||
|
duration: 0.5
|
|||
|
});
|
|||
|
|
|||
|
//设置tileset的样式
|
|||
|
tileset.style = new Cesium.Cesium3DTileStyle({
|
|||
|
color: {
|
|||
|
conditions: [
|
|||
|
["${id} ==='" + nodeid + "'", "rgb(255, 255, 255)"],
|
|||
|
["true", "rgba(255, 200, 200,0.2)"]
|
|||
|
]
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}));
|