<template>
    <div class="home">
      <div class="header">

      </div>
      <div class="content">
        <div id="left">
          <a @click="showAssetsList(0)" href=""> 材质 </a>
          <a @click="showAssetsList(1)" href=""> 贴图 </a>
        </div>
        <div id="middle">
            <div id="viewerContainner">
              
            </div>
            <div id="assetsList">

            </div>
        </div>
        <div id="right"></div>
      </div>
    </div>
</template>

<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import Viewer from '../webgl/Viewer'
import MarmosetAssetsManager from '../webgl/assets/marmosets/MarmosetAssetsManager'
import * as THREE from 'three'
import { MeshMaterial } from '../webgl/materials/marmoset';

const examples = [
  "static/model/henrique/henrique.mview",
  "static/model/vivfox/vivfox.mview",
  "static/model/metal/metal.mview",
]


@Component
export default class Home extends Vue {

  materials: MeshMaterial[] = []

  mounted() {

    let containner = this.$el.querySelector("#viewerContainner") as HTMLDivElement;
    let viewer = new Viewer();
    viewer.start(containner)
    
    let loader = new MarmosetAssetsManager()

    let index = Number(this.$route.query['index']) || 0

    loader.load(examples[index]).then( model => {

      model && viewer.add(model);
      
      let ms = loader.getMaterials();
      ms.forEach( item => this.materials.push(item));

    })
    window.THREE = THREE

  }

  showAssetsList( flag: number ) {

    

  }
}
</script>
<style lang="less" scoped>

  .home {


    display: flex;
    flex-direction: column;
    justify-content: space-between;

    position: fixed;
    width: 100%;
    height: 100%;

    .header {

      height: 3rem;

    }

    .content {

      flex: 1;
      border: 1px solid red;
      height: 100%;

      display: flex;
      justify-content: space-between;

    }

    
    #left {

      width: 3rem

    }

    #middle {

      flex: 1;

      display: flex;
      flex-direction: column;

      

    }
  
    #right {

      width: 200px;
    }

    #assetsList {

      height: 200px;
    }

    #viewerContainner {

      flex: 1;

    }

  }

</style>
