UNPKG

@awayjs/renderer

Version:
109 lines (108 loc) 4.54 kB
import { __extends } from "tslib"; import { PassEvent } from '../events/PassEvent'; import { _Render_MaterialBase } from './_Render_MaterialBase'; /** * _Render_MaterialPassBase provides an abstract base class for material shader passes. A material pass constitutes at least * a render call per required renderable. */ var _Render_MaterialPassBase = /** @class */ (function (_super) { __extends(_Render_MaterialPassBase, _super); function _Render_MaterialPassBase() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(_Render_MaterialPassBase.prototype, "shader", { get: function () { return this._shader; }, enumerable: false, configurable: true }); Object.defineProperty(_Render_MaterialPassBase.prototype, "numUsedStreams", { get: function () { return this._shader.numUsedStreams; }, enumerable: false, configurable: true }); Object.defineProperty(_Render_MaterialPassBase.prototype, "numUsedTextures", { get: function () { return this._shader.numUsedTextures; }, enumerable: false, configurable: true }); _Render_MaterialPassBase.prototype._includeDependencies = function (shader) { var material = this.material; shader.alphaThreshold = material.alphaThreshold; shader.useImageRect = material.imageRect; shader.usesCurves = material.curves; shader.useBothSides = material.bothSides; shader.usesUVTransform = material.animateUVs; shader.usesColorTransform = material.useColorTransform; }; /** * Marks the shader program as invalid, so it will be recompiled before the next render. */ _Render_MaterialPassBase.prototype.invalidate = function () { this._shader.invalidateProgram(); this.dispatchEvent(new PassEvent(PassEvent.INVALIDATE, this)); }; _Render_MaterialPassBase.prototype.dispose = function () { if (this._shader) { this._shader.dispose(); this._shader = null; } }; /** * Renders the current pass. Before calling pass, activatePass needs to be called with the same index. * @param pass The pass used to render the renderable. * @param renderable The IRenderable object to draw. * @param stage The Stage object used for rendering. * @param entityCollector The EntityCollector object that contains the visible scene data. * @param viewProjection The view-projection matrix used to project to the screen. This is not the same as * camera.viewProjection as it includes the scaling factors when rendering to textures. * * @internal */ _Render_MaterialPassBase.prototype._setRenderState = function (renderState) { this._shader._setRenderState(renderState); }; /** * Sets the render state for the pass that is independent of the rendered object. This needs to be called before * calling pass. Before activating a pass, the previously used pass needs to be deactivated. * @param stage The Stage object which is currently used for rendering. * @param camera The camera from which the scene is viewed. * @private */ _Render_MaterialPassBase.prototype._activate = function () { this._shader._activate(); }; /** * Clears the render state for the pass. This needs to be called before activating another pass. * @param stage The Stage used for rendering * * @private */ _Render_MaterialPassBase.prototype._deactivate = function () { this._shader._deactivate(); }; _Render_MaterialPassBase.prototype._initConstantData = function () { }; _Render_MaterialPassBase.prototype._getVertexCode = function (registerCache, sharedRegisters) { return ''; }; _Render_MaterialPassBase.prototype._getFragmentCode = function (registerCache, sharedRegisters) { return ''; }; _Render_MaterialPassBase.prototype._getPostAnimationFragmentCode = function (registerCache, sharedRegisters) { return ''; }; _Render_MaterialPassBase.prototype._getNormalVertexCode = function (registerCache, sharedRegisters) { return ''; }; _Render_MaterialPassBase.prototype._getNormalFragmentCode = function (registerCache, sharedRegisters) { return ''; }; return _Render_MaterialPassBase; }(_Render_MaterialBase)); export { _Render_MaterialPassBase };