Chart3DMeshContext
public sealed class Chart3DMeshContextContext handed to 3D marks when the Chart3DMeshBuilder asks
them to contribute geometry. Wraps the cached axes, scales, theme and
write targets so marks never touch the Chart3DMeshContext.Chart directly. The theme's
ChartTheme.Appearance3D block, also available as Chart3DMeshContext.Appearance, supplies materials,
color maps and surface resolution. A custom IChart3DMark adds its geometry with
Chart3DMeshContext.AddTriangles(ReadOnlySpan<Vector3>, ReadOnlySpan<Vector3>, ReadOnlySpan<Color>, ReadOnlySpan<int>) and Chart3DMeshContext.AddInstance(Mesh, Material, Matrix4x4, Color); colors it resolves are the mark's neutral colors, and
the host applies hover and selection highlight on top without rebuilding.
Fields
Section titled “Fields”
public Chart ChartReturns
ChartGuru.Chart
public ChartTheme ThemeReturns
ChartGuru.ChartTheme
XScale
Section titled “XScale”public Scale XScaleReturns
ChartGuru.Scale
YScale
Section titled “YScale”public Scale YScaleReturns
ChartGuru.Scale
ZScale
Section titled “ZScale”public Scale ZScaleReturns
ChartGuru.Scale
PlotBounds
Section titled “PlotBounds”public Bounds PlotBoundsReturns
UnityEngine.Bounds
Methods
Section titled “Methods”
Project(float, float, float)
Section titled “Project(float, float, float)”public Vector3 Project(float x, float y, float z)Map a raw (x,y,z) value triple to plot-space 3D position.
Parameters
| Name | Type |
|---|---|
x | System.Single |
y | System.Single |
z | System.Single |
Returns
UnityEngine.Vector3
Project(Vector3)
Section titled “Project(Vector3)”public Vector3 Project(Vector3 v)Maps the data values in v to a plot-space position, as Chart3DMeshContext.Project(float, float, float) does.
Parameters
| Name | Type |
|---|---|
v | UnityEngine.Vector3 |
Returns
UnityEngine.Vector3
Project(DataPoint3D)
Section titled “Project(DataPoint3D)”public Vector3 Project(DataPoint3D p)Maps the X, Y and Z of p to a plot-space position through the chart’s scales; its range ends are ignored.
Parameters
| Name | Type |
|---|---|
p | ChartGuru.DataPoint3D |
Returns
UnityEngine.Vector3
Project(IChart3DMark)
Section titled “Project(IChart3DMark)”public Vector3 Project(IChart3DMark mark)Maps the data point of mark to a plot-space position without the mark’s offset, which marks
add themselves; a null mark maps the data origin.
Parameters
| Name | Type |
|---|---|
mark | ChartGuru.IChart3DMark |
Returns
UnityEngine.Vector3
ResolveDataPoint(IChart3DMark)
Section titled “ResolveDataPoint(IChart3DMark)”public DataPoint3D ResolveDataPoint(IChart3DMark mark)Returns the data point a mark builds from, its IChart3DDataMark.DataPoint3D, or a point at the
data origin for a null mark.
Parameters
| Name | Type |
|---|---|
mark | ChartGuru.IChart3DMark |
Returns
ChartGuru.DataPoint3D
ResolveMarkColor(IChartMark, int, int)
Section titled “ResolveMarkColor(IChartMark, int, int)”public Color ResolveMarkColor(IChartMark mark, int fallbackIndex = -1, int dataPointIndex = -1)The neutral color of mark: its explicit color, gradient midpoint, style scale or series
color with its opacity, without hover and selection effects, which the host applies on top. The data point
index is accepted for compatibility with 2D color resolution and does not change the neutral color.
Parameters
| Name | Type |
|---|---|
mark | ChartGuru.IChartMark |
fallbackIndex | System.Int32 |
dataPointIndex | System.Int32 |
Returns
UnityEngine.Color
AddTriangles(ReadOnlySpan, ReadOnlySpan, ReadOnlySpan, ReadOnlySpan)
Section titled “AddTriangles(ReadOnlySpan, ReadOnlySpan, ReadOnlySpan, ReadOnlySpan)”public void AddTriangles(ReadOnlySpan<Vector3> positions, ReadOnlySpan<Vector3> normals, ReadOnlySpan<Color> colors, ReadOnlySpan<int> triangles)Adds triangles to the mark being built, in plot space: positions come from
Chart3DMeshContext.Project(Vector3), normals and colors have one entry per
position, and every three triangles index into the positions. Colors are neutral, such as
Chart3DMeshContext.ResolveMarkColor(IChartMark, int, int) returns; blended colors draw in the transparent pass. Picking and highlight map
the triangles to the mark. Arrays convert to the spans implicitly.
Parameters
| Name | Type |
|---|---|
positions | System.ReadOnlySpan{UnityEngine.Vector3} |
normals | System.ReadOnlySpan{UnityEngine.Vector3} |
colors | System.ReadOnlySpan{UnityEngine.Color} |
triangles | System.ReadOnlySpan{System.Int32} |
Examples
A custom mark that draws a small triangle at its point, in its own color:
public override void BuildMesh(Chart3DMeshContext ctx)
{
Vector3 p = ctx.Project(DataPoint3D);
Color color = ctx.ResolveMarkColor(this);
ctx.AddTriangles(
new[] { p, p + Vector3.right * 0.1f, p + Vector3.up * 0.1f },
new[] { Vector3.back, Vector3.back, Vector3.back },
new[] { color, color, color },
new[] { 0, 2, 1 });
}
### AddInstance(Mesh, Material, Matrix4x4, Color)
public void AddInstance(Mesh mesh, Material material, Matrix4x4 transform, Color color)Adds an instance of mesh drawn with material to the mark being built.
transform places the mesh in plot space and color is the neutral
instance color, which the material’s instanced color property receives. Instances of the same mesh and
material draw in one batch.
Parameters
| Name | Type |
|---|---|
mesh | UnityEngine.Mesh |
material | UnityEngine.Material |
transform | UnityEngine.Matrix4x4 |
color | UnityEngine.Color |
Constructors
Section titled “Constructors”
Chart3DMeshContext()
Section titled “Chart3DMeshContext()”public Chart3DMeshContext()Properties
Section titled “Properties”
Appearance
Section titled “Appearance”public ChartTheme3D Appearance { get; }The 3D look of Chart3DMeshContext.Theme, or of the default theme when none is set.
Returns
ChartGuru.ChartTheme3D