class DashboardsController extends WindozController {

    constructor(params) {
        super(params)
        this.arenaConfig = app.Assets.Store.json.arenaConfig
        this.eventsMapping = app.Assets.Store.json.eventsMapping
    }



    /**
     * 
     * @returns 
     */
    async spaceViewer() {
        const models = {
            agents : new AgentsModel('/agents')
        }

        const ttb = new app.LoadedModules.Threetobus({
            eventsMapping: this.eventsMapping,
            sceneSize: this.arenaConfig.arenaSize,
        })
        ttb.initScene({
            axes: true,
            grid: true,
        })

        this.agentSprites = await models.agents.getSprites('Basic 3D')
        const a1 = ttb.createAgent('agent42', this.agentSprites.find(item => item.atp_name=='nocode1').asp_3d)
        const a2 = ttb.createAgent('agent43', this.agentSprites.find(item => item.atp_name=='nocode2').asp_3d)
        ttb.scene.add(a1)
        ttb.scene.add(a2)

        //TODO: eventsMapping: address child by suffix in assignations


        this.loadWindow(
            'visualisers/SpaceView', 
            {
                title: '<i class="icon-bolt"></i> Live arena 3D view', 
                static: true,
                expanded: false,
                withSettings: true,
                windowStyle: WindozDomContent.boxFromPrefs('live.spaceview.3D', { x: 50, y:100, w:600, h:400 }),
            },
            {
                models: models,
                rendererId:'3drenderer',
                mode: '3D',
                ttb: ttb,
            }
        ) 


        this.loadWindow(
            'visualisers/SpaceView', 
            {
                title: '<i class="icon-bolt"></i> Live arena 2D View', 
                static: true,
                expanded: false,
                withSettings: true,
                windowStyle: WindozDomContent.boxFromPrefs('live.spaceview.2D', { x: 500, y:100, w:600, h:400 }),
            },
            {
                models: models,
                rendererId:'2drenderer',
                mode: '2D',
                ttb: ttb,
            }
        )         
    }


}

app.registerClass('DashboardsController', DashboardsController);