Files
OpenSpace/data/assets/educational/scale/eiffeltower.asset
2024-06-19 11:26:07 +02:00

104 lines
3.0 KiB
Lua

local earthAsset = asset.require("scene/solarsystem/planets/earth/earth")
local sunAsset = asset.require("scene/solarsystem/sun/transforms")
local modelFolder = asset.resource({
Name = "Scale Eiffel Tower",
Type = "HttpSynchronization",
Identifier = "scale_model_eiffel_tower",
Version = 1
})
local Location = { 48.85824, 2.29448 }
local ScaleModel = {
Identifier = "Scale_EiffelTower",
Parent = earthAsset.Earth.Identifier,
-- Note: Lat/Lon/Scale values come from alignment with Esri World Imagery 2D layer
Transform = {
Translation = {
Type = "GlobeTranslation",
Globe = earthAsset.Earth.Identifier,
Latitude = Location[1],
Longitude = Location[2],
Altitude = 0.0,
UseHeightmap = true
},
Rotation = {
Type = "GlobeRotation",
Globe = earthAsset.Earth.Identifier,
Latitude = Location[1],
Longitude = Location[2]
},
Scale = {
Type = "StaticScale",
Scale = 4.38
}
},
Renderable = {
Type = "RenderableModel",
GeometryFile = modelFolder .. "eiffeltower.osmodel",
RotationVector = { 0.0, 45.0, 0.0 },
LightSources = { sunAsset.LightSource },
ModelScale = "Centimeter"
},
GUI = {
Name = "Eiffel Tower",
Description = "The tower is 330 m (1,083 ft) tall.",
Path = "/Scale Objects"
}
}
local UpdatePositionAction = {
Identifier = "os.scalemodels.DropEiffelTower",
Name = "Drop Eiffel Tower under camera",
Command = [[
openspace.globebrowsing.setNodePositionFromCamera("Scale_EiffelTower")
]],
Documentation = "Updates the Eiffel Tower position based on the globe location of the camera",
GuiPath = "/Scale Objects",
IsLocal = false
}
local ResetPositionAction = {
Identifier = "os.scalemodels.ResetEiffelTower",
Name = "Reset Eiffel Tower position",
Command = [[
openspace.globebrowsing.setNodePosition("Scale_EiffelTower", "]] .. earthAsset.Earth.Identifier .. [[", ]] .. Location[1] .. "," .. Location[2] .. ")",
Documentation = "Resets the Eiffel Tower back to its actual 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)
asset.meta = {
Name = "Scale Model - Eiffel Tower",
Description = [[A 1:1 scale model of the Eiffel Tower. Per default it is placed at
its actual position in Paris, France. But the asset also includes actions to move it
to a position under the camera, or back to its original position.]],
Author = "OpenSpace Team",
URL = "http://openspaceproject.com",
License = "MIT license"
}