babylon.dynamicTexture.js 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. var BABYLON = BABYLON || {};
  2. (function () {
  3. BABYLON.DynamicTexture = function (name, size, scene, generateMipMaps) {
  4. this._scene = scene;
  5. this._scene.textures.push(this);
  6. this.name = name;
  7. this.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
  8. this.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE;
  9. this._texture = scene.getEngine().createDynamicTexture(size, generateMipMaps);
  10. var textureSize = this.getSize();
  11. this._canvas = document.createElement("canvas");
  12. this._canvas.width = textureSize.width;
  13. this._canvas.height = textureSize.height;
  14. this._context = this._canvas.getContext("2d");
  15. };
  16. BABYLON.DynamicTexture.prototype = Object.create(BABYLON.Texture.prototype);
  17. // Methods
  18. BABYLON.DynamicTexture.prototype.getContext = function() {
  19. return this._context;
  20. };
  21. BABYLON.DynamicTexture.prototype.update = function () {
  22. this._scene.getEngine().updateDynamicTexture(this._texture, this._canvas);
  23. };
  24. })();