1.划定区域 (指路另一篇博客 画矩形区域并显示长宽)
2.把区域看成一个坐标轴,eg.左上角为原点,分别有X轴、Y轴
/**添加纹理 */
const addTexture = (westSouthEastNorth: any, xNum: any, yNum: any) => {
const entity = viewer.value.entities.getById('添加纹理')
if (entity) {
entity.rectangle.material.lineCount = new Cesium.CallbackProperty(() => {
return new Cesium.Cartesian2(xNum, yNum)
}, false)
return
}
positions.value = westSouthEastNorth
viewer.value.entities.add({
id: '添加纹理',
rectangle: {
coordinates: Cesium.Rectangle.fromDegrees(westSouthEastNorth[0], westSouthEastNorth[5], westSouthEastNorth[4], westSouthEastNorth[1],),
material: new Cesium.GridMaterialProperty({
color: Cesium.Color.GREY,
cellAlpha: 0.1,
lineCount: new Cesium.CallbackProperty(() => {
return new Cesium.Cartesian2(xNum, yNum)
}, false),
}),
outline: true,
outlineColor: Cesium.Color.GREY,
height: 0,
}
})
}
3.监听X,Y
watch([() => xNum.value, () => yNum.value], () => {
emits("addTexture", props.positions, Number(xNum.value), Number(yNum.value));
})
欢迎补充,一起进步。