Entity 的材质
普通物体的材质
import { nextTick, onMounted, ref } from 'vue'
import * as Cesium from 'cesium'
const viewer = ref< any> ( null ) onMounted ( ( ) => { ... } ) let material = Cesium. Color. YELLOW . withAlpha ( 0.5 ) ` Cesium.ColorMaterialProperty ` 是 ` Cesium.MaterialProperty ` 的子类
let material = new Cesium. ColorMaterialProperty ( new Cesium. Color ( 1.0 , 1.0 , 1.0 , 1.0 ) ) ` 棋盘纹理 `
let material = new Cesium. CheckerboardMaterialProperty ( { evenColor : Cesium. Color. RED , oddColor : Cesium. Color. YELLOW , repeat : new Cesium. Cartesian2 ( 4 , 4 )
} ) ` 条纹纹理 `
let material = new Cesium. StripeMaterialProperty ( { evenColor : Cesium. Color. WHITE , oddColor : Cesium. Color. BLACK , repeat : 8
} ) ` 网格纹理 `
let material = new Cesium. GridMaterialProperty ( { color : Cesium. Color. YELLOW , cellAlpha : 0.5 , lineCount : new Cesium. Cartesian2 ( 4 , 4 ) , lineThickness : new Cesium. Cartesian2 ( 1.0 , 1.0 )
} ) const rectangleEntity = new Cesium. Entity ( { id : 'rectangleEntity' , name : '矩形' , rectangle : { coordinates : Cesium. Rectangle. fromDegrees ( 100 , 20 , 110 , 30 ) , outline : true , outlineColor : Cesium. Color. BLACK , height : 1 , material : material}
} )
const setView = ( ) => { const position = Cesium. Cartesian3. fromDegrees ( 113.3191 , 23.109 , 2000 ) viewer. value. camera. setView ( { destination : position, orientation : { heading : Cesium. Math. toRadians ( 0 ) , pitch : Cesium. Math. toRadians ( - 90 ) , roll : Cesium. Math. toRadians ( 90 ) } } )
} nextTick ( ( ) => { setView ( ) viewer. value. entities. add ( rectangleEntity)
} )
线的材质
onMounted ( ( ) => { ... } ) let material = Cesium. Color. RED . withAlpha ( 0.5 ) ` 设置虚线材质 `
let material = new Cesium. PolylineDashMaterialProperty ( { dashLength : 60 , color : Cesium. Color. RED
} ) ` 设置箭头材质 `
let material = new Cesium. PolylineArrowMaterialProperty ( Cesium. Color. RED ) ` 设置发光飞线效果 `
let material = new Cesium. PolylineGlowMaterialProperty ( { glowPower : 0.8 , taperPower : 0.7 , color : Cesium. Color. RED
} ) const polyline = new Cesium. Entity ( { id : 'polyline' , polyline : { ` 因为,线的坐标是由 <多个坐标对> 组成,所以,这里使用 ` fromDegreesArray ( ) ` 方法批量转换坐标 ` positions : Cesium. Cartesian3. fromDegreesArray ( [ 112.3 , 39.9 , 114.4 , 100 ] ) , width : 10 , material : material, clampToGround : true , height : 1000 , }
} )
const setView = ( ) => { const position = Cesium. Cartesian3. fromDegrees ( 113.3191 , 23.109 , 2000 ) viewer. value. camera. setView ( { destination : position, orientation : { heading : Cesium. Math. toRadians ( 0 ) , pitch : Cesium. Math. toRadians ( - 90 ) , roll : Cesium. Math. toRadians ( 90 ) } } )
} nextTick ( ( ) => { setView ( ) viewer. value. entities. add ( polyline)
} )