babylon.standardProceduralTexture.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. var __extends = this.__extends || function (d, b) {
  2. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3. function __() { this.constructor = d; }
  4. __.prototype = b.prototype;
  5. d.prototype = new __();
  6. };
  7. var BABYLON;
  8. (function (BABYLON) {
  9. var WoodProceduralTexture = (function (_super) {
  10. __extends(WoodProceduralTexture, _super);
  11. function WoodProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  12. _super.call(this, name, size, "wood", scene, fallbackTexture, generateMipMaps);
  13. this._ampScale = 0.03;
  14. this._ringScale = 5;
  15. this._woodColor1 = new BABYLON.Color3(0.80, 0.55, 0.01);
  16. this._woodColor2 = new BABYLON.Color3(0.60, 0.41, 0.0);
  17. this.updateShaderUniforms();
  18. // Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19. this.refreshRate = 0;
  20. }
  21. WoodProceduralTexture.prototype.updateShaderUniforms = function () {
  22. this.setFloat("ampScale", this._ampScale);
  23. this.setFloat("ringScale", this._ringScale);
  24. this.setColor3("woodColor1", this._woodColor1);
  25. this.setColor3("woodColor2", this._woodColor2);
  26. };
  27. Object.defineProperty(WoodProceduralTexture.prototype, "ampScale", {
  28. get: function () {
  29. return this._ampScale;
  30. },
  31. set: function (value) {
  32. this._ampScale = value;
  33. this.updateShaderUniforms();
  34. },
  35. enumerable: true,
  36. configurable: true
  37. });
  38. Object.defineProperty(WoodProceduralTexture.prototype, "ringScale", {
  39. get: function () {
  40. return this._ringScale;
  41. },
  42. set: function (value) {
  43. this._ringScale = value;
  44. this.updateShaderUniforms();
  45. },
  46. enumerable: true,
  47. configurable: true
  48. });
  49. Object.defineProperty(WoodProceduralTexture.prototype, "woodColor1", {
  50. get: function () {
  51. return this._woodColor1;
  52. },
  53. set: function (value) {
  54. this._woodColor1 = value;
  55. this.updateShaderUniforms();
  56. },
  57. enumerable: true,
  58. configurable: true
  59. });
  60. Object.defineProperty(WoodProceduralTexture.prototype, "woodColor2", {
  61. get: function () {
  62. return this._woodColor2;
  63. },
  64. set: function (value) {
  65. this._woodColor2 = value;
  66. this.updateShaderUniforms();
  67. },
  68. enumerable: true,
  69. configurable: true
  70. });
  71. return WoodProceduralTexture;
  72. })(BABYLON.ProceduralTexture);
  73. BABYLON.WoodProceduralTexture = WoodProceduralTexture;
  74. var FireProceduralTexture = (function (_super) {
  75. __extends(FireProceduralTexture, _super);
  76. function FireProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  77. _super.call(this, name, size, "fire", scene, fallbackTexture, generateMipMaps);
  78. this._time = 0.0;
  79. this._speed = new BABYLON.Vector2(0.5, 0.3);
  80. this._shift = 1.6;
  81. this._alpha = 1.0;
  82. this._autoGenerateTime = true;
  83. this._fireColors = FireProceduralTexture.RedFireColors;
  84. this.updateShaderUniforms();
  85. // Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  86. this.refreshRate = 1;
  87. }
  88. FireProceduralTexture.prototype.updateShaderUniforms = function () {
  89. this.setFloat("iGlobalTime", this._time);
  90. this.setVector2("speed", this._speed);
  91. this.setFloat("shift", this._shift);
  92. this.setFloat("alpha", this._alpha);
  93. this.setColor3("c1", new BABYLON.Color3(this._fireColors[0][0], this._fireColors[0][1], this._fireColors[0][2]));
  94. this.setColor3("c2", new BABYLON.Color3(this._fireColors[1][0], this._fireColors[1][1], this._fireColors[1][2]));
  95. this.setColor3("c3", new BABYLON.Color3(this._fireColors[2][0], this._fireColors[2][1], this._fireColors[2][2]));
  96. this.setColor3("c4", new BABYLON.Color3(this._fireColors[3][0], this._fireColors[3][1], this._fireColors[3][2]));
  97. this.setColor3("c5", new BABYLON.Color3(this._fireColors[4][0], this._fireColors[4][1], this._fireColors[4][2]));
  98. this.setColor3("c6", new BABYLON.Color3(this._fireColors[5][0], this._fireColors[5][1], this._fireColors[5][2]));
  99. };
  100. FireProceduralTexture.prototype.render = function (useCameraPostProcess) {
  101. if (this._autoGenerateTime) {
  102. this._time += this.getScene().getAnimationRatio() * 0.03;
  103. this.updateShaderUniforms();
  104. }
  105. _super.prototype.render.call(this, useCameraPostProcess);
  106. };
  107. Object.defineProperty(FireProceduralTexture, "PurpleFireColors", {
  108. get: function () {
  109. return [
  110. [0.5, 0.0, 1.0],
  111. [0.9, 0.0, 1.0],
  112. [0.2, 0.0, 1.0],
  113. [1.0, 0.9, 1.0],
  114. [0.1, 0.1, 1.0],
  115. [0.9, 0.9, 1.0]
  116. ];
  117. },
  118. enumerable: true,
  119. configurable: true
  120. });
  121. Object.defineProperty(FireProceduralTexture, "GreenFireColors", {
  122. get: function () {
  123. return [
  124. [0.5, 1.0, 0.0],
  125. [0.5, 1.0, 0.0],
  126. [0.3, 0.4, 0.0],
  127. [0.5, 1.0, 0.0],
  128. [0.2, 0.0, 0.0],
  129. [0.5, 1.0, 0.0]
  130. ];
  131. },
  132. enumerable: true,
  133. configurable: true
  134. });
  135. Object.defineProperty(FireProceduralTexture, "RedFireColors", {
  136. get: function () {
  137. return [
  138. [0.5, 0.0, 0.1],
  139. [0.9, 0.0, 0.0],
  140. [0.2, 0.0, 0.0],
  141. [1.0, 0.9, 0.0],
  142. [0.1, 0.1, 0.1],
  143. [0.9, 0.9, 0.9]
  144. ];
  145. },
  146. enumerable: true,
  147. configurable: true
  148. });
  149. Object.defineProperty(FireProceduralTexture, "BlueFireColors", {
  150. get: function () {
  151. return [
  152. [0.1, 0.0, 0.5],
  153. [0.0, 0.0, 0.5],
  154. [0.1, 0.0, 0.2],
  155. [0.0, 0.0, 1.0],
  156. [0.1, 0.2, 0.3],
  157. [0.0, 0.2, 0.9]
  158. ];
  159. },
  160. enumerable: true,
  161. configurable: true
  162. });
  163. Object.defineProperty(FireProceduralTexture.prototype, "fireColors", {
  164. get: function () {
  165. return this._fireColors;
  166. },
  167. set: function (value) {
  168. this._fireColors = value;
  169. this.updateShaderUniforms();
  170. },
  171. enumerable: true,
  172. configurable: true
  173. });
  174. Object.defineProperty(FireProceduralTexture.prototype, "time", {
  175. get: function () {
  176. return this._time;
  177. },
  178. set: function (value) {
  179. this._time = value;
  180. this.updateShaderUniforms();
  181. },
  182. enumerable: true,
  183. configurable: true
  184. });
  185. Object.defineProperty(FireProceduralTexture.prototype, "speed", {
  186. get: function () {
  187. return this._speed;
  188. },
  189. set: function (value) {
  190. this._speed = value;
  191. this.updateShaderUniforms();
  192. },
  193. enumerable: true,
  194. configurable: true
  195. });
  196. Object.defineProperty(FireProceduralTexture.prototype, "shift", {
  197. get: function () {
  198. return this._shift;
  199. },
  200. set: function (value) {
  201. this._shift = value;
  202. this.updateShaderUniforms();
  203. },
  204. enumerable: true,
  205. configurable: true
  206. });
  207. Object.defineProperty(FireProceduralTexture.prototype, "alpha", {
  208. get: function () {
  209. return this._alpha;
  210. },
  211. set: function (value) {
  212. this._alpha = value;
  213. this.updateShaderUniforms();
  214. },
  215. enumerable: true,
  216. configurable: true
  217. });
  218. return FireProceduralTexture;
  219. })(BABYLON.ProceduralTexture);
  220. BABYLON.FireProceduralTexture = FireProceduralTexture;
  221. var CloudProceduralTexture = (function (_super) {
  222. __extends(CloudProceduralTexture, _super);
  223. function CloudProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  224. _super.call(this, name, size, "cloud", scene, fallbackTexture, generateMipMaps);
  225. // Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  226. this.refreshRate = 0;
  227. }
  228. return CloudProceduralTexture;
  229. })(BABYLON.ProceduralTexture);
  230. BABYLON.CloudProceduralTexture = CloudProceduralTexture;
  231. })(BABYLON || (BABYLON = {}));
  232. //# sourceMappingURL=babylon.standardProceduralTexture.js.map