修改线流动样式在二维中显示bug
This commit is contained in:
@ -11,7 +11,7 @@ import LabelObject from '../LabelObject'
|
|||||||
import MouseEvent from '../../../Event/index'
|
import MouseEvent from '../../../Event/index'
|
||||||
import MouseTip from '../../../MouseTip'
|
import MouseTip from '../../../MouseTip'
|
||||||
import Controller from '../../../Controller/index'
|
import Controller from '../../../Controller/index'
|
||||||
import { syncData } from '../../../Global/MultiViewportMode'
|
import { syncData, get3DView } from '../../../Global/MultiViewportMode'
|
||||||
import { legp } from '../../Element/datalist'
|
import { legp } from '../../Element/datalist'
|
||||||
import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/SplitScreen'
|
import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/SplitScreen'
|
||||||
import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Global/global'
|
import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Global/global'
|
||||||
@ -1306,6 +1306,7 @@ class PolylineObject extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static create(that) {
|
static create(that) {
|
||||||
|
|
||||||
let ground
|
let ground
|
||||||
if (that.heightMode == 2) {
|
if (that.heightMode == 2) {
|
||||||
ground = true
|
ground = true
|
||||||
@ -1422,9 +1423,17 @@ class PolylineObject extends Base {
|
|||||||
var groundResolution = that.sdk.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight)
|
var groundResolution = that.sdk.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight)
|
||||||
repeatX *= groundResolution / cameraHeight / (param.space * (canvasEle.width / canvasEle.height * 5) + 1);
|
repeatX *= groundResolution / cameraHeight / (param.space * (canvasEle.width / canvasEle.height * 5) + 1);
|
||||||
// if (entity.polyline.material.oriRepeat) {
|
// if (entity.polyline.material.oriRepeat) {
|
||||||
|
|
||||||
|
if (that.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE3D) {
|
||||||
let speed = repeatX / entity.polyline.oriRepeat
|
let speed = repeatX / entity.polyline.oriRepeat
|
||||||
entity.polyline.oriSpeed = speed
|
entity.polyline.oriSpeed = speed
|
||||||
entity.polyline.oriRepeatX = repeatX
|
entity.polyline.oriRepeatX = repeatX
|
||||||
|
} else {
|
||||||
|
let sdk3d = get3DView()
|
||||||
|
let sdk3dEntity = sdk3d.viewer.entities.getById(that.options.id)
|
||||||
|
entity.polyline.oriSpeed = sdk3dEntity.polyline.oriSpeed
|
||||||
|
entity.polyline.oriRepeatX = sdk3dEntity.polyline.oriRepeatX
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1436,8 +1445,21 @@ class PolylineObject extends Base {
|
|||||||
getSceenLine(entity, options, canvasEle) {
|
getSceenLine(entity, options, canvasEle) {
|
||||||
let point1 = new Cesium.Cartesian2(0, this.sdk.viewer.canvas.clientHeight)
|
let point1 = new Cesium.Cartesian2(0, this.sdk.viewer.canvas.clientHeight)
|
||||||
let point2 = new Cesium.Cartesian2(this.sdk.viewer.canvas.clientWidth / 2, this.sdk.viewer.canvas.clientHeight)
|
let point2 = new Cesium.Cartesian2(this.sdk.viewer.canvas.clientWidth / 2, this.sdk.viewer.canvas.clientHeight)
|
||||||
var cartesian1 = this.sdk.viewer.scene.pickPosition(point1)
|
// var cartesian1 = this.sdk.viewer.scene.pickPosition(point1)
|
||||||
var cartesian2 = this.sdk.viewer.scene.pickPosition(point2)
|
// var cartesian2 = this.sdk.viewer.scene.pickPosition(point2)
|
||||||
|
|
||||||
|
let ray = this.sdk.viewer.camera.getPickRay(point1);
|
||||||
|
let cartesian1 = this.sdk.viewer.scene.globe.pick(ray, this.sdk.viewer.scene);
|
||||||
|
|
||||||
|
let ray2 = this.sdk.viewer.camera.getPickRay(point2);
|
||||||
|
let cartesian2 = this.sdk.viewer.scene.globe.pick(ray2, this.sdk.viewer.scene);
|
||||||
|
// if (!cartesian1 || !cartesian2) {
|
||||||
|
// let ray = this.sdk.viewer.camera.getPickRay(point1);
|
||||||
|
// cartesian1 = this.sdk.viewer.scene.globe.pick(ray, this.sdk.viewer.scene);
|
||||||
|
|
||||||
|
// let ray2 = this.sdk.viewer.camera.getPickRay(point2);
|
||||||
|
// cartesian2 = this.sdk.viewer.scene.globe.pick(ray2, this.sdk.viewer.scene);
|
||||||
|
// }
|
||||||
|
|
||||||
var distance = Cesium.Cartesian3.distance(cartesian1, cartesian2);
|
var distance = Cesium.Cartesian3.distance(cartesian1, cartesian2);
|
||||||
|
|
||||||
@ -1449,6 +1471,7 @@ class PolylineObject extends Base {
|
|||||||
500000 // 半径(距离)
|
500000 // 半径(距离)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// 获取绘图缓冲区的宽度和高度(通常是屏幕的分辨率)
|
// 获取绘图缓冲区的宽度和高度(通常是屏幕的分辨率)
|
||||||
var drawingBufferWidth = this.sdk.viewer.canvas.clientWidth;
|
var drawingBufferWidth = this.sdk.viewer.canvas.clientWidth;
|
||||||
var drawingBufferHeight = this.sdk.viewer.canvas.clientHeight;
|
var drawingBufferHeight = this.sdk.viewer.canvas.clientHeight;
|
||||||
@ -1462,7 +1485,14 @@ class PolylineObject extends Base {
|
|||||||
repeatX = undefined;
|
repeatX = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE3D) {
|
||||||
return repeatX
|
return repeatX
|
||||||
|
} else {
|
||||||
|
let sdk3d = get3DView()
|
||||||
|
let sdk3dEntity = sdk3d.viewer.entities.getById(this.options.id)
|
||||||
|
return sdk3dEntity.polyline.oriRepeatX
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 编辑框
|
* 编辑框
|
||||||
|
@ -11,6 +11,7 @@ import { open as projConvertOpen, close as projConvertClose } from './projConver
|
|||||||
import { open as projectionConvertOpen, close as projectionConvertClose } from './projectionConvert'
|
import { open as projectionConvertOpen, close as projectionConvertClose } from './projectionConvert'
|
||||||
import { setActiveViewer, closeRotateAround, closeViewFollow } from '../Global/global'
|
import { setActiveViewer, closeRotateAround, closeViewFollow } from '../Global/global'
|
||||||
import FlowPictureMaterialProperty from '../Obj/Materail/FlowPictureMaterialProperty'
|
import FlowPictureMaterialProperty from '../Obj/Materail/FlowPictureMaterialProperty'
|
||||||
|
import { syncData, get3DView } from '../Global/MultiViewportMode'
|
||||||
|
|
||||||
class Tools {
|
class Tools {
|
||||||
/**
|
/**
|
||||||
@ -646,25 +647,52 @@ class Tools {
|
|||||||
// dashSize: newParam.dashSize,
|
// dashSize: newParam.dashSize,
|
||||||
space: newParam.space,
|
space: newParam.space,
|
||||||
scale: new Cesium.CallbackProperty(function () {
|
scale: new Cesium.CallbackProperty(function () {
|
||||||
var oriPositions = entity.polyline.positions.getValue();
|
|
||||||
|
if (that.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE3D) {
|
||||||
|
let oriPositions = entity.polyline.positions.getValue();
|
||||||
|
|
||||||
if (!Cesium.defined(oriPositions)) {
|
if (!Cesium.defined(oriPositions)) {
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
var distance = 0;
|
let distance = 0;
|
||||||
for (var i = 0; i < oriPositions.length - 1; ++i) {
|
for (let i = 0; i < oriPositions.length - 1; ++i) {
|
||||||
distance += Cesium.Cartesian3.distance(oriPositions[i], oriPositions[i + 1]);
|
distance += Cesium.Cartesian3.distance(oriPositions[i], oriPositions[i + 1]);
|
||||||
}
|
}
|
||||||
//屏幕坐标
|
//屏幕坐标
|
||||||
let point1 = new Cesium.Cartesian2(0, that.sdk.viewer.canvas.clientHeight)
|
let point1 = new Cesium.Cartesian2(0, that.sdk.viewer.canvas.clientHeight)
|
||||||
let point2 = new Cesium.Cartesian2(that.sdk.viewer.canvas.clientWidth / 2, that.sdk.viewer.canvas.clientHeight)
|
let point2 = new Cesium.Cartesian2(that.sdk.viewer.canvas.clientWidth / 2, that.sdk.viewer.canvas.clientHeight)
|
||||||
var cartesian1 = that.sdk.viewer.scene.pickPosition(point1)
|
let cartesian1 = that.sdk.viewer.scene.pickPosition(point1)
|
||||||
var cartesian2 = that.sdk.viewer.scene.pickPosition(point2)
|
let cartesian2 = that.sdk.viewer.scene.pickPosition(point2)
|
||||||
if (cartesian1 && cartesian2) {
|
if (cartesian1 && cartesian2) {
|
||||||
var distance2 = Cesium.Cartesian3.distance(cartesian1, cartesian2);
|
let distance2 = Cesium.Cartesian3.distance(cartesian1, cartesian2);
|
||||||
repeatX = distance2 * 2 / distance
|
repeatX = distance2 * 2 / distance
|
||||||
}
|
}
|
||||||
return repeatX;
|
return repeatX;
|
||||||
|
} else {
|
||||||
|
let sdk3d = get3DView()
|
||||||
|
let sdk3dEntity = sdk3d.viewer.entities.getById(that.options.id)
|
||||||
|
let oriPositions = sdk3dEntity.polyline.positions.getValue();
|
||||||
|
|
||||||
|
if (!Cesium.defined(oriPositions)) {
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
let distance = 0;
|
||||||
|
for (let i = 0; i < oriPositions.length - 1; ++i) {
|
||||||
|
distance += Cesium.Cartesian3.distance(oriPositions[i], oriPositions[i + 1]);
|
||||||
|
}
|
||||||
|
//屏幕坐标
|
||||||
|
let point1 = new Cesium.Cartesian2(0, sdk3d.viewer.canvas.clientHeight)
|
||||||
|
let point2 = new Cesium.Cartesian2(sdk3d.viewer.canvas.clientWidth / 2, sdk3d.viewer.canvas.clientHeight)
|
||||||
|
let cartesian1 = sdk3d.viewer.scene.pickPosition(point1)
|
||||||
|
let cartesian2 = sdk3d.viewer.scene.pickPosition(point2)
|
||||||
|
if (cartesian1 && cartesian2) {
|
||||||
|
let distance2 = Cesium.Cartesian3.distance(cartesian1, cartesian2);
|
||||||
|
repeatX = distance2 * 2 / distance
|
||||||
|
}
|
||||||
|
return repeatX;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -730,33 +758,36 @@ class Tools {
|
|||||||
image: canvasEle,
|
image: canvasEle,
|
||||||
speed: options.speed,
|
speed: options.speed,
|
||||||
repeat: new Cesium.CallbackProperty(function () {
|
repeat: new Cesium.CallbackProperty(function () {
|
||||||
var positionProperty = entity.polyline.positions;
|
|
||||||
var positions = positionProperty.getValue(that.sdk.viewer.clock.currentTime);
|
if (that.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE3D) {
|
||||||
|
let positionProperty = entity.polyline.positions;
|
||||||
|
let positions = positionProperty.getValue(that.sdk.viewer.clock.currentTime);
|
||||||
|
|
||||||
if (!Cesium.defined(positions)) {
|
if (!Cesium.defined(positions)) {
|
||||||
return new Cesium.Cartesian2(1.0, 1.0);
|
return new Cesium.Cartesian2(1.0, 1.0);
|
||||||
// return 1.0;
|
// return 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var distance = 0;
|
let distance = 0;
|
||||||
for (var i = 0; i < positions.length - 1; ++i) {
|
for (let i = 0; i < positions.length - 1; ++i) {
|
||||||
|
// if (that.sdk.viewer.scene.mode===Cesium.SceneMode.SCENE2D){}
|
||||||
distance += Cesium.Cartesian3.distance(positions[i], positions[i + 1]);
|
distance += Cesium.Cartesian3.distance(positions[i], positions[i + 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var repeatX = distance / entity.polyline.width.getValue();
|
let repeatX = distance / entity.polyline.width.getValue();
|
||||||
// 根据地图缩放程度调整repeatX
|
// 根据地图缩放程度调整repeatX
|
||||||
var cameraHeight = that.sdk.viewer.camera.positionCartographic.height;
|
let cameraHeight = that.sdk.viewer.camera.positionCartographic.height;
|
||||||
var boundingSphere = new Cesium.BoundingSphere(
|
let boundingSphere = new Cesium.BoundingSphere(
|
||||||
new Cesium.Cartesian3(-1000000, 0, 0), // 中心点坐标
|
new Cesium.Cartesian3(-1000000, 0, 0), // 中心点坐标
|
||||||
500000 // 半径(距离)
|
500000 // 半径(距离)
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取绘图缓冲区的宽度和高度(通常是屏幕的分辨率)
|
// 获取绘图缓冲区的宽度和高度(通常是屏幕的分辨率)
|
||||||
var drawingBufferWidth = that.sdk.viewer.canvas.clientWidth;
|
let drawingBufferWidth = that.sdk.viewer.canvas.clientWidth;
|
||||||
var drawingBufferHeight = that.sdk.viewer.canvas.clientHeight;
|
let drawingBufferHeight = that.sdk.viewer.canvas.clientHeight;
|
||||||
|
|
||||||
// 使用 getPixelSize 方法获取包围球在屏幕上的像素大小
|
// 使用 getPixelSize 方法获取包围球在屏幕上的像素大小
|
||||||
var groundResolution = that.sdk.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight)
|
let groundResolution = that.sdk.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight)
|
||||||
let result
|
let result
|
||||||
if (groundResolution > 700) {
|
if (groundResolution > 700) {
|
||||||
repeatX *= groundResolution / cameraHeight / (options.space * (canvasEle.width / canvasEle.height * 5) + 1);
|
repeatX *= groundResolution / cameraHeight / (options.space * (canvasEle.width / canvasEle.height * 5) + 1);
|
||||||
@ -775,6 +806,61 @@ class Tools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
let sdk3d = get3DView()
|
||||||
|
let sdk3dEntity = sdk3d.viewer.entities.getById(that.options.id)
|
||||||
|
let positionProperty = sdk3dEntity.polyline.positions;
|
||||||
|
let positions = positionProperty.getValue(sdk3d.viewer.clock.currentTime);
|
||||||
|
|
||||||
|
if (!Cesium.defined(positions)) {
|
||||||
|
return new Cesium.Cartesian2(1.0, 1.0);
|
||||||
|
// return 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
let distance = 0;
|
||||||
|
for (let i = 0; i < positions.length - 1; ++i) {
|
||||||
|
// if (that.sdk.viewer.scene.mode===Cesium.SceneMode.SCENE2D){}
|
||||||
|
distance += Cesium.Cartesian3.distance(positions[i], positions[i + 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
let repeatX = distance / sdk3dEntity.polyline.width.getValue();
|
||||||
|
// 根据地图缩放程度调整repeatX
|
||||||
|
let cameraHeight = sdk3d.viewer.camera.positionCartographic.height;
|
||||||
|
let boundingSphere = new Cesium.BoundingSphere(
|
||||||
|
new Cesium.Cartesian3(-1000000, 0, 0), // 中心点坐标
|
||||||
|
500000 // 半径(距离)
|
||||||
|
);
|
||||||
|
|
||||||
|
// 获取绘图缓冲区的宽度和高度(通常是屏幕的分辨率)
|
||||||
|
let drawingBufferWidth = sdk3d.viewer.canvas.clientWidth;
|
||||||
|
let drawingBufferHeight = sdk3d.viewer.canvas.clientHeight;
|
||||||
|
|
||||||
|
// 使用 getPixelSize 方法获取包围球在屏幕上的像素大小
|
||||||
|
let groundResolution = sdk3d.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight)
|
||||||
|
let result
|
||||||
|
if (groundResolution > 700) {
|
||||||
|
repeatX *= groundResolution / cameraHeight / (options.space * (canvasEle.width / canvasEle.height * 5) + 1);
|
||||||
|
// if (entity.polyline.material.oriRepeat) {
|
||||||
|
let speed = repeatX / sdk3dEntity.polyline.oriRepeat
|
||||||
|
sdk3dEntity.polyline.oriSpeed = speed
|
||||||
|
sdk3dEntity.polyline.oriRepeatX = repeatX
|
||||||
|
// } else {
|
||||||
|
// entity.polyline.material.oriRepeat = repeatX
|
||||||
|
// }
|
||||||
|
beforeSpeed = speed
|
||||||
|
repeat = repeatX
|
||||||
|
result = new Cesium.Cartesian2(repeatX, speed || 1.0)
|
||||||
|
} else {
|
||||||
|
result = new Cesium.Cartesian2(repeat || sdk3dEntity.polyline.oriRepeatX, beforeSpeed || sdk3dEntity.polyline.oriSpeed)
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// return repeatX;
|
// return repeatX;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -787,8 +873,13 @@ class Tools {
|
|||||||
getSceenLine(entity, options, canvasEle) {
|
getSceenLine(entity, options, canvasEle) {
|
||||||
let point1 = new Cesium.Cartesian2(0, this.sdk.viewer.canvas.clientHeight)
|
let point1 = new Cesium.Cartesian2(0, this.sdk.viewer.canvas.clientHeight)
|
||||||
let point2 = new Cesium.Cartesian2(this.sdk.viewer.canvas.clientWidth / 2, this.sdk.viewer.canvas.clientHeight)
|
let point2 = new Cesium.Cartesian2(this.sdk.viewer.canvas.clientWidth / 2, this.sdk.viewer.canvas.clientHeight)
|
||||||
var cartesian1 = this.sdk.viewer.scene.pickPosition(point1)
|
// var cartesian1 = this.sdk.viewer.scene.pickPosition(point1)
|
||||||
var cartesian2 = this.sdk.viewer.scene.pickPosition(point2)
|
// var cartesian2 = this.sdk.viewer.scene.pickPosition(point2)
|
||||||
|
let ray = this.sdk.viewer.camera.getPickRay(point1);
|
||||||
|
let cartesian1 = this.sdk.viewer.scene.globe.pick(ray, this.sdk.viewer.scene);
|
||||||
|
|
||||||
|
let ray2 = this.sdk.viewer.camera.getPickRay(point2);
|
||||||
|
let cartesian2 = this.sdk.viewer.scene.globe.pick(ray2, this.sdk.viewer.scene);
|
||||||
|
|
||||||
var distance = Cesium.Cartesian3.distance(cartesian1, cartesian2);
|
var distance = Cesium.Cartesian3.distance(cartesian1, cartesian2);
|
||||||
|
|
||||||
@ -813,7 +904,14 @@ class Tools {
|
|||||||
repeatX = undefined;
|
repeatX = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE3D) {
|
||||||
return repeatX
|
return repeatX
|
||||||
|
} else {
|
||||||
|
let sdk3d = get3DView()
|
||||||
|
let sdk3dEntity = sdk3d.viewer.entities.getById(this.options.id)
|
||||||
|
return sdk3dEntity.polyline.oriRepeatX
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*创建直箭头图片*/
|
/*创建直箭头图片*/
|
||||||
|
Reference in New Issue
Block a user