@awayjs/graphics
Version:
AwayJS graphics classes
86 lines (85 loc) • 4.01 kB
JavaScript
import { __extends } from "tslib";
import { AnimationStateBase } from './AnimationStateBase';
/**
* ...
*/
var ParticleStateBase = /** @class */ (function (_super) {
__extends(ParticleStateBase, _super);
function ParticleStateBase(animator, particleNode, needUpdateTime) {
if (needUpdateTime === void 0) { needUpdateTime = false; }
var _this = _super.call(this, animator, particleNode) || this;
_this._pDynamicProperties = new Array();
_this._pDynamicPropertiesDirty = new Object();
_this._pParticleAnimator = animator;
_this._particleNode = particleNode;
_this._pNeedUpdateTime = needUpdateTime;
return _this;
}
Object.defineProperty(ParticleStateBase.prototype, "needUpdateTime", {
get: function () {
return this._pNeedUpdateTime;
},
enumerable: false,
configurable: true
});
ParticleStateBase.prototype.setRenderState = function (shader, renderable, animationElements, animationRegisterData) {
};
ParticleStateBase.prototype._pUpdateDynamicProperties = function (animationElements) {
this._pDynamicPropertiesDirty[animationElements._iUniqueId] = true;
var animationParticles = animationElements.animationParticles;
var vertexData = animationElements.vertexData;
var totalLenOfOneVertex = animationElements.totalLenOfOneVertex;
var dataLength = this._particleNode.dataLength;
var dataOffset = this._particleNode._iDataOffset;
var vertexLength;
// var particleOffset:number;
var startingOffset;
var vertexOffset;
var data;
var animationParticle;
// var numParticles:number = _positions.length/dataLength;
var numParticles = this._pDynamicProperties.length;
var i = 0;
var j = 0;
var k = 0;
//loop through all particles
while (i < numParticles) {
//loop through each particle data for the current particle
while (j < numParticles && (animationParticle = animationParticles[j]).index == i) {
data = this._pDynamicProperties[i];
vertexLength = animationParticle.numVertices * totalLenOfOneVertex;
startingOffset = animationParticle.startVertexIndex * totalLenOfOneVertex + dataOffset;
//loop through each vertex in the particle data
for (k = 0; k < vertexLength; k += totalLenOfOneVertex) {
vertexOffset = startingOffset + k;
// particleOffset = i * dataLength;
//loop through all vertex data for the current particle data
for (k = 0; k < vertexLength; k += totalLenOfOneVertex) {
vertexOffset = startingOffset + k;
vertexData[vertexOffset++] = data.x;
vertexData[vertexOffset++] = data.y;
vertexData[vertexOffset++] = data.z;
if (dataLength == 4)
vertexData[vertexOffset++] = data.w;
}
//loop through each value in the particle vertex
// switch(dataLength) {
// case 4:
// vertexData[vertexOffset++] = _positions[particleOffset++];
// case 3:
// vertexData[vertexOffset++] = _positions[particleOffset++];
// case 2:
// vertexData[vertexOffset++] = _positions[particleOffset++];
// case 1:
// vertexData[vertexOffset++] = _positions[particleOffset++];
// }
}
j++;
}
i++;
}
animationElements.invalidateBuffer();
};
return ParticleStateBase;
}(AnimationStateBase));
export { ParticleStateBase };