RenderableSwitch

Inherits Renderable

A RenderableSwitch can be used to render one of two renderables depending on the distance between the camera and the object’s position.

The two renderables are specified separately: RenderableNear and RenderableFar. These can be any renderable types.

The DistanceThreshold property determines which renderable will be shown. If the camera is closer to the object than the threshold, RenderableNear is used, otherwise, RenderableFar is rendered.

Members

Name

Documentation

Type

Description

Optional

DistanceThreshold

Threshold in meters for when the switch happens between the two renderables.

Double

Greater than: 0

Yes

RenderableFar

The renderable to show when the camera is further away than the threshold.

Table

Renderable

Yes

RenderableNear

The renderable to show when the camera is closer to the object than the threshold.

Table

Renderable

Yes

Inherited members from Renderable

Name

Documentation

Type

Description

Optional

DimInAtmosphere

Decides if the object should be dimmed (i.e. faded out) when the camera is in the sunny part of an atmosphere.

Boolean

Value of type ‘Boolean’

Yes

Enabled

Determines whether this object will be visible or not.

Boolean

Value of type ‘Boolean’

Yes

Opacity

This value determines the opacity of this renderable. A value of 0 means completely transparent.

Double

In range: ( 0,1 )

Yes

RenderBinMode

A value that specifies if the renderable should be rendered in the Background, Opaque, Pre-/PostDeferredTransparency, Overlay, or Sticker rendering step.

String

In list { Background, Opaque, PreDeferredTransparent, Overlay, PostDeferredTransparent, Sticker }

Yes

Tag

A single tag or a list of tags that this renderable will respond to when setting properties.

Table, or String

Value of type ‘Table’, or Value of type ‘String’

Yes

Type

The type of the renderable.

String

Value of type ‘String’

Yes

Asset Examples

Basic

This example shows how to create a renderable that switches between two textured planes in 3D space, where one texture is loaded from a local file on disk and the other is loaded from the internet though a web URL. The switch is done based on the distance from the camera to the renderable.

 1local Node = {
 2  Identifier = "RenderableSwitch_Example",
 3  Renderable = {
 4    Type = "RenderableSwitch",
 5    RenderableNear = {
 6      Type = "RenderablePlaneImageLocal",
 7      Size = 300000000000,
 8      Texture = openspace.absPath("${DATA}/test.jpg")
 9    },
10    RenderableFar = {
11      Type = "RenderablePlaneImageOnline",
12      Size = 300000000000,
13      URL = "http://data.openspaceproject.com/examples/renderableplaneimageonline.jpg"
14    },
15    DistanceThreshold = 2000000000000
16  },
17  GUI = {
18    Name = "RenderableSwitch - Basic",
19    Path = "/Examples"
20  }
21}
22
23asset.onInitialize(function()
24  openspace.addSceneGraphNode(Node)
25end)
26
27asset.onDeinitialize(function()
28  openspace.removeSceneGraphNode(Node)
29end)
Only Far Renderable

This example uses only shows a textured plane when the camera is further than the specified distance from the object and shows nothing if the camera is closer than that distance

 1local Node = {
 2  Identifier = "RenderableSwitch_Example-Far",
 3  Renderable = {
 4    Type = "RenderableSwitch",
 5    RenderableFar = {
 6      Type = "RenderablePlaneImageLocal",
 7      Size = 300000000000,
 8      Texture = openspace.absPath("${DATA}/test.jpg")
 9    },
10    DistanceThreshold = 3000000000000
11  },
12  GUI = {
13    Name = "RenderableSwitch - Far",
14    Path = "/Examples"
15  }
16}
17
18asset.onInitialize(function()
19  openspace.addSceneGraphNode(Node)
20end)
21
22asset.onDeinitialize(function()
23  openspace.removeSceneGraphNode(Node)
24end)
Only Near Renderable

This example uses only shows a textured plane when the camera is within the specified distance from the object and shows nothing if the camera is further away.

 1local Node = {
 2  Identifier = "RenderableSwitch_Example-Near",
 3  Renderable = {
 4    Type = "RenderableSwitch",
 5    RenderableNear = {
 6      Type = "RenderablePlaneImageLocal",
 7      Size = 300000000000,
 8      Texture = openspace.absPath("${DATA}/test.jpg")
 9    },
10    DistanceThreshold = 2000000000000
11  },
12  GUI = {
13    Name = "RenderableSwitch - Near",
14    Path = "/Examples"
15  }
16}
17
18asset.onInitialize(function()
19  openspace.addSceneGraphNode(Node)
20end)
21
22asset.onDeinitialize(function()
23  openspace.removeSceneGraphNode(Node)
24end)