babylon.standardProceduralTexture.js 19 KB

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