Lin_Ye_Fang_Huo/public/widgets/analysis/widget.js

634 lines
17 KiB
JavaScript
Raw Normal View History

2023-07-18 09:04:15 +08:00
(function (window, mars3d) {
2023-07-08 15:37:34 +08:00
//创建widget类需要继承BaseWidget
class MyWidget extends mars3d.widget.BaseWidget {
//弹窗配置
get view() {
return {
2023-07-18 09:04:15 +08:00
type: "window",
url: "view.html",
2023-07-08 15:37:34 +08:00
windowOptions: {
width: 320,
height: 400,
},
2023-07-18 09:04:15 +08:00
};
2023-07-08 15:37:34 +08:00
}
//初始化[仅执行1次]
create() {
2023-07-18 09:04:15 +08:00
this.arrKsyList = [];
2023-07-08 15:37:34 +08:00
}
//每个窗口创建完成后调用
winCreateOK(opt, result) {
2023-07-18 09:04:15 +08:00
this.viewWindow = result;
2023-07-08 15:37:34 +08:00
}
//激活插件
activate() {}
//释放插件
disable() {
2023-07-18 09:04:15 +08:00
this.viewWindow = null;
this.destroyAll();
2023-07-08 15:37:34 +08:00
}
openTerrainDepthTest() {
2023-07-18 09:04:15 +08:00
this._last_depthTestAgainstTerrain = this.map.scene.globe.depthTestAgainstTerrain;
this.map.scene.globe.depthTestAgainstTerrain = true;
2023-07-08 15:37:34 +08:00
}
resetTerrainDepthTest() {
if (Cesium.defined(this._last_depthTestAgainstTerrain)) {
2023-07-18 09:04:15 +08:00
this.map.scene.globe.depthTestAgainstTerrain = this._last_depthTestAgainstTerrain;
delete this._last_depthTestAgainstTerrain;
2023-07-08 15:37:34 +08:00
}
}
destroyAll() {
2023-07-18 09:04:15 +08:00
this.destroyRZFX(); //日照分析
this.destroyPDPX(); //坡度坡向
this.destroyKSY(); //可视域分析
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
this.destroyFLFX(); //方量分析
this.destroyDXKW(); //地形开挖
this.destroyDBTM(); //地表透明
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
this.destroyMXPQ(); //模型剖切
this.destroyMXYP(); //模型压平
this.destroyMXCJ(); //模型裁剪
2023-07-08 15:37:34 +08:00
}
enableControl(value) {
if (this.map.popup) {
2023-07-18 09:04:15 +08:00
this.map.popup.enabled = value;
2023-07-08 15:37:34 +08:00
}
if (this.map.tooltip) {
2023-07-18 09:04:15 +08:00
this.map.tooltip.enabled = value;
2023-07-08 15:37:34 +08:00
}
if (this.map.contextmenu) {
2023-07-18 09:04:15 +08:00
this.map.contextmenu.enabled = value;
2023-07-08 15:37:34 +08:00
}
}
//=========日照分析========
createRZFX() {
2023-07-18 09:04:15 +08:00
this.destroyRZFX();
2023-07-08 15:37:34 +08:00
//日照分析类
this.shadows = new mars3d.thing.Shadows({
multiplier: 1600,
time: this.viewWindow.getCurrTime(),
2023-07-18 09:04:15 +08:00
});
this.map.addThing(this.shadows);
2023-07-08 15:37:34 +08:00
this.shadows.on(mars3d.EventType.change, (event) => {
2023-07-18 09:04:15 +08:00
this.viewWindow.setRZFXNowTime(this.shadows.time);
});
2023-07-08 15:37:34 +08:00
}
destroyRZFX() {
if (this.shadows) {
2023-07-18 09:04:15 +08:00
this.map.removeThing(this.shadows, true);
delete this.shadows;
2023-07-08 15:37:34 +08:00
}
}
//=========可视域分析========
createKSY() {
//不开启抗锯齿,可视域会闪烁
2023-07-18 09:04:15 +08:00
this.map.scene.postProcessStages.fxaa.enabled = true;
2023-07-08 15:37:34 +08:00
//不加无法投射到地形上
2023-07-18 09:04:15 +08:00
this.openTerrainDepthTest();
2023-07-08 15:37:34 +08:00
}
destroyKSY() {
2023-07-18 09:04:15 +08:00
this.clearKSY();
this.resetTerrainDepthTest();
2023-07-08 15:37:34 +08:00
}
clearKSY() {
for (var i = 0, len = this.arrKsyList.length; i < len; i++) {
2023-07-18 09:04:15 +08:00
this.map.removeThing(this.arrKsyList[i], true);
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
this.arrKsyList = [];
delete this.lastViewField;
2023-07-08 15:37:34 +08:00
}
getLastKSY() {
2023-07-18 09:04:15 +08:00
return this.lastViewField || {};
2023-07-08 15:37:34 +08:00
}
addKSY(options) {
var thisViewField = new mars3d.thing.ViewShed3D({
2023-07-18 09:04:15 +08:00
...options,
2023-07-08 15:37:34 +08:00
offsetHeight: 1.5, //增加人的升高
2023-07-18 09:04:15 +08:00
});
this.map.addThing(thisViewField);
2023-07-08 15:37:34 +08:00
thisViewField.on(mars3d.EventType.end, (event) => {
if (this.viewWindow) {
2023-07-18 09:04:15 +08:00
this.viewWindow.updateKsyDistance(event.distance);
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
});
this.lastViewField = thisViewField;
this.arrKsyList.push(thisViewField);
2023-07-08 15:37:34 +08:00
}
updateKsyDebugFrustum(show) {
for (var i = 0, len = this.arrKsyList.length; i < len; i++) {
2023-07-18 09:04:15 +08:00
this.arrKsyList[i].showFrustum = show;
2023-07-08 15:37:34 +08:00
}
}
//=========方量分析========
createFLFX() {
if (this.measure) {
2023-07-18 09:04:15 +08:00
return;
2023-07-08 15:37:34 +08:00
}
this.measure = new mars3d.thing.Measure({
heightLabel: true,
// offsetLabel: true,
2023-07-18 09:04:15 +08:00
});
this.map.addThing(this.measure);
2023-07-08 15:37:34 +08:00
this.measure.on(mars3d.EventType.start, (e) => {
2023-07-18 09:04:15 +08:00
haoutil.loading.show({ type: "loader-bar" });
});
2023-07-08 15:37:34 +08:00
this.measure.on(mars3d.EventType.end, (e) => {
2023-07-18 09:04:15 +08:00
haoutil.loading.hide();
this.viewWindow.showFLFXHeightRg();
});
2023-07-08 15:37:34 +08:00
}
destroyFLFX() {
if (this.measure) {
2023-07-18 09:04:15 +08:00
this.map.removeThing(this.measure, true);
delete this.measure;
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
this.measureVolume = null;
2023-07-08 15:37:34 +08:00
}
clearFLFX() {
if (!this.measure) {
2023-07-18 09:04:15 +08:00
return;
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
this.measure.clear();
this.measureVolume = null;
2023-07-08 15:37:34 +08:00
}
startFLFX() {
this.measureVolume = this.measure.volume({
splitNum: 6, //面内插值次数,控制精度[注意精度越大,分析时间越长]
// minHeight: 50 //可以设置一个固定的最低高度
2023-07-18 09:04:15 +08:00
});
2023-07-08 15:37:34 +08:00
}
//=========地形开挖========
createDXKW() {
2023-07-18 09:04:15 +08:00
this.openTerrainDepthTest();
2023-07-08 15:37:34 +08:00
}
startDrawDXKW() {
2023-07-18 09:04:15 +08:00
this.enableControl(false);
2023-07-08 15:37:34 +08:00
this.map.graphicLayer.startDraw({
2023-07-18 09:04:15 +08:00
type: "polygon",
2023-07-08 15:37:34 +08:00
style: {
2023-07-18 09:04:15 +08:00
color: "#29cf34",
2023-07-08 15:37:34 +08:00
opacity: 0.5,
},
success: (graphic) => {
//绘制成功后回调
2023-07-18 09:04:15 +08:00
this.enableControl(true);
2023-07-08 15:37:34 +08:00
//绘制成功后回调
2023-07-18 09:04:15 +08:00
var positions = graphic.positionsShow;
this.map.graphicLayer.clear();
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
this.showDXKWTerrainClip(positions);
2023-07-08 15:37:34 +08:00
},
2023-07-18 09:04:15 +08:00
});
2023-07-08 15:37:34 +08:00
}
startDrawDXKWExtent() {
2023-07-18 09:04:15 +08:00
this.enableControl(false);
2023-07-08 15:37:34 +08:00
this.map.graphicLayer.startDraw({
2023-07-18 09:04:15 +08:00
type: "rectangle",
2023-07-08 15:37:34 +08:00
style: {
2023-07-18 09:04:15 +08:00
color: "#007be6",
2023-07-08 15:37:34 +08:00
opacity: 0.8,
},
success: (graphic) => {
//绘制成功后回调
2023-07-18 09:04:15 +08:00
this.enableControl(true);
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
var positions = graphic.getOutlinePositions(false);
this.map.graphicLayer.clear();
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
this.showDXKWTerrainClip(positions);
2023-07-08 15:37:34 +08:00
},
2023-07-18 09:04:15 +08:00
});
2023-07-08 15:37:34 +08:00
}
destroyDXKW() {
if (this.terrainClip) {
2023-07-18 09:04:15 +08:00
this.map.removeThing(this.terrainClip, true);
delete this.terrainClip;
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
this.resetTerrainDepthTest();
2023-07-08 15:37:34 +08:00
}
clearDXKW() {
if (this.terrainClip) {
2023-07-18 09:04:15 +08:00
this.terrainClip.clear(); //清除挖地区域
2023-07-08 15:37:34 +08:00
}
//同时有模型时,清除模型裁剪
2023-07-18 09:04:15 +08:00
this.clearMXCJ();
2023-07-08 15:37:34 +08:00
}
showDXKWTerrainClip(positions) {
2023-07-18 09:04:15 +08:00
var height = this.viewWindow.getDXKWNowHeight();
2023-07-08 15:37:34 +08:00
if (!this.terrainClip) {
this.terrainClip = new mars3d.thing.TerrainClip({
diffHeight: height, //井的深度
2023-07-18 09:04:15 +08:00
image: this.path + "img/textures/excavationregion_top.jpg",
imageBottom: this.path + "img/textures/excavationregion_side.jpg",
2023-07-08 15:37:34 +08:00
splitNum: 50, //井边界插值数
2023-07-18 09:04:15 +08:00
});
this.map.addThing(this.terrainClip);
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
this.terrainClip.addArea(positions, { diffHeight: height });
2023-07-08 15:37:34 +08:00
//同时有模型时,进行模型裁剪
2023-07-18 09:04:15 +08:00
this.addMxcjPoly(positions);
2023-07-08 15:37:34 +08:00
}
updateDXKWHeight(nowValue) {
if (this.terrainClip) {
2023-07-18 09:04:15 +08:00
this.terrainClip.diffHeight = nowValue;
2023-07-08 15:37:34 +08:00
}
}
//=========地表透明========
createDBTM() {
this.underground = new mars3d.thing.Underground({
alpha: 0.5,
2023-07-18 09:04:15 +08:00
});
this.map.addThing(this.underground);
2023-07-08 15:37:34 +08:00
}
destroyDBTM() {
if (this.underground) {
2023-07-18 09:04:15 +08:00
this.map.removeThing(this.underground, true);
delete this.underground;
2023-07-08 15:37:34 +08:00
}
}
clearDBTM() {}
//=========坡度坡向========
createPDPX() {
if (this.slope) {
2023-07-18 09:04:15 +08:00
return;
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
//渲染效果
this.contourLine = new mars3d.thing.ContourLine({
contourShow: false, //是否显示等高线
shadingType: "none", //地表渲染效果类型:无nono, 高程 elevation, 坡度slope, 坡向aspect
});
this.map.addThing(this.contourLine);
2023-07-08 15:37:34 +08:00
this.slope = new mars3d.thing.Slope({
point: {
pixelSize: 9,
color: Cesium.Color.RED.withAlpha(0.5),
//disableDepthTestDistance: Number.POSITIVE_INFINITY,
},
arrow: {
scale: 0.3, //箭头长度的比例范围0.1-0.9
width: 15, //箭头宽度
color: Cesium.Color.YELLOW,
},
2023-07-18 09:04:15 +08:00
});
this.map.addThing(this.slope);
2023-07-08 15:37:34 +08:00
}
destroyPDPX() {
2023-07-18 09:04:15 +08:00
this.clearPDPX();
2023-07-08 15:37:34 +08:00
if (this.slope) {
2023-07-18 09:04:15 +08:00
this.map.removeThing(this.slope, true);
delete this.slope;
}
if (this.contourLine) {
this.map.removeThing(this.contourLine, true);
delete this.contourLine;
2023-07-08 15:37:34 +08:00
}
}
clearPDPX() {
if (this.slope) {
2023-07-18 09:04:15 +08:00
this.slope.clear();
}
if (this.contourLine) {
this.contourLine.clear();
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
this.map.graphicLayer.clear();
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
drawPDPXPoly(splitNum) {
this.map.graphicLayer.clear();
2023-07-08 15:37:34 +08:00
this.map.graphicLayer.startDraw({
2023-07-18 09:04:15 +08:00
type: "polygon",
2023-07-08 15:37:34 +08:00
style: {
2023-07-18 09:04:15 +08:00
color: "#29cf34",
2023-07-08 15:37:34 +08:00
opacity: 0.3,
outline: true,
2023-07-18 09:04:15 +08:00
outlineColor: "#ffffff",
2023-07-08 15:37:34 +08:00
clampToGround: true,
},
success: (graphic) => {
//绘制成功后回调
2023-07-18 09:04:15 +08:00
var positions = graphic.positionsShow;
this.map.graphicLayer.clear();
this.contourLine.positions = positions;
2023-07-08 15:37:34 +08:00
this.slope.add(positions, {
splitNum: splitNum, //splitNum插值分割的个数
radius: 1, //缓冲半径(影响坡度坡向的精度)
count: 4, //缓冲的数量(影响坡度坡向的精度)会求周边(count*4)个点
2023-07-18 09:04:15 +08:00
});
2023-07-08 15:37:34 +08:00
},
2023-07-18 09:04:15 +08:00
});
}
drawPDPXExtent(splitNum) {
this.map.graphicLayer.clear();
this.map.graphicLayer.startDraw({
type: "rectangle",
style: {
color: "#007be6",
opacity: 0.8,
outline: false,
},
success: (graphic) => {
//绘制成功后回调
var positions = graphic.getOutlinePositions(false);
this.map.graphicLayer.clear();
this.contourLine.positions = positions;
this.slope.add(positions, {
splitNum: splitNum, //splitNum插值分割的个数
radius: 1, //缓冲半径(影响坡度坡向的精度)
count: 4, //缓冲的数量(影响坡度坡向的精度)会求周边(count*4)个点
});
},
});
2023-07-08 15:37:34 +08:00
}
//=========模型剖切========
selectedPQMX() {
2023-07-18 09:04:15 +08:00
this.enableControl(false);
2023-07-08 15:37:34 +08:00
this.map.graphicLayer.startDraw({
2023-07-18 09:04:15 +08:00
type: "point",
2023-07-08 15:37:34 +08:00
style: {
2023-07-18 09:04:15 +08:00
color: "#007be6",
2023-07-08 15:37:34 +08:00
},
success: (graphic) => {
//绘制成功后回调
2023-07-18 09:04:15 +08:00
var position = graphic.positionShow;
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
this.map.graphicLayer.clear();
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
this.enableControl(true);
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
var tileset = this.map.pick3DTileset([position]); //拾取绘制返回的模型
2023-07-08 15:37:34 +08:00
if (!tileset) {
2023-07-18 09:04:15 +08:00
haoutil.msg("请单击选择模型");
return;
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
var radius = tileset.boundingSphere.radius / 2;
this.viewWindow.setClipDistanceRange(radius, tileset.name || "未命名");
2023-07-08 15:37:34 +08:00
this.tilesetPlanClip = new mars3d.thing.TilesetPlanClip({
tileset: tileset,
2023-07-18 09:04:15 +08:00
});
this.map.addThing(this.tilesetPlanClip);
2023-07-08 15:37:34 +08:00
},
2023-07-18 09:04:15 +08:00
});
2023-07-08 15:37:34 +08:00
}
drawLinePQMX() {
if (this.tilesetPlanClip) {
2023-07-18 09:04:15 +08:00
this.tilesetPlanClip.clear();
2023-07-08 15:37:34 +08:00
}
this.map.graphicLayer.startDraw({
2023-07-18 09:04:15 +08:00
type: "polyline",
2023-07-08 15:37:34 +08:00
maxPointNum: 2,
style: {
2023-07-18 09:04:15 +08:00
color: "#007be6",
2023-07-08 15:37:34 +08:00
opacity: 0.8,
outline: false,
},
success: (graphic) => {
//绘制成功后回调
2023-07-18 09:04:15 +08:00
var positions = graphic.positionsShow;
this.map.graphicLayer.clear();
2023-07-08 15:37:34 +08:00
if (this.tilesetPlanClip) {
2023-07-18 09:04:15 +08:00
this.tilesetPlanClip.clear();
2023-07-08 15:37:34 +08:00
} else {
2023-07-18 09:04:15 +08:00
var tileset = this.map.pick3DTileset(positions); //拾取绘制返回的模型
2023-07-08 15:37:34 +08:00
if (!tileset) {
2023-07-18 09:04:15 +08:00
haoutil.msg("请单击选择模型");
return;
2023-07-08 15:37:34 +08:00
}
this.tilesetPlanClip = new mars3d.thing.TilesetPlanClip({
tileset: tileset,
2023-07-18 09:04:15 +08:00
});
this.map.addThing(this.tilesetPlanClip);
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
this.tilesetPlanClip.positions = positions;
2023-07-08 15:37:34 +08:00
},
2023-07-18 09:04:15 +08:00
});
2023-07-08 15:37:34 +08:00
}
destroyMXPQ() {
if (this.tilesetPlanClip) {
2023-07-18 09:04:15 +08:00
this.map.removeThing(this.tilesetPlanClip, true);
delete this.tilesetPlanClip;
2023-07-08 15:37:34 +08:00
}
}
clearMXPQ() {
if (!this.tilesetPlanClip) {
2023-07-18 09:04:15 +08:00
return;
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
this.tilesetPlanClip.clear();
2023-07-08 15:37:34 +08:00
}
//=========模型压平========
createMXYP() {}
destroyMXYP() {
2023-07-18 09:04:15 +08:00
this.clearMXYP();
this._mxypTileset = null;
2023-07-08 15:37:34 +08:00
}
clearMXYP() {
if (this.tilesetFlat) {
2023-07-18 09:04:15 +08:00
this.map.removeThing(this.tilesetFlat, true);
delete this.tilesetFlat;
2023-07-08 15:37:34 +08:00
}
}
2023-07-18 09:04:15 +08:00
selectedYPMX() {
this.enableControl(false);
this.map.graphicLayer.startDraw({
type: "point",
style: {
color: "#007be6",
},
success: (graphic) => {
//绘制成功后回调
var position = graphic.positionShow;
this.map.graphicLayer.clear();
this.enableControl(true);
var tileset = this.map.pick3DTileset([position]); //拾取绘制返回的模型
if (!tileset) {
haoutil.msg("请单击选择模型");
return;
}
this._mxypTileset = tileset;
this.viewWindow.setMxpyName(tileset.name || "未命名");
},
});
}
2023-07-08 15:37:34 +08:00
drawMxypPoly(flatHeight) {
2023-07-18 09:04:15 +08:00
this.enableControl(false);
2023-07-08 15:37:34 +08:00
this.map.graphicLayer.startDraw({
2023-07-18 09:04:15 +08:00
type: "polygon",
2023-07-08 15:37:34 +08:00
style: {
2023-07-18 09:04:15 +08:00
color: "#007be6",
2023-07-08 15:37:34 +08:00
opacity: 0.5,
},
success: (graphic) => {
//绘制成功后回调
2023-07-18 09:04:15 +08:00
this.enableControl(true);
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
var positions = graphic.positionsShow;
this.map.graphicLayer.clear();
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
this.showMxypTilesetFlat(positions, flatHeight);
2023-07-08 15:37:34 +08:00
},
2023-07-18 09:04:15 +08:00
});
2023-07-08 15:37:34 +08:00
}
drawMxypPolyExtent(flatHeight) {
2023-07-18 09:04:15 +08:00
this.enableControl(false);
2023-07-08 15:37:34 +08:00
this.map.graphicLayer.startDraw({
2023-07-18 09:04:15 +08:00
type: "rectangle",
2023-07-08 15:37:34 +08:00
style: {
2023-07-18 09:04:15 +08:00
color: "#007be6",
2023-07-08 15:37:34 +08:00
opacity: 0.8,
},
success: (graphic) => {
//绘制成功后回调
2023-07-18 09:04:15 +08:00
this.enableControl(true);
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
var positions = graphic.getOutlinePositions(false);
this.map.graphicLayer.clear();
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
this.showMxypTilesetFlat(positions, flatHeight);
2023-07-08 15:37:34 +08:00
},
2023-07-18 09:04:15 +08:00
});
2023-07-08 15:37:34 +08:00
}
showMxypTilesetFlat(positions, height) {
2023-07-18 09:04:15 +08:00
var tileset = this._mxypTileset || this.map.pick3DTileset(positions); //拾取绘制返回的模型
if (!this.tilesetFlat || this.tilesetFlat.tileset != tileset) {
2023-07-08 15:37:34 +08:00
if (!tileset) {
2023-07-18 09:04:15 +08:00
haoutil.msg("请单击选择模型");
return;
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
this.clearMXYP();
2023-07-08 15:37:34 +08:00
this.tilesetFlat = new mars3d.thing.TilesetFlat({
tileset: tileset,
positions: positions,
height: height,
2023-07-18 09:04:15 +08:00
});
this.map.addThing(this.tilesetFlat);
2023-07-08 15:37:34 +08:00
} else {
2023-07-18 09:04:15 +08:00
this.tilesetFlat.height = height;
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
this.tilesetFlat.addArea(positions);
2023-07-08 15:37:34 +08:00
}
//=========模型裁剪========
createMXCJ() {}
destroyMXCJ() {
2023-07-18 09:04:15 +08:00
this.clearMXCJ();
if (this.tilesetClip) {
this.map.removeThing(this.tilesetClip, true);
delete this.tilesetClip;
}
2023-07-08 15:37:34 +08:00
}
clearMXCJ() {
if (this.tilesClipPlan) {
2023-07-18 09:04:15 +08:00
this.map.removeThing(this.tilesClipPlan, true);
delete this.tilesClipPlan;
}
if (this.tilesetClip) {
this.tilesetClip.clear();
2023-07-08 15:37:34 +08:00
}
}
drawMxcjPoly(clipOutSide) {
2023-07-18 09:04:15 +08:00
this.clearMXCJ();
2023-07-08 15:37:34 +08:00
this.map.graphicLayer.startDraw({
2023-07-18 09:04:15 +08:00
type: "rectangle",
2023-07-08 15:37:34 +08:00
style: {
2023-07-18 09:04:15 +08:00
color: "#007be6",
2023-07-08 15:37:34 +08:00
opacity: 0.8,
},
success: (graphic) => {
//绘制成功后回调
2023-07-18 09:04:15 +08:00
var positions = graphic.getOutlinePositions(false);
this.map.graphicLayer.clear();
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
var isAdd = this.addMxcjPoly(positions, clipOutSide);
2023-07-08 15:37:34 +08:00
if (!isAdd) {
2023-07-18 09:04:15 +08:00
haoutil.msg("请单击选择模型");
2023-07-08 15:37:34 +08:00
}
},
2023-07-18 09:04:15 +08:00
});
2023-07-08 15:37:34 +08:00
}
addMxcjPoly(positions, clipOutSide) {
2023-07-18 09:04:15 +08:00
var tileset = this.map.pick3DTileset(positions); //拾取绘制返回的模型
2023-07-08 15:37:34 +08:00
if (!tileset) {
2023-07-18 09:04:15 +08:00
return false;
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
//模型开挖处理类(Plan围合的)
2023-07-08 15:37:34 +08:00
this.tilesClipPlan = new mars3d.thing.TilesetPlanClip({
tileset: tileset,
positions: positions,
clipOutSide: clipOutSide,
2023-07-18 09:04:15 +08:00
});
this.map.addThing(this.tilesClipPlan);
//倾斜模型开挖处理类(只适用于部分倾斜模型)
if (!this.tilesetClip || this.tilesetClip.tileset != tileset) {
if (this.tilesetClip) {
this.map.removeThing(this.tilesetClip, true);
delete this.tilesetClip;
}
this.tilesetClip = new mars3d.thing.TilesetClip({
tileset: tileset,
positions: positions,
clipOutSide: clipOutSide,
});
this.map.addThing(this.tilesetClip);
} else {
this.tilesetClip.addArea(positions);
}
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
return true;
2023-07-08 15:37:34 +08:00
}
}
//注册到widget管理器中。
2023-07-18 09:04:15 +08:00
mars3d.widget.bindClass(MyWidget);
2023-07-08 15:37:34 +08:00
//每个widet之间都是直接引入到index.html中会存在彼此命名冲突所以闭包处理下。
2023-07-18 09:04:15 +08:00
})(window, mars3d);