From f340432c1910dcc41dc5fd5e1dbfdf0590cc527f Mon Sep 17 00:00:00 2001 From: liteng <930372551@qq.com> Date: Sun, 14 Oct 2018 13:07:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=92=AD=E6=94=BE=E5=99=A8=E7=B2=92=E5=AD=90?= =?UTF-8?q?=E5=8A=A8=E7=94=BB=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/player/animator/ParticleAnimator.js | 31 +++++++++++++++++++ .../src/player/component/PlayerAnimation.js | 4 ++- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 ShadowEditor.Web/src/player/animator/ParticleAnimator.js 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) ]; }