UNPKG

@awayjs/graphics

Version:
59 lines (58 loc) 2.72 kB
import { __extends } from "tslib"; import { Vector3D } from '@awayjs/core'; import { ContextGLVertexBufferFormat } from '@awayjs/stage'; import { ParticlePropertiesMode } from '../data/ParticlePropertiesMode'; import { ParticleStateBase } from './ParticleStateBase'; /** * ... */ var ParticleOscillatorState = /** @class */ (function (_super) { __extends(ParticleOscillatorState, _super); function ParticleOscillatorState(animator, particleOscillatorNode) { var _this = _super.call(this, animator, particleOscillatorNode) || this; _this._particleOscillatorNode = particleOscillatorNode; _this._oscillator = _this._particleOscillatorNode._iOscillator; _this.updateOscillatorData(); return _this; } Object.defineProperty(ParticleOscillatorState.prototype, "oscillator", { /** * Defines the default oscillator axis (x, y, z) and cycleDuration (w) of the state, used when in global mode. */ get: function () { return this._oscillator; }, set: function (value) { this._oscillator = value; this.updateOscillatorData(); }, enumerable: false, configurable: true }); /** * @inheritDoc */ ParticleOscillatorState.prototype.setRenderState = function (shader, renderable, animationElements, animationRegisterData) { var index = animationRegisterData.getRegisterIndex(this._pAnimationNode, ParticleOscillatorState.OSCILLATOR_INDEX); if (this._particleOscillatorNode.mode == ParticlePropertiesMode.LOCAL_STATIC) animationElements.activateVertexBuffer(index, this._particleOscillatorNode._iDataOffset, shader.stage, ContextGLVertexBufferFormat.FLOAT_4); else shader.setVertexConst(index, this._oscillatorData.x, this._oscillatorData.y, this._oscillatorData.z, this._oscillatorData.w); }; ParticleOscillatorState.prototype.updateOscillatorData = function () { if (this._particleOscillatorNode.mode == ParticlePropertiesMode.GLOBAL) { if (this._oscillator.w <= 0) throw (new Error('the cycle duration must greater than zero')); if (this._oscillatorData == null) this._oscillatorData = new Vector3D(); this._oscillatorData.x = this._oscillator.x; this._oscillatorData.y = this._oscillator.y; this._oscillatorData.z = this._oscillator.z; this._oscillatorData.w = Math.PI * 2 / this._oscillator.w; } }; /** @private */ ParticleOscillatorState.OSCILLATOR_INDEX = 0; return ParticleOscillatorState; }(ParticleStateBase)); export { ParticleOscillatorState };