babylon.standardProceduralTexture.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  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. this.refreshRate = 0;
  17. }
  18. WoodProceduralTexture.prototype.updateShaderUniforms = function () {
  19. this.setFloat("ampScale", this._ampScale);
  20. this.setColor3("woodColor", this._woodColor);
  21. };
  22. Object.defineProperty(WoodProceduralTexture.prototype, "ampScale", {
  23. get: function () {
  24. return this._ampScale;
  25. },
  26. set: function (value) {
  27. this._ampScale = value;
  28. this.updateShaderUniforms();
  29. },
  30. enumerable: true,
  31. configurable: true
  32. });
  33. Object.defineProperty(WoodProceduralTexture.prototype, "woodColor", {
  34. get: function () {
  35. return this._woodColor;
  36. },
  37. set: function (value) {
  38. this._woodColor = value;
  39. this.updateShaderUniforms();
  40. },
  41. enumerable: true,
  42. configurable: true
  43. });
  44. return WoodProceduralTexture;
  45. })(BABYLON.ProceduralTexture);
  46. BABYLON.WoodProceduralTexture = WoodProceduralTexture;
  47. var FireProceduralTexture = (function (_super) {
  48. __extends(FireProceduralTexture, _super);
  49. function FireProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  50. _super.call(this, name, size, "fire", scene, fallbackTexture, generateMipMaps);
  51. this._time = 0.0;
  52. this._speed = new BABYLON.Vector2(0.5, 0.3);
  53. this._shift = 1.6;
  54. this._autoGenerateTime = true;
  55. this._alphaThreshold = 0.5;
  56. this._fireColors = FireProceduralTexture.RedFireColors;
  57. this.updateShaderUniforms();
  58. this.refreshRate = 1;
  59. }
  60. FireProceduralTexture.prototype.updateShaderUniforms = function () {
  61. this.setFloat("time", this._time);
  62. this.setVector2("speed", this._speed);
  63. this.setFloat("shift", this._shift);
  64. this.setColor3("c1", this._fireColors[0]);
  65. this.setColor3("c2", this._fireColors[1]);
  66. this.setColor3("c3", this._fireColors[2]);
  67. this.setColor3("c4", this._fireColors[3]);
  68. this.setColor3("c5", this._fireColors[4]);
  69. this.setColor3("c6", this._fireColors[5]);
  70. this.setFloat("alphaThreshold", this._alphaThreshold);
  71. };
  72. FireProceduralTexture.prototype.render = function (useCameraPostProcess) {
  73. if (this._autoGenerateTime) {
  74. this._time += this.getScene().getAnimationRatio() * 0.03;
  75. this.updateShaderUniforms();
  76. }
  77. _super.prototype.render.call(this, useCameraPostProcess);
  78. };
  79. Object.defineProperty(FireProceduralTexture, "PurpleFireColors", {
  80. get: function () {
  81. return [
  82. new BABYLON.Color3(0.5, 0.0, 1.0),
  83. new BABYLON.Color3(0.9, 0.0, 1.0),
  84. new BABYLON.Color3(0.2, 0.0, 1.0),
  85. new BABYLON.Color3(1.0, 0.9, 1.0),
  86. new BABYLON.Color3(0.1, 0.1, 1.0),
  87. new BABYLON.Color3(0.9, 0.9, 1.0)
  88. ];
  89. },
  90. enumerable: true,
  91. configurable: true
  92. });
  93. Object.defineProperty(FireProceduralTexture, "GreenFireColors", {
  94. get: function () {
  95. return [
  96. new BABYLON.Color3(0.5, 1.0, 0.0),
  97. new BABYLON.Color3(0.5, 1.0, 0.0),
  98. new BABYLON.Color3(0.3, 0.4, 0.0),
  99. new BABYLON.Color3(0.5, 1.0, 0.0),
  100. new BABYLON.Color3(0.2, 0.0, 0.0),
  101. new BABYLON.Color3(0.5, 1.0, 0.0)
  102. ];
  103. },
  104. enumerable: true,
  105. configurable: true
  106. });
  107. Object.defineProperty(FireProceduralTexture, "RedFireColors", {
  108. get: function () {
  109. return [
  110. new BABYLON.Color3(0.5, 0.0, 0.1),
  111. new BABYLON.Color3(0.9, 0.0, 0.0),
  112. new BABYLON.Color3(0.2, 0.0, 0.0),
  113. new BABYLON.Color3(1.0, 0.9, 0.0),
  114. new BABYLON.Color3(0.1, 0.1, 0.1),
  115. new BABYLON.Color3(0.9, 0.9, 0.9)
  116. ];
  117. },
  118. enumerable: true,
  119. configurable: true
  120. });
  121. Object.defineProperty(FireProceduralTexture, "BlueFireColors", {
  122. get: function () {
  123. return [
  124. new BABYLON.Color3(0.1, 0.0, 0.5),
  125. new BABYLON.Color3(0.0, 0.0, 0.5),
  126. new BABYLON.Color3(0.1, 0.0, 0.2),
  127. new BABYLON.Color3(0.0, 0.0, 1.0),
  128. new BABYLON.Color3(0.1, 0.2, 0.3),
  129. new BABYLON.Color3(0.0, 0.2, 0.9)
  130. ];
  131. },
  132. enumerable: true,
  133. configurable: true
  134. });
  135. Object.defineProperty(FireProceduralTexture.prototype, "fireColors", {
  136. get: function () {
  137. return this._fireColors;
  138. },
  139. set: function (value) {
  140. this._fireColors = value;
  141. this.updateShaderUniforms();
  142. },
  143. enumerable: true,
  144. configurable: true
  145. });
  146. Object.defineProperty(FireProceduralTexture.prototype, "time", {
  147. get: function () {
  148. return this._time;
  149. },
  150. set: function (value) {
  151. this._time = value;
  152. this.updateShaderUniforms();
  153. },
  154. enumerable: true,
  155. configurable: true
  156. });
  157. Object.defineProperty(FireProceduralTexture.prototype, "speed", {
  158. get: function () {
  159. return this._speed;
  160. },
  161. set: function (value) {
  162. this._speed = value;
  163. this.updateShaderUniforms();
  164. },
  165. enumerable: true,
  166. configurable: true
  167. });
  168. Object.defineProperty(FireProceduralTexture.prototype, "shift", {
  169. get: function () {
  170. return this._shift;
  171. },
  172. set: function (value) {
  173. this._shift = value;
  174. this.updateShaderUniforms();
  175. },
  176. enumerable: true,
  177. configurable: true
  178. });
  179. Object.defineProperty(FireProceduralTexture.prototype, "alphaThreshold", {
  180. get: function () {
  181. return this._alphaThreshold;
  182. },
  183. set: function (value) {
  184. this._alphaThreshold = value;
  185. this.updateShaderUniforms();
  186. },
  187. enumerable: true,
  188. configurable: true
  189. });
  190. return FireProceduralTexture;
  191. })(BABYLON.ProceduralTexture);
  192. BABYLON.FireProceduralTexture = FireProceduralTexture;
  193. var CloudProceduralTexture = (function (_super) {
  194. __extends(CloudProceduralTexture, _super);
  195. function CloudProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  196. _super.call(this, name, size, "cloud", scene, fallbackTexture, generateMipMaps);
  197. this._skyColor = new BABYLON.Color3(0.15, 0.68, 1.0);
  198. this._cloudColor = new BABYLON.Color3(1, 1, 1);
  199. this.updateShaderUniforms();
  200. this.refreshRate = 0;
  201. }
  202. CloudProceduralTexture.prototype.updateShaderUniforms = function () {
  203. this.setColor3("skyColor", this._skyColor);
  204. this.setColor3("cloudColor", this._cloudColor);
  205. };
  206. Object.defineProperty(CloudProceduralTexture.prototype, "skyColor", {
  207. get: function () {
  208. return this._skyColor;
  209. },
  210. set: function (value) {
  211. this._skyColor = value;
  212. this.updateShaderUniforms();
  213. },
  214. enumerable: true,
  215. configurable: true
  216. });
  217. Object.defineProperty(CloudProceduralTexture.prototype, "cloudColor", {
  218. get: function () {
  219. return this._cloudColor;
  220. },
  221. set: function (value) {
  222. this._cloudColor = value;
  223. this.updateShaderUniforms();
  224. },
  225. enumerable: true,
  226. configurable: true
  227. });
  228. return CloudProceduralTexture;
  229. })(BABYLON.ProceduralTexture);
  230. BABYLON.CloudProceduralTexture = CloudProceduralTexture;
  231. var GrassProceduralTexture = (function (_super) {
  232. __extends(GrassProceduralTexture, _super);
  233. function GrassProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  234. _super.call(this, name, size, "grass", scene, fallbackTexture, generateMipMaps);
  235. this._herb1 = new BABYLON.Color3(0.29, 0.38, 0.02);
  236. this._herb2 = new BABYLON.Color3(0.36, 0.49, 0.09);
  237. this._herb3 = new BABYLON.Color3(0.51, 0.6, 0.28);
  238. this._groundColor = new BABYLON.Color3(1, 1, 1);
  239. this._grassColors = [
  240. new BABYLON.Color3(0.29, 0.38, 0.02),
  241. new BABYLON.Color3(0.36, 0.49, 0.09),
  242. new BABYLON.Color3(0.51, 0.6, 0.28)
  243. ];
  244. this.updateShaderUniforms();
  245. this.refreshRate = 0;
  246. }
  247. GrassProceduralTexture.prototype.updateShaderUniforms = function () {
  248. this.setColor3("herb1Color", this._grassColors[0]);
  249. this.setColor3("herb2Color", this._grassColors[1]);
  250. this.setColor3("herb3Color", this._grassColors[2]);
  251. this.setColor3("groundColor", this._groundColor);
  252. };
  253. Object.defineProperty(GrassProceduralTexture.prototype, "grassColors", {
  254. get: function () {
  255. return this._grassColors;
  256. },
  257. set: function (value) {
  258. this._grassColors = value;
  259. this.updateShaderUniforms();
  260. },
  261. enumerable: true,
  262. configurable: true
  263. });
  264. Object.defineProperty(GrassProceduralTexture.prototype, "groundColor", {
  265. get: function () {
  266. return this._groundColor;
  267. },
  268. set: function (value) {
  269. this.groundColor = value;
  270. this.updateShaderUniforms();
  271. },
  272. enumerable: true,
  273. configurable: true
  274. });
  275. return GrassProceduralTexture;
  276. })(BABYLON.ProceduralTexture);
  277. BABYLON.GrassProceduralTexture = GrassProceduralTexture;
  278. var RoadProceduralTexture = (function (_super) {
  279. __extends(RoadProceduralTexture, _super);
  280. function RoadProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  281. _super.call(this, name, size, "road", scene, fallbackTexture, generateMipMaps);
  282. this._roadColor = new BABYLON.Color3(0.53, 0.53, 0.53);
  283. this.updateShaderUniforms();
  284. this.refreshRate = 0;
  285. }
  286. RoadProceduralTexture.prototype.updateShaderUniforms = function () {
  287. this.setColor3("roadColor", this._roadColor);
  288. };
  289. Object.defineProperty(RoadProceduralTexture.prototype, "roadColor", {
  290. get: function () {
  291. return this._roadColor;
  292. },
  293. set: function (value) {
  294. this._roadColor = value;
  295. this.updateShaderUniforms();
  296. },
  297. enumerable: true,
  298. configurable: true
  299. });
  300. return RoadProceduralTexture;
  301. })(BABYLON.ProceduralTexture);
  302. BABYLON.RoadProceduralTexture = RoadProceduralTexture;
  303. var BrickProceduralTexture = (function (_super) {
  304. __extends(BrickProceduralTexture, _super);
  305. function BrickProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  306. _super.call(this, name, size, "brick", scene, fallbackTexture, generateMipMaps);
  307. this._numberOfBricksHeight = 15;
  308. this._numberOfBricksWidth = 5;
  309. this._jointColor = new BABYLON.Color3(0.72, 0.72, 0.72);
  310. this._brickColor = new BABYLON.Color3(0.77, 0.47, 0.40);
  311. this.updateShaderUniforms();
  312. this.refreshRate = 0;
  313. }
  314. BrickProceduralTexture.prototype.updateShaderUniforms = function () {
  315. this.setFloat("numberOfBricksHeight", this._numberOfBricksHeight);
  316. this.setFloat("numberOfBricksWidth", this._numberOfBricksWidth);
  317. this.setColor3("brickColor", this._brickColor);
  318. this.setColor3("jointColor", this._jointColor);
  319. };
  320. Object.defineProperty(BrickProceduralTexture.prototype, "numberOfBricksHeight", {
  321. get: function () {
  322. return this._numberOfBricksHeight;
  323. },
  324. set: function (value) {
  325. this._numberOfBricksHeight = value;
  326. this.updateShaderUniforms();
  327. },
  328. enumerable: true,
  329. configurable: true
  330. });
  331. Object.defineProperty(BrickProceduralTexture.prototype, "numberOfBricksWidth", {
  332. get: function () {
  333. return this._numberOfBricksWidth;
  334. },
  335. set: function (value) {
  336. this._numberOfBricksHeight = value;
  337. this.updateShaderUniforms();
  338. },
  339. enumerable: true,
  340. configurable: true
  341. });
  342. Object.defineProperty(BrickProceduralTexture.prototype, "jointColor", {
  343. get: function () {
  344. return this._jointColor;
  345. },
  346. set: function (value) {
  347. this._jointColor = value;
  348. this.updateShaderUniforms();
  349. },
  350. enumerable: true,
  351. configurable: true
  352. });
  353. Object.defineProperty(BrickProceduralTexture.prototype, "brickColor", {
  354. get: function () {
  355. return this._brickColor;
  356. },
  357. set: function (value) {
  358. this._brickColor = value;
  359. this.updateShaderUniforms();
  360. },
  361. enumerable: true,
  362. configurable: true
  363. });
  364. return BrickProceduralTexture;
  365. })(BABYLON.ProceduralTexture);
  366. BABYLON.BrickProceduralTexture = BrickProceduralTexture;
  367. var MarbleProceduralTexture = (function (_super) {
  368. __extends(MarbleProceduralTexture, _super);
  369. function MarbleProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  370. _super.call(this, name, size, "marble", scene, fallbackTexture, generateMipMaps);
  371. this._numberOfTilesHeight = 3;
  372. this._numberOfTilesWidth = 3;
  373. this._amplitude = 9.0;
  374. this._marbleColor = new BABYLON.Color3(0.77, 0.47, 0.40);
  375. this._jointColor = new BABYLON.Color3(0.72, 0.72, 0.72);
  376. this.updateShaderUniforms();
  377. this.refreshRate = 0;
  378. }
  379. MarbleProceduralTexture.prototype.updateShaderUniforms = function () {
  380. this.setFloat("numberOfTilesHeight", this._numberOfTilesHeight);
  381. this.setFloat("numberOfTilesWidth", this._numberOfTilesWidth);
  382. this.setFloat("amplitude", this._amplitude);
  383. this.setColor3("marbleColor", this._marbleColor);
  384. this.setColor3("jointColor", this._jointColor);
  385. };
  386. Object.defineProperty(MarbleProceduralTexture.prototype, "numberOfTilesHeight", {
  387. get: function () {
  388. return this._numberOfTilesHeight;
  389. },
  390. set: function (value) {
  391. this._numberOfTilesHeight = value;
  392. this.updateShaderUniforms();
  393. },
  394. enumerable: true,
  395. configurable: true
  396. });
  397. Object.defineProperty(MarbleProceduralTexture.prototype, "numberOfTilesWidth", {
  398. get: function () {
  399. return this._numberOfTilesWidth;
  400. },
  401. set: function (value) {
  402. this._numberOfTilesWidth = value;
  403. this.updateShaderUniforms();
  404. },
  405. enumerable: true,
  406. configurable: true
  407. });
  408. Object.defineProperty(MarbleProceduralTexture.prototype, "jointColor", {
  409. get: function () {
  410. return this._jointColor;
  411. },
  412. set: function (value) {
  413. this._jointColor = value;
  414. this.updateShaderUniforms();
  415. },
  416. enumerable: true,
  417. configurable: true
  418. });
  419. Object.defineProperty(MarbleProceduralTexture.prototype, "marbleColor", {
  420. get: function () {
  421. return this._marbleColor;
  422. },
  423. set: function (value) {
  424. this._marbleColor = value;
  425. this.updateShaderUniforms();
  426. },
  427. enumerable: true,
  428. configurable: true
  429. });
  430. return MarbleProceduralTexture;
  431. })(BABYLON.ProceduralTexture);
  432. BABYLON.MarbleProceduralTexture = MarbleProceduralTexture;
  433. })(BABYLON || (BABYLON = {}));
  434. //# sourceMappingURL=babylon.standardProceduralTexture.js.map