LuaScale
Inherits Scale
Members
Name |
Documentation |
Type |
Description |
Optional |
---|---|---|---|---|
|
This value is the path to the Lua script that will be executed to compute the scaling factor for this transformation. The script needs to define a function ‘scale’ that takes the current simulation time in seconds past the J2000 epoch as the first argument, the simulation time in seconds past the J2000 epoch of the last frame as the second argument, and the current wall time as milliseconds past the J2000 epoch the third argument and computes the three scaling factors returned as a table. |
|
Value of type ‘File’ |
No |
Inherited members from Scale
Name |
Documentation |
Type |
Description |
Optional |
---|---|---|---|---|
|
The type of the scaling that is described in this element. The available types of scaling depend on the configuration of the application and can be written to disk on application startup into the FactoryDocumentation |
|
Must name a valid Scale type |
No |
Asset Examples
Basic
This asset creates a SceneGraphNode that only displays coordinate axes. The sizes of coordinate axes are determined by executing a Lua file that returns the scaling parameters to be used as a table.
-- The `scale` function takes exactly three arguments and returns the three scaling
-- values (one for each axis) as a single table.
-- The three parameters are all provided as the number of seconds past the J2000 epoch
-- (2000-01-01 12:00:00), which can be both fractional numbers as well as negative numbers
-- for dates earlier than the epoch.
-- 1. `simulationTime` is the value of the in-game clock for the current frame
-- 2. `prevSimulationTime` is the value of the in-game clock for the previous frame
-- 3. `wallTime` is the value of the computer clock as seconds past the epoch
function scale(simulationTime, prevSimulationTime, wallTime)
-- Make the scaling along the x-axis oscillate between -3 and 3 once per second
return { 3 * math.sin(simulationTime), 1, 1 }
end
1local Node = {
2 Identifier = "LuaScale_Example",
3 Transform = {
4 Scale = {
5 Type = "LuaScale",
6 Script = asset.resource("example.lua")
7 }
8 },
9 Renderable = {
10 Type = "RenderableCartesianAxes"
11 },
12 GUI = {
13 Name = "LuaScale - Basic",
14 Path = "/Examples"
15 }
16}
17
18asset.onInitialize(function()
19 openspace.addSceneGraphNode(Node)
20end)
21
22asset.onDeinitialize(function()
23 openspace.removeSceneGraphNode(Node)
24end)