mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-08-01 04:45:51 +00:00
wip
This commit is contained in:
@@ -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<void>();
|
||||
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();
|
||||
|
||||
@@ -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))],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user