-- ActorFrame name, used for controlling the children from control actor (in FG).
local name = 'underlay'

local base_param = ...
local sw,sh,scx,scy,songdir,rr,am,bt,hs,pe,hr,ease,wratio,hratio,paraph = base_param.sw,base_param.sh,base_param.scx,base_param.scy,base_param.songdir,base_param.rr,base_param.am,base_param.bt,base_param.hs,base_param.pe,base_param.hr,base_param.ease,base_param.wratio,base_param.hratio,base_param.paraph

-- Camera manipulation table
local Cameras = {
	Name=name,
	Tween={
	}
}

-- Children manipulation table
local Actors = {
	Name=name,
	Tween={
		{'space', 0, 'zoom', sw/2048},
		{'black', 6240, 'diffusealpha', 0},
		{'white', 6240, 'diffusealpha', 1},
		{'black', 10128, 'diffusealpha', 1},
		{'white', 10128, 'diffusealpha', 0},
		{'space', 12096, {12144, 'accelerate', 'diffusealpha', 0, 1}},
		{'nova', 12096, {12144, 'accelerate', 'diffusealpha', 0, 0.75}},
	}
}

local Players = {
	Tween={
	}
}

-- Shortcut to the 'FG' ActorFrame.
local FG

-- We can use "InitializeCommand" instead of usual "OnCommand", which is executed on the beginning of section.
-- This reduces that ridiculously large frame drop on beat 0.
return Def.ActorFrame{
Name=name,
InitCommand=function(self) FG = self:GetParent():GetParent() self:visible(false) end,
InitializeCommand=function(self)
	local c = FG:GetChild('Cameras')
	local a = FG:GetChild('Actors')
--	local plt = a[1].Tween
--	for i = 1, #Players do
--		plt[#plt+1] = Players[i]
--	end
	c[#c+1] = Cameras
	a[#a+1] = Actors
	self:fov(90)
end,
Def.Quad{Name='black', InitCommand=function(self) self:zoomto(sw,sh):diffuse(0,0,0,1) end},
Def.Quad{Name='white', InitCommand=function(self) self:zoomto(sw,sh):diffuse(1,1,1,0) end},
Def.Sprite{Name='space',Texture=songdir..'fg/texture/space.png',InitializeCommand=function(self) self:texcoordvelocity(0,0.002):diffusealpha(0) end},
Def.Sprite{Name='nova', Texture=songdir..'fg/texture/nova.png', InitializeCommand=function(self) self:blend('BlendMode_Add'):diffusealpha(0) end},
}