mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-03 01:09:34 -05:00
Merge branch 'master' into feature/space-mouse
* Resolve conflicts
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
local icons = asset.syncedResource({
|
||||
Name = "Icons",
|
||||
Type = "HttpSynchronization",
|
||||
Identifier = "icons",
|
||||
Version = 1
|
||||
})
|
||||
|
||||
asset.onInitialize(function()
|
||||
openspace.addScreenSpaceRenderable({
|
||||
Identifier = "target-marker",
|
||||
Name = "Target Marker",
|
||||
Type = "ScreenSpaceImageLocal",
|
||||
TexturePath = icons .. '/target.png'
|
||||
})
|
||||
end)
|
||||
|
||||
asset.onDeinitialize(function()
|
||||
openspace.removeScreenSpaceRenderable('target-marker');
|
||||
end)
|
||||
+134
-134
@@ -1,179 +1,179 @@
|
||||
local tableLength = function(table)
|
||||
local count = 0
|
||||
for _ in pairs(table) do count = count + 1 end
|
||||
return count
|
||||
local count = 0
|
||||
for _ in pairs(table) do count = count + 1 end
|
||||
return count
|
||||
end
|
||||
|
||||
|
||||
local registerSpiceKernels = function (spiceAsset, kernels)
|
||||
spiceAsset.onInitialize(function ()
|
||||
for i, kernel in ipairs(kernels) do
|
||||
openspace.spice.loadKernel(kernel)
|
||||
end
|
||||
end)
|
||||
spiceAsset.onDeinitialize(function ()
|
||||
for i = #kernels, 1, -1 do
|
||||
local kernel = kernels[i]
|
||||
openspace.spice.unloadKernel(kernel)
|
||||
end
|
||||
end)
|
||||
spiceAsset.onInitialize(function ()
|
||||
for i, kernel in ipairs(kernels) do
|
||||
openspace.spice.loadKernel(kernel)
|
||||
end
|
||||
end)
|
||||
spiceAsset.onDeinitialize(function ()
|
||||
for i = #kernels, 1, -1 do
|
||||
local kernel = kernels[i]
|
||||
openspace.spice.unloadKernel(kernel)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local registerSceneGraphNodes = function (sceneAsset, nodes, override)
|
||||
override = override or false
|
||||
if not override then
|
||||
if tableLength(nodes) == 0 then
|
||||
openspace.printWarning(sceneAsset.filePath .. ": Register function was called with an empty node list. Pass 'true' as third argument to silence this warning.")
|
||||
return
|
||||
end
|
||||
override = override or false
|
||||
if not override then
|
||||
if tableLength(nodes) == 0 then
|
||||
openspace.printWarning(sceneAsset.filePath .. ": Register function was called with an empty node list. Pass 'true' as third argument to silence this warning.")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
sceneAsset.onInitialize(function ()
|
||||
for i, node in ipairs(nodes) do
|
||||
openspace.addSceneGraphNode(node)
|
||||
end
|
||||
end)
|
||||
sceneAsset.onDeinitialize(function ()
|
||||
for i = #nodes, 1, -1 do
|
||||
node = nodes[i]
|
||||
openspace.removeSceneGraphNode(node.Identifier)
|
||||
end
|
||||
end)
|
||||
sceneAsset.onInitialize(function ()
|
||||
for i, node in ipairs(nodes) do
|
||||
openspace.addSceneGraphNode(node)
|
||||
end
|
||||
end)
|
||||
sceneAsset.onDeinitialize(function ()
|
||||
for i = #nodes, 1, -1 do
|
||||
node = nodes[i]
|
||||
openspace.removeSceneGraphNode(node.Identifier)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
local registerScreenSpaceRenderables = function (sceneAsset, renderables, override)
|
||||
override = override or false
|
||||
if not override then
|
||||
if tableLength(renderables) == 0 then
|
||||
openspace.printWarning(sceneAsset.filePath .. ": Register function was called with an empty node list. Pass 'true' as third argument to silence this warning.")
|
||||
return
|
||||
end
|
||||
override = override or false
|
||||
if not override then
|
||||
if tableLength(renderables) == 0 then
|
||||
openspace.printWarning(sceneAsset.filePath .. ": Register function was called with an empty node list. Pass 'true' as third argument to silence this warning.")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
sceneAsset.onInitialize(function ()
|
||||
for i, node in ipairs(renderables) do
|
||||
openspace.addScreenSpaceRenderable(node)
|
||||
end
|
||||
end)
|
||||
sceneAsset.onDeinitialize(function ()
|
||||
for i = #renderables, 1, -1 do
|
||||
renderable = renderables[i]
|
||||
openspace.removeScreenSpaceRenderable(renderable.Identifier)
|
||||
end
|
||||
end)
|
||||
sceneAsset.onInitialize(function ()
|
||||
for i, node in ipairs(renderables) do
|
||||
openspace.addScreenSpaceRenderable(node)
|
||||
end
|
||||
end)
|
||||
sceneAsset.onDeinitialize(function ()
|
||||
for i = #renderables, 1, -1 do
|
||||
renderable = renderables[i]
|
||||
openspace.removeScreenSpaceRenderable(renderable.Identifier)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local registerDashboardItems = function (dashboardAsset, items)
|
||||
dashboardAsset.onInitialize(
|
||||
function ()
|
||||
for i, item in ipairs(items) do
|
||||
openspace.dashboard.addDashboardItem(item)
|
||||
end
|
||||
end
|
||||
)
|
||||
dashboardAsset.onDeinitialize(function ()
|
||||
for i = #items, 1, -1 do
|
||||
local item = items[i]
|
||||
openspace.dashboard.removeDashboardItem(item.Identifier)
|
||||
end
|
||||
end)
|
||||
dashboardAsset.onInitialize(
|
||||
function ()
|
||||
for i, item in ipairs(items) do
|
||||
openspace.dashboard.addDashboardItem(item)
|
||||
end
|
||||
end
|
||||
)
|
||||
dashboardAsset.onDeinitialize(function ()
|
||||
for i = #items, 1, -1 do
|
||||
local item = items[i]
|
||||
openspace.dashboard.removeDashboardItem(item.Identifier)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local registerSceneGraphNodesAndExport = function (sceneAsset, nodes, override)
|
||||
override = override or false
|
||||
if not override then
|
||||
if tableLength(nodes) == 0 then
|
||||
openspace.printWarning(sceneAsset.filePath .. ": Register function was called with an empty node list. Pass 'true' as third argument to silence this warning.")
|
||||
return
|
||||
end
|
||||
override = override or false
|
||||
if not override then
|
||||
if tableLength(nodes) == 0 then
|
||||
openspace.printWarning(sceneAsset.filePath .. ": Register function was called with an empty node list. Pass 'true' as third argument to silence this warning.")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
for i, node in ipairs(nodes) do
|
||||
if not node.Identifier then
|
||||
openspace.printError("Could not load asset as Identifier was missing")
|
||||
end
|
||||
end
|
||||
|
||||
sceneAsset.onInitialize(function ()
|
||||
for i, node in ipairs(nodes) do
|
||||
if not node.Identifier then
|
||||
openspace.printError("Could not load asset as Identifier was missing")
|
||||
end
|
||||
openspace.addSceneGraphNode(node)
|
||||
end
|
||||
|
||||
sceneAsset.onInitialize(function ()
|
||||
for i, node in ipairs(nodes) do
|
||||
openspace.addSceneGraphNode(node)
|
||||
end
|
||||
end)
|
||||
sceneAsset.onDeinitialize(function ()
|
||||
for i = #nodes, 1, -1 do
|
||||
local node = nodes[i]
|
||||
openspace.removeSceneGraphNode(node.Identifier)
|
||||
end
|
||||
end)
|
||||
|
||||
for i, node in ipairs(nodes) do
|
||||
sceneAsset.export(node.Identifier, node)
|
||||
end)
|
||||
sceneAsset.onDeinitialize(function ()
|
||||
for i = #nodes, 1, -1 do
|
||||
local node = nodes[i]
|
||||
openspace.removeSceneGraphNode(node.Identifier)
|
||||
end
|
||||
end)
|
||||
|
||||
for i, node in ipairs(nodes) do
|
||||
sceneAsset.export(node.Identifier, node)
|
||||
end
|
||||
end
|
||||
|
||||
local requireAll = function (sceneAsset, directory)
|
||||
function string.ends(String,End)
|
||||
return End=='' or string.sub(String,-string.len(End))==End
|
||||
function string.ends(String,End)
|
||||
return End=='' or string.sub(String,-string.len(End))==End
|
||||
end
|
||||
|
||||
local result = {}
|
||||
|
||||
local files = openspace.walkDirectoryFiles(sceneAsset.localResource('') .. directory, true)
|
||||
for _, file in pairs(files) do
|
||||
if file:ends('.asset') then
|
||||
openspace.printDebug("Requiring: " .. file:sub(file:find(directory), -7))
|
||||
local exports = sceneAsset.require(file:sub(1, -7))
|
||||
table.insert(result, exports)
|
||||
end
|
||||
end
|
||||
|
||||
local result = {}
|
||||
|
||||
local files = openspace.walkDirectoryFiles(sceneAsset.localResource('') .. directory, true)
|
||||
for _, file in pairs(files) do
|
||||
if file:ends('.asset') then
|
||||
openspace.printDebug("Requiring: " .. file:sub(file:find(directory), -7))
|
||||
local exports = sceneAsset.require(file:sub(1, -7))
|
||||
table.insert(result, exports)
|
||||
end
|
||||
end
|
||||
|
||||
return result
|
||||
return result
|
||||
end
|
||||
|
||||
local getDefaultLightSources = function (solarSystemBarycenterIdentifier)
|
||||
local sourceList = {
|
||||
{
|
||||
Type = "SceneGraphLightSource",
|
||||
Identifier = "Sun",
|
||||
Node = solarSystemBarycenterIdentifier,
|
||||
Intensity = 1.0
|
||||
},
|
||||
{
|
||||
Identifier = "Camera",
|
||||
Type = "CameraLightSource",
|
||||
Intensity = 0.5
|
||||
}
|
||||
local sourceList = {
|
||||
{
|
||||
Type = "SceneGraphLightSource",
|
||||
Identifier = "Sun",
|
||||
Node = solarSystemBarycenterIdentifier,
|
||||
Intensity = 1.0
|
||||
},
|
||||
{
|
||||
Identifier = "Camera",
|
||||
Type = "CameraLightSource",
|
||||
Intensity = 0.5
|
||||
}
|
||||
return sourceList
|
||||
}
|
||||
return sourceList
|
||||
end
|
||||
|
||||
|
||||
local createModelPart = function (parent, sunLightSourceNode, models, geometry, texture, performShading)
|
||||
local lightSources = {}
|
||||
if performShading then
|
||||
lightSources[1] = {
|
||||
Type = "SceneGraphLightSource",
|
||||
Identifier = "Sun",
|
||||
Node = sunLightSourceNode,
|
||||
Intensity = 1.0
|
||||
}
|
||||
end
|
||||
return {
|
||||
Identifier = parent .. "-" .. geometry,
|
||||
Parent = parent,
|
||||
Renderable = {
|
||||
Type = "RenderableModel",
|
||||
GeometryFile = models .. "/" .. geometry .. ".obj",
|
||||
LightSources = lightSources,
|
||||
PerformShading = performShading,
|
||||
DisableFaceCulling = true
|
||||
},
|
||||
GUI = {
|
||||
Hidden = true
|
||||
}
|
||||
local lightSources = {}
|
||||
if performShading then
|
||||
lightSources[1] = {
|
||||
Type = "SceneGraphLightSource",
|
||||
Identifier = "Sun",
|
||||
Node = sunLightSourceNode,
|
||||
Intensity = 1.0
|
||||
}
|
||||
end
|
||||
return {
|
||||
Identifier = parent .. "-" .. geometry,
|
||||
Parent = parent,
|
||||
Renderable = {
|
||||
Type = "RenderableModel",
|
||||
GeometryFile = models .. "/" .. geometry .. ".obj",
|
||||
LightSources = lightSources,
|
||||
PerformShading = performShading,
|
||||
DisableFaceCulling = true
|
||||
},
|
||||
GUI = {
|
||||
Hidden = true
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
asset.export("registerSceneGraphNodes", registerSceneGraphNodes)
|
||||
|
||||
@@ -1,128 +1,120 @@
|
||||
local identifierGeneratorFunction = function (suffix)
|
||||
local nextIndex = 0
|
||||
return function (specification)
|
||||
nextIndex = nextIndex + 1
|
||||
return specification.Identifier or
|
||||
(specification.Parent .. suffix .. nextIndex)
|
||||
end
|
||||
local nextIndex = 0
|
||||
return function (specification)
|
||||
nextIndex = nextIndex + 1
|
||||
return specification.Identifier or
|
||||
(specification.Parent .. suffix .. nextIndex)
|
||||
end
|
||||
end
|
||||
|
||||
local generateGridIdentifier = identifierGeneratorFunction("Grid")
|
||||
|
||||
local addGrid = function (specification)
|
||||
local identifier = specification.Identifier or
|
||||
generateGridIdentifier(specification)
|
||||
local identifier = specification.Identifier or generateGridIdentifier(specification)
|
||||
|
||||
local name = specification.Name
|
||||
local color = specification.Color
|
||||
local parent = specification.Parent
|
||||
local scale = specification.Scale
|
||||
local position = specification.Position
|
||||
local rotation = specification.Rotation
|
||||
local name = specification.Name
|
||||
local color = specification.Color
|
||||
local parent = specification.Parent
|
||||
local scale = specification.Scale
|
||||
local position = specification.Position
|
||||
local rotation = specification.Rotation
|
||||
|
||||
local grid = {
|
||||
Identifier = identifier,
|
||||
Parent = parent,
|
||||
Transform = {
|
||||
Scale = {
|
||||
Type = "StaticScale",
|
||||
Scale = scale;
|
||||
},
|
||||
Translation = {
|
||||
Type = "StaticTranslation",
|
||||
Position = position
|
||||
},
|
||||
Rotation = {
|
||||
Type = "StaticRotation",
|
||||
Rotation = rotation
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
Type = "RenderableSphericalGrid",
|
||||
Enabled = true,
|
||||
LineWidth = 2.0,
|
||||
Color = color
|
||||
},
|
||||
GUI = {
|
||||
Name = name,
|
||||
Path = "/Other/Grids"
|
||||
}
|
||||
local grid = {
|
||||
Identifier = identifier,
|
||||
Parent = parent,
|
||||
Transform = {
|
||||
Scale = {
|
||||
Type = "StaticScale",
|
||||
Scale = scale
|
||||
},
|
||||
Translation = {
|
||||
Type = "StaticTranslation",
|
||||
Position = position
|
||||
},
|
||||
Rotation = {
|
||||
Type = "StaticRotation",
|
||||
Rotation = rotation
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
Type = "RenderableSphericalGrid",
|
||||
Enabled = true,
|
||||
LineWidth = 2.0,
|
||||
Color = color
|
||||
},
|
||||
GUI = {
|
||||
Name = name,
|
||||
Path = "/Other/Grids"
|
||||
}
|
||||
openspace.addSceneGraphNode(grid)
|
||||
return identifier;
|
||||
}
|
||||
openspace.addSceneGraphNode(grid)
|
||||
return identifier;
|
||||
end
|
||||
|
||||
local generateAxesIdentifier = identifierGeneratorFunction("Axes")
|
||||
|
||||
local addCartesianAxes = function (specification)
|
||||
local identifier = specification.Identifier or
|
||||
generateAxesIdentifier(specification)
|
||||
local identifier = specification.Identifier or generateAxesIdentifier(specification)
|
||||
|
||||
local name = specification.Name or specification.Identifier
|
||||
local parent = specification.Parent or "Root"
|
||||
local scale = specification.Scale or 1.0
|
||||
local position = specification.Position or { 0.0, 0.0, 0.0 }
|
||||
local rotation = specification.Rotation or { 0.0, 0.0, 0.0 }
|
||||
local name = specification.Name or specification.Identifier
|
||||
local parent = specification.Parent or "Root"
|
||||
local scale = specification.Scale or 1.0
|
||||
local position = specification.Position or { 0.0, 0.0, 0.0 }
|
||||
local rotation = specification.Rotation or { 0.0, 0.0, 0.0 }
|
||||
|
||||
local axes = {
|
||||
Identifier = identifier,
|
||||
Parent = parent,
|
||||
Transform = {
|
||||
Scale = {
|
||||
Type = "StaticScale",
|
||||
Scale = scale;
|
||||
},
|
||||
Translation = {
|
||||
Type = "StaticTranslation",
|
||||
Position = position
|
||||
},
|
||||
Rotation = {
|
||||
Type = "StaticRotation",
|
||||
Rotation = rotation
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
Type = "RenderableCartesianAxes",
|
||||
Enabled = true,
|
||||
XColor = { 1.0, 0.0, 0.0 },
|
||||
YColor = { 0.0, 1.0, 0.0 },
|
||||
ZColor = { 0.0, 0.0, 1.0 }
|
||||
},
|
||||
GUI = {
|
||||
Name = name,
|
||||
Path = "/Other/Coordinate Systems"
|
||||
}
|
||||
local axes = {
|
||||
Identifier = identifier,
|
||||
Parent = parent,
|
||||
Transform = {
|
||||
Scale = {
|
||||
Type = "StaticScale",
|
||||
Scale = scale
|
||||
},
|
||||
Translation = {
|
||||
Type = "StaticTranslation",
|
||||
Position = position
|
||||
},
|
||||
Rotation = {
|
||||
Type = "StaticRotation",
|
||||
Rotation = rotation
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
Type = "RenderableCartesianAxes",
|
||||
Enabled = true,
|
||||
XColor = { 1.0, 0.0, 0.0 },
|
||||
YColor = { 0.0, 1.0, 0.0 },
|
||||
ZColor = { 0.0, 0.0, 1.0 }
|
||||
},
|
||||
GUI = {
|
||||
Name = name,
|
||||
Path = "/Other/Coordinate Systems"
|
||||
}
|
||||
openspace.addSceneGraphNode(axes)
|
||||
return identifier;
|
||||
}
|
||||
openspace.addSceneGraphNode(axes)
|
||||
return identifier;
|
||||
end
|
||||
|
||||
|
||||
local registerNode = function(
|
||||
containerAsset,
|
||||
nodeCreationFunction,
|
||||
identifierGeneratorFunction,
|
||||
specification
|
||||
)
|
||||
local identifier = specification.Identifier or
|
||||
identifierGeneratorFunction(specification)
|
||||
local registerNode = function(containerAsset, nodeCreationFunction, identifierGeneratorFunction, specification)
|
||||
local identifier = specification.Identifier or identifierGeneratorFunction(specification)
|
||||
|
||||
specification.Identifier = identifier
|
||||
specification.Identifier = identifier
|
||||
|
||||
containerAsset.onInitialize(function ()
|
||||
nodeCreationFunction(specification)
|
||||
end)
|
||||
containerAsset.onDeinitialize(function ()
|
||||
openspace.removeSceneGraphNode(identifier)
|
||||
end)
|
||||
containerAsset.onInitialize(function ()
|
||||
nodeCreationFunction(specification)
|
||||
end)
|
||||
containerAsset.onDeinitialize(function ()
|
||||
openspace.removeSceneGraphNode(identifier)
|
||||
end)
|
||||
end
|
||||
|
||||
local registerGrid = function(gridAsset, specification)
|
||||
registerNode(gridAsset, addGrid, generateGridIdentifier, specification)
|
||||
registerNode(gridAsset, addGrid, generateGridIdentifier, specification)
|
||||
end
|
||||
|
||||
local registerCartesianAxes = function(axesAsset, specification)
|
||||
registerNode(axesAsset, addCartesianAxes, generateAxesIdentifier, specification)
|
||||
registerNode(axesAsset, addCartesianAxes, generateAxesIdentifier, specification)
|
||||
end
|
||||
|
||||
asset.export("addGrid", addGrid)
|
||||
@@ -130,4 +122,3 @@ asset.export("registerGrid", registerGrid)
|
||||
|
||||
asset.export("addCartesianAxes", addCartesianAxes)
|
||||
asset.export("registerCartesianAxes", registerCartesianAxes)
|
||||
|
||||
|
||||
@@ -18,57 +18,57 @@ local propertyHelper = asset.require('./property_helper')
|
||||
|
||||
|
||||
local XBoxController = {
|
||||
LeftThumbStick = { 0 , 1 },
|
||||
RightThumbStick = { 2, 3 },
|
||||
LeftTrigger = 4,
|
||||
RightTrigger = 5,
|
||||
A = 0,
|
||||
B = 1,
|
||||
X = 2,
|
||||
Y = 3,
|
||||
LB = 4,
|
||||
RB = 5,
|
||||
Select = 6,
|
||||
Start = 7,
|
||||
LeftStick = 8,
|
||||
RightStick = 9,
|
||||
DPad = {
|
||||
Up = 10,
|
||||
Right = 11,
|
||||
Down = 12,
|
||||
Left = 13
|
||||
}
|
||||
LeftThumbStick = { 0 , 1 },
|
||||
RightThumbStick = { 2, 3 },
|
||||
LeftTrigger = 4,
|
||||
RightTrigger = 5,
|
||||
A = 0,
|
||||
B = 1,
|
||||
X = 2,
|
||||
Y = 3,
|
||||
LB = 4,
|
||||
RB = 5,
|
||||
Select = 6,
|
||||
Start = 7,
|
||||
LeftStick = 8,
|
||||
RightStick = 9,
|
||||
DPad = {
|
||||
Up = 10,
|
||||
Right = 11,
|
||||
Down = 12,
|
||||
Left = 13
|
||||
}
|
||||
}
|
||||
|
||||
local PS4Controller = {
|
||||
LeftThumbStick = { 0 , 1 },
|
||||
RightThumbStick = { 2, 5 },
|
||||
LeftTrigger = 3,
|
||||
RightTrigger = 4,
|
||||
A = 1, -- Cross
|
||||
B = 2, -- Circle
|
||||
X = 0, -- Square
|
||||
Y = 3, -- Triangle
|
||||
LB = 4,
|
||||
RB = 5,
|
||||
Select = 9, -- options
|
||||
Start = 12, -- PS button
|
||||
LeftStick = 10,
|
||||
RightStick = 11,
|
||||
DPad = {
|
||||
Up = 14,
|
||||
Right = 15,
|
||||
Down = 16,
|
||||
Left = 17
|
||||
}
|
||||
LeftThumbStick = { 0 , 1 },
|
||||
RightThumbStick = { 2, 5 },
|
||||
LeftTrigger = 3,
|
||||
RightTrigger = 4,
|
||||
A = 1, -- Cross
|
||||
B = 2, -- Circle
|
||||
X = 0, -- Square
|
||||
Y = 3, -- Triangle
|
||||
LB = 4,
|
||||
RB = 5,
|
||||
Select = 9, -- options
|
||||
Start = 12, -- PS button
|
||||
LeftStick = 10,
|
||||
RightStick = 11,
|
||||
DPad = {
|
||||
Up = 14,
|
||||
Right = 15,
|
||||
Down = 16,
|
||||
Left = 17
|
||||
}
|
||||
}
|
||||
|
||||
local SpaceMouse = {
|
||||
Push = {0, 1, 2}, -- left/right, back/forth, up/down
|
||||
Twist = {5}, -- left/right
|
||||
Tilt = {4, 3}, -- left/right, back/forth
|
||||
LeftButton = 0,
|
||||
RightButton = 1
|
||||
Push = {0, 1, 2}, -- left/right, back/forth, up/down
|
||||
Twist = {5}, -- left/right
|
||||
Tilt = {4, 3}, -- left/right, back/forth
|
||||
LeftButton = 0,
|
||||
RightButton = 1
|
||||
}
|
||||
|
||||
-- Variables to store the state of the joystick between frames
|
||||
@@ -78,131 +78,131 @@ Joystick.State.IsInRollMode = false
|
||||
Joystick.State.Axis = {}
|
||||
|
||||
local bindLocalRoll = function(axis)
|
||||
return [[
|
||||
-- We only want to store the current state in the first mode that is enabled, otherwise we will overwrite the backup
|
||||
if not Joystick.State.IsInRollMode then
|
||||
-- Save current axis state
|
||||
Joystick.State.Axis.Type, Joystick.State.Axis.Inverted, Joystick.State.Axis.Normalized = openspace.navigation.joystickAxis(]] .. axis .. [[)
|
||||
end
|
||||
return [[
|
||||
-- We only want to store the current state in the first mode that is enabled, otherwise we will overwrite the backup
|
||||
if not Joystick.State.IsInRollMode then
|
||||
-- Save current axis state
|
||||
Joystick.State.Axis.Type, Joystick.State.Axis.Inverted, Joystick.State.Axis.Normalized, Joystick.State.Axis.Static = openspace.navigation.joystickAxis(]] .. axis .. [[)
|
||||
end
|
||||
|
||||
-- Set new axis state
|
||||
openspace.navigation.bindJoystickAxis(]] .. axis .. [[, "LocalRoll X", true);
|
||||
Joystick.State.IsInRollMode = true
|
||||
]]
|
||||
-- Set new axis state
|
||||
openspace.navigation.bindJoystickAxis(]] .. axis .. [[, "LocalRoll X", Joystick.State.Axis.Inverted, Joystick.State.Axis.Normalized, Joystick.State.Axis.Static);
|
||||
Joystick.State.IsInRollMode = true
|
||||
]]
|
||||
end
|
||||
|
||||
local bindGlobalRoll = function(axis)
|
||||
return [[
|
||||
-- We only want to store the current state in the first mode that is enabled, otherwise we will overwrite the backup
|
||||
if not Joystick.State.IsInRollMode then
|
||||
-- Save current axis state
|
||||
Joystick.State.Axis.Type, Joystick.State.Axis.Inverted, Joystick.State.Axis.Normalized = openspace.navigation.joystickAxis(]] .. axis .. [[)
|
||||
end
|
||||
return [[
|
||||
-- We only want to store the current state in the first mode that is enabled, otherwise we will overwrite the backup
|
||||
if not Joystick.State.IsInRollMode then
|
||||
-- Save current axis state
|
||||
Joystick.State.Axis.Type, Joystick.State.Axis.Inverted, Joystick.State.Axis.Normalized, Joystick.State.Axis.Static = openspace.navigation.joystickAxis(]] .. axis .. [[)
|
||||
end
|
||||
|
||||
-- Set new axis state
|
||||
openspace.navigation.bindJoystickAxis(]] .. axis .. [[, "GlobalRoll X", true);
|
||||
Joystick.State.IsInRollMode = true
|
||||
]]
|
||||
-- Set new axis state
|
||||
openspace.navigation.bindJoystickAxis(]] .. axis .. [[, "GlobalRoll X", Joystick.State.Axis.Inverted, Joystick.State.Axis.Normalized, Joystick.State.Axis.Static);
|
||||
Joystick.State.IsInRollMode = true
|
||||
]]
|
||||
end
|
||||
|
||||
local unbindRoll = function(axis)
|
||||
return [[
|
||||
-- Reset previous state
|
||||
openspace.navigation.bindJoystickAxis(]] .. axis .. [[, Joystick.State.Axis.Type, Joystick.State.Axis.Inverted, Joystick.State.Axis.Normalized);
|
||||
]]
|
||||
return [[
|
||||
-- Reset previous state
|
||||
openspace.navigation.bindJoystickAxis(]] .. axis .. [[, Joystick.State.Axis.Type, Joystick.State.Axis.Inverted, Joystick.State.Axis.Normalized, Joystick.State.Axis.Static);
|
||||
]]
|
||||
end
|
||||
|
||||
asset.onInitialize(function()
|
||||
-- Set the controller to the connected controller
|
||||
-- Currently: XBoxController, PS4Controller or SpaceMouse
|
||||
local controller = XBoxController;
|
||||
-- Set the controller to the connected controller
|
||||
-- Currently: XBoxController, PS4Controller or SpaceMouse
|
||||
local controller = SpaceMouse;
|
||||
|
||||
-- Case of XBoxController or PS4Controller
|
||||
if(controller.A ~= nil) then
|
||||
openspace.navigation.setAxisDeadZone(controller.LeftThumbStick[1], 0.15)
|
||||
openspace.navigation.setAxisDeadZone(controller.LeftThumbStick[2], 0.15)
|
||||
openspace.navigation.setAxisDeadZone(controller.RightThumbStick[1], 0.15)
|
||||
openspace.navigation.setAxisDeadZone(controller.RightThumbStick[2], 0.15)
|
||||
-- Case of XBoxController or PS4Controller
|
||||
if(controller.A ~= nil) then
|
||||
openspace.navigation.setAxisDeadZone(controller.LeftThumbStick[1], 0.15)
|
||||
openspace.navigation.setAxisDeadZone(controller.LeftThumbStick[2], 0.15)
|
||||
openspace.navigation.setAxisDeadZone(controller.RightThumbStick[1], 0.15)
|
||||
openspace.navigation.setAxisDeadZone(controller.RightThumbStick[2], 0.15)
|
||||
|
||||
openspace.navigation.bindJoystickAxis(controller.LeftThumbStick[1], "Orbit X");
|
||||
openspace.navigation.bindJoystickAxis(controller.LeftThumbStick[2], "Orbit Y", true);
|
||||
openspace.navigation.bindJoystickAxis(controller.RightThumbStick[1], "Pan X", true);
|
||||
openspace.navigation.bindJoystickAxis(controller.RightThumbStick[2], "Pan Y", true);
|
||||
openspace.navigation.bindJoystickAxis(controller.LeftTrigger, "Zoom Out", false, true);
|
||||
openspace.navigation.bindJoystickAxis(controller.RightTrigger, "Zoom In", false, true);
|
||||
openspace.navigation.bindJoystickAxis(controller.LeftThumbStick[1], "Orbit X");
|
||||
openspace.navigation.bindJoystickAxis(controller.LeftThumbStick[2], "Orbit Y", true);
|
||||
openspace.navigation.bindJoystickAxis(controller.RightThumbStick[1], "Pan X", true);
|
||||
openspace.navigation.bindJoystickAxis(controller.RightThumbStick[2], "Pan Y", true);
|
||||
openspace.navigation.bindJoystickAxis(controller.LeftTrigger, "Zoom Out", false, true);
|
||||
openspace.navigation.bindJoystickAxis(controller.RightTrigger, "Zoom In", false, true);
|
||||
|
||||
openspace.navigation.bindJoystickButton(
|
||||
controller.LB,
|
||||
bindLocalRoll(controller.RightThumbStick[1]),
|
||||
"Switch to local roll mode"
|
||||
)
|
||||
openspace.navigation.bindJoystickButton(
|
||||
controller.LB,
|
||||
unbindRoll(controller.RightThumbStick[1]),
|
||||
"Switch back to normal mode",
|
||||
"Release"
|
||||
)
|
||||
openspace.navigation.bindJoystickButton(
|
||||
controller.RB,
|
||||
bindGlobalRoll(controller.RightThumbStick[1]),
|
||||
"Switch to global roll mode"
|
||||
)
|
||||
openspace.navigation.bindJoystickButton(
|
||||
controller.RB,
|
||||
unbindRoll(controller.RightThumbStick[1]),
|
||||
"Switch back to normal mode",
|
||||
"Release"
|
||||
)
|
||||
openspace.navigation.bindJoystickButton(
|
||||
controller.LB,
|
||||
bindLocalRoll(controller.RightThumbStick[1]),
|
||||
"Switch to local roll mode"
|
||||
)
|
||||
openspace.navigation.bindJoystickButton(
|
||||
controller.LB,
|
||||
unbindRoll(controller.RightThumbStick[1]),
|
||||
"Switch back to normal mode",
|
||||
"Release"
|
||||
)
|
||||
openspace.navigation.bindJoystickButton(
|
||||
controller.RB,
|
||||
bindGlobalRoll(controller.RightThumbStick[1]),
|
||||
"Switch to global roll mode"
|
||||
)
|
||||
openspace.navigation.bindJoystickButton(
|
||||
controller.RB,
|
||||
unbindRoll(controller.RightThumbStick[1]),
|
||||
"Switch back to normal mode",
|
||||
"Release"
|
||||
)
|
||||
|
||||
openspace.navigation.bindJoystickButton(
|
||||
controller.A,
|
||||
propertyHelper.invert('NavigationHandler.OrbitalNavigator.Friction.ZoomFriction'),
|
||||
"Toggle zoom friction"
|
||||
)
|
||||
openspace.navigation.bindJoystickButton(
|
||||
controller.B,
|
||||
propertyHelper.invert('NavigationHandler.OrbitalNavigator.Friction.RotationalFriction'),
|
||||
"Toggle rotational friction"
|
||||
)
|
||||
openspace.navigation.bindJoystickButton(
|
||||
controller.DPad.Left,
|
||||
propertyHelper.invert('NavigationHandler.OrbitalNavigator.Friction.RollFriction'),
|
||||
"Toggle roll friction"
|
||||
)
|
||||
openspace.navigation.bindJoystickButton(
|
||||
controller.A,
|
||||
propertyHelper.invert('NavigationHandler.OrbitalNavigator.Friction.ZoomFriction'),
|
||||
"Toggle zoom friction"
|
||||
)
|
||||
openspace.navigation.bindJoystickButton(
|
||||
controller.B,
|
||||
propertyHelper.invert('NavigationHandler.OrbitalNavigator.Friction.RotationalFriction'),
|
||||
"Toggle rotational friction"
|
||||
)
|
||||
openspace.navigation.bindJoystickButton(
|
||||
controller.DPad.Left,
|
||||
propertyHelper.invert('NavigationHandler.OrbitalNavigator.Friction.RollFriction'),
|
||||
"Toggle roll friction"
|
||||
)
|
||||
|
||||
openspace.navigation.bindJoystickButton(
|
||||
controller.X,
|
||||
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Aim', '');" ..
|
||||
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Anchor', 'Earth');" ..
|
||||
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.RetargetAnchor', nil);",
|
||||
"Switch target to Earth"
|
||||
)
|
||||
openspace.navigation.bindJoystickButton(
|
||||
controller.Y,
|
||||
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Aim', '');" ..
|
||||
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Anchor', 'Mars');" ..
|
||||
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.RetargetAnchor', nil);",
|
||||
"Switch target to Mars"
|
||||
)
|
||||
-- Case of SpaceMouse
|
||||
elseif (controller.LeftButton ~= nil) then
|
||||
openspace.navigation.bindJoystickAxis(controller.Push[1], "Orbit X", false, false, true, 40.0);
|
||||
openspace.navigation.bindJoystickAxis(controller.Push[2], "Orbit Y", false, false, true, 40.0);
|
||||
openspace.navigation.bindJoystickAxis(controller.Twist[1], "Pan X", true, false, true, 40.0);
|
||||
openspace.navigation.bindJoystickAxis(controller.Tilt[2], "Pan Y", false, false, true, 35.0);
|
||||
openspace.navigation.bindJoystickAxis(controller.Push[3], "Zoom", false, false, true, 40.0);
|
||||
openspace.navigation.bindJoystickAxis(controller.Tilt[1], "LocalRoll X", false, false, true, 35.0);
|
||||
openspace.navigation.bindJoystickButton(
|
||||
controller.X,
|
||||
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Aim', '');" ..
|
||||
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Anchor', 'Earth');" ..
|
||||
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.RetargetAnchor', nil);",
|
||||
"Switch target to Earth"
|
||||
)
|
||||
openspace.navigation.bindJoystickButton(
|
||||
controller.Y,
|
||||
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Aim', '');" ..
|
||||
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Anchor', 'Mars');" ..
|
||||
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.RetargetAnchor', nil);",
|
||||
"Switch target to Mars"
|
||||
)
|
||||
-- Case of SpaceMouse
|
||||
elseif (controller.LeftButton ~= nil) then
|
||||
openspace.navigation.bindJoystickAxis(controller.Push[1], "Orbit X", false, false, true, 40.0);
|
||||
openspace.navigation.bindJoystickAxis(controller.Push[2], "Orbit Y", false, false, true, 40.0);
|
||||
openspace.navigation.bindJoystickAxis(controller.Twist[1], "Pan X", true, false, true, 40.0);
|
||||
openspace.navigation.bindJoystickAxis(controller.Tilt[2], "Pan Y", false, false, true, 35.0);
|
||||
openspace.navigation.bindJoystickAxis(controller.Push[3], "Zoom", false, false, true, 40.0);
|
||||
openspace.navigation.bindJoystickAxis(controller.Tilt[1], "LocalRoll X", false, false, true, 35.0);
|
||||
|
||||
--openspace.navigation.bindJoystickButton(
|
||||
--controller.LeftButton,
|
||||
--bindLocalRoll(controller.Tilt[1]),
|
||||
--"Switch to local roll mode"
|
||||
--)
|
||||
--[[openspace.navigation.bindJoystickButton(
|
||||
controller.LeftButton,
|
||||
bindLocalRoll(controller.Tilt[1]),
|
||||
"Switch to local roll mode"
|
||||
)
|
||||
|
||||
--openspace.navigation.bindJoystickButton(
|
||||
--controller.RightButton,
|
||||
--bindGlobalRoll(controller.Tilt[1]),
|
||||
--"Switch to global roll mode"
|
||||
--)
|
||||
end
|
||||
openspace.navigation.bindJoystickButton(
|
||||
controller.RightButton,
|
||||
bindGlobalRoll(controller.Tilt[1]),
|
||||
"Switch to global roll mode"
|
||||
)]]--
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -2,154 +2,154 @@ local sceneHelper = asset.require('./scene_helper')
|
||||
local propertyHelper = asset.require('./property_helper')
|
||||
|
||||
local Keybindings = {
|
||||
{
|
||||
Key = "F1",
|
||||
Name = "Show Native GUI",
|
||||
Command = propertyHelper.invert('Modules.ImGUI.Main.Enabled'),
|
||||
Documentation = "Shows or hides the native UI",
|
||||
GuiPath = "/Native GUI",
|
||||
Local = true
|
||||
},
|
||||
{
|
||||
Key = "ESC",
|
||||
Name = "Toggle Shutdown",
|
||||
Command = "openspace.toggleShutdown()",
|
||||
Documentation = "Toggles the shutdown that will stop OpenSpace after a grace period. Press again to cancel the shutdown during this period.",
|
||||
Local = true
|
||||
},
|
||||
{
|
||||
Key = "PRINT_SCREEN",
|
||||
Name = "Take Screenshot",
|
||||
Command = "openspace.takeScreenshot()",
|
||||
Documentation = "Saves the contents of the screen to a file in the ${SCREENSHOTS} directory.",
|
||||
GuiPath = "/Rendering",
|
||||
Local = true
|
||||
},
|
||||
{
|
||||
Key = "F12",
|
||||
Name = "Take Screenshot",
|
||||
Command = "openspace.takeScreenshot()",
|
||||
Documentation = "Saves the contents of the screen to a file in the ${SCREENSHOTS} directory.",
|
||||
GuiPath = "/Rendering",
|
||||
Local = true
|
||||
},
|
||||
{
|
||||
Key = "SPACE",
|
||||
Name = "Toggle Pause (Interpolated)",
|
||||
Command = "openspace.time.interpolateTogglePause()",
|
||||
Documentation = "Smoothly starts and stops the simulation time.",
|
||||
GuiPath = "/Simulation Speed",
|
||||
Local = true
|
||||
},
|
||||
{
|
||||
Key = "Shift+SPACE",
|
||||
Name = "Toggle Pause (Immediate)",
|
||||
Command = "openspace.time.togglePause()",
|
||||
Documentation = "Immediately starts and stops the simulation time.",
|
||||
GuiPath = "/Simulation Speed",
|
||||
Local = true
|
||||
},
|
||||
{
|
||||
Key = "f",
|
||||
Name = "Toggle Rotation friction",
|
||||
Command = propertyHelper.invert('NavigationHandler.OrbitalNavigator.Friction.RotationalFriction'),
|
||||
Documentation = "Toggles the rotational friction of the camera. If it is disabled, the camera rotates around the focus object indefinitely.",
|
||||
GuiPath = "/Navigation",
|
||||
Local = false
|
||||
},
|
||||
{
|
||||
Key = "Shift+f",
|
||||
Name = "Toggle Zoom Friction",
|
||||
Command = propertyHelper.invert('NavigationHandler.OrbitalNavigator.Friction.ZoomFriction'),
|
||||
Documentation = "Toggles the zoom friction of the camera. If it is disabled, the camera rises up from or closes in towards the focus object indefinitely.",
|
||||
GuiPath = "/Navigation",
|
||||
Local = false
|
||||
},
|
||||
{
|
||||
Key = "Ctrl+f",
|
||||
Name = "Toggle Roll Friction",
|
||||
Command = propertyHelper.invert('NavigationHandler.OrbitalNavigator.Friction.RollFriction'),
|
||||
Documentation = "Toggles the roll friction of the camera. If it is disabled, the camera rolls around its own axis indefinitely.",
|
||||
GuiPath = "/Navigation",
|
||||
Local = false
|
||||
},
|
||||
{
|
||||
Key = "w",
|
||||
Name = "Fade to/from black",
|
||||
Command = "if openspace.getPropertyValue('RenderEngine.BlackoutFactor') > 0.5 then openspace.setPropertyValueSingle('RenderEngine.BlackoutFactor', 0.0, 3) else openspace.setPropertyValueSingle('RenderEngine.BlackoutFactor', 1.0, 3) end",
|
||||
Documentation = "Toggles the fade to black within 3 seconds or shows the rendering after 3 seconds.",
|
||||
GuiPath = "/Rendering",
|
||||
Local = false
|
||||
},
|
||||
{
|
||||
Key = "Tab",
|
||||
Name = "Toggle main GUI",
|
||||
Command = propertyHelper.invert('Modules.CefWebGui.Visible'),
|
||||
Documentation = "Toggles the main GUI",
|
||||
GuiPath = "/GUI",
|
||||
Local = true
|
||||
},
|
||||
{
|
||||
Key = "Shift+Tab",
|
||||
Name = "Toggle dashboard and overlays",
|
||||
Command =
|
||||
{
|
||||
Key = "F1",
|
||||
Name = "Show Native GUI",
|
||||
Command = propertyHelper.invert('Modules.ImGUI.Main.Enabled'),
|
||||
Documentation = "Shows or hides the native UI",
|
||||
GuiPath = "/Native GUI",
|
||||
Local = true
|
||||
},
|
||||
{
|
||||
Key = "ESC",
|
||||
Name = "Toggle Shutdown",
|
||||
Command = "openspace.toggleShutdown()",
|
||||
Documentation = "Toggles the shutdown that will stop OpenSpace after a grace period. Press again to cancel the shutdown during this period.",
|
||||
Local = true
|
||||
},
|
||||
{
|
||||
Key = "PRINT_SCREEN",
|
||||
Name = "Take Screenshot",
|
||||
Command = "openspace.takeScreenshot()",
|
||||
Documentation = "Saves the contents of the screen to a file in the ${SCREENSHOTS} directory.",
|
||||
GuiPath = "/Rendering",
|
||||
Local = true
|
||||
},
|
||||
{
|
||||
Key = "F12",
|
||||
Name = "Take Screenshot",
|
||||
Command = "openspace.takeScreenshot()",
|
||||
Documentation = "Saves the contents of the screen to a file in the ${SCREENSHOTS} directory.",
|
||||
GuiPath = "/Rendering",
|
||||
Local = true
|
||||
},
|
||||
{
|
||||
Key = "SPACE",
|
||||
Name = "Toggle Pause (Interpolated)",
|
||||
Command = "openspace.time.interpolateTogglePause()",
|
||||
Documentation = "Smoothly starts and stops the simulation time.",
|
||||
GuiPath = "/Simulation Speed",
|
||||
Local = true
|
||||
},
|
||||
{
|
||||
Key = "Shift+SPACE",
|
||||
Name = "Toggle Pause (Immediate)",
|
||||
Command = "openspace.time.togglePause()",
|
||||
Documentation = "Immediately starts and stops the simulation time.",
|
||||
GuiPath = "/Simulation Speed",
|
||||
Local = true
|
||||
},
|
||||
{
|
||||
Key = "f",
|
||||
Name = "Toggle Rotation friction",
|
||||
Command = propertyHelper.invert('NavigationHandler.OrbitalNavigator.Friction.RotationalFriction'),
|
||||
Documentation = "Toggles the rotational friction of the camera. If it is disabled, the camera rotates around the focus object indefinitely.",
|
||||
GuiPath = "/Navigation",
|
||||
Local = false
|
||||
},
|
||||
{
|
||||
Key = "Shift+f",
|
||||
Name = "Toggle Zoom Friction",
|
||||
Command = propertyHelper.invert('NavigationHandler.OrbitalNavigator.Friction.ZoomFriction'),
|
||||
Documentation = "Toggles the zoom friction of the camera. If it is disabled, the camera rises up from or closes in towards the focus object indefinitely.",
|
||||
GuiPath = "/Navigation",
|
||||
Local = false
|
||||
},
|
||||
{
|
||||
Key = "Ctrl+f",
|
||||
Name = "Toggle Roll Friction",
|
||||
Command = propertyHelper.invert('NavigationHandler.OrbitalNavigator.Friction.RollFriction'),
|
||||
Documentation = "Toggles the roll friction of the camera. If it is disabled, the camera rolls around its own axis indefinitely.",
|
||||
GuiPath = "/Navigation",
|
||||
Local = false
|
||||
},
|
||||
{
|
||||
Key = "w",
|
||||
Name = "Fade to/from black",
|
||||
Command = "if openspace.getPropertyValue('RenderEngine.BlackoutFactor') > 0.5 then openspace.setPropertyValueSingle('RenderEngine.BlackoutFactor', 0.0, 3) else openspace.setPropertyValueSingle('RenderEngine.BlackoutFactor', 1.0, 3) end",
|
||||
Documentation = "Toggles the fade to black within 3 seconds or shows the rendering after 3 seconds.",
|
||||
GuiPath = "/Rendering",
|
||||
Local = false
|
||||
},
|
||||
{
|
||||
Key = "Tab",
|
||||
Name = "Toggle main GUI",
|
||||
Command = propertyHelper.invert('Modules.CefWebGui.Visible'),
|
||||
Documentation = "Toggles the main GUI",
|
||||
GuiPath = "/GUI",
|
||||
Local = true
|
||||
},
|
||||
{
|
||||
Key = "Shift+Tab",
|
||||
Name = "Toggle dashboard and overlays",
|
||||
Command =
|
||||
[[local isEnabled = openspace.getPropertyValue('Dashboard.IsEnabled');
|
||||
openspace.setPropertyValueSingle('Dashboard.IsEnabled', not isEnabled);
|
||||
openspace.setPropertyValueSingle("RenderEngine.ShowLog", not isEnabled);
|
||||
openspace.setPropertyValueSingle("RenderEngine.ShowVersion", not isEnabled);
|
||||
openspace.setPropertyValueSingle("RenderEngine.ShowCamera", not isEnabled)]],
|
||||
Documentation = "Toggles the dashboard and overlays",
|
||||
GuiPath = "/GUI",
|
||||
Local = true
|
||||
},
|
||||
{
|
||||
Key = "Alt+R",
|
||||
Name = "Toggle rendering on master",
|
||||
Command = propertyHelper.invert('RenderEngine.DisableMasterRendering'),
|
||||
Documentation = "Toggles the rendering on master",
|
||||
GuiPath = "/Rendering",
|
||||
Local = true
|
||||
},
|
||||
{
|
||||
Key = "Right",
|
||||
Name = "Next Delta Time Step (Interpolate)",
|
||||
Command = "openspace.time.interpolateNextDeltaTimeStep()",
|
||||
Documentation = "Smoothly interpolates the simulation speed to the next delta time step, if one exists.",
|
||||
GuiPath = "/Simulation Speed",
|
||||
Local = true
|
||||
},
|
||||
{
|
||||
Key = "Shift+Right",
|
||||
Name = "Next Delta Time Step (Immediate)",
|
||||
Command = "openspace.time.setNextDeltaTimeStep()",
|
||||
Documentation = "Immediately set the simulation speed to the next delta time step, if one exists.",
|
||||
GuiPath = "/Simulation Speed",
|
||||
Local = true
|
||||
},
|
||||
{
|
||||
Key = "Left",
|
||||
Name = "Previous Delta Time Step (Interpolate)",
|
||||
Command = "openspace.time.interpolatePreviousDeltaTimeStep()",
|
||||
Documentation = "Smoothly interpolates the simulation speed to the previous delta time step, if one exists.",
|
||||
GuiPath = "/Simulation Speed",
|
||||
Local = true
|
||||
},
|
||||
{
|
||||
Key = "Shift+Left",
|
||||
Name = "Previous Delta Time Step (Immediate)",
|
||||
Command = "openspace.time.setPreviousDeltaTimeStep()",
|
||||
Documentation = "Immediately set the simulation speed to the previous delta time step, if one exists.",
|
||||
GuiPath = "/Simulation Speed",
|
||||
Local = true
|
||||
}
|
||||
Documentation = "Toggles the dashboard and overlays",
|
||||
GuiPath = "/GUI",
|
||||
Local = true
|
||||
},
|
||||
{
|
||||
Key = "Alt+R",
|
||||
Name = "Toggle rendering on master",
|
||||
Command = propertyHelper.invert('RenderEngine.DisableMasterRendering'),
|
||||
Documentation = "Toggles the rendering on master",
|
||||
GuiPath = "/Rendering",
|
||||
Local = true
|
||||
},
|
||||
{
|
||||
Key = "Right",
|
||||
Name = "Next Delta Time Step (Interpolate)",
|
||||
Command = "openspace.time.interpolateNextDeltaTimeStep()",
|
||||
Documentation = "Smoothly interpolates the simulation speed to the next delta time step, if one exists.",
|
||||
GuiPath = "/Simulation Speed",
|
||||
Local = true
|
||||
},
|
||||
{
|
||||
Key = "Shift+Right",
|
||||
Name = "Next Delta Time Step (Immediate)",
|
||||
Command = "openspace.time.setNextDeltaTimeStep()",
|
||||
Documentation = "Immediately set the simulation speed to the next delta time step, if one exists.",
|
||||
GuiPath = "/Simulation Speed",
|
||||
Local = true
|
||||
},
|
||||
{
|
||||
Key = "Left",
|
||||
Name = "Previous Delta Time Step (Interpolate)",
|
||||
Command = "openspace.time.interpolatePreviousDeltaTimeStep()",
|
||||
Documentation = "Smoothly interpolates the simulation speed to the previous delta time step, if one exists.",
|
||||
GuiPath = "/Simulation Speed",
|
||||
Local = true
|
||||
},
|
||||
{
|
||||
Key = "Shift+Left",
|
||||
Name = "Previous Delta Time Step (Immediate)",
|
||||
Command = "openspace.time.setPreviousDeltaTimeStep()",
|
||||
Documentation = "Immediately set the simulation speed to the previous delta time step, if one exists.",
|
||||
GuiPath = "/Simulation Speed",
|
||||
Local = true
|
||||
}
|
||||
}
|
||||
|
||||
asset.onInitialize(function()
|
||||
sceneHelper.bindKeys(Keybindings)
|
||||
sceneHelper.bindKeys(Keybindings)
|
||||
end)
|
||||
|
||||
asset.onDeinitialize(function ()
|
||||
sceneHelper.unbindKeys(Keybindings)
|
||||
sceneHelper.unbindKeys(Keybindings)
|
||||
end)
|
||||
|
||||
asset.export("DefaultKeybindings", Keybindings)
|
||||
|
||||
@@ -5,78 +5,78 @@ local getBookmarks = function (guiPath, bookmarkfile)
|
||||
local notFirstLine = false;
|
||||
local PARSEC_CONSTANT = 3.0856776E16;
|
||||
for line in io.lines(openspace.absPath(bookmarkfile)) do
|
||||
if (notFirstLine) then
|
||||
local matchstring = '(.-),(.-),(.-),(.-),(.-),(.-),(.-),(.-),(.-),(.-),(.-)$'
|
||||
local group, name, globe, lat, lon, altitude, x, y, z, scale, linewidth = line:match(matchstring)
|
||||
if (notFirstLine) then
|
||||
local matchstring = '(.-),(.-),(.-),(.-),(.-),(.-),(.-),(.-),(.-),(.-),(.-)$'
|
||||
local group, name, globe, lat, lon, altitude, x, y, z, scale, linewidth = line:match(matchstring)
|
||||
|
||||
scale = (scale == '' and 75000 or scale)
|
||||
linewidth = (linewidth == '' and 2.0 or tonumber(linewidth))
|
||||
group = (group == '' and globe or group)
|
||||
scale = (scale == '' and 75000 or scale)
|
||||
linewidth = (linewidth == '' and 2.0 or tonumber(linewidth))
|
||||
group = (group == '' and globe or group)
|
||||
|
||||
local parent = (globe == '' and 'Root' or globe)
|
||||
local parent = (globe == '' and 'Root' or globe)
|
||||
|
||||
local sgn = {
|
||||
Identifier = guiPath .. '-' .. name,
|
||||
Parent = parent,
|
||||
Transform = {
|
||||
Scale = {
|
||||
Type = 'StaticScale',
|
||||
Scale = tonumber(scale);
|
||||
},
|
||||
Rotation = {
|
||||
Type = "StaticRotation",
|
||||
Rotation = {
|
||||
-0.05487554, 0.4941095, -0.8676661,
|
||||
-0.9938214 , -0.1109906, -0.0003515167,
|
||||
-0.09647644, 0.8622859, 0.4971472
|
||||
}
|
||||
local sgn = {
|
||||
Identifier = guiPath .. '-' .. name,
|
||||
Parent = parent,
|
||||
Transform = {
|
||||
Scale = {
|
||||
Type = 'StaticScale',
|
||||
Scale = tonumber(scale);
|
||||
},
|
||||
Rotation = {
|
||||
Type = "StaticRotation",
|
||||
Rotation = {
|
||||
-0.05487554, 0.4941095, -0.8676661,
|
||||
-0.9938214 , -0.1109906, -0.0003515167,
|
||||
-0.09647644, 0.8622859, 0.4971472
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
Type = 'RenderableSphericalGrid',
|
||||
Enabled = false,
|
||||
Opacity = 0.3,
|
||||
Color = { 0.3, 0.84, 1.0},
|
||||
LineWidth = linewidth
|
||||
},
|
||||
GUI = {
|
||||
Name = name,
|
||||
Path = '/' .. guiPath
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
Type = 'RenderableSphericalGrid',
|
||||
Enabled = false,
|
||||
Opacity = 0.3,
|
||||
Color = { 0.3, 0.84, 1.0},
|
||||
LineWidth = linewidth
|
||||
},
|
||||
GUI = {
|
||||
Name = name,
|
||||
Path = '/' .. guiPath
|
||||
}
|
||||
}
|
||||
|
||||
if (group ~= '') then
|
||||
sgn.GUI.Path = sgn.GUI.Path .. '/' .. group
|
||||
end
|
||||
|
||||
if (globe == '') then
|
||||
sgn.Transform.Translation = {
|
||||
Type = 'StaticTranslation',
|
||||
Position = {
|
||||
tonumber(x) * PARSEC_CONSTANT,
|
||||
tonumber(y) * PARSEC_CONSTANT,
|
||||
tonumber(z) * PARSEC_CONSTANT
|
||||
}
|
||||
}
|
||||
|
||||
if (group ~= '') then
|
||||
sgn.GUI.Path = sgn.GUI.Path .. '/' .. group
|
||||
end
|
||||
|
||||
if (globe == '') then
|
||||
sgn.Transform.Translation = {
|
||||
Type = 'StaticTranslation',
|
||||
Position = {
|
||||
tonumber(x) * PARSEC_CONSTANT,
|
||||
tonumber(y) * PARSEC_CONSTANT,
|
||||
tonumber(z) * PARSEC_CONSTANT
|
||||
}
|
||||
}
|
||||
else
|
||||
sgn.Transform.Translation = {
|
||||
Type = 'GlobeTranslation',
|
||||
Globe = globe,
|
||||
Latitude = tonumber(lat),
|
||||
Longitude = tonumber(lon)
|
||||
}
|
||||
if (altitude == nil) then
|
||||
sgn.Transform.Translation.UseHeightMap = true;
|
||||
else
|
||||
sgn.Transform.Translation.UseHeightMap = false;
|
||||
sgn.Transform.Translation.Altitude = tonumber(altitude);
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(genBookmarks, sgn);
|
||||
else
|
||||
notFirstLine = true
|
||||
sgn.Transform.Translation = {
|
||||
Type = 'GlobeTranslation',
|
||||
Globe = globe,
|
||||
Latitude = tonumber(lat),
|
||||
Longitude = tonumber(lon)
|
||||
}
|
||||
if (altitude == nil) then
|
||||
sgn.Transform.Translation.UseHeightMap = true;
|
||||
else
|
||||
sgn.Transform.Translation.UseHeightMap = false;
|
||||
sgn.Transform.Translation.Altitude = tonumber(altitude);
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(genBookmarks, sgn);
|
||||
else
|
||||
notFirstLine = true
|
||||
end
|
||||
end
|
||||
return genBookmarks
|
||||
end
|
||||
|
||||
+13
-13
@@ -1,18 +1,18 @@
|
||||
asset.onInitialize(function()
|
||||
openspace.clearKeys()
|
||||
openspace.bindKey("RIGHT", "openspace.navigation.addGlobalRotation(-5.0, 0.0)");
|
||||
openspace.bindKey("LEFT", "openspace.navigation.addGlobalRotation(5.0, 0.0)");
|
||||
openspace.bindKey("UP", "openspace.navigation.addGlobalRotation(0.0, 5.0)");
|
||||
openspace.bindKey("DOWN", "openspace.navigation.addGlobalRotation(0.0, -5.0)");
|
||||
openspace.clearKeys()
|
||||
openspace.bindKey("RIGHT", "openspace.navigation.addGlobalRotation(-5.0, 0.0)");
|
||||
openspace.bindKey("LEFT", "openspace.navigation.addGlobalRotation(5.0, 0.0)");
|
||||
openspace.bindKey("UP", "openspace.navigation.addGlobalRotation(0.0, 5.0)");
|
||||
openspace.bindKey("DOWN", "openspace.navigation.addGlobalRotation(0.0, -5.0)");
|
||||
|
||||
openspace.bindKey("CTRL+RIGHT", "openspace.navigation.addLocalRotation(-5.0, 0.0)");
|
||||
openspace.bindKey("CTRL+LEFT", "openspace.navigation.addLocalRotation(5.0, 0.0)");
|
||||
openspace.bindKey("CTRL+UP", "openspace.navigation.addLocalRotation(0.0, 5.0)");
|
||||
openspace.bindKey("CTRL+DOWN", "openspace.navigation.addLocalRotation(0.0, -5.0)");
|
||||
openspace.bindKey("CTRL+RIGHT", "openspace.navigation.addLocalRotation(-5.0, 0.0)");
|
||||
openspace.bindKey("CTRL+LEFT", "openspace.navigation.addLocalRotation(5.0, 0.0)");
|
||||
openspace.bindKey("CTRL+UP", "openspace.navigation.addLocalRotation(0.0, 5.0)");
|
||||
openspace.bindKey("CTRL+DOWN", "openspace.navigation.addLocalRotation(0.0, -5.0)");
|
||||
|
||||
openspace.bindKey("ALT+UP", "openspace.navigation.addTruckMovement(0.0, 5.0)");
|
||||
openspace.bindKey("ALT+DOWN", "openspace.navigation.addTruckMovement(0.0, -5.0)");
|
||||
openspace.bindKey("ALT+UP", "openspace.navigation.addTruckMovement(0.0, 5.0)");
|
||||
openspace.bindKey("ALT+DOWN", "openspace.navigation.addTruckMovement(0.0, -5.0)");
|
||||
|
||||
openspace.bindKey("SPACE", "openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Aim', '');openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Anchor', 'Moon');openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.RetargetAnchor', nil);")
|
||||
openspace.bindKey("Z", "openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Aim', '');openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Anchor', 'Earth');openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.RetargetAnchor', nil);")
|
||||
openspace.bindKey("SPACE", "openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Aim', '');openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Anchor', 'Moon');openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.RetargetAnchor', nil);")
|
||||
openspace.bindKey("Z", "openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Aim', '');openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Anchor', 'Earth');openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.RetargetAnchor', nil);")
|
||||
end)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
local DataPath = asset.syncedResource({
|
||||
Name = "Launcher Images",
|
||||
Type = "HttpSynchronization",
|
||||
Identifier = "launcher_images",
|
||||
Version = 1
|
||||
Name = "Launcher Images",
|
||||
Type = "HttpSynchronization",
|
||||
Identifier = "launcher_images",
|
||||
Version = 1
|
||||
})
|
||||
asset.export("DataPath", DataPath)
|
||||
|
||||
@@ -2,119 +2,119 @@ asset.require('spice/base')
|
||||
|
||||
local createGlobeWithoutName = function(identifier, parent, parentSpiceName, spiceName,
|
||||
radii, tags, trailTags, guiPath, trailColor, orbitPeriod, kernels)
|
||||
return {
|
||||
Identifier = identifier,
|
||||
Parent = parent,
|
||||
Transform = {
|
||||
Translation = {
|
||||
Type = "SpiceTranslation",
|
||||
Target = spiceName,
|
||||
Observer = parentSpiceName,
|
||||
Kernels = kernels
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
Type = "RenderableGlobe",
|
||||
Radii = radii,
|
||||
SegmentsPerPatch = 64,
|
||||
Layers = {},
|
||||
Tag = tags
|
||||
},
|
||||
GUI = {
|
||||
Path = guiPath
|
||||
return {
|
||||
Identifier = identifier,
|
||||
Parent = parent,
|
||||
Transform = {
|
||||
Translation = {
|
||||
Type = "SpiceTranslation",
|
||||
Target = spiceName,
|
||||
Observer = parentSpiceName,
|
||||
Kernels = kernels
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
Type = "RenderableGlobe",
|
||||
Radii = radii,
|
||||
SegmentsPerPatch = 64,
|
||||
Layers = {},
|
||||
Tag = tags
|
||||
},
|
||||
GUI = {
|
||||
Path = guiPath
|
||||
}
|
||||
},
|
||||
{
|
||||
Identifier = identifier .. "Trail",
|
||||
Parent = parent,
|
||||
Renderable = {
|
||||
Type = "RenderableTrailOrbit",
|
||||
Translation = {
|
||||
Type = "SpiceTranslation",
|
||||
Target = spiceName,
|
||||
Observer = parentSpiceName
|
||||
},
|
||||
Color = trailColor,
|
||||
Period = orbitPeriod,
|
||||
Resolution = 1000,
|
||||
Tag = trailTags,
|
||||
},
|
||||
{
|
||||
Identifier = identifier .. "Trail",
|
||||
Parent = parent,
|
||||
Renderable = {
|
||||
Type = "RenderableTrailOrbit",
|
||||
Translation = {
|
||||
Type = "SpiceTranslation",
|
||||
Target = spiceName,
|
||||
Observer = parentSpiceName
|
||||
},
|
||||
Color = trailColor,
|
||||
Period = orbitPeriod,
|
||||
Resolution = 1000,
|
||||
Tag = trailTags,
|
||||
},
|
||||
GUI = {
|
||||
Path = guiPath
|
||||
}
|
||||
GUI = {
|
||||
Path = guiPath
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
local createGlobeWithName = function(identifier, name, parent, parentSpiceName, spiceName,
|
||||
radii, tags, trailTags, guiPath, trailColor, orbitPeriod, kernels, layers)
|
||||
g, t = createGlobeWithoutName(identifier, parent, parentSpiceName, spiceName, radii,
|
||||
tags, trailTags, guiPath, trailColor, orbitPeriod, kernels, layers)
|
||||
g.GUI.Name = name
|
||||
t.GUI.Name = name .. " Trail"
|
||||
g, t = createGlobeWithoutName(identifier, parent, parentSpiceName, spiceName, radii,
|
||||
tags, trailTags, guiPath, trailColor, orbitPeriod, kernels, layers)
|
||||
g.GUI.Name = name
|
||||
t.GUI.Name = name .. " Trail"
|
||||
|
||||
return g, t
|
||||
return g, t
|
||||
end
|
||||
asset.export("createGlobeWithoutName", createGlobeWithoutName)
|
||||
asset.export("createGlobeWithName", createGlobeWithName)
|
||||
|
||||
|
||||
local createGlobes = function(t)
|
||||
for _,v in pairs(t) do
|
||||
if type(v) ~= "table" then
|
||||
local warning = "The table passed to 'createGlobes' was not a table of tables"
|
||||
openspace.printWarning(warning)
|
||||
-- We return an empty table of tables to silence a potential future warning
|
||||
return {{}}
|
||||
end
|
||||
for _,v in pairs(t) do
|
||||
if type(v) ~= "table" then
|
||||
local warning = "The table passed to 'createGlobes' was not a table of tables"
|
||||
openspace.printWarning(warning)
|
||||
-- We return an empty table of tables to silence a potential future warning
|
||||
return {{}}
|
||||
end
|
||||
end
|
||||
|
||||
local result = {}
|
||||
|
||||
for i, v in ipairs(t) do
|
||||
local globe = nil
|
||||
local trail = nil
|
||||
if not v.Layers then
|
||||
v.Layers = {}
|
||||
end
|
||||
if not v.TrailTags then
|
||||
v.TrailTags = {}
|
||||
end
|
||||
if v.Name then
|
||||
globe, trail = createGlobeWithName(
|
||||
v.Identifier,
|
||||
v.GUI.Name,
|
||||
v.Parent.Identifier,
|
||||
v.Parent.Spice,
|
||||
v.Spice,
|
||||
v.Radii,
|
||||
v.Tags,
|
||||
v.TrailTags,
|
||||
v.GUI.Path,
|
||||
v.TrailColor,
|
||||
v.OrbitPeriod,
|
||||
v.Kernels,
|
||||
v.Layers
|
||||
)
|
||||
else
|
||||
globe, trail = createGlobeWithoutName(
|
||||
v.Identifier,
|
||||
v.Parent.Identifier,
|
||||
v.Parent.Spice,
|
||||
v.Spice,
|
||||
v.Radii,
|
||||
v.Tags,
|
||||
v.TrailTags,
|
||||
v.GUI.Path,
|
||||
v.TrailColor,
|
||||
v.OrbitPeriod,
|
||||
v.Kernels,
|
||||
v.Layers
|
||||
)
|
||||
end
|
||||
|
||||
local result = {}
|
||||
|
||||
for i, v in ipairs(t) do
|
||||
local globe = nil
|
||||
local trail = nil
|
||||
if not v.Layers then
|
||||
v.Layers = {}
|
||||
end
|
||||
if not v.TrailTags then
|
||||
v.TrailTags = {}
|
||||
end
|
||||
if v.Name then
|
||||
globe, trail = createGlobeWithName(
|
||||
v.Identifier,
|
||||
v.GUI.Name,
|
||||
v.Parent.Identifier,
|
||||
v.Parent.Spice,
|
||||
v.Spice,
|
||||
v.Radii,
|
||||
v.Tags,
|
||||
v.TrailTags,
|
||||
v.GUI.Path,
|
||||
v.TrailColor,
|
||||
v.OrbitPeriod,
|
||||
v.Kernels,
|
||||
v.Layers
|
||||
)
|
||||
else
|
||||
globe, trail = createGlobeWithoutName(
|
||||
v.Identifier,
|
||||
v.Parent.Identifier,
|
||||
v.Parent.Spice,
|
||||
v.Spice,
|
||||
v.Radii,
|
||||
v.Tags,
|
||||
v.TrailTags,
|
||||
v.GUI.Path,
|
||||
v.TrailColor,
|
||||
v.OrbitPeriod,
|
||||
v.Kernels,
|
||||
v.Layers
|
||||
)
|
||||
end
|
||||
|
||||
table.insert(result, globe)
|
||||
table.insert(result, trail)
|
||||
end
|
||||
return result
|
||||
table.insert(result, globe)
|
||||
table.insert(result, trail)
|
||||
end
|
||||
return result
|
||||
end
|
||||
asset.export("createGlobes", createGlobes)
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
-- Function that returns the string that inverts the fully qualified boolean property 'property'
|
||||
local invert = function(prop)
|
||||
local escaped_property = "'" .. prop .. "'"
|
||||
return "openspace.setPropertyValueSingle(" .. escaped_property .. ", not openspace.getPropertyValue(" .. escaped_property .. "));"
|
||||
local escaped_property = "'" .. prop .. "'"
|
||||
return "openspace.setPropertyValueSingle(" .. escaped_property .. ", not openspace.getPropertyValue(" .. escaped_property .. "));"
|
||||
end
|
||||
|
||||
-- Function that returns the string that increments the 'property' by the 'value'
|
||||
local increment = function(prop, value)
|
||||
local v = value or 1
|
||||
local escaped_property = "'" .. prop .. "'"
|
||||
return "openspace.setPropertyValueSingle(" .. escaped_property .. ", openspace.getPropertyValue(" .. escaped_property .. ") + " .. v .. ");"
|
||||
local v = value or 1
|
||||
local escaped_property = "'" .. prop .. "'"
|
||||
return "openspace.setPropertyValueSingle(" .. escaped_property .. ", openspace.getPropertyValue(" .. escaped_property .. ") + " .. v .. ");"
|
||||
end
|
||||
|
||||
-- Function that returns the string that decrements the 'property' by the 'value'
|
||||
local decrement = function(prop, value)
|
||||
return increment(prop, -value)
|
||||
return increment(prop, -value)
|
||||
end
|
||||
|
||||
local fade = function(prop, value, duration)
|
||||
assert(type(prop) == "string", "prop must be a number")
|
||||
assert(type(duration) == "number", "duration must be a number")
|
||||
assert(type(prop) == "string", "prop must be a number")
|
||||
assert(type(duration) == "number", "duration must be a number")
|
||||
|
||||
local escaped_property = "'" .. prop .. "'"
|
||||
return "openspace.setPropertyValueSingle(" .. escaped_property ..", " .. tostring(value) .. ", " .. tostring(duration) .. ")"
|
||||
local escaped_property = "'" .. prop .. "'"
|
||||
return "openspace.setPropertyValueSingle(" .. escaped_property ..", " .. tostring(value) .. ", " .. tostring(duration) .. ")"
|
||||
end
|
||||
|
||||
local fadeOut = function(prop, duration)
|
||||
return fade(prop, 0.0, duration)
|
||||
return fade(prop, 0.0, duration)
|
||||
end
|
||||
|
||||
local fadeIn = function(prop, duration)
|
||||
return fade(prop, 1.0, duration)
|
||||
return fade(prop, 1.0, duration)
|
||||
end
|
||||
|
||||
local fadeInOut = function(prop, duration)
|
||||
assert(type(prop) == "string", "prop must be a number")
|
||||
assert(type(duration) == "number", "duration must be a number")
|
||||
assert(type(prop) == "string", "prop must be a number")
|
||||
assert(type(duration) == "number", "duration must be a number")
|
||||
|
||||
local escaped_property = "'" .. prop .. "'"
|
||||
-- If the value is > 0.5 fade out, otherwise fade in
|
||||
return "local v = openspace.getPropertyValue(" .. escaped_property .. "); if v <= 0.5 then " .. fadeIn(prop, duration) .. " else " .. fadeOut(prop, duration) .. " end"
|
||||
local escaped_property = "'" .. prop .. "'"
|
||||
-- If the value is > 0.5 fade out, otherwise fade in
|
||||
return "local v = openspace.getPropertyValue(" .. escaped_property .. "); if v <= 0.5 then " .. fadeIn(prop, duration) .. " else " .. fadeOut(prop, duration) .. " end"
|
||||
end
|
||||
|
||||
asset.export('invert', invert)
|
||||
|
||||
@@ -2,12 +2,12 @@ local propertyHelper = asset.require('./property_helper')
|
||||
|
||||
-- Function that returns the string that enables/disables the renderable 'renderable'
|
||||
local toggle = function(renderable)
|
||||
return propertyHelper.invert(renderable .. ".Renderable.Enabled")
|
||||
return propertyHelper.invert(renderable .. ".Renderable.Enabled")
|
||||
end
|
||||
|
||||
-- Function that returns the string that sets the enabled property of <renderable> to <enabled>
|
||||
local setEnabled = function(renderable, enabled)
|
||||
return "openspace.setPropertyValue('" .. renderable .. ".Renderable.Enabled', " .. (enabled and "true" or "false") .. ");";
|
||||
return "openspace.setPropertyValue('" .. renderable .. ".Renderable.Enabled', " .. (enabled and "true" or "false") .. ");";
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -1,108 +1,108 @@
|
||||
local bindKeys = function(t, ignoreWarning)
|
||||
ignoreWarning = ignoreWarning or false
|
||||
for _, k in ipairs(t) do
|
||||
assert(k.Key, 'No key provided')
|
||||
assert(k.Command, 'No command provided for key ' .. k.Key)
|
||||
ignoreWarning = ignoreWarning or false
|
||||
for _, k in ipairs(t) do
|
||||
assert(k.Key, 'No key provided')
|
||||
assert(k.Command, 'No command provided for key ' .. k.Key)
|
||||
|
||||
k.Name = k.Name or k.Key
|
||||
k.GuiPath = k.GuiPath or ''
|
||||
k.Name = k.Name or k.Key
|
||||
k.GuiPath = k.GuiPath or ''
|
||||
|
||||
local currentKey = openspace.getKeyBinding(k.Key)
|
||||
if (next(currentKey) ~= nil) and (not ignoreWarning) then
|
||||
openspace.printWarning('New keybind for "' .. k.Key .. '" is added, but a previous keybind already existed. If you want to silence this warning, pass "true", to this call to bindKeys')
|
||||
end
|
||||
|
||||
if k.Local then
|
||||
openspace.bindKeyLocal(k.Key, k.Command, k.Documentation, k.Name, k.GuiPath)
|
||||
else
|
||||
openspace.bindKey(k.Key, k.Command, k.Documentation, k.Name, k.GuiPath)
|
||||
end
|
||||
local currentKey = openspace.getKeyBinding(k.Key)
|
||||
if (next(currentKey) ~= nil) and (not ignoreWarning) then
|
||||
openspace.printWarning('New keybind for "' .. k.Key .. '" is added, but a previous keybind already existed. If you want to silence this warning, pass "true", to this call to bindKeys')
|
||||
end
|
||||
|
||||
if k.Local then
|
||||
openspace.bindKeyLocal(k.Key, k.Command, k.Documentation, k.Name, k.GuiPath)
|
||||
else
|
||||
openspace.bindKey(k.Key, k.Command, k.Documentation, k.Name, k.GuiPath)
|
||||
end
|
||||
end
|
||||
end
|
||||
asset.export("bindKeys", bindKeys)
|
||||
|
||||
local unbindKeys = function(keys)
|
||||
-- We check against k and k.Key to provide compatability
|
||||
-- for both calls with the same table that goes to bindKeys
|
||||
-- as well as the return values from setDeltaTimeKeys
|
||||
for _, k in ipairs(keys) do
|
||||
openspace.clearKey(k.Key or k)
|
||||
end
|
||||
-- We check against k and k.Key to provide compatability
|
||||
-- for both calls with the same table that goes to bindKeys
|
||||
-- as well as the return values from setDeltaTimeKeys
|
||||
for _, k in ipairs(keys) do
|
||||
openspace.clearKey(k.Key or k)
|
||||
end
|
||||
end
|
||||
asset.export("unbindKeys", unbindKeys)
|
||||
|
||||
--shortcut function
|
||||
local function has_value (tab, val)
|
||||
for index, value in ipairs(tab) do
|
||||
-- We grab the first index of our sub-table instead
|
||||
if value[1] == val then
|
||||
return true
|
||||
end
|
||||
for index, value in ipairs(tab) do
|
||||
-- We grab the first index of our sub-table instead
|
||||
if value[1] == val then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
return false
|
||||
end
|
||||
|
||||
local extractShortcuts = function(names, shortcuts)
|
||||
local foundShortcuts = {};
|
||||
local foundShortcuts = {};
|
||||
|
||||
if type(names) ~= "table" then
|
||||
openspace.printWarning("scene_helper.extractShortcuts invalid paramater names (not Table)")
|
||||
if type(names) ~= "table" then
|
||||
openspace.printWarning("scene_helper.extractShortcuts invalid paramater names (not Table)")
|
||||
end
|
||||
|
||||
if type(shortcuts) ~= "table" then
|
||||
openspace.printWarning("scene_helper.extractShortcuts invalid paramater shortcuts (not Table)")
|
||||
end
|
||||
|
||||
for _, shortcut in ipairs(shortcuts) do
|
||||
for _, name in ipairs(names ) do
|
||||
if (shortcut.Name == name) then
|
||||
foundShortcuts[#foundShortcuts+1] = shortcut
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if type(shortcuts) ~= "table" then
|
||||
openspace.printWarning("scene_helper.extractShortcuts invalid paramater shortcuts (not Table)")
|
||||
end
|
||||
|
||||
for _, shortcut in ipairs(shortcuts) do
|
||||
for _, name in ipairs(names ) do
|
||||
if (shortcut.Name == name) then
|
||||
foundShortcuts[#foundShortcuts+1] = shortcut
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return foundShortcuts
|
||||
return foundShortcuts
|
||||
end
|
||||
asset.export("extractShortcuts", extractShortcuts)
|
||||
|
||||
local createKeyBindFromShortcuts = function(key, shortcuts, guipath, title, documentation)
|
||||
if type(key) ~= "string" then
|
||||
openspace.printWarning("scene_helper.createKeyBindFromShortcuts invalid paramater key (not String)")
|
||||
if type(key) ~= "string" then
|
||||
openspace.printWarning("scene_helper.createKeyBindFromShortcuts invalid paramater key (not String)")
|
||||
end
|
||||
|
||||
if type(shortcuts) ~= "table" or #shortcuts == 0 then
|
||||
openspace.printWarning("scene_helper.createKeyBindFromShortcuts invalid paramater shortcuts (not Table or empty)")
|
||||
end
|
||||
|
||||
-- if type(guipath) ~= "string" then
|
||||
-- guipath = shortcuts[0].GuiPath
|
||||
-- end
|
||||
|
||||
local concatTitle = type(title) ~= "string"
|
||||
local concatDocumentation = type(documentation) ~= "string"
|
||||
|
||||
local keybind = {
|
||||
Key = key,
|
||||
Command = "",
|
||||
Name = name or "",
|
||||
Documentation = documentation or "",
|
||||
GuiPath = guipath or "",
|
||||
Local = false
|
||||
}
|
||||
|
||||
for _, shortcut in ipairs(shortcuts) do
|
||||
keybind.Command = keybind.Command .. shortcut.Command
|
||||
if concatTitle then
|
||||
keybind.Name = keybind.Name .. "/" .. shortcut.Name
|
||||
end
|
||||
if concatDocumentation then
|
||||
keybind.Documentation = keybind.Documentation .. "," .. shortcut.Documentation
|
||||
end
|
||||
|
||||
if type(shortcuts) ~= "table" or #shortcuts == 0 then
|
||||
openspace.printWarning("scene_helper.createKeyBindFromShortcuts invalid paramater shortcuts (not Table or empty)")
|
||||
end
|
||||
keybind.Local = keybind.Local and shortcut.Local
|
||||
end
|
||||
|
||||
-- if type(guipath) ~= "string" then
|
||||
-- guipath = shortcuts[0].GuiPath
|
||||
-- end
|
||||
|
||||
local concatTitle = type(title) ~= "string"
|
||||
local concatDocumentation = type(documentation) ~= "string"
|
||||
|
||||
local keybind = {
|
||||
Key = key,
|
||||
Command = "",
|
||||
Name = name or "",
|
||||
Documentation = documentation or "",
|
||||
GuiPath = guipath or "",
|
||||
Local = false
|
||||
}
|
||||
|
||||
for _, shortcut in ipairs(shortcuts) do
|
||||
keybind.Command = keybind.Command .. shortcut.Command
|
||||
if concatTitle then
|
||||
keybind.Name = keybind.Name .. "/" .. shortcut.Name
|
||||
end
|
||||
if concatDocumentation then
|
||||
keybind.Documentation = keybind.Documentation .. "," .. shortcut.Documentation
|
||||
end
|
||||
|
||||
keybind.Local = keybind.Local and shortcut.Local
|
||||
end
|
||||
|
||||
return keybind
|
||||
return keybind
|
||||
end
|
||||
asset.export("createKeyBindFromShortcuts", createKeyBindFromShortcuts)
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
asset.onInitialize(function ()
|
||||
-- Disable the server, add production gui endpoint, and restart server.
|
||||
-- The temporary disabling avoids restarting the server on each property change.
|
||||
-- TODO: Add a trigger property to the module to restart the server "manually"
|
||||
-- and remove automatic restart on each property change,
|
||||
-- since frequent restarting seems to be unstable on mac.
|
||||
-- Disable the server, add production gui endpoint, and restart server.
|
||||
-- The temporary disabling avoids restarting the server on each property change.
|
||||
-- TODO: Add a trigger property to the module to restart the server "manually"
|
||||
-- and remove automatic restart on each property change,
|
||||
-- since frequent restarting seems to be unstable on mac.
|
||||
|
||||
local enabled = openspace.getPropertyValue("Modules.WebGui.ServerProcessEnabled")
|
||||
openspace.setPropertyValueSingle("Modules.WebGui.ServerProcessEnabled", false)
|
||||
local enabled = openspace.getPropertyValue("Modules.WebGui.ServerProcessEnabled")
|
||||
openspace.setPropertyValueSingle("Modules.WebGui.ServerProcessEnabled", false)
|
||||
|
||||
local directories = openspace.getPropertyValue("Modules.WebGui.Directories")
|
||||
directories[#directories + 1] = "screenshots"
|
||||
directories[#directories + 1] = "${SCREENSHOTS}"
|
||||
openspace.setPropertyValueSingle("Modules.WebGui.Directories", directories)
|
||||
openspace.setPropertyValueSingle("Modules.WebGui.ServerProcessEnabled", enabled)
|
||||
local directories = openspace.getPropertyValue("Modules.WebGui.Directories")
|
||||
directories[#directories + 1] = "screenshots"
|
||||
directories[#directories + 1] = "${SCREENSHOTS}"
|
||||
openspace.setPropertyValueSingle("Modules.WebGui.Directories", directories)
|
||||
openspace.setPropertyValueSingle("Modules.WebGui.ServerProcessEnabled", enabled)
|
||||
end)
|
||||
|
||||
asset.onDeinitialize(function ()
|
||||
-- TODO: Remove endpoints. As of 2019-10-29, OpenSpace sometimes
|
||||
-- crashes when endpoints are removed while the application is closing.
|
||||
-- TODO: Remove endpoints. As of 2019-10-29, OpenSpace sometimes
|
||||
-- crashes when endpoints are removed while the application is closing.
|
||||
end)
|
||||
|
||||
@@ -3,21 +3,21 @@ local renderableHelper = asset.require('./renderable_helper')
|
||||
-- Function that schedules scripts setting the enabled property
|
||||
-- of <renderable> to <enabled> at time <time>.
|
||||
local scheduleRenderableEnabled = function(time, renderable, enabled)
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
time,
|
||||
renderableHelper.setEnabled(renderable, enabled)
|
||||
)
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
time,
|
||||
renderableHelper.setEnabled(renderable, enabled)
|
||||
)
|
||||
end
|
||||
|
||||
-- Function that schedules scripts setting the enabled property
|
||||
-- of <renderable> to <enabled> when time <time> is passed
|
||||
-- and inverts it if time is passed in reversed order.
|
||||
local scheduleRenderableEnabledReversable = function(time, renderable, enabled)
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
time,
|
||||
renderableHelper.setEnabled(renderable, enabled),
|
||||
renderableHelper.setEnabled(renderable, not enabled)
|
||||
)
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
time,
|
||||
renderableHelper.setEnabled(renderable, enabled),
|
||||
renderableHelper.setEnabled(renderable, not enabled)
|
||||
)
|
||||
end
|
||||
|
||||
asset.export('scheduleRenderableEnabledReversable', scheduleRenderableEnabledReversable)
|
||||
|
||||
@@ -1,99 +1,99 @@
|
||||
local createDeck = function (identifier, defaultRenderableProperties)
|
||||
return {
|
||||
SlideIdentifiers = {},
|
||||
IdentifierPrefix = identifier,
|
||||
CurrentSlideIndex = 1,
|
||||
DefaultRenderableProperties = defaultRenderableProperties,
|
||||
Visible = true
|
||||
}
|
||||
return {
|
||||
SlideIdentifiers = {},
|
||||
IdentifierPrefix = identifier,
|
||||
CurrentSlideIndex = 1,
|
||||
DefaultRenderableProperties = defaultRenderableProperties,
|
||||
Visible = true
|
||||
}
|
||||
end
|
||||
|
||||
local removeDeck = function (deck)
|
||||
for i, identifier in pairs(deck.SlideIdentifiers) do
|
||||
openspace.removeScreenSpaceRenderable(identifier)
|
||||
end
|
||||
for i, identifier in pairs(deck.SlideIdentifiers) do
|
||||
openspace.removeScreenSpaceRenderable(identifier)
|
||||
end
|
||||
end
|
||||
|
||||
local addSlide = function (deck, path)
|
||||
local index = #deck.SlideIdentifiers + 1
|
||||
local identifier = deck.IdentifierPrefix .. index
|
||||
local index = #deck.SlideIdentifiers + 1
|
||||
local identifier = deck.IdentifierPrefix .. index
|
||||
|
||||
local spec = {
|
||||
Type = "ScreenSpaceImageLocal",
|
||||
Identifier = identifier,
|
||||
Name = identifier,
|
||||
TexturePath = path
|
||||
};
|
||||
local spec = {
|
||||
Type = "ScreenSpaceImageLocal",
|
||||
Identifier = identifier,
|
||||
Name = identifier,
|
||||
TexturePath = path
|
||||
};
|
||||
|
||||
for key, value in pairs(deck.DefaultRenderableProperties) do
|
||||
spec[key] = value
|
||||
end
|
||||
for key, value in pairs(deck.DefaultRenderableProperties) do
|
||||
spec[key] = value
|
||||
end
|
||||
|
||||
openspace.addScreenSpaceRenderable(spec)
|
||||
openspace.addScreenSpaceRenderable(spec)
|
||||
|
||||
deck.SlideIdentifiers[#deck.SlideIdentifiers + 1] = identifier
|
||||
deck.SlideIdentifiers[#deck.SlideIdentifiers + 1] = identifier
|
||||
end
|
||||
|
||||
|
||||
local setCurrentSlide = function (deck, index, interpolationDuration)
|
||||
if (interpolationDuration == nil) then
|
||||
interpolationDuration = 0
|
||||
end
|
||||
if (interpolationDuration == nil) then
|
||||
interpolationDuration = 0
|
||||
end
|
||||
|
||||
if (index < 0) then
|
||||
index = 0
|
||||
end
|
||||
if (index < 0) then
|
||||
index = 0
|
||||
end
|
||||
|
||||
if (index > #deck.SlideIdentifiers + 1) then
|
||||
index = #deck.SlideIdentifiers + 1
|
||||
end
|
||||
if (index > #deck.SlideIdentifiers + 1) then
|
||||
index = #deck.SlideIdentifiers + 1
|
||||
end
|
||||
|
||||
deck.CurrentSlideIndex = index
|
||||
deck.CurrentSlideIndex = index
|
||||
|
||||
if not deck.Visible then
|
||||
return
|
||||
end
|
||||
if not deck.Visible then
|
||||
return
|
||||
end
|
||||
|
||||
for i, identifier in pairs(deck.SlideIdentifiers) do
|
||||
local opacity = 0
|
||||
if (index == i) then
|
||||
opacity = 1
|
||||
end
|
||||
if interpolationDuration == 0 then
|
||||
openspace.setPropertyValueSingle("ScreenSpace." .. identifier .. ".Opacity", opacity)
|
||||
else
|
||||
openspace.setPropertyValueSingle("ScreenSpace." .. identifier .. ".Opacity", opacity, interpolationDuration, "QuadraticEaseOut")
|
||||
end
|
||||
for i, identifier in pairs(deck.SlideIdentifiers) do
|
||||
local opacity = 0
|
||||
if (index == i) then
|
||||
opacity = 1
|
||||
end
|
||||
if interpolationDuration == 0 then
|
||||
openspace.setPropertyValueSingle("ScreenSpace." .. identifier .. ".Opacity", opacity)
|
||||
else
|
||||
openspace.setPropertyValueSingle("ScreenSpace." .. identifier .. ".Opacity", opacity, interpolationDuration, "QuadraticEaseOut")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local goToNextSlide = function (deck, interpolationDuration)
|
||||
setCurrentSlide(deck, deck.CurrentSlideIndex + 1, interpolationDuration)
|
||||
setCurrentSlide(deck, deck.CurrentSlideIndex + 1, interpolationDuration)
|
||||
end
|
||||
|
||||
local goToPreviousSlide = function (deck, interpolationDuration)
|
||||
setCurrentSlide(deck, deck.CurrentSlideIndex - 1, interpolationDuration)
|
||||
setCurrentSlide(deck, deck.CurrentSlideIndex - 1, interpolationDuration)
|
||||
end
|
||||
|
||||
local toggleSlides = function (deck, interpolationDuration)
|
||||
deck.Visible = not deck.Visible
|
||||
if deck.Visible then
|
||||
for i, identifier in pairs(deck.SlideIdentifiers) do
|
||||
local opacity = 0
|
||||
if (i == deck.CurrentSlideIndex) then
|
||||
opacity = 1
|
||||
end
|
||||
openspace.setPropertyValueSingle(
|
||||
"ScreenSpace." .. identifier .. ".Opacity", opacity,
|
||||
interpolationDuration, "QuadraticEaseOut")
|
||||
end
|
||||
else
|
||||
for i, identifier in pairs(deck.SlideIdentifiers) do
|
||||
openspace.setPropertyValueSingle(
|
||||
"ScreenSpace." .. identifier .. ".Opacity", 0,
|
||||
interpolationDuration, "QuadraticEaseOut")
|
||||
end
|
||||
deck.Visible = not deck.Visible
|
||||
if deck.Visible then
|
||||
for i, identifier in pairs(deck.SlideIdentifiers) do
|
||||
local opacity = 0
|
||||
if (i == deck.CurrentSlideIndex) then
|
||||
opacity = 1
|
||||
end
|
||||
openspace.setPropertyValueSingle(
|
||||
"ScreenSpace." .. identifier .. ".Opacity", opacity,
|
||||
interpolationDuration, "QuadraticEaseOut")
|
||||
end
|
||||
else
|
||||
for i, identifier in pairs(deck.SlideIdentifiers) do
|
||||
openspace.setPropertyValueSingle(
|
||||
"ScreenSpace." .. identifier .. ".Opacity", 0,
|
||||
interpolationDuration, "QuadraticEaseOut")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
asset.export('createDeck', createDeck)
|
||||
|
||||
@@ -1,58 +1,56 @@
|
||||
|
||||
local goToNextStateFunction = function (machine)
|
||||
if (machine.currentStateIndex >= #machine.states) then
|
||||
machine.currentStateIndex = #machine.states
|
||||
return
|
||||
end
|
||||
if (machine.currentStateIndex >= #machine.states) then
|
||||
machine.currentStateIndex = #machine.states
|
||||
return
|
||||
end
|
||||
|
||||
if (machine.currentStateIndex == 0) then
|
||||
openspace.printInfo("Starting state machine with " ..
|
||||
machine.states[machine.currentStateIndex + 1].Title)
|
||||
elseif (machine.currentStateIndex == #machine.states) then
|
||||
openspace.printInfo("Proceed from " ..
|
||||
machine.states[machine.currentStateIndex].Title
|
||||
)
|
||||
else
|
||||
openspace.printInfo("Proceed from " ..
|
||||
machine.states[machine.currentStateIndex].Title .. " to " ..
|
||||
machine.states[machine.currentStateIndex + 1].Title
|
||||
)
|
||||
end
|
||||
if (machine.currentStateIndex == 0) then
|
||||
openspace.printInfo("Starting state machine with " ..
|
||||
machine.states[machine.currentStateIndex + 1].Title)
|
||||
elseif (machine.currentStateIndex == #machine.states) then
|
||||
openspace.printInfo("Proceed from " ..
|
||||
machine.states[machine.currentStateIndex].Title
|
||||
)
|
||||
else
|
||||
openspace.printInfo("Proceed from " ..
|
||||
machine.states[machine.currentStateIndex].Title .. " to " ..
|
||||
machine.states[machine.currentStateIndex + 1].Title
|
||||
)
|
||||
end
|
||||
|
||||
machine.currentStateIndex = machine.currentStateIndex + 1
|
||||
machine.currentStateIndex = machine.currentStateIndex + 1
|
||||
|
||||
machine.states[machine.currentStateIndex].Play()
|
||||
machine.states[machine.currentStateIndex].Play()
|
||||
end
|
||||
|
||||
local goToPreviousStateFunction = function (machine)
|
||||
if (machine.currentStateIndex < 1) then
|
||||
machine.currentStateIndex = 0
|
||||
return
|
||||
end
|
||||
if (machine.currentStateIndex < 1) then
|
||||
machine.currentStateIndex = 0
|
||||
return
|
||||
end
|
||||
|
||||
if (machine.currentStateIndex == 1) then
|
||||
openspace.printInfo("Rewind from " ..
|
||||
machine.states[machine.currentStateIndex].Title
|
||||
)
|
||||
else
|
||||
openspace.printInfo("Rewind from " ..
|
||||
machine.states[machine.currentStateIndex].Title .. " to " ..
|
||||
machine.states[machine.currentStateIndex - 1].Title
|
||||
)
|
||||
end
|
||||
if (machine.currentStateIndex == 1) then
|
||||
openspace.printInfo("Rewind from " .. machine.states[machine.currentStateIndex].Title)
|
||||
else
|
||||
openspace.printInfo("Rewind from " ..
|
||||
machine.states[machine.currentStateIndex].Title .. " to " ..
|
||||
machine.states[machine.currentStateIndex - 1].Title
|
||||
)
|
||||
end
|
||||
|
||||
machine.states[machine.currentStateIndex].Rewind()
|
||||
machine.currentStateIndex = machine.currentStateIndex - 1
|
||||
machine.states[machine.currentStateIndex].Rewind()
|
||||
machine.currentStateIndex = machine.currentStateIndex - 1
|
||||
end
|
||||
|
||||
local createStateMachine = function (states)
|
||||
local machine = {
|
||||
states = states,
|
||||
currentStateIndex = 0
|
||||
}
|
||||
machine.goToNextState = function () goToNextStateFunction(machine) end
|
||||
machine.goToPreviousState = function () goToPreviousStateFunction(machine) end
|
||||
return machine
|
||||
local machine = {
|
||||
states = states,
|
||||
currentStateIndex = 0
|
||||
}
|
||||
machine.goToNextState = function () goToNextStateFunction(machine) end
|
||||
machine.goToPreviousState = function () goToPreviousStateFunction(machine) end
|
||||
return machine
|
||||
end
|
||||
|
||||
asset.export('createStateMachine', createStateMachine)
|
||||
|
||||
@@ -2,20 +2,20 @@ local backendHash = "7ca0a34e9c4c065b7bfad0623db0e322bf3e0af9"
|
||||
local dataProvider = "data.openspaceproject.com/files/webgui"
|
||||
|
||||
local backend = asset.syncedResource({
|
||||
Identifier = "WebGuiBackend",
|
||||
Name = "Web Gui Backend",
|
||||
Type = "UrlSynchronization",
|
||||
Url = dataProvider .. "/backend/" .. backendHash .. "/backend.zip"
|
||||
Identifier = "WebGuiBackend",
|
||||
Name = "Web Gui Backend",
|
||||
Type = "UrlSynchronization",
|
||||
Url = dataProvider .. "/backend/" .. backendHash .. "/backend.zip"
|
||||
})
|
||||
|
||||
asset.onInitialize(function ()
|
||||
-- Unzip the server bundle
|
||||
local dest = backend .. "/backend"
|
||||
if not openspace.directoryExists(dest) then
|
||||
openspace.unzipFile(backend .. "/backend.zip", dest, true)
|
||||
end
|
||||
-- Unzip the server bundle
|
||||
local dest = backend .. "/backend"
|
||||
if not openspace.directoryExists(dest) then
|
||||
openspace.unzipFile(backend .. "/backend.zip", dest, true)
|
||||
end
|
||||
|
||||
openspace.setPropertyValueSingle(
|
||||
"Modules.WebGui.ServerProcessEntryPoint", backend .. "/backend/backend.js"
|
||||
)
|
||||
openspace.setPropertyValueSingle(
|
||||
"Modules.WebGui.ServerProcessEntryPoint", backend .. "/backend/backend.js"
|
||||
)
|
||||
end)
|
||||
|
||||
@@ -4,20 +4,20 @@ local sceneHelper = asset.require('./scene_helper')
|
||||
local propertyHelper = asset.require('./property_helper')
|
||||
|
||||
local Keybindings = {
|
||||
{
|
||||
Key = "F7",
|
||||
Name = "Take Screenshot",
|
||||
Command = "openspace.takeScreenshot()",
|
||||
Documentation = "Saves the contents of the screen to a file in the ${SCREENSHOTS} directory.",
|
||||
GuiPath = "/Rendering",
|
||||
Local = true
|
||||
}
|
||||
{
|
||||
Key = "F7",
|
||||
Name = "Take Screenshot",
|
||||
Command = "openspace.takeScreenshot()",
|
||||
Documentation = "Saves the contents of the screen to a file in the ${SCREENSHOTS} directory.",
|
||||
GuiPath = "/Rendering",
|
||||
Local = true
|
||||
}
|
||||
}
|
||||
|
||||
asset.onInitialize(function()
|
||||
Keys = sceneHelper.bindKeys(Keybindings)
|
||||
Keys = sceneHelper.bindKeys(Keybindings)
|
||||
end)
|
||||
|
||||
asset.onDeinitialize(function ()
|
||||
sceneHelper.unbindKeys(Keybindings)
|
||||
sceneHelper.unbindKeys(Keybindings)
|
||||
end)
|
||||
|
||||
@@ -2,40 +2,40 @@ local transforms = asset.require('scene/solarsystem/planets/earth/transforms')
|
||||
local assetHelper = asset.require('util/asset_helper')
|
||||
|
||||
function downloadTLEFile(sceneAsset, url, name, filename)
|
||||
local identifier = name
|
||||
identifier = identifier:gsub(" ", "")
|
||||
identifier = identifier:gsub("&", "")
|
||||
identifier = identifier:gsub("-", "")
|
||||
local identifier = name
|
||||
identifier = identifier:gsub(" ", "")
|
||||
identifier = identifier:gsub("&", "")
|
||||
identifier = identifier:gsub("-", "")
|
||||
|
||||
local urlSyncTable = {
|
||||
Name = "Satellite TLE Data (" .. name .. ")",
|
||||
Type = "UrlSynchronization",
|
||||
Identifier = "satellite_tle_data_" .. identifier,
|
||||
Url = url,
|
||||
Override = true
|
||||
}
|
||||
local urlSyncTable = {
|
||||
Name = "Satellite TLE Data (" .. name .. ")",
|
||||
Type = "UrlSynchronization",
|
||||
Identifier = "satellite_tle_data_" .. identifier,
|
||||
Url = url,
|
||||
Override = true
|
||||
}
|
||||
|
||||
if (filename ~= '') then
|
||||
urlSyncTable.Filename = filename
|
||||
end
|
||||
if (filename ~= '') then
|
||||
urlSyncTable.Filename = filename
|
||||
end
|
||||
|
||||
return sceneAsset.syncedResource(urlSyncTable)
|
||||
return sceneAsset.syncedResource(urlSyncTable)
|
||||
end
|
||||
|
||||
-- Check format of a set of 3 TLE file lines and return nonzero if there is a format error
|
||||
function isValidTLEFileFormat(lineArr)
|
||||
local function isEmpty(s) return s == nil or s == '' end
|
||||
local function isEmpty(s) return s == nil or s == '' end
|
||||
|
||||
if isEmpty(lineArr[1]) or isEmpty(lineArr[2]) or isEmpty(lineArr[3]) then
|
||||
return false
|
||||
end
|
||||
if string.sub(lineArr[2], 1, 2) ~= "1 " then
|
||||
return false
|
||||
end
|
||||
if string.sub(lineArr[3], 1, 2) ~= "2 " then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
if isEmpty(lineArr[1]) or isEmpty(lineArr[2]) or isEmpty(lineArr[3]) then
|
||||
return false
|
||||
end
|
||||
if string.sub(lineArr[2], 1, 2) ~= "1 " then
|
||||
return false
|
||||
end
|
||||
if string.sub(lineArr[3], 1, 2) ~= "2 " then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local makeSingleLineElement = function(tle, filename)
|
||||
@@ -43,7 +43,7 @@ local makeSingleLineElement = function(tle, filename)
|
||||
local file = io.open(path, "r")
|
||||
assert(file, "File not found: " .. path)
|
||||
|
||||
local line = {
|
||||
local line = {
|
||||
file:read('*l'), --title line
|
||||
file:read('*l'),
|
||||
file:read('*l')
|
||||
@@ -61,9 +61,9 @@ local makeSingleLineElement = function(tle, filename)
|
||||
end
|
||||
|
||||
function numLinesInFile(filename)
|
||||
local ctr = 0
|
||||
for _ in io.lines(filename) do ctr = ctr + 1 end
|
||||
return ctr
|
||||
local ctr = 0
|
||||
for _ in io.lines(filename) do ctr = ctr + 1 end
|
||||
return ctr
|
||||
end
|
||||
|
||||
local getPeriodFromElement = function(element)
|
||||
@@ -76,34 +76,34 @@ local getPeriodFromElement = function(element)
|
||||
end
|
||||
|
||||
function satellites(title, file, color, group)
|
||||
return {
|
||||
Identifier = title,
|
||||
Parent = transforms.EarthInertial.Identifier,
|
||||
Renderable = {
|
||||
Type = "RenderableSatellites",
|
||||
Path = file,
|
||||
SegmentQuality = 3,
|
||||
Color = color,
|
||||
Fade = 1.5,
|
||||
RenderBinMode = "PostDeferredTransparent",
|
||||
StartRenderIdx = group.StartRenderIdx,
|
||||
RenderSize = group.RenderSize
|
||||
},
|
||||
Tag = { "earth_satellites" },
|
||||
GUI = {
|
||||
Path = "/Solar System/Planets/Earth/Satellites"
|
||||
}
|
||||
return {
|
||||
Identifier = title,
|
||||
Parent = transforms.EarthInertial.Identifier,
|
||||
Renderable = {
|
||||
Type = "RenderableSatellites",
|
||||
Path = file,
|
||||
SegmentQuality = 3,
|
||||
Color = color,
|
||||
Fade = 1.5,
|
||||
RenderBinMode = "PostDeferredTransparent",
|
||||
StartRenderIdx = group.StartRenderIdx,
|
||||
RenderSize = group.RenderSize
|
||||
},
|
||||
Tag = { "earth_satellites" },
|
||||
GUI = {
|
||||
Path = "/Solar System/Planets/Earth/Satellites"
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
local registerSatelliteGroupObjects = function(containingAsset, group, tleFolder, shouldAddDuplicates)
|
||||
local filename = group.Url:match("([^/]+)$")
|
||||
local filenameSansExt = filename:gsub(filename:match("(%.%w+)$"), "")
|
||||
local filename = group.Url:match("([^/]+)$")
|
||||
local filenameSansExt = filename:gsub(filename:match("(%.%w+)$"), "")
|
||||
|
||||
local path = tleFolder .. "/" .. filename
|
||||
local path = tleFolder .. "/" .. filename
|
||||
|
||||
local SatelliteBatch = satellites(filenameSansExt, path, group.TrailColor, group)
|
||||
assetHelper.registerSceneGraphNodesAndExport(containingAsset, { SatelliteBatch })
|
||||
local SatelliteBatch = satellites(filenameSansExt, path, group.TrailColor, group)
|
||||
assetHelper.registerSceneGraphNodesAndExport(containingAsset, { SatelliteBatch })
|
||||
end
|
||||
|
||||
asset.export("downloadTLEFile", downloadTLEFile)
|
||||
|
||||
@@ -1,49 +1,46 @@
|
||||
--vrt_slideshow_helper.asset
|
||||
local createFlipbook = function (assetPrefix, assetGlobe, count)
|
||||
return {
|
||||
AssetPrefix = assetPrefix,
|
||||
AssetGlobe = assetGlobe,
|
||||
TotalCount = count,
|
||||
CurrentFlipIndex = -1,
|
||||
}
|
||||
return {
|
||||
AssetPrefix = assetPrefix,
|
||||
AssetGlobe = assetGlobe,
|
||||
TotalCount = count,
|
||||
CurrentFlipIndex = -1,
|
||||
}
|
||||
end
|
||||
|
||||
local nextFlipbookPage = function (flipbook)
|
||||
if (flipbook.CurrentFlipIndex >= 0) then
|
||||
local assetSring = flipbook.AssetPrefix .. flipbook.CurrentFlipIndex;
|
||||
openspace.setPropertyValueSingle("Scene." .. flipbook.AssetGlobe .. ".Renderable.Layers.ColorLayers.".. assetSring .. ".Enabled", false)
|
||||
end
|
||||
|
||||
if (flipbook.CurrentFlipIndex >= 0) then
|
||||
local assetSring = flipbook.AssetPrefix .. flipbook.CurrentFlipIndex;
|
||||
openspace.setPropertyValueSingle("Scene." .. flipbook.AssetGlobe .. ".Renderable.Layers.ColorLayers.".. assetSring .. ".Enabled", false)
|
||||
end
|
||||
|
||||
if (flipbook.CurrentFlipIndex < flipbook.TotalCount - 1) then
|
||||
flipbook.CurrentFlipIndex = flipbook.CurrentFlipIndex + 1;
|
||||
local assetSring = flipbook.AssetPrefix .. flipbook.CurrentFlipIndex;
|
||||
openspace.setPropertyValueSingle("Scene." .. flipbook.AssetGlobe .. ".Renderable.Layers.ColorLayers.".. assetSring .. ".Enabled", true)
|
||||
end
|
||||
if (flipbook.CurrentFlipIndex < flipbook.TotalCount - 1) then
|
||||
flipbook.CurrentFlipIndex = flipbook.CurrentFlipIndex + 1;
|
||||
local assetSring = flipbook.AssetPrefix .. flipbook.CurrentFlipIndex;
|
||||
openspace.setPropertyValueSingle("Scene." .. flipbook.AssetGlobe .. ".Renderable.Layers.ColorLayers.".. assetSring .. ".Enabled", true)
|
||||
end
|
||||
end
|
||||
|
||||
local previousFlipbookPage = function (flipbook)
|
||||
local localIndex = flipbook.CurrentFlipIndex;
|
||||
|
||||
local localIndex = flipbook.CurrentFlipIndex;
|
||||
if (localIndex == -1) then
|
||||
return
|
||||
end
|
||||
|
||||
if (localIndex == -1) then
|
||||
return
|
||||
end
|
||||
local assetSring = flipbook.AssetPrefix .. localIndex;
|
||||
openspace.setPropertyValueSingle("Scene." .. flipbook.AssetGlobe .. ".Renderable.Layers.ColorLayers.".. assetSring .. ".Enabled", false)
|
||||
localIndex = localIndex - 1;
|
||||
|
||||
local assetSring = flipbook.AssetPrefix .. localIndex;
|
||||
openspace.setPropertyValueSingle("Scene." .. flipbook.AssetGlobe .. ".Renderable.Layers.ColorLayers.".. assetSring .. ".Enabled", false)
|
||||
localIndex = localIndex - 1;
|
||||
|
||||
if (localIndex >= 0 ) then
|
||||
assetSring = flipbook.AssetPrefix .. localIndex;
|
||||
openspace.setPropertyValueSingle("Scene." .. flipbook.AssetGlobe .. ".Renderable.Layers.ColorLayers.".. assetSring .. ".Enabled", true)
|
||||
end
|
||||
|
||||
if (localIndex < -1) then
|
||||
localIndex = -1
|
||||
end
|
||||
flipbook.CurrentFlipIndex = localIndex;
|
||||
if (localIndex >= 0 ) then
|
||||
assetSring = flipbook.AssetPrefix .. localIndex;
|
||||
openspace.setPropertyValueSingle("Scene." .. flipbook.AssetGlobe .. ".Renderable.Layers.ColorLayers.".. assetSring .. ".Enabled", true)
|
||||
end
|
||||
|
||||
if (localIndex < -1) then
|
||||
localIndex = -1
|
||||
end
|
||||
flipbook.CurrentFlipIndex = localIndex;
|
||||
end
|
||||
|
||||
asset.export('nextFlipbookPage', nextFlipbookPage)
|
||||
|
||||
@@ -3,96 +3,95 @@ asset.require('./static_server')
|
||||
local guiCustomization = asset.require('customization/gui')
|
||||
|
||||
-- Select which commit hashes to use for the frontend and backend
|
||||
local frontendHash = "02d6b86e40ea4db4bd8755bf7ade22fd9d839785"
|
||||
local frontendHash = "17b69f29a4a596d488ba8c9de953cc22fb0dce5c"
|
||||
local dataProvider = "data.openspaceproject.com/files/webgui"
|
||||
|
||||
local frontend = asset.syncedResource({
|
||||
Identifier = "WebGuiFrontend",
|
||||
Name = "Web Gui Frontend",
|
||||
Type = "UrlSynchronization",
|
||||
Url = dataProvider .. "/frontend/" .. frontendHash .. "/frontend.zip"
|
||||
Identifier = "WebGuiFrontend",
|
||||
Name = "Web Gui Frontend",
|
||||
Type = "UrlSynchronization",
|
||||
Url = dataProvider .. "/frontend/" .. frontendHash .. "/frontend.zip"
|
||||
})
|
||||
|
||||
asset.onInitialize(function ()
|
||||
-- Unzip the frontend bundle
|
||||
local dest = frontend .. "/frontend"
|
||||
if not openspace.directoryExists(dest) then
|
||||
openspace.unzipFile(frontend .. "/frontend.zip", dest, true)
|
||||
-- Unzip the frontend bundle
|
||||
local dest = frontend .. "/frontend"
|
||||
if not openspace.directoryExists(dest) then
|
||||
openspace.unzipFile(frontend .. "/frontend.zip", dest, true)
|
||||
end
|
||||
|
||||
-- Disable the server, add production gui endpoint, and restart server.
|
||||
-- The temporary disabling avoids restarting the server on each property change.
|
||||
-- TODO: Add a trigger property to the module to restart the server "manually"
|
||||
-- and remove automatic restart on each property change,
|
||||
-- since frequent restarting seems to be unstable on mac.
|
||||
|
||||
local enabled = openspace.getPropertyValue("Modules.WebGui.ServerProcessEnabled")
|
||||
openspace.setPropertyValueSingle("Modules.WebGui.ServerProcessEnabled", false)
|
||||
|
||||
local directories = openspace.getPropertyValue("Modules.WebGui.Directories")
|
||||
directories[#directories + 1] = "frontend"
|
||||
directories[#directories + 1] = frontend .. '/frontend'
|
||||
|
||||
openspace.setPropertyValueSingle("Modules.WebGui.Directories", directories)
|
||||
openspace.setPropertyValueSingle("Modules.WebGui.DefaultEndpoint", "frontend")
|
||||
openspace.setPropertyValueSingle("Modules.WebGui.ServerProcessEnabled", enabled)
|
||||
|
||||
-- The GUI contains date and simulation increment,
|
||||
-- so let's remove these from the dashboard.
|
||||
if openspace.getPropertyValue('Modules.CefWebGui.Visible') then
|
||||
if openspace.hasProperty('Dashboard.Date.Enabled') then
|
||||
openspace.setPropertyValueSingle('Dashboard.Date.Enabled', false)
|
||||
end
|
||||
|
||||
-- Disable the server, add production gui endpoint, and restart server.
|
||||
-- The temporary disabling avoids restarting the server on each property change.
|
||||
-- TODO: Add a trigger property to the module to restart the server "manually"
|
||||
-- and remove automatic restart on each property change,
|
||||
-- since frequent restarting seems to be unstable on mac.
|
||||
|
||||
local enabled = openspace.getPropertyValue("Modules.WebGui.ServerProcessEnabled")
|
||||
openspace.setPropertyValueSingle("Modules.WebGui.ServerProcessEnabled", false)
|
||||
|
||||
local directories = openspace.getPropertyValue("Modules.WebGui.Directories")
|
||||
directories[#directories + 1] = "frontend"
|
||||
directories[#directories + 1] = frontend .. '/frontend'
|
||||
|
||||
openspace.setPropertyValueSingle("Modules.WebGui.Directories", directories)
|
||||
openspace.setPropertyValueSingle("Modules.WebGui.DefaultEndpoint", "frontend")
|
||||
openspace.setPropertyValueSingle("Modules.WebGui.ServerProcessEnabled", enabled)
|
||||
|
||||
-- The GUI contains date and simulation increment,
|
||||
-- so let's remove these from the dashboard.
|
||||
if openspace.getPropertyValue('Modules.CefWebGui.Visible') then
|
||||
if openspace.hasProperty('Dashboard.Date.Enabled') then
|
||||
openspace.setPropertyValueSingle('Dashboard.Date.Enabled', false)
|
||||
end
|
||||
if openspace.hasProperty('Dashboard.SimulationIncrement.Enabled') then
|
||||
openspace.setPropertyValueSingle('Dashboard.SimulationIncrement.Enabled', false)
|
||||
end
|
||||
if openspace.hasProperty('Dashboard.SimulationIncrement.Enabled') then
|
||||
openspace.setPropertyValueSingle('Dashboard.SimulationIncrement.Enabled', false)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
asset.onDeinitialize(function ()
|
||||
-- Remove the frontend endpoint
|
||||
local directories = openspace.getPropertyValue("Modules.WebGui.Directories")
|
||||
local newDirectories = {};
|
||||
-- Remove the frontend endpoint
|
||||
local directories = openspace.getPropertyValue("Modules.WebGui.Directories")
|
||||
local newDirectories = {};
|
||||
|
||||
-- @TODO(maci, 2019-08-23) see message below
|
||||
--openspace.setPropertyValueSingle("Modules.WebGui.DefaultEndpoint", "")
|
||||
-- @TODO(maci, 2019-08-23) see message below
|
||||
--openspace.setPropertyValueSingle("Modules.WebGui.DefaultEndpoint", "")
|
||||
|
||||
for i = 0, #directories, 2 do
|
||||
-- @TODO(abock, 2019-08-20) The explicit check for directories[i] is a workaround
|
||||
-- for an error that was otherwise thrown when directories[i] was nil
|
||||
if (directories[i] and string.find(directories[i], "frontend") == nil) then
|
||||
newDirectories[#newDirectories + 1] = directories[i]
|
||||
newDirectories[#newDirectories + 1] = directories[i + 1]
|
||||
end
|
||||
for i = 0, #directories, 2 do
|
||||
-- @TODO(abock, 2019-08-20) The explicit check for directories[i] is a workaround
|
||||
-- for an error that was otherwise thrown when directories[i] was nil
|
||||
if (directories[i] and string.find(directories[i], "frontend") == nil) then
|
||||
newDirectories[#newDirectories + 1] = directories[i]
|
||||
newDirectories[#newDirectories + 1] = directories[i + 1]
|
||||
end
|
||||
-- @TODO(maci, 2019-08-23) setting this value on exit was causing the server to restart
|
||||
-- on macos, which in turn, stopped the application from exiting.
|
||||
-- need to address in webguimodule.cpp
|
||||
--openspace.setPropertyValueSingle("Modules.WebGui.Directories", newDirectories)
|
||||
end
|
||||
-- @TODO(maci, 2019-08-23) setting this value on exit was causing the server to restart
|
||||
-- on macos, which in turn, stopped the application from exiting.
|
||||
-- need to address in webguimodule.cpp
|
||||
--openspace.setPropertyValueSingle("Modules.WebGui.Directories", newDirectories)
|
||||
end)
|
||||
|
||||
function setCefRoute(route)
|
||||
local port = 4680
|
||||
-- As a developer, you can manually serve the webgui from port 4690
|
||||
-- with the command `npm start` in the web gui repository
|
||||
if guiCustomization.webguiDevelopmentMode then
|
||||
port = 4690
|
||||
end
|
||||
openspace.setPropertyValueSingle(
|
||||
"Modules.CefWebGui.GuiUrl",
|
||||
"http://127.0.0.1:" .. port .. "/frontend/#/" .. route
|
||||
)
|
||||
local port = 4680
|
||||
-- As a developer, you can manually serve the webgui from port 4690
|
||||
-- with the command `npm start` in the web gui repository
|
||||
if guiCustomization.webguiDevelopmentMode then
|
||||
port = 4690
|
||||
end
|
||||
openspace.setPropertyValueSingle(
|
||||
"Modules.CefWebGui.GuiUrl",
|
||||
"http://127.0.0.1:" .. port .. "/frontend/#/" .. route
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
asset.export("setCefRoute", setCefRoute)
|
||||
|
||||
|
||||
asset.meta = {
|
||||
Name = "WebGUI",
|
||||
Version = "0.1",
|
||||
Description = [[ insert CEF rant ]],
|
||||
Author = "OpenSpace Team",
|
||||
URL = "http://openspaceproject.com",
|
||||
License = "MIT license"
|
||||
Name = "WebGUI",
|
||||
Version = "0.1",
|
||||
Description = [[ insert CEF rant ]],
|
||||
Author = "OpenSpace Team",
|
||||
URL = "http://openspaceproject.com",
|
||||
License = "MIT license"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user