@awayjs/graphics
Version:
AwayJS graphics classes
71 lines (70 loc) • 3.8 kB
JavaScript
import { __extends } from "tslib";
import { Vector3D } from '@awayjs/core';
import { ContextGLVertexBufferFormat } from '@awayjs/stage';
import { ParticlePropertiesMode } from '../data/ParticlePropertiesMode';
import { ParticleStateBase } from './ParticleStateBase';
/**
*
*/
var ParticleInitialColorState = /** @class */ (function (_super) {
__extends(ParticleInitialColorState, _super);
function ParticleInitialColorState(animator, particleInitialColorNode) {
var _this = _super.call(this, animator, particleInitialColorNode) || this;
_this._particleInitialColorNode = particleInitialColorNode;
_this._usesMultiplier = particleInitialColorNode._iUsesMultiplier;
_this._usesOffset = particleInitialColorNode._iUsesOffset;
_this._initialColor = particleInitialColorNode._iInitialColor;
_this.updateColorData();
return _this;
}
Object.defineProperty(ParticleInitialColorState.prototype, "initialColor", {
/**
* Defines the initial color transform of the state, when in global mode.
*/
get: function () {
return this._initialColor;
},
set: function (value) {
this._initialColor = value;
},
enumerable: false,
configurable: true
});
/**
* @inheritDoc
*/
ParticleInitialColorState.prototype.setRenderState = function (shader, renderable, animationElements, animationRegisterData) {
if (shader.usesFragmentAnimation) {
var index = void 0;
if (this._particleInitialColorNode.mode == ParticlePropertiesMode.LOCAL_STATIC) {
var dataOffset = this._particleInitialColorNode._iDataOffset;
if (this._usesMultiplier) {
animationElements.activateVertexBuffer(animationRegisterData.getRegisterIndex(this._pAnimationNode, ParticleInitialColorState.MULTIPLIER_INDEX), dataOffset, shader.stage, ContextGLVertexBufferFormat.FLOAT_4);
dataOffset += 4;
}
if (this._usesOffset)
animationElements.activateVertexBuffer(animationRegisterData.getRegisterIndex(this._pAnimationNode, ParticleInitialColorState.OFFSET_INDEX), dataOffset, shader.stage, ContextGLVertexBufferFormat.FLOAT_4);
}
else {
if (this._usesMultiplier)
shader.setVertexConst(animationRegisterData.getRegisterIndex(this._pAnimationNode, ParticleInitialColorState.MULTIPLIER_INDEX), this._multiplierData.x, this._multiplierData.y, this._multiplierData.z, this._multiplierData.w);
if (this._usesOffset)
shader.setVertexConst(animationRegisterData.getRegisterIndex(this._pAnimationNode, ParticleInitialColorState.OFFSET_INDEX), this._offsetData.x, this._offsetData.y, this._offsetData.z, this._offsetData.w);
}
}
};
ParticleInitialColorState.prototype.updateColorData = function () {
if (this._particleInitialColorNode.mode == ParticlePropertiesMode.GLOBAL) {
if (this._usesMultiplier)
this._multiplierData = new Vector3D(this._initialColor.redMultiplier, this._initialColor.greenMultiplier, this._initialColor.blueMultiplier, this._initialColor.alphaMultiplier);
if (this._usesOffset)
this._offsetData = new Vector3D(this._initialColor.redOffset / 255, this._initialColor.greenOffset / 255, this._initialColor.blueOffset / 255, this._initialColor.alphaOffset / 255);
}
};
/** @private */
ParticleInitialColorState.MULTIPLIER_INDEX = 0;
/** @private */
ParticleInitialColorState.OFFSET_INDEX = 1;
return ParticleInitialColorState;
}(ParticleStateBase));
export { ParticleInitialColorState };