This article is relevant for layers constructed with the TLsp3DTileLayerBuilder only. See How to customize the styling of a LIDAR point cloud if you work with layers constructed with the TLspLIDARLayerBuilder.

You can customize the styling of Lightspeed layers constructed with the TLsp3DTileLayerBuilder by specifying a TLspPointCloudStyle on the builder.

The TLspPointCloudStyle uses the ILcdExpression API for efficient, data-dependent customization of the size, color, opacity, and visibility of points. See the Introduction to data-driven styling for more information about the ILcdExpression API.

In this example, we also make use of the TLspEyeDomeLightingSettings API in the point cloud style, to improve depth perception. Eye-dome lighting helps accentuate the shapes of objects by shading their outlines.

//In this example we use an OGC 3D Tiles point cloud model, but you can do the same for
// other point cloud formats which use the TLsp3DTileLayerBuilder for visualization
TLcdOGC3DTilesModelDecoder decoder = new TLcdOGC3DTilesModelDecoder();
String sourceName = "https://sampleservices.luciad.com/ogc/3dtiles/marseille-lidar/tileset.json";
ILcdModel model = decoder.decode(sourceName);

// Extract the data type for the point cloud data.
// See the class javadoc of TLcdOGC3DTilesModelDecoder for more info
TLcdDataType domainObjectType = ((ILcdDataModelDescriptor) model.getModelDescriptor())
    .getModelTypes().iterator().next();
TLcdDataProperty classificationProperty = domainObjectType.getProperty("Classification");

// Create an expression to filter points based on the "Classification" attribute
ILcdExpression<Boolean> visibilityExpression = eq(attribute(Byte.class, classificationProperty),
                                                  constant((byte) 3));

// Create eye-dome lighting settings that will apply a red shade to the view to enhance depth perception
TLspEyeDomeLightingSettings eyeDomeLighting = TLspEyeDomeLightingSettings.newBuilder()
                                                                         .color(Color.RED)
                                                                         .build();

// Create a point cloud style that
// - uses a fixed point size of 8 pixels
// - uses the visibilityExpression and eyeDomeLighting created earlier
TLspPointCloudStyle pointCloudStyle = TLspPointCloudStyle
    .newBuilder()
    .scalingMode(TLspPointCloudStyle.ScalingMode.PIXEL_SIZE)
    .scale(constant(8f))
    .visibility(visibilityExpression)
    .eyeDomeLighting(eyeDomeLighting)
    .build();

// Specify the style on the builder
TLspLayer layer = TLsp3DTileLayerBuilder.newBuilder()
                                        .model(model)
                                        .bodyStyles(TLspPaintState.REGULAR, pointCloudStyle)
                                        .build();