babylon.standardProceduralTexture.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  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._alpha = 0.0;
  55. this._autoGenerateTime = true;
  56. this._alphaThreshold = 0.5;
  57. this._fireColors = FireProceduralTexture.RedFireColors;
  58. this.updateShaderUniforms();
  59. this.refreshRate = 1;
  60. }
  61. FireProceduralTexture.prototype.updateShaderUniforms = function () {
  62. this.setFloat("iGlobalTime", this._time);
  63. this.setVector2("speed", this._speed);
  64. this.setFloat("shift", this._shift);
  65. this.setFloat("alpha", this._alpha);
  66. this.setColor3("c1", this._fireColors[0]);
  67. this.setColor3("c2", this._fireColors[1]);
  68. this.setColor3("c3", this._fireColors[2]);
  69. this.setColor3("c4", this._fireColors[3]);
  70. this.setColor3("c5", this._fireColors[4]);
  71. this.setColor3("c6", this._fireColors[5]);
  72. this.setFloat("alphaThreshold", this._alphaThreshold);
  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. new BABYLON.Color3(0.5, 0.0, 1.0),
  85. new BABYLON.Color3(0.9, 0.0, 1.0),
  86. new BABYLON.Color3(0.2, 0.0, 1.0),
  87. new BABYLON.Color3(1.0, 0.9, 1.0),
  88. new BABYLON.Color3(0.1, 0.1, 1.0),
  89. new BABYLON.Color3(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. new BABYLON.Color3(0.5, 1.0, 0.0),
  99. new BABYLON.Color3(0.5, 1.0, 0.0),
  100. new BABYLON.Color3(0.3, 0.4, 0.0),
  101. new BABYLON.Color3(0.5, 1.0, 0.0),
  102. new BABYLON.Color3(0.2, 0.0, 0.0),
  103. new BABYLON.Color3(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. new BABYLON.Color3(0.5, 0.0, 0.1),
  113. new BABYLON.Color3(0.9, 0.0, 0.0),
  114. new BABYLON.Color3(0.2, 0.0, 0.0),
  115. new BABYLON.Color3(1.0, 0.9, 0.0),
  116. new BABYLON.Color3(0.1, 0.1, 0.1),
  117. new BABYLON.Color3(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. new BABYLON.Color3(0.1, 0.0, 0.5),
  127. new BABYLON.Color3(0.0, 0.0, 0.5),
  128. new BABYLON.Color3(0.1, 0.0, 0.2),
  129. new BABYLON.Color3(0.0, 0.0, 1.0),
  130. new BABYLON.Color3(0.1, 0.2, 0.3),
  131. new BABYLON.Color3(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. this.updateShaderUniforms();
  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. this._herb1 = new BABYLON.Color3(0.29, 0.38, 0.02);
  238. this._herb2 = new BABYLON.Color3(0.36, 0.49, 0.09);
  239. this._herb3 = new BABYLON.Color3(0.51, 0.6, 0.28);
  240. this._dirtColor = new BABYLON.Color3(0.6, 0.46, 0.13);
  241. this._groundColor = new BABYLON.Color3(1, 1, 1);
  242. this._grassColors = [
  243. new BABYLON.Color3(0.29, 0.38, 0.02),
  244. new BABYLON.Color3(0.36, 0.49, 0.09),
  245. new BABYLON.Color3(0.51, 0.6, 0.28)
  246. ];
  247. this.updateShaderUniforms();
  248. this.refreshRate = 0;
  249. }
  250. GrassProceduralTexture.prototype.updateShaderUniforms = function () {
  251. this.setColor3("herb1", this._grassColors[0]);
  252. this.setColor3("herb2", this._grassColors[1]);
  253. this.setColor3("herb3", this._grassColors[2]);
  254. this.setColor3("dirt", this._dirtColor);
  255. this.setColor3("ground", this._groundColor);
  256. };
  257. Object.defineProperty(GrassProceduralTexture.prototype, "grassColors", {
  258. get: function () {
  259. return this._grassColors;
  260. },
  261. set: function (value) {
  262. this._grassColors = value;
  263. this.updateShaderUniforms();
  264. },
  265. enumerable: true,
  266. configurable: true
  267. });
  268. Object.defineProperty(GrassProceduralTexture.prototype, "dirtColor", {
  269. get: function () {
  270. return this._dirtColor;
  271. },
  272. set: function (value) {
  273. this._dirtColor = value;
  274. this.updateShaderUniforms();
  275. },
  276. enumerable: true,
  277. configurable: true
  278. });
  279. Object.defineProperty(GrassProceduralTexture.prototype, "groundColor", {
  280. get: function () {
  281. return this._groundColor;
  282. },
  283. enumerable: true,
  284. configurable: true
  285. });
  286. Object.defineProperty(GrassProceduralTexture.prototype, "ground", {
  287. set: function (value) {
  288. this.groundColor = value;
  289. this.updateShaderUniforms();
  290. },
  291. enumerable: true,
  292. configurable: true
  293. });
  294. return GrassProceduralTexture;
  295. })(BABYLON.ProceduralTexture);
  296. BABYLON.GrassProceduralTexture = GrassProceduralTexture;
  297. var RoadProceduralTexture = (function (_super) {
  298. __extends(RoadProceduralTexture, _super);
  299. function RoadProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  300. _super.call(this, name, size, "road", scene, fallbackTexture, generateMipMaps);
  301. this._roadColor = new BABYLON.Color3(0.53, 0.53, 0.53);
  302. this.updateShaderUniforms();
  303. this.refreshRate = 0;
  304. }
  305. RoadProceduralTexture.prototype.updateShaderUniforms = function () {
  306. this.setColor3("roadColor", this._roadColor);
  307. };
  308. Object.defineProperty(RoadProceduralTexture.prototype, "roadColor", {
  309. get: function () {
  310. return this._roadColor;
  311. },
  312. set: function (value) {
  313. this._roadColor = value;
  314. this.updateShaderUniforms();
  315. },
  316. enumerable: true,
  317. configurable: true
  318. });
  319. return RoadProceduralTexture;
  320. })(BABYLON.ProceduralTexture);
  321. BABYLON.RoadProceduralTexture = RoadProceduralTexture;
  322. var BrickProceduralTexture = (function (_super) {
  323. __extends(BrickProceduralTexture, _super);
  324. function BrickProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  325. _super.call(this, name, size, "brick", scene, fallbackTexture, generateMipMaps);
  326. this._numberOfBricksHeight = 15;
  327. this._numberOfBricksWidth = 5;
  328. this._jointColor = new BABYLON.Color3(0.72, 0.72, 0.72);
  329. this._brickColor = new BABYLON.Color3(0.77, 0.47, 0.40);
  330. this.updateShaderUniforms();
  331. this.refreshRate = 0;
  332. }
  333. BrickProceduralTexture.prototype.updateShaderUniforms = function () {
  334. this.setFloat("numberOfBricksHeight", this._numberOfBricksHeight);
  335. this.setFloat("numberOfBricksWidth", this._numberOfBricksWidth);
  336. this.setColor3("brick", this._brickColor);
  337. this.setColor3("joint", this._jointColor);
  338. };
  339. Object.defineProperty(BrickProceduralTexture.prototype, "numberOfBricksHeight", {
  340. get: function () {
  341. return this._numberOfBricksHeight;
  342. },
  343. enumerable: true,
  344. configurable: true
  345. });
  346. Object.defineProperty(BrickProceduralTexture.prototype, "cloudColor", {
  347. set: function (value) {
  348. this._numberOfBricksHeight = value;
  349. this.updateShaderUniforms();
  350. },
  351. enumerable: true,
  352. configurable: true
  353. });
  354. Object.defineProperty(BrickProceduralTexture.prototype, "numberOfBricksWidth", {
  355. get: function () {
  356. return this._numberOfBricksWidth;
  357. },
  358. set: function (value) {
  359. this._numberOfBricksHeight = value;
  360. this.updateShaderUniforms();
  361. },
  362. enumerable: true,
  363. configurable: true
  364. });
  365. Object.defineProperty(BrickProceduralTexture.prototype, "jointColor", {
  366. get: function () {
  367. return this._jointColor;
  368. },
  369. set: function (value) {
  370. this._jointColor = value;
  371. this.updateShaderUniforms();
  372. },
  373. enumerable: true,
  374. configurable: true
  375. });
  376. Object.defineProperty(BrickProceduralTexture.prototype, "brickColor", {
  377. get: function () {
  378. return this._brickColor;
  379. },
  380. set: function (value) {
  381. this._brickColor = value;
  382. this.updateShaderUniforms();
  383. },
  384. enumerable: true,
  385. configurable: true
  386. });
  387. return BrickProceduralTexture;
  388. })(BABYLON.ProceduralTexture);
  389. BABYLON.BrickProceduralTexture = BrickProceduralTexture;
  390. var MarbleProceduralTexture = (function (_super) {
  391. __extends(MarbleProceduralTexture, _super);
  392. function MarbleProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  393. _super.call(this, name, size, "marble", scene, fallbackTexture, generateMipMaps);
  394. this._numberOfTilesHeight = 3;
  395. this._numberOfTilesWidth = 3;
  396. this._amplitude = 9.0;
  397. this._marbleColor = new BABYLON.Color3(0.77, 0.47, 0.40);
  398. this._jointColor = new BABYLON.Color3(0.72, 0.72, 0.72);
  399. this.updateShaderUniforms();
  400. this.refreshRate = 0;
  401. }
  402. MarbleProceduralTexture.prototype.updateShaderUniforms = function () {
  403. this.setFloat("numberOfBricksHeight", this._numberOfTilesHeight);
  404. this.setFloat("numberOfBricksWidth", this._numberOfTilesWidth);
  405. this.setFloat("amplitude", this._amplitude);
  406. this.setColor3("brick", this._marbleColor);
  407. this.setColor3("joint", this._jointColor);
  408. };
  409. Object.defineProperty(MarbleProceduralTexture.prototype, "numberOfTilesHeight", {
  410. get: function () {
  411. return this._numberOfTilesHeight;
  412. },
  413. set: function (value) {
  414. this._numberOfTilesHeight = value;
  415. this.updateShaderUniforms();
  416. },
  417. enumerable: true,
  418. configurable: true
  419. });
  420. Object.defineProperty(MarbleProceduralTexture.prototype, "numberOfTilesWidth", {
  421. get: function () {
  422. return this._numberOfTilesWidth;
  423. },
  424. set: function (value) {
  425. this._numberOfTilesWidth = value;
  426. this.updateShaderUniforms();
  427. },
  428. enumerable: true,
  429. configurable: true
  430. });
  431. Object.defineProperty(MarbleProceduralTexture.prototype, "jointColor", {
  432. get: function () {
  433. return this._jointColor;
  434. },
  435. set: function (value) {
  436. this._jointColor = value;
  437. this.updateShaderUniforms();
  438. },
  439. enumerable: true,
  440. configurable: true
  441. });
  442. Object.defineProperty(MarbleProceduralTexture.prototype, "marbleColor", {
  443. get: function () {
  444. return this._marbleColor;
  445. },
  446. set: function (value) {
  447. this._marbleColor = value;
  448. this.updateShaderUniforms();
  449. },
  450. enumerable: true,
  451. configurable: true
  452. });
  453. return MarbleProceduralTexture;
  454. })(BABYLON.ProceduralTexture);
  455. BABYLON.MarbleProceduralTexture = MarbleProceduralTexture;
  456. })(BABYLON || (BABYLON = {}));
  457. //# sourceMappingURL=babylon.standardProceduralTexture.js.map