UNPKG

@awayjs/graphics

Version:
52 lines (51 loc) 2.6 kB
import { __extends } from "tslib"; import { Matrix3D } from '@awayjs/core'; import { ContextGLVertexBufferFormat } from '@awayjs/stage'; import { ParticlePropertiesMode } from '../data/ParticlePropertiesMode'; import { ParticleStateBase } from './ParticleStateBase'; /** * ... */ var ParticleRotateToPositionState = /** @class */ (function (_super) { __extends(ParticleRotateToPositionState, _super); function ParticleRotateToPositionState(animator, particleRotateToPositionNode) { var _this = _super.call(this, animator, particleRotateToPositionNode) || this; _this._matrix = new Matrix3D(); _this._particleRotateToPositionNode = particleRotateToPositionNode; _this._position = _this._particleRotateToPositionNode._iPosition; return _this; } Object.defineProperty(ParticleRotateToPositionState.prototype, "position", { /** * Defines the position of the point the particle will rotate to face when in global mode. Defaults to 0,0,0. */ get: function () { return this._position; }, set: function (value) { this._position = value; }, enumerable: false, configurable: true }); ParticleRotateToPositionState.prototype.setRenderState = function (shader, renderable, animationElements, animationRegisterData) { var index = animationRegisterData.getRegisterIndex(this._pAnimationNode, ParticleRotateToPositionState.POSITION_INDEX); if (this._pParticleAnimator.animationSet.hasBillboard) { this._matrix.copyFrom(renderable.node.getMatrix3D()); this._matrix.append(shader.view.projection.transform.inverseMatrix3D); shader.setVertexConstFromMatrix(animationRegisterData.getRegisterIndex(this._pAnimationNode, ParticleRotateToPositionState.MATRIX_INDEX), this._matrix); } if (this._particleRotateToPositionNode.mode == ParticlePropertiesMode.GLOBAL) { this._offset = renderable.node.getMatrix3D().transformVector(this._position); shader.setVertexConst(index, this._offset.x, this._offset.y, this._offset.z); } else animationElements.activateVertexBuffer(index, this._particleRotateToPositionNode._iDataOffset, shader.stage, ContextGLVertexBufferFormat.FLOAT_3); }; /** @private */ ParticleRotateToPositionState.MATRIX_INDEX = 0; /** @private */ ParticleRotateToPositionState.POSITION_INDEX = 1; return ParticleRotateToPositionState; }(ParticleStateBase)); export { ParticleRotateToPositionState };