Files
OpenSpace/data/assets/examples/animation.asset
T
Emma Broman 8a42657deb Feature/examples naming (#3305)
* Update name and path format of examples that follow the new structure
* Fix a broken (updated) property name in an example
* Make other examples' GUI paths more consistent
* Put them all in the Examples folder
2024-06-13 10:42:00 +02:00

199 lines
5.0 KiB
Lua

local sun = asset.require("scene/solarsystem/sun/transforms")
local transforms = asset.require("scene/solarsystem/planets/earth/transforms")
local model = asset.resource({
Name = "Animated Box",
Type = "HttpSynchronization",
Identifier = "animated_box",
Version = 1
})
local StartTime = "2021 06 01 00:00:00"
local AnimationLoop = {
Identifier = "AnimationLoop",
Parent = transforms.EarthCenter.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = { 0.0, -11E7, 0.0 }
}
},
Renderable = {
Type = "RenderableModel",
GeometryFile = model .. "BoxAnimated.glb",
EnableAnimation = true,
AnimationMode = "LoopFromStart",
AnimationStartTime = StartTime,
ModelScale = 3E7,
LightSources = {
sun.LightSource
}
},
GUI = {
Name = "Animated Model (LoopFromStart)",
Path = "/Examples",
Description = "Simple animated box model with the animation mode 'LoopFromStart'"
}
}
local AnimationLoopInf = {
Identifier = "AnimationLoopInf",
Parent = transforms.EarthCenter.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = { 0.0, 11E7, 0.0 }
}
},
Renderable = {
Type = "RenderableModel",
GeometryFile = model .. "BoxAnimated.glb",
EnableAnimation = true,
AnimationMode = "LoopInfinitely",
AnimationStartTime = StartTime,
ModelScale = 3E7,
LightSources = {
sun.LightSource
}
},
GUI = {
Name = "Animated Model (LoopInfinitely)",
Path = "/Examples",
Description = "Simple animated box model with the animation mode 'LoopInfinitely'"
}
}
local AnimationOnce = {
Identifier = "AnimationOnce",
Parent = transforms.EarthCenter.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = { 11E7, 0.0, 0.0 }
}
},
Renderable = {
Type = "RenderableModel",
GeometryFile = model .. "BoxAnimated.glb",
EnableAnimation = true,
AnimationMode = "Once",
AnimationStartTime = StartTime,
ModelScale = 3E7,
LightSources = {
sun.LightSource
}
},
GUI = {
Name = "Animated Model (Once)",
Path = "/Examples",
Description = "Simple animated box model with the animation mode 'Once'"
}
}
local AnimationBounceInf = {
Identifier = "AnimationBounceInf",
Parent = transforms.EarthCenter.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = { 0.0, 0.0, 11E7 }
}
},
Renderable = {
Type = "RenderableModel",
GeometryFile = model .. "BoxAnimated.glb",
EnableAnimation = true,
AnimationMode = "BounceInfinitely",
AnimationStartTime = StartTime,
ModelScale = 3E7,
LightSources = {
sun.LightSource
}
},
GUI = {
Name = "Animated Model (BounceInfinitely)",
Path = "/Examples",
Description = "Simple animated box model with the animation mode 'BounceInfinitely'"
}
}
local AnimationBounce = {
Identifier = "AnimationBounce",
Parent = transforms.EarthCenter.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = { 0.0, 0.0, -11E7 }
}
},
Renderable = {
Type = "RenderableModel",
GeometryFile = model .. "BoxAnimated.glb",
EnableAnimation = true,
AnimationMode = "BounceFromStart",
AnimationStartTime = StartTime,
ModelScale = 3E7,
LightSources = {
sun.LightSource
}
},
GUI = {
Name = "Animated Model (BounceFromStart)",
Path = "/Examples",
Description = "Simple animated box model with the animation mode 'BounceFromStart'"
}
}
asset.onInitialize(function()
openspace.addSceneGraphNode(AnimationLoop)
openspace.addSceneGraphNode(AnimationLoopInf)
openspace.addSceneGraphNode(AnimationOnce)
openspace.addSceneGraphNode(AnimationBounceInf)
openspace.addSceneGraphNode(AnimationBounce)
end)
asset.onDeinitialize(function()
openspace.removeSceneGraphNode(AnimationBounce)
openspace.removeSceneGraphNode(AnimationBounceInf)
openspace.removeSceneGraphNode(AnimationOnce)
openspace.removeSceneGraphNode(AnimationLoopInf)
openspace.removeSceneGraphNode(AnimationLoop)
end)
asset.export(AnimationLoop)
asset.export(AnimationLoopInf)
asset.export(AnimationOnce)
asset.export(AnimationBounceInf)
asset.export(AnimationBounce)
asset.meta = {
Name = "Animation Example asset",
Version = "1.0",
Description = "Simple animation example asset with an animated box model",
Author = "OpenSpace Team",
URL = "http://openspaceproject.com",
License = "MIT license"
}
-- Model
-- @TODO: At the moment, this overwrites the previous meta description. Probably needs a way to specify multiple meta's per file?
asset.meta = {
Name = "Animated Box Model",
Version = "1.0",
Description = "Simple animated box model",
Author = "Cesium, https://cesium.com/",
URL = "https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/BoxAnimated",
License = [[
Creative Commons Attribution 4.0 International License,
https://creativecommons.org/licenses/by/4.0/
]]
}