mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 03:29:44 -06:00
88 lines
2.1 KiB
Lua
88 lines
2.1 KiB
Lua
local sun = asset.require("scene/solarsystem/sun/transforms")
|
|
local earth = asset.require("scene/solarsystem/planets/earth/earth")
|
|
|
|
|
|
|
|
local models = asset.resource({
|
|
Name = "New Horizons Model",
|
|
Type = "HttpSynchronization",
|
|
Identifier = "newhorizons_model",
|
|
Version = 2
|
|
})
|
|
|
|
|
|
local ExampleFixedHeight = {
|
|
Identifier = "ExampleFixedHeight",
|
|
Parent = earth.Earth.Identifier,
|
|
Transform = {
|
|
Translation = {
|
|
Type = "GlobeTranslation",
|
|
Globe = earth.Earth.Identifier,
|
|
Latitude = 40.7128,
|
|
Longitude = -74.006,
|
|
Altitude = 100000.0
|
|
}
|
|
},
|
|
Renderable = {
|
|
Type = "RenderableModel",
|
|
GeometryFile = models .. "NewHorizonsCleanModel.obj",
|
|
LightSources = {
|
|
sun.LightSource
|
|
}
|
|
},
|
|
GUI = {
|
|
Name = "GlobeTranslation - Fixed Height",
|
|
Path = "/Examples"
|
|
}
|
|
}
|
|
|
|
local ExampleAdaptiveHeight = {
|
|
Identifier = "ExampleAdaptiveHeight",
|
|
Parent = earth.Earth.Identifier,
|
|
Transform = {
|
|
Translation = {
|
|
Type = "GlobeTranslation",
|
|
Globe = earth.Earth.Identifier,
|
|
Latitude = 40.7128,
|
|
Longitude = -74.006,
|
|
UseHeightmap = true
|
|
}
|
|
},
|
|
Renderable = {
|
|
Type = "RenderableModel",
|
|
GeometryFile = models .. "NewHorizonsCleanModel.obj",
|
|
LightSources = {
|
|
sun.LightSource
|
|
}
|
|
},
|
|
GUI = {
|
|
Name = "GlobeTranslation - Adaptive Height",
|
|
Path = "/Examples"
|
|
}
|
|
}
|
|
|
|
|
|
asset.onInitialize(function()
|
|
openspace.addSceneGraphNode(ExampleFixedHeight)
|
|
openspace.addSceneGraphNode(ExampleAdaptiveHeight)
|
|
end)
|
|
|
|
asset.onDeinitialize(function()
|
|
openspace.removeSceneGraphNode(ExampleAdaptiveHeight)
|
|
openspace.removeSceneGraphNode(ExampleFixedHeight)
|
|
end)
|
|
|
|
asset.export(ExampleFixedHeight)
|
|
asset.export(ExampleAdaptiveHeight)
|
|
|
|
|
|
asset.meta = {
|
|
Name = "GlobeTranslation Example",
|
|
Description = [[An example that demonstrates how to place an object on a planet surface
|
|
using the "GlobeTranslation" transform. For the altitude, a fixed height can be used,
|
|
or the height can be queried from the height map]],
|
|
Author = "OpenSpace Team",
|
|
URL = "http://openspaceproject.com",
|
|
License = "MIT license"
|
|
}
|