import * as THREE from 'three'

const defaultMaterial = new THREE.MeshLambertMaterial({
  color: 0xffffff,
  reflectivity: 0.8,
  emissive: 0xffffff,
  emissiveIntensity: 0.5,
  wireframe: false,
  flatShading: true
});

let materials = {
  // 贸易大厦
  commercial: new THREE.MeshLambertMaterial({
    color: 0xc1e8e4,
    reflectivity: 0.8,
    emissive: 0xc1e8e4,
    emissiveIntensity: 0.5,
    wireframe: false,
    flatShading: true
  }),
  // 屋顶
  roof: new THREE.MeshLambertMaterial({
    color: 0xdbc315,
    reflectivity: 0.8,
    emissive: 0xdbc315,
    emissiveIntensity: 0.5,
    wireframe: false,
    flatShading: true
  }),
  // 商业
  commercial: new THREE.MeshLambertMaterial({
    color: 0xcc6f3e,
    reflectivity: 0.8,
    emissive: 0xcc6f3e,
    emissiveIntensity: 0.5,
    wireframe: false,
    flatShading: true
  }),
  // 零售业
  retail: new THREE.MeshLambertMaterial({
    color: 0xaeaaa3,
    reflectivity: 0.8,
    emissive: 0xaeaaa3,
    emissiveIntensity: 0.5,
    wireframe: false,
    flatShading: true
  }),
  // 公寓
  apartments: new THREE.MeshLambertMaterial({
    color: 0xba673a,
    reflectivity: 0.8,
    emissive: 0xba673a,
    emissiveIntensity: 0.5,
    wireframe: false,
    flatShading: true
  }),
  // 住宅区
  residential: new THREE.MeshLambertMaterial({
    color: 0xba673a,
    reflectivity: 0.8,
    emissive: 0xba673a,
    emissiveIntensity: 0.5,
    wireframe: false,
    flatShading: true
  }),
  // 温室
  greenhouse: new THREE.MeshLambertMaterial({
    color: 0x750000,
    reflectivity: 0.8,
    emissive: 0x750000,
    emissiveIntensity: 0.5,
    wireframe: false,
    flatShading: true
  }),
  // 医院
  hospital: new THREE.MeshLambertMaterial({
    color: 0xbc6067,
    reflectivity: 0.8,
    emissive: 0xbc6067,
    emissiveIntensity: 0.5,
    wireframe: false,
    flatShading: true
  }),
  // 桥
  bridge: new THREE.MeshLambertMaterial({
    color: 0x3f3f3e,
    reflectivity: 0.8,
    emissive: 0x3f3f3e,
    emissiveIntensity: 0.5, 
    wireframe: false,
    flatShading: true
  }),
  // 火车站
  train_station: new THREE.MeshLambertMaterial({
    color: 0x896343,
    reflectivity: 0.8,
    emissive: 0x896343,
    emissiveIntensity: 0.5,
    wireframe: false,
    flatShading: true
  }),
  // 学校
  school: new THREE.MeshLambertMaterial({
    color: 0x668142,
    reflectivity: 0.8,
    emissive: 0x668142,
    emissiveIntensity: 0.5,
    wireframe: false,
    flatShading: true
  }),
  // 建设中
  construction: new THREE.MeshLambertMaterial({
    color: 0xe6cb00,
    reflectivity: 0.8,
    emissive: 0xe6cb00,
    emissiveIntensity: 0.5,
    wireframe: false,
    flatShading: true
  }),
}





function grentMesh(geometry, type) {
  // console.log(type)
  let mesh = new THREE.Mesh(geometry, materials[type] || defaultMaterial)
  mesh.castShadow = true; 
  mesh.receiveShadow = true;
  return mesh
}

export default grentMesh
