DashboardItemDistance
Inherits DashboardItem
Members
Name |
Documentation |
Type |
Description |
Optional |
---|---|---|---|---|
|
If a scene graph node is selected as type, this value specifies the name of the node that is to be used as the destination for computing the distance. |
|
Value of type ‘String’ |
Yes |
|
The type of position that is used as the destination to calculate the distance. The default value for this is ‘Focus’. |
|
In list { Node, Node Surface, Focus, Camera } |
Yes |
|
This value is the name of the font that is used. It can either refer to an internal name registered previously, or it can refer to a path that is used. |
|
Value of type ‘String’ |
Yes |
|
This value determines the size of the font that is used to render the distance. |
|
Value of type ‘Double’ |
Yes |
|
The format string that is used for formatting the distance string. This format receives four parameters: The name of the source, the name of the destination the value of the distance and the unit of the distance. |
|
Value of type ‘String’ |
Yes |
|
If the simplification is disabled, this distance unit is used as a destination to convert the meters into. |
|
In list { nanometer, micrometer, millimeter, centimeter, decimeter, meter, km, AU, lighthour, lightday, lightmonth, lightyear, parsec, kiloparsec, megaparsec, gigaparsec, gigalightyear, thou, inch, foot, yard, chain, furlong, mile, league } |
Yes |
|
If this value is enabled, the distance is displayed in nuanced units, such as km, AU, light years, parsecs, etc. If this value is disabled, the unit can be explicitly requested. |
|
Value of type ‘Boolean’ |
Yes |
|
If a scene graph node is selected as type, this value specifies the name of the node that is to be used as the source for computing the distance. |
|
Value of type ‘String’ |
Yes |
|
The type of position that is used as the source to calculate the distance. The default value is ‘Camera’. |
|
In list { Node, Node Surface, Focus, Camera } |
Yes |
Asset Examples
1local earth = asset.require("scene/solarsystem/planets/earth/earth")
2
3local Dashboard = {
4 Identifier = "ScreenSpaceDistanceToEarth",
5 Name = "Distance to Earth",
6 Type = "ScreenSpaceDashboard",
7 FaceCamera = false,
8 Scale = 3.0,
9 UseRadiusAzimuthElevation = true,
10 RadiusAzimuthElevation = { 2.0, -0.2, -0.2 },
11 Items = {
12 {
13 Type = "DashboardItemDistance",
14 Identifier = "EarthToCameraDistance",
15 GuiName = "Distance to Earth",
16 FontSize = 40,
17 SourceType = "Camera",
18 DestinationType = "Node",
19 DestinationNodeName = earth.Earth.Identifier,
20 -- Specify to use a specific unit, by disabling the automatic simplification of
21 -- unit and instead use light-years
22 Simplification = false,
23 RequestedUnit = "lightyear",
24 -- If we don't want to use the default format of the text, we can specify our own
25 -- format. Here we've decided to not include the name of the source object (index 0),
26 -- which would be "Camera". We just include the name of the destination node (Earth,
27 -- index 1), the distance (index 2) as a floating point number (f), and then the
28 -- name for the unit (index 3)
29 FormatString = "Distance to {1}: {2:f} {3}"
30 }
31 }
32}
33
34
35asset.onInitialize(function()
36 openspace.addScreenSpaceRenderable(Dashboard)
37 openspace.setPropertyValueSingle(
38 "ScreenSpace.ScreenSpaceDistanceToEarth.Size",
39 {0.0, 0.0, 640.0, 320.0}
40 )
41end)
42
43asset.onDeinitialize(function()
44 openspace.addScreenSpaceRenderable(Dashboard)
45end)
46
47asset.export(Dashboard)
48
49
50
51asset.meta = {
52 Name = "ScreenSpace - Distance to Earth",
53 Description = [[
54 This asset provides a screenspace dashboard item that shows the distance from the
55 camera to Earth, in light-years. This can be placed on a dome surface to show the
56 current distance to the audience.
57 ]],
58 Author = "OpenSpace Team",
59 URL = "http://openspaceproject.com",
60 License = "MIT license"
61}