babylon.standardProceduralTexture.js 10.0 KB

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