diff --git a/ShadowEditor.Web/src/player/animator/ParticleAnimator.js b/ShadowEditor.Web/src/player/animator/ParticleAnimator.js new file mode 100644 index 00000000..af427b47 --- /dev/null +++ b/ShadowEditor.Web/src/player/animator/ParticleAnimator.js @@ -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; \ No newline at end of file diff --git a/ShadowEditor.Web/src/player/component/PlayerAnimation.js b/ShadowEditor.Web/src/player/component/PlayerAnimation.js index 3d209c80..383d0612 100644 --- a/ShadowEditor.Web/src/player/component/PlayerAnimation.js +++ b/ShadowEditor.Web/src/player/component/PlayerAnimation.js @@ -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) ]; }