Cesium 创建 BoxGometry 使用不同的外观
整体流程:
// step1:
const geometry = Cesium.BoxGeometry.fromDimensions({
// Cesium.PerInstanceColorAppearance.VERTEX_FORMAT,
vertexFormat: Cesium.VertexFormat.POSITION_AND_NORMAL,
dimensions: new Cesium.Cartesian3(4.0, 3.0, 5.0),
})
// step2:
...
// step3:
...
// step4:
const primitive = new Cesium.Primitive({
appearance,
geometryInstances: instance,
})
1、PerInstanceColorAppearance
// step2:
const instance = new Cesium.GeometryInstance({
geometry,
modelMatrix,
attributes: {
color: Cesium.ColorGeometryInstanceAttribute.fromColor(
Cesium.Color.RED.withAlpha(0.5)
),
},
})
// step3:
const appearance = new Cesium.PerInstanceColorAppearance({
closed: true,
});
2、MaterialAppearance
// step2:
const instance = new Cesium.GeometryInstance({
geometry,
modelMatrix,
})
// step3:
const appearance = new Cesium.MaterialAppearance({
materialSupport: Cesium.MaterialAppearance.MaterialSupport.BASIC,
material : new Cesium.Material({
fabric : {
type : 'Color',
uniforms : {
color : new Cesium.Color(1.0, 0.0, 0.0, 1.0)
}
}
}),
faceForward : true
})
3、EllipsoidSurfaceAppearance
// step2:
const instance = new Cesium.GeometryInstance({
geometry,
modelMatrix,
})
// step3:
const appearance = new Cesium.EllipsoidSurfaceAppearance({
material : new Cesium.Material({
fabric : {
type : 'Color',
uniforms : {
color : new Cesium.Color(1.0, 0.0, 0.0, 1.0)
}
}
}),
faceForward : true
})