Fabric is a JSON schema used in CesiumJS to describe materials for objects like polygons, polylines, ellipsoids, and sensors. Materials define the visual appearance of these objects, ranging from simple colors to complex procedural patterns or combined textures.
To apply a material, assign it to the object's material property. You can use the shorthand Cesium.Material.fromType(type) or provide a full Fabric JSON object via new Cesium.Material({ fabric: { ... } }).
Each material has uniforms—input parameters that can be set during creation or modified later to update the appearance dynamically.
// Using shorthand for a built-in material
polygon.material = Cesium.Material.fromType("Color");
// Using the full Fabric JSON schema
polygon.material = new Cesium.Material({
fabric: {
type: "Color",
},
});
// Modifying a uniform after creation
polygon.material.uniforms.color = Cesium.Color.WHITE;