Files
OpenSpace/data/assets/educational/scale/scientist.asset
T
Alexander Bock 705c898ccd Asset File cleanup (#2713)
* Updating all assets to new coding style
* Cleaning up asset files
* Moving default_actions and default_keybindings files
* Changing procedural globes to explicitly specified globes
* Move Spice loading explicitly to the initialize part and also deinitialize
* Removing unused asset files
  * Removing asset_helper
  * Removing scale_model_helper asset
  * Removing script_scheduler_helper
  * Removing testing_keybindings
  * Remove procedural_globe
2023-05-28 17:23:20 +02:00

87 lines
2.4 KiB
Lua

local earthAsset = asset.require("scene/solarsystem/planets/earth/earth")
local sunAsset = asset.require("scene/solarsystem/sun/sun")
local modelFolder = asset.syncedResource({
Name = "Scale Model Scientist",
Type = "HttpSynchronization",
Identifier = "scale_model_scientist",
Version = 1
})
-- The scientist model is located at Jet Propulsion Laboratory in Pasadena by default
local Location = { 34.201639, -118.171319, 0.78 }
local ScaleModel = {
Identifier = "Scale_Scientist",
Parent = earthAsset.Earth.Identifier,
Transform = {
Translation = {
Type = "GlobeTranslation",
Globe = earthAsset.Earth.Identifier,
Latitude = Location[1],
Longitude = Location[2],
Altitude = Location[3],
UseHeightmap = true
},
Rotation = {
Type = "GlobeRotation",
Globe = earthAsset.Earth.Identifier,
Latitude = Location[1],
Longitude = Location[2]
}
},
Renderable = {
Type = "RenderableModel",
GeometryFile = modelFolder .. "scientist.gltf",
RotationVector = { 0.0, 90.0, 0.0 },
LightSources = { sunAsset.LightSource }
},
GUI = {
Name = "Scientist",
Path = "/Scale Objects"
}
}
local UpdatePositionAction = {
Identifier = "os.scalemodels.DropScientist",
Name = "Drop Scientist under camera",
Command = [[
openspace.globebrowsing.setNodePositionFromCamera("Scale_Scientist")
]],
Documentation = "Updates the Scientist position based on the globe location of the camera",
GuiPath = "/Scale Objects",
IsLocal = false
}
local ResetPositionAction = {
Identifier = "os.scalemodels.ResetScientist",
Name = "Reset Scientist position",
Command = [[
openspace.globebrowsing.setNodePosition("Scale_Scientist", "]] .. earthAsset.Earth.Identifier .. [[", ]] .. Location[1] .. "," .. Location[2] .. ")",
Documentation = "Resets the Scientist back to its start location",
GuiPath = "/Scale Objects",
IsLocal = false
}
asset.onInitialize(function()
openspace.addSceneGraphNode(ScaleModel)
openspace.action.registerAction(UpdatePositionAction)
openspace.action.registerAction(ResetPositionAction)
end)
asset.onDeinitialize(function()
openspace.action.removeAction(ResetPositionAction)
openspace.action.removeAction(UpdatePositionAction)
openspace.removeSceneGraphNode(ScaleModel)
end)
asset.export(ScaleModel)
asset.export("UpdatePositionAction", UpdatePositionAction.Identifier)
asset.export("ResetPositionAction", ResetPositionAction.Identifier)