@awayjs/graphics
Version:
AwayJS graphics classes
53 lines (52 loc) • 2.32 kB
JavaScript
import { __extends } from "tslib";
import { ContextGLVertexBufferFormat } from '@awayjs/stage';
import { ParticlePropertiesMode } from '../data/ParticlePropertiesMode';
import { ParticleStateBase } from './ParticleStateBase';
/**
* ...
*/
var ParticleVelocityState = /** @class */ (function (_super) {
__extends(ParticleVelocityState, _super);
function ParticleVelocityState(animator, particleVelocityNode) {
var _this = _super.call(this, animator, particleVelocityNode) || this;
_this._particleVelocityNode = particleVelocityNode;
_this._velocity = _this._particleVelocityNode._iVelocity;
return _this;
}
Object.defineProperty(ParticleVelocityState.prototype, "velocity", {
/**
* Defines the default velocity vector of the state, used when in global mode.
*/
get: function () {
return this._velocity;
},
set: function (value) {
this._velocity = value;
},
enumerable: false,
configurable: true
});
/**
*
*/
ParticleVelocityState.prototype.getVelocities = function () {
return this._pDynamicProperties;
};
ParticleVelocityState.prototype.setVelocities = function (value) {
this._pDynamicProperties = value;
this._pDynamicPropertiesDirty = new Object();
};
ParticleVelocityState.prototype.setRenderState = function (shader, renderable, animationElements, animationRegisterData) {
if (this._particleVelocityNode.mode == ParticlePropertiesMode.LOCAL_DYNAMIC && !this._pDynamicPropertiesDirty[animationElements._iUniqueId])
this._pUpdateDynamicProperties(animationElements);
var index = animationRegisterData.getRegisterIndex(this._pAnimationNode, ParticleVelocityState.VELOCITY_INDEX);
if (this._particleVelocityNode.mode == ParticlePropertiesMode.GLOBAL)
shader.setVertexConst(index, this._velocity.x, this._velocity.y, this._velocity.z);
else
animationElements.activateVertexBuffer(index, this._particleVelocityNode._iDataOffset, shader.stage, ContextGLVertexBufferFormat.FLOAT_3);
};
/** @private */
ParticleVelocityState.VELOCITY_INDEX = 0;
return ParticleVelocityState;
}(ParticleStateBase));
export { ParticleVelocityState };