babylon.cubeTexture.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 (!preventExtensions) {
  13. extensions = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"];
  14. }
  15. if (!this._texture) {
  16. if (!scene.useDelayedTextureLoading) {
  17. this._texture = scene.getEngine().createCubeTexture(rootUrl, scene, extensions);
  18. } else {
  19. this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NOTLOADED;
  20. }
  21. }
  22. this.isCube = true;
  23. this._textureMatrix = BABYLON.Matrix.Identity();
  24. };
  25. BABYLON.CubeTexture.prototype = Object.create(BABYLON.BaseTexture.prototype);
  26. // Methods
  27. BABYLON.CubeTexture.prototype.delayLoad = function () {
  28. if (this.delayLoadState != BABYLON.Engine.DELAYLOADSTATE_NOTLOADED) {
  29. return;
  30. }
  31. this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_LOADED;
  32. this._texture = this._getFromCache(this.url);
  33. if (!this._texture) {
  34. this._texture = this._scene.getEngine().createCubeTexture(this.url, this._scene);
  35. }
  36. };
  37. BABYLON.CubeTexture.prototype._computeReflectionTextureMatrix = function() {
  38. return this._textureMatrix;
  39. };
  40. })();