From cb62a1d4fe352e378fda174362247738010d6978 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Thu, 30 Jul 2026 10:11:29 +0900 Subject: [PATCH] wip --- .../src/Firework.ts | 32 +++++++++---------- .../src/envs/lobby.ts | 2 +- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/packages/frontend-misskey-world-engine/src/Firework.ts b/packages/frontend-misskey-world-engine/src/Firework.ts index 51201aa9c8..40a9550cd0 100644 --- a/packages/frontend-misskey-world-engine/src/Firework.ts +++ b/packages/frontend-misskey-world-engine/src/Firework.ts @@ -26,7 +26,7 @@ export class Firework { //const emitter = new BABYLON.TransformNode('emitter', this.engine.scene); const emitter = BABYLON.MeshBuilder.CreateBox('emitter', { size: cm(10) }, this.engine.scene); emitter.position = new BABYLON.Vector3(options.position[0], options.position[1], options.position[2]); - const ps = new BABYLON.ParticleSystem('', 128, this.engine.scene); + const ps = new BABYLON.ParticleSystem('', 32, this.engine.scene); ps.particleTexture = texture; ps.emitter = emitter; ps.minEmitPower = cm(100); @@ -55,29 +55,24 @@ export class Firework { ); launchAnim.setKeys([ { frame: 0, value: new BABYLON.Vector3(options.position[0], options.position[1], options.position[2]) }, - { frame: 60, value: new BABYLON.Vector3(options.position[0], options.position[1] + cm(randomRange(1000, 3000)), options.position[2]) }, + { frame: 60, value: new BABYLON.Vector3(options.position[0], options.position[1] + cm(randomRange(1000, 4000)), options.position[2]) }, ]); emitter.animations.push(launchAnim); const animating = Promise.withResolvers(); - const animationObserver = this.engine.scene.onAfterAnimationsObservable.add(() => { - }); this.engine.scene.beginAnimation(emitter, 0, 60, false, 1, () => { animating.resolve(); }); animating.promise.then(() => { - this.engine.scene.onAfterAnimationsObservable.remove(animationObserver); - ps.stop(); - this.timer.setTimeout(() => { - this.engine.sr.disableSnapshotRendering(); - ps.dispose(); - emitter.dispose(); - this.engine.sr.enableSnapshotRendering(); - }, 1000); - this.explode({ position: [emitter.position.x, emitter.position.y, emitter.position.z], texture, + callback: () => { // explode途中でSRの状態を切り替えるとパーティクルが消える現象があるため、explodeが終了してから片づける + this.engine.sr.disableSnapshotRendering(); + ps.dispose(); + emitter.dispose(); + this.engine.sr.enableSnapshotRendering(); + }, }); }); @@ -87,26 +82,27 @@ export class Firework { public explode(options: { position: [number, number, number]; texture: BABYLON.Texture; + callback: () => void; }) { this.engine.sr.disableSnapshotRendering(); const ps = new BABYLON.ParticleSystem('', 128, this.engine.scene); ps.particleTexture = options.texture; ps.emitter = new BABYLON.Vector3(options.position[0], options.position[1], options.position[2]); - ps.minEmitPower = cm(2000); + ps.minEmitPower = cm(3700); ps.maxEmitPower = cm(4000); - ps.minLifeTime = 0.7; + ps.minLifeTime = 0.8; ps.maxLifeTime = 1; ps.addDragGradient(0, 0.1); ps.addDragGradient(1, 0.8); - ps.gravity = new BABYLON.Vector3(0, -30, 0).scale(WORLD_SCALE); + ps.gravity = new BABYLON.Vector3(0, -50, 0).scale(WORLD_SCALE); ps.minSize = cm(20); ps.maxSize = cm(40); const sphereEmitter = ps.createSphereEmitter(cm(1)); //ps.direction1 = new BABYLON.Vector3(0, 1, 0); //ps.direction2 = new BABYLON.Vector3(0, 1, 0); ps.manualEmitCount = 100; - ps.blendMode = BABYLON.ParticleSystem.BLENDMODE_ADD; + ps.blendMode = BABYLON.ParticleSystem.BLENDMODE_MULTIPLYADD; ps.color1 = new BABYLON.Color4(1, 1, 1, 1); ps.color2 = new BABYLON.Color4(1, 1, 1, 1); ps.colorDead = new BABYLON.Color4(1, 1, 1, 0); @@ -118,6 +114,8 @@ export class Firework { this.engine.sr.disableSnapshotRendering(); ps.dispose(); this.engine.sr.enableSnapshotRendering(); + + options.callback(); }, 2000); this.engine.sr.enableSnapshotRendering(); diff --git a/packages/frontend-misskey-world-engine/src/envs/lobby.ts b/packages/frontend-misskey-world-engine/src/envs/lobby.ts index b6a453208c..724ea74e52 100644 --- a/packages/frontend-misskey-world-engine/src/envs/lobby.ts +++ b/packages/frontend-misskey-world-engine/src/envs/lobby.ts @@ -473,8 +473,8 @@ export class LobbyEnvManager extends WorldEnvManager { //ps.start(); //this.engine.sr.fixParticleSystem(ps); + const firework = new Firework(this.engine); this.timer.setInterval(() => { - const firework = new Firework(this.engine); firework.launch({ position: [randomRange(cm(-2000), cm(2000)), cm(randomRange(1000, 3000)), randomRange(cm(-2000), cm(2000))], });