线贴图 速度bug修改
This commit is contained in:
@ -202,7 +202,7 @@ class Tools {
|
||||
return length.toFixed(fractionDigits)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
computeDistance2(positions = [], fractionDigits = 2, ground = true) {
|
||||
if (positions.length < 2) {
|
||||
return 0
|
||||
@ -586,6 +586,17 @@ class Tools {
|
||||
|
||||
getMaterial(color = '#2ab0c2', type = 0, entity = null, newParam = {}) {
|
||||
let material = ''
|
||||
let arr = {
|
||||
'7': 10,
|
||||
'8': 3,
|
||||
'9': 4,
|
||||
'10': 4,
|
||||
'11': 4,
|
||||
'12': 2
|
||||
}
|
||||
if (entity) {
|
||||
arr[type + ''] ? (entity.polyline.width = entity.polyline.oriWidth + arr[type + '']) : (entity.polyline.width = entity.polyline.oriWidth)
|
||||
}
|
||||
|
||||
switch (Number(type)) {
|
||||
|
||||
@ -616,22 +627,48 @@ class Tools {
|
||||
})
|
||||
break
|
||||
case 5: //普通流动虚线
|
||||
material = new Cesium.FlowDashedLineFlowMaterialProperty({
|
||||
color: color,
|
||||
uType: 0,
|
||||
speed: newParam.rotate ? newParam.speed : 0 - newParam.speed,
|
||||
// dashSize: newParam.dashSize,
|
||||
space: newParam.space
|
||||
})
|
||||
break
|
||||
// material = new Cesium.FlowDashedLineFlowMaterialProperty({
|
||||
// color: color,
|
||||
// uType: 0,
|
||||
// speed: newParam.rotate ? newParam.speed : 0 - newParam.speed,
|
||||
// // dashSize: newParam.dashSize,
|
||||
// space: newParam.space,
|
||||
// scale: 1.0
|
||||
// })
|
||||
// break
|
||||
case 6: //流动虚线2
|
||||
let that = this
|
||||
|
||||
material = new Cesium.FlowDashedLineFlowMaterialProperty({
|
||||
color: color,
|
||||
uType: 1,
|
||||
uType: type == 5 ? 0 : 1,
|
||||
speed: newParam.rotate ? newParam.speed : 0 - newParam.speed,
|
||||
// dashSize: newParam.dashSize,
|
||||
space: newParam.space
|
||||
space: newParam.space,
|
||||
scale: new Cesium.CallbackProperty(function () {
|
||||
var oriPositions = entity.polyline.positions.getValue();
|
||||
|
||||
if (!Cesium.defined(oriPositions)) {
|
||||
return 1.0;
|
||||
}
|
||||
var distance = 0;
|
||||
for (var i = 0; i < oriPositions.length - 1; ++i) {
|
||||
distance += Cesium.Cartesian3.distance(oriPositions[i], oriPositions[i + 1]);
|
||||
}
|
||||
//屏幕坐标
|
||||
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)
|
||||
var cartesian1 = that.sdk.viewer.scene.pickPosition(point1)
|
||||
var cartesian2 = that.sdk.viewer.scene.pickPosition(point2)
|
||||
|
||||
var distance2 = Cesium.Cartesian3.distance(cartesian1, cartesian2);
|
||||
|
||||
let repeatX = distance2 * 2 / distance
|
||||
|
||||
return repeatX;
|
||||
})
|
||||
})
|
||||
|
||||
break
|
||||
case 7: //流动箭头1
|
||||
case 8: //流动箭头2
|
||||
@ -645,20 +682,8 @@ class Tools {
|
||||
space: newParam.space,
|
||||
speed: newParam.speed
|
||||
}
|
||||
let arr = {
|
||||
'7': 10,
|
||||
'8': 3,
|
||||
'9': 4,
|
||||
'10': 4,
|
||||
'11': 4,
|
||||
'12': 2
|
||||
}
|
||||
|
||||
|
||||
param.speed = newParam.rotate ? param.speed : 0 - param.speed
|
||||
entity.polyline.width = entity.polyline.oriWidth + arr[type + '']
|
||||
|
||||
|
||||
|
||||
this.getFlowTexture(this, param, entity)
|
||||
|
||||
@ -669,6 +694,7 @@ class Tools {
|
||||
}
|
||||
return material
|
||||
}
|
||||
|
||||
getFlowTexture(that, options, entity) {
|
||||
|
||||
const canvasEle = document.createElement('canvas');
|
||||
@ -698,15 +724,13 @@ class Tools {
|
||||
// }, false)
|
||||
// entity.polyline.material.oriRepeat = that.getSceenLine(entity, options, canvasEle)
|
||||
// entity.polyline.material.oriSpeed = undefined
|
||||
let beforeSpeed = 0, repeat = 0
|
||||
entity.polyline.material = new Cesium.LineTextureMaterialProperty(
|
||||
{
|
||||
color: options.color,
|
||||
// image: options.image,
|
||||
image: canvasEle,
|
||||
speed: options.speed,
|
||||
// repeat: repeat
|
||||
repeat: new Cesium.CallbackProperty(function () {
|
||||
// function getRepeat() {
|
||||
var positionProperty = entity.polyline.positions;
|
||||
var positions = positionProperty.getValue(that.sdk.viewer.clock.currentTime);
|
||||
|
||||
@ -734,24 +758,30 @@ class Tools {
|
||||
|
||||
// 使用 getPixelSize 方法获取包围球在屏幕上的像素大小
|
||||
var groundResolution = that.sdk.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight)
|
||||
// repeatX *= groundResolution / cameraHeight / ((myImg.width / myImg.height * 5) + 1);
|
||||
repeatX *= groundResolution / cameraHeight / (options.space * (canvasEle.width / canvasEle.height * 5) + 1);
|
||||
let speed
|
||||
if (entity.polyline.material.oriRepeat) {
|
||||
speed = repeatX / entity.polyline.material.oriRepeat
|
||||
let result
|
||||
if (groundResolution > 700) {
|
||||
repeatX *= groundResolution / cameraHeight / (options.space * (canvasEle.width / canvasEle.height * 5) + 1);
|
||||
// if (entity.polyline.material.oriRepeat) {
|
||||
let speed = repeatX / entity.polyline.oriRepeat
|
||||
entity.polyline.oriSpeed = speed
|
||||
entity.polyline.oriRepeatX = repeatX
|
||||
// } else {
|
||||
// entity.polyline.material.oriRepeat = repeatX
|
||||
// }
|
||||
beforeSpeed = speed
|
||||
repeat = repeatX
|
||||
result = new Cesium.Cartesian2(repeatX, speed || 1.0)
|
||||
} else {
|
||||
entity.polyline.material.oriRepeat = repeatX
|
||||
result = new Cesium.Cartesian2(repeat || entity.polyline.oriRepeatX, beforeSpeed || entity.polyline.oriSpeed)
|
||||
}
|
||||
// if (repeatX < 3) {
|
||||
// repeatX = 3
|
||||
// }
|
||||
return new Cesium.Cartesian2(repeatX, speed || 1.0);
|
||||
|
||||
return result;
|
||||
// return repeatX;
|
||||
})
|
||||
}
|
||||
)
|
||||
// entity.polyline.material.oriSpeed = options.speed
|
||||
entity.polyline.material.oriRepeat = that.getSceenLine(entity, options, canvasEle)
|
||||
let oriRepeat = that.getSceenLine(entity, options, canvasEle)
|
||||
oriRepeat && (entity.polyline.oriRepeat = oriRepeat)
|
||||
}
|
||||
}
|
||||
/**获取当前满屏横线速度 */
|
||||
@ -778,8 +808,13 @@ class Tools {
|
||||
// 使用 getPixelSize 方法获取包围球在屏幕上的像素大小
|
||||
var groundResolution = this.sdk.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight)
|
||||
// repeatX *= groundResolution / cameraHeight / ((myImg.width / myImg.height * 5) + 1);
|
||||
repeatX *= groundResolution / cameraHeight / (options.space * (canvasEle.width / canvasEle.height * 5) + 1);
|
||||
return repeatX * 2
|
||||
if (groundResolution > 700) {
|
||||
repeatX *= groundResolution / cameraHeight / (options.space * (canvasEle.width / canvasEle.height * 5) + 1);
|
||||
} else {
|
||||
repeatX = undefined;
|
||||
}
|
||||
|
||||
return repeatX
|
||||
}
|
||||
|
||||
/*创建直箭头图片*/
|
||||
|
Reference in New Issue
Block a user