RenderableVectorField
Inherits Renderable
Renders vectors from a given 3D volumetric dataset or a sparse point-like dataset, optionally including color mapping and custom filtering via Lua script.
If mode is set to Volume, the vector field is defined on a regular 3D grid specified by Dimensions, and occupies the spatial domain defined by MinDomain and MaxDomain.
If mode is set to Sparse, the vector field is defined by the position given by the Cartesian coordinates and direction (e.g., velocity).
The Stride parameter controls how densely vectors are sampled from the volume (a stride of 1 renders every vector).
There are several coloring methods to choose from. By default, the vectors are colored with a fixed color. Other options include using a color map to color the vectors by the direction magnitude. And lastly, color by direction, similar to a 3D model normal map as follows: +X -> Red, -X -> Cyan +Y -> Green, -Y -> Magenta +Z -> Blue, -Z -> Yellow
Members
Name |
Documentation |
Type |
Description |
Optional |
|---|---|---|---|---|
|
The mode determines the type of vector field data that is loaded. In |
|
In list { Volume, Sparse } |
No |
|
Settings related to the coloring of the vectors, such as a fixed color, color map, etc. |
|
Yes |
|
|
Decides if the object should be dimmed (i.e. faded out) when the camera is in the sunny part of an atmosphere. |
|
Value of type ‘Boolean’ |
Yes |
|
Determines whether this object will be visible or not. |
|
Value of type ‘Boolean’ |
Yes |
|
If enabled, the vector field is filtered by the provided custom Lua script. |
|
Value of type ‘Boolean’ |
Yes |
|
The width of the vector lines. |
|
Greater than: 0 |
Yes |
|
This value determines the opacity of this renderable. A value of 0 means completely transparent. |
|
In range: ( 0, 1) |
Yes |
|
A value that specifies if the renderable should be rendered in the Background, Opaque, Pre-/PostDeferredTransparency, Overlay, or Sticker rendering step. |
|
In list { Background, Opaque, PreDeferredTransparent, Overlay, PostDeferredTransparent, Sticker } |
Yes |
|
This value is the path to the Lua script that will be executed to compute the filtering. The script needs to define a function ‘filter’ that takes the current voxel position (x, y, z) given in galactic coordinates, and the velocity vector (vx, vy, vz). The function should return true/false if the voxel should be visualized or discarded, respectively. |
|
Value of type ‘File’ |
Yes |
|
Settings related to using a sparse dataset. |
|
Yes |
|
|
Controls how densely vectors are sampled from the volume. A stride of 1 renders every vector. |
|
Value of type ‘Integer’ |
Yes |
|
A single tag or a list of tags that this renderable will respond to when setting properties. |
|
Value of type ‘Table’, or Value of type ‘String’ |
Yes |
|
The type of the renderable. |
|
Value of type ‘String’ |
Yes |
|
Scales the vector field lines using an exponential scale. |
|
Greater than: 1 |
Yes |
|
Settings related to using a volumetric dataset. |
|
Yes |
Inherited members from Renderable
Name |
Documentation |
Type |
Description |
Optional |
|---|---|---|---|---|
|
Decides if the object should be dimmed (i.e. faded out) when the camera is in the sunny part of an atmosphere. |
|
Value of type ‘Boolean’ |
Yes |
|
Determines whether this object will be visible or not. |
|
Value of type ‘Boolean’ |
Yes |
|
This value determines the opacity of this renderable. A value of 0 means completely transparent. |
|
In range: ( 0, 1) |
Yes |
|
A value that specifies if the renderable should be rendered in the Background, Opaque, Pre-/PostDeferredTransparency, Overlay, or Sticker rendering step. |
|
In list { Background, Opaque, PreDeferredTransparent, Overlay, PostDeferredTransparent, Sticker } |
Yes |
|
A single tag or a list of tags that this renderable will respond to when setting properties. |
|
Value of type ‘Table’, or Value of type ‘String’ |
Yes |
|
The type of the renderable. |
|
Value of type ‘String’ |
Yes |
Table parameters for Coloring
Settings related to the coloring of the vectors, such as a fixed color, color map, etc.
Optional: Yes
Name |
Documentation |
Type |
Description |
Optional |
|---|---|---|---|---|
|
The path to the color map file used for coloring the vector field. |
|
Value of type ‘File’ |
Yes |
|
The magnitude data range used to normalize the magnitude value for color lookup. Computed from the volume data if unspecified. |
|
Value of type ‘Vector2 |
Yes |
|
Controls how the vectors are colored. “Fixed” color all vectors with the same static color. “Magnitude” color the vector field based on the min and max magnitudes defined in the volume. “Direction” colors the vector based on their direction, as follows: +X -> Red, -X -> Cyan, +Y -> Green, -Y -> Magenta, +Z -> Blue, -Z -> Yellow. |
|
In list { Fixed, Magnitude, Direction } |
No |
|
The color of the vectors, when no color map is used. |
|
Value of type ‘Color4’ |
Yes |
Table parameters for Sparse
Settings related to using a sparse dataset.
Optional: Yes
Name |
Documentation |
Type |
Description |
Optional |
|---|---|---|---|---|
|
The path to the CSV file containing the vector field data. |
|
Value of type ‘File’ |
No |
|
Specifies the column name for the vx velocity component. |
|
Value of type ‘String’ |
Yes |
|
Specifies the column name for the vy velocity component. |
|
Value of type ‘String’ |
Yes |
|
Specifies the column name for the vz velocity component. |
|
Value of type ‘String’ |
Yes |
|
Specifies the column name for the x coordinate. |
|
Value of type ‘String’ |
Yes |
|
Specifies the column name for the y coordinate. |
|
Value of type ‘String’ |
Yes |
|
Specifies the column name for the z coordinate. |
|
Value of type ‘String’ |
Yes |
Table parameters for Volume
Settings related to using a volumetric dataset.
Optional: Yes
Name |
Documentation |
Type |
Description |
Optional |
|---|---|---|---|---|
|
The dimensions of the volume data. |
|
Value of type ‘Vector3 |
No |
|
The max domain values that the volume should be mapped to. |
|
Value of type ‘Vector3 |
No |
|
The min domain values that the volume should be mapped to. |
|
Value of type ‘Vector3 |
No |
|
The path to the file containing the volume data. |
|
Value of type ‘File’ |
No |
Asset Examples
Color Mapped
This example creates a vector field where vector colors are determined by a color mapping.
The color mapping is applied to the magnitude of each vector, which is computed internally from the vector components. The color mapping range is automatically computed from the minimum and maximum magnitude values present in the dataset.
1-- Note that the color map is loaded from another asset. This is a utility asset that
2-- includes some common color maps for general usage.
3local colormaps = asset.require("util/default_colormaps")
4
5-- Load the volume data from OpenSpace servers
6local volume = asset.resource({
7 Name = "Vector Field - Example",
8 Type = "HttpSynchronization",
9 Identifier = "vectorfield_volume",
10 Version = 1
11})
12
13local Node = {
14 Identifier = "RenderableVectorField_Example_ColorMapped",
15 Renderable = {
16 Type = "RenderableVectorField",
17 Mode = "Volume",
18 VectorFieldScale = 8.0,
19 Volume = {
20 VolumeFile = volume .. "vectorfield_16x16x16_magnitude_radial.bin",
21 MinDomain = { -5000.0, -5000.0, -5000.0 },
22 MaxDomain = { 5000.0, 5000.0, 5000.0 },
23 Dimensions = { 16, 16, 16 }
24 },
25 Coloring = {
26 ColorMode = "Magnitude";
27 ColorMap = colormaps.Uniform.Viridis,
28 FixedColor = { 1.0, 0.7, 0.5, 1.0 }
29 }
30 },
31 GUI = {
32 Name = "RenderableVectorField - Color Mapped",
33 Path = "/Examples"
34 }
35}
36
37
38asset.onInitialize(function()
39 openspace.addSceneGraphNode(Node)
40end)
41
42asset.onDeinitialize(function()
43 openspace.removeSceneGraphNode(Node)
44end)
Lua Filtered
This example creates a vector field where the visibility of individual vectors is controlled using a Lua filter.
The Lua filter allows custom logic to determine whether a vector should be rendered or hidden based on its position and direction. This makes it possible to selectively visualize regions or directional subsets of the vector field, such as hiding vectors below a magnitude threshold or excluding vectors outside a specific spatial region.
The filter is provided as a separate Lua script asset. The script is executed at runtime and changes to the filter logic are applied by updating that asset.
1-- Load the volume data from OpenSpace servers
2local volume = asset.resource({
3 Name = "Vector Field - Example",
4 Type = "HttpSynchronization",
5 Identifier = "vectorfield_volume",
6 Version = 1
7})
8
9local Node = {
10 Identifier = "RenderableVectorField_Example_LuaFilter",
11 Renderable = {
12 Type = "RenderableVectorField",
13 Mode = "Volume",
14 VectorFieldScale = 8.0,
15 Volume = {
16 VolumeFile = volume .. "vectorfield_16x16x16.bin",
17 MinDomain = { -5000.0, -5000.0, -5000.0 },
18 MaxDomain = { 5000.0, 5000.0, 5000.0 },
19 Dimensions = { 16, 16, 16 }
20 },
21 FilterByLua = true,
22 Script = asset.resource("script/filter.lua")
23 },
24 GUI = {
25 Name = "RenderableVectorField - Lua Filter",
26 Path = "/Examples"
27 }
28}
29
30
31asset.onInitialize(function()
32 openspace.addSceneGraphNode(Node)
33end)
34
35asset.onDeinitialize(function()
36 openspace.removeSceneGraphNode(Node)
37end)
Basic
This example creates a basic vector field visualization from a volumetric data file.
1-- Load the volume data from OpenSpace servers
2local volume = asset.resource({
3 Name = "Vector Field - Example",
4 Type = "HttpSynchronization",
5 Identifier = "vectorfield_volume",
6 Version = 1
7})
8
9local Node = {
10 Identifier = "RenderableVectorField_Example",
11 Renderable = {
12 Type = "RenderableVectorField",
13 Mode = "Volume",
14 VectorFieldScale = 8.0,
15 Volume = {
16 VolumeFile = volume .. "vectorfield_16x16x16.bin",
17 MinDomain = { -5000.0, -5000.0, -5000.0 },
18 MaxDomain = { 5000.0, 5000.0, 5000.0 },
19 Dimensions = { 16, 16, 16 }
20 }
21 },
22 GUI = {
23 Name = "RenderableVectorField - Basic",
24 Path = "/Examples"
25 }
26}
27
28
29asset.onInitialize(function()
30 openspace.addSceneGraphNode(Node)
31end)
32
33asset.onDeinitialize(function()
34 openspace.removeSceneGraphNode(Node)
35end)
Sparse
This example creates a vector field visualization from a sparse point-cloud datase, provided in a CSV data file with one row per vector.
Optionally, one can specify the column names for the position and direction. Otherwise, x, y, z, and vx, vy, vz are assumed as the position and direction columns, respectively.
1local Node = {
2 Identifier = "RenderableVectorField_Example_Sparse",
3 Renderable = {
4 Type = "RenderableVectorField",
5 Mode = "Sparse",
6 VectorFieldScale = 15.0,
7 Sparse = {
8 FilePath = asset.resource("../renderablepointcloud/data/dummydata.csv")
9 }
10 },
11 GUI = {
12 Name = "RenderableVectorField - Sparse",
13 Path = "/Examples"
14 }
15}
16
17
18asset.onInitialize(function()
19 openspace.addSceneGraphNode(Node)
20end)
21
22asset.onDeinitialize(function()
23 openspace.removeSceneGraphNode(Node)
24end)