@awayjs/graphics
Version:
AwayJS graphics classes
55 lines (54 loc) • 2.53 kB
JavaScript
import { __extends } from "tslib";
import { ParticlePropertiesMode } from '../data/ParticlePropertiesMode';
import { ParticleBillboardState } from '../states/ParticleBillboardState';
import { ParticleNodeBase } from './ParticleNodeBase';
/**
* A particle animation node that controls the rotation of a particle to always face the camera.
*/
var ParticleBillboardNode = /** @class */ (function (_super) {
__extends(ParticleBillboardNode, _super);
/**
* Creates a new <code>ParticleBillboardNode</code>
*/
function ParticleBillboardNode(billboardAxis) {
if (billboardAxis === void 0) { billboardAxis = null; }
var _this = _super.call(this, 'ParticleBillboard', ParticlePropertiesMode.GLOBAL, 0, 4) || this;
_this._pStateClass = ParticleBillboardState;
_this._iBillboardAxis = billboardAxis;
return _this;
}
/**
* @inheritDoc
*/
ParticleBillboardNode.prototype.getAGALVertexCode = function (shader, animationSet, registerCache, animationRegisterData) {
var rotationMatrixRegister = registerCache.getFreeVertexConstant();
animationRegisterData.setRegisterIndex(this, ParticleBillboardState.MATRIX_INDEX, rotationMatrixRegister.index);
registerCache.getFreeVertexConstant();
registerCache.getFreeVertexConstant();
registerCache.getFreeVertexConstant();
var temp = registerCache.getFreeVertexVectorTemp();
var code = 'm33 ' + temp + '.xyz,' + animationRegisterData.scaleAndRotateTarget + ',' + rotationMatrixRegister + '\n' +
'mov ' + animationRegisterData.scaleAndRotateTarget + '.xyz,' + temp + '\n';
var shaderRegisterElement;
for (var i = 0; i < animationRegisterData.rotationRegisters.length; i++) {
shaderRegisterElement = animationRegisterData.rotationRegisters[i];
code += 'm33 ' + temp + '.xyz,' + shaderRegisterElement + ',' + rotationMatrixRegister + '\n' +
'mov ' + shaderRegisterElement + '.xyz,' + shaderRegisterElement + '\n';
}
return code;
};
/**
* @inheritDoc
*/
ParticleBillboardNode.prototype.getAnimationState = function (animator) {
return animator.getAnimationState(this);
};
/**
* @inheritDoc
*/
ParticleBillboardNode.prototype._iProcessAnimationSetting = function (particleAnimationSet) {
particleAnimationSet.hasBillboard = true;
};
return ParticleBillboardNode;
}(ParticleNodeBase));
export { ParticleBillboardNode };