Material.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. function Material(layer3D)
  2. {
  3. this.scene=layer3D.scene3D.scene;
  4. this.parameter=layer3D.layer.parameter;
  5. this.groundMaterial;
  6. this.skyboxMaterial;
  7. this.wallmaterial;
  8. this.floormaterial;
  9. this.frameMaterial;
  10. this.doorknobMaterial;
  11. this.doorMaterial;
  12. this.windowframeMaterial;
  13. this.selectMaterial;
  14. this.selectRotatorMaterial;
  15. this.measureTextPlaneMaterial;
  16. };
  17. Material.prototype.initialize= function ()
  18. {
  19. this.groundMaterial=this.setground();
  20. this.skyboxMaterial=this.setskybox();
  21. this.wallmaterial=this.setwall();
  22. this.floormaterial=this.setfloor();
  23. this.frameMaterial=this.setframe();
  24. this.doorMaterial=this.setdoor();
  25. this.doorknobMaterial=this.setdoorknob();
  26. this.windowframeMaterial=this.setwindowframe();
  27. this.selectMaterial=this.setselect();
  28. this.selectRotatorMaterial=this.setselectRotator();
  29. this.measureTextPlaneMaterial=this.setMeasureTextPlane();
  30. };
  31. Material.prototype.setselectRotator= function ()
  32. {
  33. var material = new BABYLON.StandardMaterial("buttons", this.scene);
  34. material.diffuseTexture = new BABYLON.Texture(this.parameter.selectRotator.img, this.scene);
  35. material.diffuseTexture.hasAlpha = !0;
  36. material.backFaceCulling = !1;
  37. return material;
  38. };
  39. Material.prototype.setselect= function ()
  40. {
  41. var material=new BABYLON.StandardMaterial("selectMat", this.scene);
  42. material.alpha = 1.0;
  43. material.diffuseColor = new BABYLON.Color3.Green();
  44. material.backFaceCulling = false;
  45. return material;
  46. };
  47. Material.prototype.getwallmaterial = function (id) {
  48. var wallmaterial = new BABYLON.StandardMaterial("wall"+id, this.scene);
  49. //wallmaterial.emissiveColor = new BABYLON.Color3(0.8,0.8,0.8);
  50. wallmaterial.diffuseColor = new BABYLON.Color3(0.5,0.5,0.5);
  51. wallmaterial.specularColor = new BABYLON.Color3(.6,.6,.6);
  52. wallmaterial.useSpecularOverAlpha=false;
  53. wallmaterial.backFaceCulling = false;
  54. return wallmaterial;
  55. };
  56. Material.prototype.setwall = function ()
  57. {
  58. var material = new BABYLON.StandardMaterial("wallmaterial", this.scene);
  59. material.backFaceCulling = false;
  60. material.diffuseColor = new BABYLON.Color3(0.5,0.5,0.5);
  61. material.specularColor = new BABYLON.Color3(.6,.6,.6);
  62. material.useSpecularOverAlpha=false;
  63. return material;
  64. };
  65. Material.prototype.getwall = function (id)
  66. {
  67. var wallmaterial = new BABYLON.StandardMaterial("wall"+id, this.scene);
  68. wallmaterial.diffuseColor = new BABYLON.Color3(0.5,0.5,0.5);
  69. wallmaterial.specularColor = new BABYLON.Color3(.6,.6,.6);
  70. wallmaterial.useSpecularOverAlpha=false;
  71. wallmaterial.backFaceCulling = false;
  72. return wallmaterial;
  73. };
  74. Material.prototype.setground= function ()
  75. {
  76. var material = new BABYLON.StandardMaterial("groundmaterial", this.scene);
  77. material.diffuseTexture = new BABYLON.Texture(this.parameter.groundImgUrl, this.scene);
  78. material.diffuseTexture.uScale = 5.0; //Repeat 5 times on the Vertical Axes
  79. material.diffuseTexture.vScale = 5.0; //Repeat 5 times on the Horizont
  80. return material;
  81. };
  82. Material.prototype.setskybox= function ()
  83. {
  84. var material = new BABYLON.StandardMaterial("skyBox", this.scene);
  85. material.backFaceCulling = false;
  86. material.reflectionTexture = new BABYLON.CubeTexture(this.parameter.skyImgUrl, this.scene);
  87. material.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
  88. material.diffuseColor = new BABYLON.Color3(0, 0, 0);
  89. material.specularColor = new BABYLON.Color3(0, 0, 0);
  90. material.disableLighting = true;
  91. return material;
  92. };
  93. //ÃÅ¿ò
  94. Material.prototype.setframe= function ()
  95. {
  96. var material = new BABYLON.StandardMaterial("frameMaterial", this.scene);
  97. material.alpha = 1.0;
  98. material.emissiveColor = new BABYLON.Color3(0.7,0.7,0.7);
  99. material.backFaceCulling = true;
  100. return material;
  101. };
  102. //´°»§¿ò
  103. Material.prototype.setwindowframe= function ()
  104. {
  105. var material = new BABYLON.StandardMaterial("windowframeMaterial", this.scene);
  106. material.alpha = 1.0;
  107. material.emissiveColor = new BABYLON.Color3(0.5,0.5,0.5);
  108. material.backFaceCulling = true;
  109. return material;
  110. };
  111. Material.prototype.setdoorknob= function ()
  112. {
  113. var material = new BABYLON.StandardMaterial("doorknobMaterial", this.scene);
  114. material.alpha = 1.0;
  115. material.emissiveColor = new BABYLON.Color3(0.1,0.1,0.1);
  116. material.backFaceCulling = true;
  117. return material;
  118. };
  119. Material.prototype.setdoor= function ()
  120. {
  121. var material = new BABYLON.StandardMaterial("doormaterial", this.scene);
  122. material.diffuseTexture = new BABYLON.Texture("images/door.png", this.scene);
  123. material.backFaceCulling = false;
  124. return material;
  125. };
  126. Material.prototype.setfloor = function ()
  127. {
  128. var material = new BABYLON.StandardMaterial("floormaterial", this.scene);
  129. material.diffuseTexture = new BABYLON.Texture(this.parameter.floorImgUrl, this.scene);
  130. material.bumpTexture = new BABYLON.Texture("images/floor1.png", this.scene);
  131. material.specularColor=new BABYLON.Color3(0.2,0.2,0.2);
  132. return material;
  133. };
  134. Material.prototype.setMeasureTextPlane = function ()
  135. {
  136. var dynamicTexture = new BABYLON.DynamicTexture("DynamicTexture", 50, this.scene, true);
  137. dynamicTexture.hasAlpha = true;
  138. var material = new BABYLON.StandardMaterial("TextPlaneMaterial", this.scene);
  139. material.backFaceCulling = false;
  140. material.specularColor = new BABYLON.Color3(0, 0, 0);
  141. material.diffuseTexture = dynamicTexture;
  142. return material;
  143. };