pbrBaseSimpleMaterial.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. import { __decorate } from "../../tslib.es6.js";
  2. import { serialize, serializeAsColor3, expandToProperty, serializeAsTexture } from "../../Misc/decorators.js";
  3. import { Color3 } from "../../Maths/math.color.js";
  4. import { PBRBaseMaterial } from "./pbrBaseMaterial.js";
  5. /**
  6. * The Physically based simple base material of BJS.
  7. *
  8. * This enables better naming and convention enforcements on top of the pbrMaterial.
  9. * It is used as the base class for both the specGloss and metalRough conventions.
  10. */
  11. export class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  12. /**
  13. * Gets the current double sided mode.
  14. */
  15. get doubleSided() {
  16. return this._twoSidedLighting;
  17. }
  18. /**
  19. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  20. */
  21. set doubleSided(value) {
  22. if (this._twoSidedLighting === value) {
  23. return;
  24. }
  25. this._twoSidedLighting = value;
  26. this.backFaceCulling = !value;
  27. this._markAllSubMeshesAsTexturesDirty();
  28. }
  29. /**
  30. * Instantiates a new PBRMaterial instance.
  31. *
  32. * @param name The material name
  33. * @param scene The scene the material will be use in.
  34. */
  35. constructor(name, scene) {
  36. super(name, scene);
  37. /**
  38. * Number of Simultaneous lights allowed on the material.
  39. */
  40. this.maxSimultaneousLights = 4;
  41. /**
  42. * If sets to true, disables all the lights affecting the material.
  43. */
  44. this.disableLighting = false;
  45. /**
  46. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47. */
  48. this.invertNormalMapX = false;
  49. /**
  50. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51. */
  52. this.invertNormalMapY = false;
  53. /**
  54. * Emissivie color used to self-illuminate the model.
  55. */
  56. this.emissiveColor = new Color3(0, 0, 0);
  57. /**
  58. * Occlusion Channel Strength.
  59. */
  60. this.occlusionStrength = 1.0;
  61. /**
  62. * If true, the light map contains occlusion information instead of lighting info.
  63. */
  64. this.useLightmapAsShadowmap = false;
  65. this._useAlphaFromAlbedoTexture = true;
  66. this._useAmbientInGrayScale = true;
  67. }
  68. getClassName() {
  69. return "PBRBaseSimpleMaterial";
  70. }
  71. }
  72. __decorate([
  73. serialize(),
  74. expandToProperty("_markAllSubMeshesAsLightsDirty")
  75. ], PBRBaseSimpleMaterial.prototype, "maxSimultaneousLights", void 0);
  76. __decorate([
  77. serialize(),
  78. expandToProperty("_markAllSubMeshesAsLightsDirty")
  79. ], PBRBaseSimpleMaterial.prototype, "disableLighting", void 0);
  80. __decorate([
  81. serializeAsTexture(),
  82. expandToProperty("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")
  83. ], PBRBaseSimpleMaterial.prototype, "environmentTexture", void 0);
  84. __decorate([
  85. serialize(),
  86. expandToProperty("_markAllSubMeshesAsTexturesDirty")
  87. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapX", void 0);
  88. __decorate([
  89. serialize(),
  90. expandToProperty("_markAllSubMeshesAsTexturesDirty")
  91. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapY", void 0);
  92. __decorate([
  93. serializeAsTexture(),
  94. expandToProperty("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")
  95. ], PBRBaseSimpleMaterial.prototype, "normalTexture", void 0);
  96. __decorate([
  97. serializeAsColor3("emissive"),
  98. expandToProperty("_markAllSubMeshesAsTexturesDirty")
  99. ], PBRBaseSimpleMaterial.prototype, "emissiveColor", void 0);
  100. __decorate([
  101. serializeAsTexture(),
  102. expandToProperty("_markAllSubMeshesAsTexturesDirty")
  103. ], PBRBaseSimpleMaterial.prototype, "emissiveTexture", void 0);
  104. __decorate([
  105. serialize(),
  106. expandToProperty("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")
  107. ], PBRBaseSimpleMaterial.prototype, "occlusionStrength", void 0);
  108. __decorate([
  109. serializeAsTexture(),
  110. expandToProperty("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")
  111. ], PBRBaseSimpleMaterial.prototype, "occlusionTexture", void 0);
  112. __decorate([
  113. serialize(),
  114. expandToProperty("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")
  115. ], PBRBaseSimpleMaterial.prototype, "alphaCutOff", void 0);
  116. __decorate([
  117. serialize()
  118. ], PBRBaseSimpleMaterial.prototype, "doubleSided", null);
  119. __decorate([
  120. serializeAsTexture(),
  121. expandToProperty("_markAllSubMeshesAsTexturesDirty", null)
  122. ], PBRBaseSimpleMaterial.prototype, "lightmapTexture", void 0);
  123. __decorate([
  124. serialize(),
  125. expandToProperty("_markAllSubMeshesAsTexturesDirty")
  126. ], PBRBaseSimpleMaterial.prototype, "useLightmapAsShadowmap", void 0);
  127. //# sourceMappingURL=pbrBaseSimpleMaterial.js.map