guanqb
2023-03-30 9ee5bafa0d00816fad6793a470f1b570c99cce1b
src/views/activity/components/drawBtnBox.vue
@@ -82,7 +82,10 @@
        this.$nextTick(() => {
            drawThreeTool = new Plot(global.viewer, {
                clampToModel: true
                clampToModel: true,
                icon_center: "/img/draw/red.png", // 自定义的中心点图标
                icon_anchor: "/img/draw/red.png", //自定义的锚点图标
                icon_midAnchor: "/img/draw/blue.png", //自定义的中心锚点图标
            })
            // global.viewer.scene.globe.depthTestAgainstTerrain = true
@@ -135,34 +138,46 @@
                    break
            }
            if (type == 'polygon') {
                drawThreeTool && drawThreeTool.draw(type, overlay => {
                    if (drawFlag) return
                    if (overlay) {
                        addPlotOverlayData = overlay
                        overlay.customType = 'polygon'
                        that.$parent.addArrowsListLayer(overlay)
                        let polygonPosition = overlay.positions.map(item => `${item.lng} ${item.lat}`).join()
                        const altitude = overlay.positions.map(item => item.alt).join()
                        setTimeout(() => {
                            that.$parent.addSaveNewDraw(polygonPosition, 5, altitude)
                        }, 100)
                        global.viewer.scene.globe.depthTestAgainstTerrain = false
                        currentStatus = ''
                        that.startDrawFlag = false
                    }
                }, {
            let drawConfig = {}
            if (type == 'polygon') {
                drawConfig = {
                    material: global.DC.Namespace.Cesium.Color.fromBytes(64, 158, 255, 122),
                    perPositionHeight: true,
                    outline: true,
                    outlineColor: global.DC.Namespace.Cesium.Color.fromBytes(64, 158, 255, 255),
                    outlineWidth: 4.0,
                }, true)
                }
            } else if (type == 'billboard') {
                drawThreeTool && drawThreeTool.draw(type, overlay => {
                    if (drawFlag) return
                    if (overlay) {
                drawConfig = {
                    size: [32, 32],
                    verticalOrigin: global.DC.Namespace.Cesium.VerticalOrigin.BOTTOM,
                    color: material,
                    // eyeOffset: new global.DC.Namespace.Cesium.Cartesian3(0, 0, -10),
                    billboardImage: `/img/icon/${imgUrl}.png`
                }
            } else if (type == 'polyline') {
                drawConfig = {
                    material: global.DC.Namespace.Cesium.Color.fromBytes(28, 160, 133, 122),
                }
            }
            drawThreeTool.draw(type, overlay => {
                if (drawFlag) return
                if (overlay) {
                    if (type == 'polygon') {
                        addPlotOverlayData = overlay
                        overlay.customType = 'polygon'
                        that.$parent.addArrowsListLayer(overlay)
                        let polygonPosition = overlay.positions.map(item => `${item.lng} ${item.lat}`).join()
                        const altitude = overlay.positions.map(item => item.alt).join()
                        setTimeout(() => {
                            that.$parent.addSaveNewDraw(polygonPosition, 5, altitude)
                        }, 100)
                    }
                    if (type == 'billboard') {
                        addPlotOverlayData = overlay
                        overlay.customType = 'billboard'
                        that.$parent.addPointCircleCarLayer(overlay)
@@ -171,21 +186,9 @@
                        } else {
                            that.$parent.addPointPopupShow(typeValue, overlay.position)
                        }
                        global.viewer.scene.globe.depthTestAgainstTerrain = false
                        currentStatus = ''
                        that.startDrawFlag = false
                    }
                }, {
                    size: [32, 32],
                    verticalOrigin: global.DC.Namespace.Cesium.VerticalOrigin.BOTTOM,
                    color: material,
                    // eyeOffset: new global.DC.Namespace.Cesium.Cartesian3(0, 0, -10),
                    billboardImage: `/img/icon/${imgUrl}.png`
                }, true)
            } else if (type == 'polyline') {
                drawThreeTool && drawThreeTool.draw(type, overlay => {
                    if (drawFlag) return
                    if (overlay) {
                    if (type == 'polyline') {
                        addPlotOverlayData = overlay
                        overlay.customType = 'polyline'
                        that.$parent.addLineLayer(overlay)
@@ -194,14 +197,13 @@
                        setTimeout(() => {
                            that.$parent.addSaveNewDrawLine(polylinePosition, altitude)
                        }, 100)
                        global.viewer.scene.globe.depthTestAgainstTerrain = false
                        currentStatus = ''
                        that.startDrawFlag = false
                    }
                }, {
                    material: global.DC.Namespace.Cesium.Color.fromBytes(28, 160, 133, 122),
                }, true)
            }
                    global.viewer.scene.globe.depthTestAgainstTerrain = false
                    currentStatus = ''
                    that.startDrawFlag = false
                }
            }, drawConfig, true)
        },
        removeDrawArrow () {
@@ -553,6 +555,7 @@
        stopDraw () {
            if (drawThreeTool) {
                drawFlag = true
                currentStatus == 'draw' && drawThreeTool.stop()
                currentStatus == 'emit' && drawThreeTool.stop(currentEmitEl)
            }