cesium模型加载-点击-高亮
模型加载, Cesium3DTileset
文档地址
var tileset = scene. primitives. add ( new Cesium. Cesium3DTileset ( {
url : 'http://localhost:8002/tilesets/Seattle/tileset.json'
} ) ) ;
设置tileset的样式, Cesium3DTileStyle
文档地址
tileset. style = new Cesium. Cesium3DTileStyle ( {
color : {
conditions : [
[ '${Height} >= 100' , 'color("purple", 0.5)' ] ,
[ '${Height} >= 50' , 'color("red")' ] ,
[ 'true' , 'color("blue")' ]
]
} ,
show : '${Height} > 0' ,
meta : {
description : '"Building id ${id} has height ${Height}."'
}
} ) ;
业务需要点击相关数据对于模型id高亮
const filterLayer = ( id ) => {
let that = this
let ids = [ 1 , 2 , 3 ] ;
const exp = [ '${names} !== undefined && ' , 'regExp("' , ids. join ( '|' ) , '")' , '.test(${names})' ] . join (
'' ,
)
const falseExp = [
'${names} === undefined || ' ,
'!regExp("' ,
ids. join ( '|' ) ,
'")' ,
'.test(${names})' ,
] . join ( '' )
const selExp = [
'${names} !== undefined && ' ,
'${names} === ' ,
'"' + id + '"' ,
] . join ( '' )
tileset. style = new Cesium. Cesium3DTileStyle ( {
color : {
conditions : [
[ selExp, 'rgba(0,0,0,0)' ] ,
[ falseExp, 'rgba(255,255,255,0)' ] ,
] ,
} ,
} )
}