播放器粒子动画。

This commit is contained in:
liteng 2018-10-14 13:07:45 +08:00
parent dfb989496b
commit f340432c19
2 changed files with 34 additions and 1 deletions

View File

@ -0,0 +1,31 @@
import PlayerComponent from '../component/PlayerComponent';
import Ease from '../../animation/Ease';
/**
* 粒子动画控制器
* @param {*} app 应用
*/
function ParticleAnimator(app) {
PlayerComponent.call(this, app);
}
ParticleAnimator.prototype = Object.create(PlayerComponent.prototype);
ParticleAnimator.prototype.constructor = ParticleAnimator;
ParticleAnimator.prototype.create = function (scene, camera, renderer) {
this.scene = scene;
};
ParticleAnimator.prototype.update = function (clock, deltaTime, time) {
this.scene.children.forEach(n => {
if (n.userData.type === 'ParticleEmitter') {
n.userData.group.tick(deltaTime);
}
});
};
ParticleAnimator.prototype.dispose = function () {
this.scene = null;
};
export default ParticleAnimator;

View File

@ -3,6 +3,7 @@ import Ease from '../../animation/Ease';
import TweenAnimator from '../animator/TweenAnimator';
import MMDAnimator from '../animator/MMDAnimator';
import ParticleAnimator from '../animator/ParticleAnimator';
/**
* 播放器动画
@ -17,7 +18,8 @@ function PlayerAnimation(app) {
this.animators = [
new TweenAnimator(this.app),
new MMDAnimator(this.app)
new MMDAnimator(this.app),
new ParticleAnimator(this.app)
];
}