UNPKG

@awayjs/renderer

Version:
74 lines (73 loc) 2.69 kB
import { __extends } from "tslib"; import { AbstractMethodError, AbstractionBase } from '@awayjs/core'; /** * * @class away.pool._Shader_TextureBaseBase */ var _Shader_TextureBase = /** @class */ (function (_super) { __extends(_Shader_TextureBase, _super); function _Shader_TextureBase() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(_Shader_TextureBase.prototype, "texture", { get: function () { return this._useWeak ? this._asset.deref() : this._asset; }, enumerable: false, configurable: true }); _Shader_TextureBase.prototype.init = function (texture, shader) { _super.prototype.init.call(this, texture, shader, true); this._shader = shader; this._stage = shader._stage; }; /** * */ _Shader_TextureBase.prototype.onClear = function () { _super.prototype.onClear.call(this); this._shader = null; this._stage = null; }; /** * Initializes the properties for a MethodVO, including register and texture indices. * * @param methodVO The MethodVO object linking this method with the pass currently being compiled. * * @internal */ _Shader_TextureBase.prototype._initVO = function (chunkVO) { }; /** * Initializes unchanging shader constants using the data from a MethodVO. * * @param methodVO The MethodVO object linking this method with the pass currently being compiled. * * @internal */ _Shader_TextureBase.prototype._initConstants = function () { }; _Shader_TextureBase.prototype._getFragmentCode = function (targetReg, regCache, sharedReg, inputReg) { if (inputReg === void 0) { inputReg = null; } throw new AbstractMethodError(); }; _Shader_TextureBase.prototype._setRenderState = function (renderState) { //overidden for state logic }; _Shader_TextureBase.prototype.activate = function () { //overridden for activation logic }; _Shader_TextureBase.prototype.getTextureReg = function (imageIndex, regCache, sharedReg) { //todo: collapse the index based on duplicate image objects to save registrations var index = this._shader.imageIndices.indexOf(imageIndex); if (index == -1) { var textureReg = regCache.getFreeTextureReg(); sharedReg.textures.push(textureReg); this._shader.imageIndices.push(imageIndex); return textureReg; } return sharedReg.textures[index]; }; return _Shader_TextureBase; }(AbstractionBase)); export { _Shader_TextureBase };