RenderableDistanceLabel
Inherits Renderable
This Renderable creates a label that shows the distance between two nodes, based on an existing RenderableNodeLine. The label will be placed halfway between the two scene graph nodes that the line connects.
The unit in which the distance is displayed can be customized, as well as the precision of the number.
Members
Name |
Documentation |
Type |
Description |
Optional |
|---|---|---|---|---|
|
The identifier of a scene graph node with a RenderableNodeLine that this label should track. The label text will be updating based on the distance from the node line’s start and end. |
|
Value of type ‘String’ |
No |
|
Property to define a custom unit descriptor to use to describe the distance value. Defaults to the selected unit’s SI descriptor if not specified. |
|
Value of type ‘String’ |
Yes |
|
The unit in which the distance value should be displayed. Defaults to ‘km’ if not specified. |
|
In list { Nanometer, Micrometer, Millimeter, Centimeter, Decimeter, Meter, Kilometer, AU, Lighthour, Lightday, Lightmonth, Lightyear, Parsec, Kiloparsec, Megaparsec, Gigaparsec, Gigalightyear, Thou, Inch, Foot, Yard, Chain, Furlong, Mile, League, Nautical Mile } |
Yes |
|
The precision in which to to show the distance number, i.e. the number of digits after the decimal point. |
|
Greater or equal to: 0 |
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 |
Asset Examples
Custom Unit Descriptor
In addition to setting the unit, it is also possible to specify a custom unit descriptor, i.e. a text that will de displayed for the unit instead of the default one. Here, we write out “Astronomical Units” instead of using the default descriptor for AU.
1local nodelineAsset = asset.require("examples/renderable/renderablenodeline/nodeline")
2
3local Node = {
4 Identifier = "RenderableDistanceLabel_Example_CustomDescriptor",
5 Renderable = {
6 Type = "RenderableDistanceLabel",
7 NodeLine = nodelineAsset.NodeLine.Identifier,
8 DistanceUnit = "AU",
9 Precision = 2,
10 CustomUnitDescriptor = "Astronomical Units"
11 },
12 GUI = {
13 Name = "RenderableDistanceLabel - Custom Unit Descriptor",
14 Path = "/Examples"
15 }
16}
17
18asset.onInitialize(function()
19 openspace.addSceneGraphNode(Node)
20end)
21
22asset.onDeinitialize(function()
23 openspace.removeSceneGraphNode(Node)
24end)
Basic
This example adds a distance label between two nodes in the scene, based on an existing
RenderableNodeLine. Note that the identifier of the
RenderableNodeLine is accessed by importing another example asset, which also adds
the node line to the scene.
1local nodelineAsset = asset.require("examples/renderable/renderablenodeline/nodeline")
2
3local Node = {
4 Identifier = "RenderableDistanceLabel_Example",
5 Renderable = {
6 Type = "RenderableDistanceLabel",
7 NodeLine = nodelineAsset.NodeLine.Identifier
8 },
9 GUI = {
10 Name = "RenderableDistanceLabel - Basic",
11 Path = "/Examples"
12 }
13}
14
15asset.onInitialize(function()
16 openspace.addSceneGraphNode(Node)
17end)
18
19asset.onDeinitialize(function()
20 openspace.removeSceneGraphNode(Node)
21end)
Set Unit
Per default, the distance is displayed in meters. This example shows how to specify a specific unit, and how to set the precision of dislayed number.
1local nodelineAsset = asset.require("examples/renderable/renderablenodeline/nodeline")
2
3local Node = {
4 Identifier = "RenderableDistanceLabel_Example_Unit",
5 Renderable = {
6 Type = "RenderableDistanceLabel",
7 NodeLine = nodelineAsset.NodeLine.Identifier,
8 DistanceUnit = "AU",
9 Precision = 2
10 },
11 GUI = {
12 Name = "RenderableDistanceLabel - Unit",
13 Path = "/Examples"
14 }
15}
16
17asset.onInitialize(function()
18 openspace.addSceneGraphNode(Node)
19end)
20
21asset.onDeinitialize(function()
22 openspace.removeSceneGraphNode(Node)
23end)