UNPKG

@awayjs/stage

Version:
92 lines (91 loc) 2.58 kB
import { __extends } from "tslib"; import { ImageUtils } from '../utils/ImageUtils'; import { ImageBase } from './ImageBase'; var ImageCube = /** @class */ (function (_super) { __extends(ImageCube, _super); /** * */ function ImageCube(size) { var _this = _super.call(this) || this; _this._size = size; _this._testDimensions(); return _this; } Object.defineProperty(ImageCube.prototype, "assetType", { /** * * @returns {string} */ get: function () { return ImageCube.assetType; }, enumerable: false, configurable: true }); Object.defineProperty(ImageCube.prototype, "size", { /** * The size of the cube bitmap in pixels. */ get: function () { return this._size; }, set: function (value) { if (this._size == value) return; this._setSize(this._size); }, enumerable: false, configurable: true }); /** * * @param width * @param height * @private */ ImageCube.prototype._setSize = function (size) { if (this._size != size) this.clear(); this._size = size; this._testDimensions(); }; /** * * @private */ ImageCube.prototype._testDimensions = function () { if (!ImageUtils.isDimensionValid(this._size)) throw new Error('Invalid dimension: Width and height must be power of 2 and cannot exceed 2048'); }; ImageCube.assetType = '[image ImageCube]'; return ImageCube; }(ImageBase)); export { ImageCube }; import { ContextGLTextureFormat } from '../base/ContextGLTextureFormat'; import { _Stage_ImageBase } from './ImageBase'; /** * * @class away.pool.GL_ImageCubeBase */ var _Stage_ImageCube = /** @class */ (function (_super) { __extends(_Stage_ImageCube, _super); function _Stage_ImageCube() { return _super !== null && _super.apply(this, arguments) || this; } _Stage_ImageCube.prototype.getType = function () { return 'cube'; }; /** * * @param context * @returns {ITexture} */ _Stage_ImageCube.prototype._createTexture = function () { this._texture = this._stage.context.createCubeTexture(this._asset.size, ContextGLTextureFormat.BGRA, false); }; return _Stage_ImageCube; }(_Stage_ImageBase)); export { _Stage_ImageCube }; // MOVED TO LIB ROOT // Stage.registerAbstraction(_Stage_ImageCube, ImageCube);