mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-13 23:20:48 -06:00
72 lines
1.8 KiB
Lua
72 lines
1.8 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 ExampleGlobeRotation = {
|
|
Identifier = "ExampleGlobeRotation",
|
|
Parent = earth.Earth.Identifier,
|
|
Transform = {
|
|
Translation = {
|
|
Type = "GlobeTranslation",
|
|
Globe = earth.Earth.Identifier,
|
|
Latitude = 40.7306,
|
|
Longitude = -73.9352,
|
|
Altitude = 6,
|
|
UseHeightmap = true
|
|
},
|
|
Rotation = {
|
|
Type = "GlobeRotation",
|
|
Globe = earth.Earth.Identifier,
|
|
Latitude = 40.7306,
|
|
Longitude = -73.9352
|
|
-- Can be used to to put flat on leaning surfaces, but also leads to updating
|
|
-- the rotation every frame
|
|
--UseHeightmap = true
|
|
}
|
|
},
|
|
Renderable = {
|
|
Type = "RenderableModel",
|
|
GeometryFile = models .. "NewHorizonsCleanModel.obj",
|
|
LightSources = {
|
|
sun.LightSource
|
|
}
|
|
},
|
|
GUI = {
|
|
Name = "GlobeRotation",
|
|
Path = "/Examples"
|
|
}
|
|
}
|
|
|
|
|
|
asset.onInitialize(function()
|
|
openspace.addSceneGraphNode(ExampleGlobeRotation)
|
|
end)
|
|
|
|
asset.onDeinitialize(function()
|
|
openspace.removeSceneGraphNode(ExampleGlobeRotation)
|
|
end)
|
|
|
|
asset.export(ExampleGlobeRotation)
|
|
|
|
|
|
|
|
asset.meta = {
|
|
Name = "GlobeRotation Example",
|
|
Description = [[An example that demonstrates how to load a 3D model from a geometry
|
|
file, placing it on a planetary surface and rotate it to align with the surface
|
|
normal using a "GlobeRotation" transform. Note that "GlobeTranslation" is needed to
|
|
put the model in the correct location.]],
|
|
Author = "OpenSpace Team",
|
|
URL = "http://openspaceproject.com",
|
|
License = "MIT license"
|
|
}
|