@awayjs/graphics
Version:
AwayJS graphics classes
53 lines (52 loc) • 2.46 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 ParticleAccelerationState = /** @class */ (function (_super) {
__extends(ParticleAccelerationState, _super);
function ParticleAccelerationState(animator, particleAccelerationNode) {
var _this = _super.call(this, animator, particleAccelerationNode) || this;
_this._particleAccelerationNode = particleAccelerationNode;
_this._acceleration = _this._particleAccelerationNode._acceleration;
_this.updateAccelerationData();
return _this;
}
Object.defineProperty(ParticleAccelerationState.prototype, "acceleration", {
/**
* Defines the acceleration vector of the state, used when in global mode.
*/
get: function () {
return this._acceleration;
},
set: function (value) {
this._acceleration.x = value.x;
this._acceleration.y = value.y;
this._acceleration.z = value.z;
this.updateAccelerationData();
},
enumerable: false,
configurable: true
});
/**
* @inheritDoc
*/
ParticleAccelerationState.prototype.setRenderState = function (shader, renderable, animationElements, animationRegisterData) {
var index = animationRegisterData.getRegisterIndex(this._pAnimationNode, ParticleAccelerationState.ACCELERATION_INDEX);
if (this._particleAccelerationNode.mode == ParticlePropertiesMode.LOCAL_STATIC)
animationElements.activateVertexBuffer(index, this._particleAccelerationNode._iDataOffset, shader.stage, ContextGLVertexBufferFormat.FLOAT_3);
else
shader.setVertexConst(index, this._halfAcceleration.x, this._halfAcceleration.y, this._halfAcceleration.z);
};
ParticleAccelerationState.prototype.updateAccelerationData = function () {
if (this._particleAccelerationNode.mode == ParticlePropertiesMode.GLOBAL)
this._halfAcceleration = new Vector3D(this._acceleration.x / 2, this._acceleration.y / 2, this._acceleration.z / 2);
};
/** @private */
ParticleAccelerationState.ACCELERATION_INDEX = 0;
return ParticleAccelerationState;
}(ParticleStateBase));
export { ParticleAccelerationState };