babylon.cubeTexture.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. "use strict";
  2. var BABYLON = BABYLON || {};
  3. (function () {
  4. BABYLON.CubeTexture = function (rootUrl, scene, extensions) {
  5. this._scene = scene;
  6. this._scene.textures.push(this);
  7. this.name = rootUrl;
  8. this.url = rootUrl;
  9. this.hasAlpha = false;
  10. this.coordinatesMode = BABYLON.Texture.CUBIC_MODE;
  11. this._texture = this._getFromCache(rootUrl);
  12. if (!extensions) {
  13. extensions = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"];
  14. }
  15. this._extensions = extensions;
  16. if (!this._texture) {
  17. if (!scene.useDelayedTextureLoading) {
  18. this._texture = scene.getEngine().createCubeTexture(rootUrl, scene, extensions);
  19. } else {
  20. this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NOTLOADED;
  21. }
  22. }
  23. this.isCube = true;
  24. this._textureMatrix = BABYLON.Matrix.Identity();
  25. };
  26. BABYLON.CubeTexture.prototype = Object.create(BABYLON.BaseTexture.prototype);
  27. // Methods
  28. BABYLON.CubeTexture.prototype.delayLoad = function () {
  29. if (this.delayLoadState != BABYLON.Engine.DELAYLOADSTATE_NOTLOADED) {
  30. return;
  31. }
  32. this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_LOADED;
  33. this._texture = this._getFromCache(this.url);
  34. if (!this._texture) {
  35. this._texture = this._scene.getEngine().createCubeTexture(this.url, this._scene, this._extensions);
  36. }
  37. };
  38. BABYLON.CubeTexture.prototype._computeReflectionTextureMatrix = function() {
  39. return this._textureMatrix;
  40. };
  41. })();