VoxelLayer Opacity Stops

This sample shows how to modify the opacity of a variable with continuous data using transferFunction on a VoxelLayer. One way to use opacityStops is to make the parts of the volume containing values you're not interested in be invisible, allowing you to see through those areas into areas containing values that are important for your analysis.

If the variable represents quantitative values of continuous measurements, such as temperature and pressure, you can visualize this variable using transferFunction. The transferFunction defines how an individual continuous variable is rendered as a volume or as sections. The stretchRange specifies the minimum and maximum value of the data to apply the colorStops and opacityStops to. The opacityStops is a collection of VoxelOpacityStop that defines an opacity and a normalized position (i.e. 0 to 1). The opacity value ranges from 0 (transparent) to 1 (opaque).

Refer to sample VoxelLayer Color Stops on how to use colorStops.

Opacity stops from transparent to opaque.

Use dark colors for code blocksCopy
const currentVariableStyle = vxlLayer.getVariableStyle(null);
const transferFunction = currentVariableStyle.transferFunction();
const opacityPosition0 = new VoxelOpacityStop({"opacity": 0, "position": 0});
const opacityPositionMid = new  VoxelOpacityStop({"opacity": 0.5, "position": 0.5});
const opacityPosition1 = new  VoxelOpacityStop({"opacity": 1, "position": 1});
transferFunction.opacityStops = [opacityPosition0, opacityPositionMid, opacityPosition1];

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.