线贴图速度优化

This commit is contained in:
2025-07-15 10:41:58 +08:00
parent f24a95ab32
commit 6e2efbe544

View File

@ -651,10 +651,13 @@ class Tools {
'11': 4,
'12': 2
}
param.speed = newParam.rotate ? param.speed : 0 - param.speed
console.log(entity.polyline.oriWidth, arr[type + ''], type, 'oriWidth')
entity.polyline.width = entity.polyline.oriWidth + arr[type + '']
this.getFlowTexture(this, param, entity)
break
@ -691,8 +694,8 @@ class Tools {
// let repeat = getRepeat()
// }, false)
entity.polyline.material.oriRepeat = undefined
entity.polyline.material.oriSpeed = undefined
// entity.polyline.material.oriRepeat = that.getSceenLine(entity, options, canvasEle)
// entity.polyline.material.oriSpeed = undefined
entity.polyline.material = new Cesium.LineTextureMaterialProperty(
{
color: options.color,
@ -745,9 +748,37 @@ class Tools {
})
}
)
entity.polyline.material.oriSpeed = options.speed
// entity.polyline.material.oriSpeed = options.speed
entity.polyline.material.oriRepeat = that.getSceenLine(entity, options, canvasEle)
}
}
/**获取当前满屏横线速度 */
getSceenLine(entity, options, canvasEle) {
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)
var cartesian1 = this.sdk.viewer.scene.pickPosition(point1)
var cartesian2 = this.sdk.viewer.scene.pickPosition(point2)
var distance = Cesium.Cartesian3.distance(cartesian1, cartesian2);
var repeatX = distance / entity.polyline.width.getValue();
// 根据地图缩放程度调整repeatX
var cameraHeight = this.sdk.viewer.camera.positionCartographic.height;
var boundingSphere = new Cesium.BoundingSphere(
new Cesium.Cartesian3(-1000000, 0, 0), // 中心点坐标
500000 // 半径(距离)
);
// 获取绘图缓冲区的宽度和高度(通常是屏幕的分辨率)
var drawingBufferWidth = this.sdk.viewer.canvas.clientWidth;
var drawingBufferHeight = this.sdk.viewer.canvas.clientHeight;
// 使用 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
}
/*创建直箭头图片*/
create_arrow1_picture(color) {