babylon.standardProceduralTexture.js 17 KB

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