diff --git a/character-fx.js b/character-fx.js index e514514c27..f4cd431f6e 100644 --- a/character-fx.js +++ b/character-fx.js @@ -260,24 +260,18 @@ class CharacterFx { }; _updateNameplate(); const _updateHealEffectMesh = () => { - + if (!this.healEffect) { + this.healEffect = metaversefile.createApp(); + (async () => { + const {modules} = metaversefile.useDefaultModules(); + const m = modules['healEffect']; + await this.healEffect.addModule(m); + })(); + sceneLowPriority.add(this.healEffect); + } if(this.player.hasAction('cure')){ - if (!this.healEffect) { - this.healEffect = metaversefile.createApp(); - (async () => { - const {modules} = metaversefile.useDefaultModules(); - const m = modules['healEffect']; - await this.healEffect.addModule(m); - this.healEffect.playEffect(this.player); - this.player.removeAction('cure') - })(); - sceneLowPriority.add(this.healEffect); - } - else{ - this.healEffect.playEffect(this.player); - this.player.removeAction('cure') - } - + this.healEffect.playEffect(this.player); + this.player.removeAction('cure') } }; diff --git a/metaverse_modules/heal-effect/index.js b/metaverse_modules/heal-effect/index.js index 8a54641f76..8848b82624 100644 --- a/metaverse_modules/heal-effect/index.js +++ b/metaverse_modules/heal-effect/index.js @@ -13,7 +13,7 @@ let playEffect = false; export default () => { let player = null; const app = useApp(); - const {camera} = useInternals(); + const {camera, renderer} = useInternals(); app.playEffect = (p) =>{ playEffect = true; player = p; @@ -229,13 +229,13 @@ export default () => { idAttribute.setX(i,i); } idAttribute.needsUpdate = true; + app.add(flashMesh); } addInstancedMesh(); const pixel = new THREE.Points(pixelGeometry, pixelMaterial); group.add(pixel); + app.add(group); - let storeMaterial = false; - let particleAlreadyInScene= false; let circlePlay = false; let materialStartTime = -1; let healMaterial = []; @@ -279,11 +279,6 @@ export default () => { const pixelScaleAttribute = pixel.geometry.getAttribute('scales'); if(playEffect){ - if(!particleAlreadyInScene){ - app.add(flashMesh); - app.add(group); - particleAlreadyInScene=true; - } for (let i = 0; i < flashParticleCount; i++) { dir.x = camera.position.x-player.position.x; dir.y = camera.position.y-player.position.y; @@ -414,13 +409,7 @@ export default () => { healMaterial[i].r = 0; healMaterial[i].g = 0; healMaterial[i].b = 0; - if(particleAlreadyInScene){ - app.remove(group); - app.remove(flashMesh); - particleAlreadyInScene=false; - materialStartTime = 0; - } - + materialStartTime = 0; } }