@awayjs/graphics
Version:
AwayJS graphics classes
57 lines (56 loc) • 2.37 kB
JavaScript
import { __extends } from "tslib";
import { ContextGLVertexBufferFormat } from '@awayjs/stage';
import { ParticlePropertiesMode } from '../data/ParticlePropertiesMode';
import { ParticleStateBase } from './ParticleStateBase';
/**
* ...
* @author ...
*/
var ParticlePositionState = /** @class */ (function (_super) {
__extends(ParticlePositionState, _super);
function ParticlePositionState(animator, particlePositionNode) {
var _this = _super.call(this, animator, particlePositionNode) || this;
_this._particlePositionNode = particlePositionNode;
_this._position = _this._particlePositionNode._iPosition;
return _this;
}
Object.defineProperty(ParticlePositionState.prototype, "position", {
/**
* Defines the position of the particle when in global mode. Defaults to 0,0,0.
*/
get: function () {
return this._position;
},
set: function (value) {
this._position = value;
},
enumerable: false,
configurable: true
});
/**
*
*/
ParticlePositionState.prototype.getPositions = function () {
return this._pDynamicProperties;
};
ParticlePositionState.prototype.setPositions = function (value) {
this._pDynamicProperties = value;
this._pDynamicPropertiesDirty = new Object();
};
/**
* @inheritDoc
*/
ParticlePositionState.prototype.setRenderState = function (shader, renderable, animationElements, animationRegisterData) {
if (this._particlePositionNode.mode == ParticlePropertiesMode.LOCAL_DYNAMIC && !this._pDynamicPropertiesDirty[animationElements._iUniqueId])
this._pUpdateDynamicProperties(animationElements);
var index = animationRegisterData.getRegisterIndex(this._pAnimationNode, ParticlePositionState.POSITION_INDEX);
if (this._particlePositionNode.mode == ParticlePropertiesMode.GLOBAL)
shader.setVertexConst(index, this._position.x, this._position.y, this._position.z);
else
animationElements.activateVertexBuffer(index, this._particlePositionNode._iDataOffset, shader.stage, ContextGLVertexBufferFormat.FLOAT_3);
};
/** @private */
ParticlePositionState.POSITION_INDEX = 0;
return ParticlePositionState;
}(ParticleStateBase));
export { ParticlePositionState };