bae1806c27510f2a40780b9a75aa4b90e465fc72.svn-base 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import * as THREE from 'three'
  2. const defaultMaterial = new THREE.MeshLambertMaterial({
  3. color: 0xffffff,
  4. reflectivity: 0.8,
  5. emissive: 0xffffff,
  6. emissiveIntensity: 0.5,
  7. wireframe: false,
  8. flatShading: true
  9. });
  10. let materials = {
  11. // 贸易大厦
  12. commercial: new THREE.MeshLambertMaterial({
  13. color: 0xc1e8e4,
  14. reflectivity: 0.8,
  15. emissive: 0xc1e8e4,
  16. emissiveIntensity: 0.5,
  17. wireframe: false,
  18. flatShading: true
  19. }),
  20. // 屋顶
  21. roof: new THREE.MeshLambertMaterial({
  22. color: 0xdbc315,
  23. reflectivity: 0.8,
  24. emissive: 0xdbc315,
  25. emissiveIntensity: 0.5,
  26. wireframe: false,
  27. flatShading: true
  28. }),
  29. // 商业
  30. commercial: new THREE.MeshLambertMaterial({
  31. color: 0xcc6f3e,
  32. reflectivity: 0.8,
  33. emissive: 0xcc6f3e,
  34. emissiveIntensity: 0.5,
  35. wireframe: false,
  36. flatShading: true
  37. }),
  38. // 零售业
  39. retail: new THREE.MeshLambertMaterial({
  40. color: 0xaeaaa3,
  41. reflectivity: 0.8,
  42. emissive: 0xaeaaa3,
  43. emissiveIntensity: 0.5,
  44. wireframe: false,
  45. flatShading: true
  46. }),
  47. // 公寓
  48. apartments: new THREE.MeshLambertMaterial({
  49. color: 0xba673a,
  50. reflectivity: 0.8,
  51. emissive: 0xba673a,
  52. emissiveIntensity: 0.5,
  53. wireframe: false,
  54. flatShading: true
  55. }),
  56. // 住宅区
  57. residential: new THREE.MeshLambertMaterial({
  58. color: 0xba673a,
  59. reflectivity: 0.8,
  60. emissive: 0xba673a,
  61. emissiveIntensity: 0.5,
  62. wireframe: false,
  63. flatShading: true
  64. }),
  65. // 温室
  66. greenhouse: new THREE.MeshLambertMaterial({
  67. color: 0x750000,
  68. reflectivity: 0.8,
  69. emissive: 0x750000,
  70. emissiveIntensity: 0.5,
  71. wireframe: false,
  72. flatShading: true
  73. }),
  74. // 医院
  75. hospital: new THREE.MeshLambertMaterial({
  76. color: 0xbc6067,
  77. reflectivity: 0.8,
  78. emissive: 0xbc6067,
  79. emissiveIntensity: 0.5,
  80. wireframe: false,
  81. flatShading: true
  82. }),
  83. // 桥
  84. bridge: new THREE.MeshLambertMaterial({
  85. color: 0x3f3f3e,
  86. reflectivity: 0.8,
  87. emissive: 0x3f3f3e,
  88. emissiveIntensity: 0.5,
  89. wireframe: false,
  90. flatShading: true
  91. }),
  92. // 火车站
  93. train_station: new THREE.MeshLambertMaterial({
  94. color: 0x896343,
  95. reflectivity: 0.8,
  96. emissive: 0x896343,
  97. emissiveIntensity: 0.5,
  98. wireframe: false,
  99. flatShading: true
  100. }),
  101. // 学校
  102. school: new THREE.MeshLambertMaterial({
  103. color: 0x668142,
  104. reflectivity: 0.8,
  105. emissive: 0x668142,
  106. emissiveIntensity: 0.5,
  107. wireframe: false,
  108. flatShading: true
  109. }),
  110. // 建设中
  111. construction: new THREE.MeshLambertMaterial({
  112. color: 0xe6cb00,
  113. reflectivity: 0.8,
  114. emissive: 0xe6cb00,
  115. emissiveIntensity: 0.5,
  116. wireframe: false,
  117. flatShading: true
  118. }),
  119. }
  120. function grentMesh(geometry, type) {
  121. console.log(type)
  122. let mesh = new THREE.Mesh(geometry, materials[type] || defaultMaterial)
  123. mesh.castShadow = true;
  124. mesh.receiveShadow = true;
  125. return mesh
  126. }
  127. export default grentMesh