mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-23 12:39:24 -05:00
48 lines
1.7 KiB
Lua
48 lines
1.7 KiB
Lua
local createFlipbook = function (assetPrefix, assetGlobe, count)
|
|
return {
|
|
AssetPrefix = assetPrefix,
|
|
AssetGlobe = assetGlobe,
|
|
TotalCount = count,
|
|
CurrentFlipIndex = -1,
|
|
}
|
|
end
|
|
|
|
local nextFlipbookPage = function (flipbook)
|
|
if (flipbook.CurrentFlipIndex >= 0) then
|
|
local assetSring = flipbook.AssetPrefix .. flipbook.CurrentFlipIndex;
|
|
openspace.setPropertyValueSingle("Scene." .. flipbook.AssetGlobe .. ".Renderable.Layers.ColorLayers.".. assetSring .. ".Enabled", false)
|
|
end
|
|
|
|
if (flipbook.CurrentFlipIndex < flipbook.TotalCount - 1) then
|
|
flipbook.CurrentFlipIndex = flipbook.CurrentFlipIndex + 1;
|
|
local assetSring = flipbook.AssetPrefix .. flipbook.CurrentFlipIndex;
|
|
openspace.setPropertyValueSingle("Scene." .. flipbook.AssetGlobe .. ".Renderable.Layers.ColorLayers.".. assetSring .. ".Enabled", true)
|
|
end
|
|
end
|
|
|
|
local previousFlipbookPage = function (flipbook)
|
|
local localIndex = flipbook.CurrentFlipIndex;
|
|
|
|
if (localIndex == -1) then
|
|
return
|
|
end
|
|
|
|
local assetSring = flipbook.AssetPrefix .. localIndex;
|
|
openspace.setPropertyValueSingle("Scene." .. flipbook.AssetGlobe .. ".Renderable.Layers.ColorLayers.".. assetSring .. ".Enabled", false)
|
|
localIndex = localIndex - 1;
|
|
|
|
if (localIndex >= 0 ) then
|
|
assetSring = flipbook.AssetPrefix .. localIndex;
|
|
openspace.setPropertyValueSingle("Scene." .. flipbook.AssetGlobe .. ".Renderable.Layers.ColorLayers.".. assetSring .. ".Enabled", true)
|
|
end
|
|
|
|
if (localIndex < -1) then
|
|
localIndex = -1
|
|
end
|
|
flipbook.CurrentFlipIndex = localIndex;
|
|
end
|
|
|
|
asset.export("nextFlipbookPage", nextFlipbookPage)
|
|
asset.export("previousFlipbookPage", previousFlipbookPage)
|
|
asset.export("createFlipbook", createFlipbook)
|