你的小棍棍 单体化gltf方式加载吧,当然3dtiles也是可以的,下面的代码是gltf方式的,高亮,与属性获取,弹窗自备:
picFeature(viewer) {
var fragmentShaderSource =
"uniform sampler2D colorTexture;\n" +
"varying vec2 v_textureCoordinates;\n" +
"uniform vec4 highlight;\n" +
"void main() {\n" +
" vec4 color = texture2D(colorTexture, v_textureCoordinates);\n" +
" if (czm_selected()) {\n" +
" vec3 highlighted = highlight.a * highlight.rgb + (1.0 - highlight.a) * color.rgb;\n" +
" gl_FragColor = vec4(highlighted, 1.0);\n" +
" } else { \n" +
" gl_FragColor = color;\n" +
" }\n" +
"}\n";
var stage = viewer.scene.postProcessStages.add(
new Cesium.PostProcessStage({
fragmentShader: fragmentShaderSource,
uniforms: {
highlight: function() {
return new Cesium.Color(1.0, 0.0, 0.0, 0.5);
}
}
})
);
stage.selected = [];
viewer.screenSpaceEventHandler.setInputAction(movement => {
var pickedFeature = viewer.scene.drillPick(
movement.position,
10,
10,
10
);
if (!Cesium.defined(pickedFeature)) {
stage.selected = [];
return;
}
if (pickedFeature.length == 0) {
stage.selected = [];
return;
}
let pickedObject = pickedFeature[0];
//f12看下你选中对象的相关属性吧
if (Cesium.defined(pickedObject) && pickedObject.id != null) {
let properties = pickedObject.id.properties.sign.getValue();
this.tname = properties.name;
this.tid = properties.id;
this.type = properties.type;
}
if (Cesium.defined(pickedObject)) {
stage.selected = [pickedObject.primitive];
} else {
stage.selected = [];
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
}