in modules/core/src/components/log-viewer/core-3d-viewer.js [242:349]
_getLayers(opts) {
const {
frame,
streamsMetadata,
objectStates,
customLayers,
getTransformMatrix,
styleParser
} = opts;
if (!frame) {
return [];
}
const {streams, lookAheads = {}} = frame;
const streamFilter = normalizeStreamFilter(opts.streamFilter);
const featuresAndFutures = new Set(
Object.keys(streams)
.concat(Object.keys(lookAheads))
.filter(streamFilter)
);
let layerList = [this._getCarLayer(opts)];
layerList = layerList.concat(
Array.from(featuresAndFutures)
.map(streamName => {
// Check lookAheads first because it will contain the selected futures
// while streams would contain the full futures array
const stream = lookAheads[streamName] || streams[streamName];
const coordinateProps = resolveCoordinateTransform(
frame,
streamName,
streamsMetadata[streamName],
getTransformMatrix
);
const stylesheet = styleParser.getStylesheet(streamName);
// Support both features and lookAheads, respectively
const primitives = stream.features || stream;
if (primitives && primitives.length) {
return new XVIZLayer({
id: `xviz-${streamName}`,
...coordinateProps,
pickable: true,
data: primitives,
style: stylesheet,
objectStates,
vehicleRelativeTransform: frame.vehicleRelativeTransform,
// Hack: draw extruded polygons last to defeat depth test when rendering translucent objects
// This is not used by deck.gl, only used in this function to sort the layers
zIndex: Z_INDEX[primitives[0].type] || 0,
// Selection props (app defined, not used by deck.gl)
streamName
});
}
return null;
})
.filter(Boolean)
);
layerList = layerList.concat(
customLayers.map(layer => {
// Clone layer props
const {props} = layer;
const additionalProps = {
zIndex: 'zIndex' in props ? props.zIndex : Z_INDEX.customDefault
};
if (props.streamName) {
// Use log data
const stream = streams[props.streamName];
Object.assign(
additionalProps,
resolveCoordinateTransform(
frame,
props.streamName,
streamsMetadata[props.streamName],
getTransformMatrix
),
{
data: stream && stream.features
}
);
} else if (props.coordinate) {
// Apply log-specific coordinate props
Object.assign(
additionalProps,
resolveCoordinateTransform(frame, null, props, getTransformMatrix)
);
} else {
return layer;
}
return layer.clone(additionalProps);
})
);
// Sort layers by zIndex to avoid depth test issues
return layerList.sort(
(layer1, layer2) => (layer1.props.zIndex || 0) - (layer2.props.zIndex || 0)
);
}