
import {YtAssetsManager} from "../../libs/yt/index"
import {YtSceneManager} from "../../libs/yt/index"



export class ExGameScene{

    private static instance: ExGameScene;

    public static get ins(): ExGameScene {
        if (!this.instance) {
            this.instance = new ExGameScene();
        }
        return this.instance;
    }

    public display;

    protected scene;

    constructor(){
       // super()
    }


    public creatScene(){
        this.scene=YtSceneManager.ins.scene

        //设置背景色
        this.scene.clearColor=new BABYLON.Color4(52/255,156/255,255/255);

        var camera3 = new BABYLON.ArcRotateCamera("Camera", 0, 0, 10, new BABYLON.Vector3(0, 0, 0), this.scene);
        camera3.fov=1.3
        camera3.radius=10;
        camera3.upperRadiusLimit=10;
        camera3.lowerRadiusLimit=10;
        camera3.upperAlphaLimit=-2.2;
        camera3.lowerAlphaLimit=-2.2;
        camera3.upperBetaLimit=1.4;
        camera3.lowerBetaLimit=1.4;
      //  camera3.attachControl(YtSceneManager.ins.canvas2,true)
        camera3.detachControl(YtSceneManager.ins.canvas2)
        this.scene.activeCamera=camera3;

        this.scene.fogMode = BABYLON.Scene.FOGMODE_LINEAR ;
        //this.scene.fogDensity = 0.05;
        this.scene.fogStart = 14.0;
        this.scene.fogEnd = 30.0;
        this.scene.fogColor = new BABYLON.Color3(115/255,141/255,245/255);
        //YtSceneManager.ins.engine.setHardwareScalingLevel(0.4)


        var light = new BABYLON.HemisphericLight("HemiLight", new BABYLON.Vector3(0, 10, 0), this.scene);
        light.intensity=0.1
        light.diffuse = new BABYLON.Color3(1, 1, 1);
        light.groundColor = new BABYLON.Color3(1, 1, 1);

        var light3 = new BABYLON.DirectionalLight("DirectionalLight", new BABYLON.Vector3(0.5, -0.3, 0.4), this.scene);
        light3.intensity=0.4
       

        var light4 = new BABYLON.PointLight("pointLight", new BABYLON.Vector3(1, 10, 1), this.scene);
        light4.intensity=2;
        light4.range=6;



       var skySphere = BABYLON.MeshBuilder.CreateSphere("sphere", {diameter:100}, this.scene);
       skySphere.position=new BABYLON.Vector3(0,0,0);
       var skyMaterial=new BABYLON.StandardMaterial("skyMaterial",this.scene);
       /* skyMaterial.diffuseColor=new BABYLON.Color3(0,1,0);
       skyMaterial.emissiveColor=new BABYLON.Color3(0,1,0); */
     //  skyMaterial.emissiveTexture=YtAssetsManager.ins.resourceObject["textures"]["gameScene"]["skybox"].clone()
       skyMaterial.disableLighting=true;
       //skyMaterial.fogEnabled=false;
       skyMaterial.backFaceCulling=false;
       skySphere.material=skyMaterial;

       var map1Material=new BABYLON.StandardMaterial("skyMaterial",this.scene);
       map1Material.diffuseColor=new BABYLON.Color3(5/255,100/255,255/255);
       map1Material.specularColor=new BABYLON.Color3(1,1,1);
      // map1Material.disableLighting=true;
     //  map1Material.fogEnabled=false;
     //  map1Material.backFaceCulling=false;

       var map2Material=new BABYLON.StandardMaterial("skyMaterial",this.scene);
      // map2Material.emissiveColor=new BABYLON.Color3(0,0,1);
       map2Material.diffuseColor=new BABYLON.Color3(33/255,150/255,243/255);
       map2Material.specularColor=new BABYLON.Color3(1,1,1);
     //  map2Material.disableLighting=true;
     //  map2Material.fogEnabled=false;
     //  map2Material.backFaceCulling=false;


        var lightMaterial=new BABYLON.StandardMaterial("skyMaterial",this.scene);
        lightMaterial.emissiveColor=new BABYLON.Color3(255/255,255/255,255/255);
        lightMaterial.disableLighting=true;
        lightMaterial.fogEnabled=false;

        var b_1Material=new BABYLON.StandardMaterial("skyMaterial",this.scene);
        b_1Material.emissiveColor=new BABYLON.Color3(255/255,255/255,255/255);
        b_1Material.diffuseTexture=YtAssetsManager.ins.resourceObject["textures"]["gameScene"]["b_1"].clone();
        b_1Material.emissiveTexture=YtAssetsManager.ins.resourceObject["textures"]["gameScene"]["b_1"].clone();
        b_1Material.diffuseTexture.hasAlpha=true;
      //  baziMaterial.opacityTexture=YtAssetsManager.ins.resourceObject["textures"]["gameScene"]["bazi"].clone();
        b_1Material.disableLighting=true;
      //  b_1Material.fogEnabled=false;


        var b_2Material=new BABYLON.StandardMaterial("skyMaterial",this.scene);
        b_2Material.emissiveColor=new BABYLON.Color3(255/255,255/255,255/255);
        b_2Material.diffuseTexture=YtAssetsManager.ins.resourceObject["textures"]["gameScene"]["b_2"].clone();
        b_2Material.emissiveTexture=YtAssetsManager.ins.resourceObject["textures"]["gameScene"]["b_2"].clone();
        b_2Material.diffuseTexture.hasAlpha=true;
      //  baziMaterial.opacityTexture=YtAssetsManager.ins.resourceObject["textures"]["gameScene"]["bazi"].clone();
        b_2Material.disableLighting=true;
     //   b_2Material.fogEnabled=false;


        var b_3Material=new BABYLON.StandardMaterial("skyMaterial",this.scene);
        b_3Material.emissiveColor=new BABYLON.Color3(255/255,255/255,255/255);
        b_3Material.diffuseTexture=YtAssetsManager.ins.resourceObject["textures"]["gameScene"]["b_3"].clone();
        b_3Material.emissiveTexture=YtAssetsManager.ins.resourceObject["textures"]["gameScene"]["b_3"].clone();
        b_3Material.diffuseTexture.hasAlpha=true;
      //  baziMaterial.opacityTexture=YtAssetsManager.ins.resourceObject["textures"]["gameScene"]["bazi"].clone();
        b_3Material.disableLighting=true;
      //  b_3Material.fogEnabled=false;

        var b_4Material=new BABYLON.StandardMaterial("skyMaterial",this.scene);
        b_4Material.emissiveColor=new BABYLON.Color3(255/255,255/255,255/255);
        b_4Material.diffuseTexture=YtAssetsManager.ins.resourceObject["textures"]["gameScene"]["b_4"].clone();
        b_4Material.emissiveTexture=YtAssetsManager.ins.resourceObject["textures"]["gameScene"]["b_4"].clone();
        b_4Material.diffuseTexture.hasAlpha=true;
      //  baziMaterial.opacityTexture=YtAssetsManager.ins.resourceObject["textures"]["gameScene"]["bazi"].clone();
        b_4Material.disableLighting=true;
       // b_4Material.fogEnabled=false;

        var b_5Material=new BABYLON.StandardMaterial("skyMaterial",this.scene);
        b_5Material.emissiveColor=new BABYLON.Color3(255/255,255/255,255/255);
        b_5Material.diffuseTexture=YtAssetsManager.ins.resourceObject["textures"]["gameScene"]["b_5"].clone();
        b_5Material.emissiveTexture=YtAssetsManager.ins.resourceObject["textures"]["gameScene"]["b_5"].clone();
        b_5Material.diffuseTexture.hasAlpha=true;
      //  baziMaterial.opacityTexture=YtAssetsManager.ins.resourceObject["textures"]["gameScene"]["bazi"].clone();
        b_5Material.disableLighting=true;
       // b_5Material.fogEnabled=false;

        var b_6Material=new BABYLON.StandardMaterial("skyMaterial",this.scene);
        b_6Material.emissiveColor=new BABYLON.Color3(255/255,255/255,255/255);
        b_6Material.diffuseTexture=YtAssetsManager.ins.resourceObject["textures"]["gameScene"]["b_6"].clone();
        b_6Material.emissiveTexture=YtAssetsManager.ins.resourceObject["textures"]["gameScene"]["b_6"].clone();
        b_6Material.diffuseTexture.hasAlpha=true;
      //  baziMaterial.opacityTexture=YtAssetsManager.ins.resourceObject["textures"]["gameScene"]["bazi"].clone();
        b_6Material.disableLighting=true;
      //  b_6Material.fogEnabled=false;

       console.log("this.scene")
       console.log(this.scene)
        this.display={
            camera3:camera3,
            light:light,
            light3:light3,
            skySphere:skySphere,
            map1Material:map1Material,
            map2Material:map2Material,
            lightMaterial:lightMaterial,
            b_1Material:b_1Material,
            b_2Material:b_2Material,
            b_3Material:b_3Material,
            b_4Material:b_4Material,
            b_5Material:b_5Material,
            b_6Material:b_6Material,
            light4:light4,
        }

        console.log(this.display)

      //  GameSceneCon.ins.resetGame(this.display);
    }

}


