babylon.rawTexture.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5. };
  6. var BABYLON;
  7. (function (BABYLON) {
  8. var RawTexture = (function (_super) {
  9. __extends(RawTexture, _super);
  10. function RawTexture(data, width, height, format, scene, generateMipMaps, invertY, samplingMode) {
  11. if (generateMipMaps === void 0) { generateMipMaps = true; }
  12. if (invertY === void 0) { invertY = false; }
  13. if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
  14. _super.call(this, null, scene, !generateMipMaps, invertY);
  15. this.format = format;
  16. this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode);
  17. this.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
  18. this.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE;
  19. }
  20. RawTexture.prototype.update = function (data) {
  21. this.getScene().getEngine().updateRawTexture(this._texture, data, this.format, this._invertY);
  22. };
  23. // Statics
  24. RawTexture.CreateLuminanceTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  25. if (generateMipMaps === void 0) { generateMipMaps = true; }
  26. if (invertY === void 0) { invertY = false; }
  27. if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
  28. return new RawTexture(data, width, height, BABYLON.Engine.TEXTUREFORMAT_LUMINANCE, scene, generateMipMaps, invertY, samplingMode);
  29. };
  30. RawTexture.CreateLuminanceAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  31. if (generateMipMaps === void 0) { generateMipMaps = true; }
  32. if (invertY === void 0) { invertY = false; }
  33. if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
  34. return new RawTexture(data, width, height, BABYLON.Engine.TEXTUREFORMAT_LUMINANCE_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  35. };
  36. RawTexture.CreateAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  37. if (generateMipMaps === void 0) { generateMipMaps = true; }
  38. if (invertY === void 0) { invertY = false; }
  39. if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
  40. return new RawTexture(data, width, height, BABYLON.Engine.TEXTUREFORMAT_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  41. };
  42. RawTexture.CreateRGBTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  43. if (generateMipMaps === void 0) { generateMipMaps = true; }
  44. if (invertY === void 0) { invertY = false; }
  45. if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
  46. return new RawTexture(data, width, height, BABYLON.Engine.TEXTUREFORMAT_RGB, scene, generateMipMaps, invertY, samplingMode);
  47. };
  48. RawTexture.CreateRGBATexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  49. if (generateMipMaps === void 0) { generateMipMaps = true; }
  50. if (invertY === void 0) { invertY = false; }
  51. if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
  52. return new RawTexture(data, width, height, BABYLON.Engine.TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode);
  53. };
  54. return RawTexture;
  55. })(BABYLON.Texture);
  56. BABYLON.RawTexture = RawTexture;
  57. })(BABYLON || (BABYLON = {}));