Files

52 lines
1.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Jade.js — runExplosionParticles() (satır 428)
[← Jade.js](index.md) · [← Master](../../wiki.md)
Parça 1/2 · [sonraki](runExplosionParticles-2.md)
```javascript
function runExplosionParticles(c) {
var world = c.getWorld();
var cx = c.getValue("hitCx");
var cy = c.getValue("hitCy");
var cz = c.getValue("hitCz");
var animTick = c.getValue("explosionAnimTick");
if (cx === null || cy === null || cz === null || animTick === null) {
return;
}
var maxAnimTick = 15; // 15 ticks duration for the morph animation
if (animTick > maxAnimTick) {
return; // Finished morphing
}
var p1 = SPELL_CONFIG.PARTICLE_EXPLODE_1; // smoke
var p2 = SPELL_CONFIG.PARTICLE_EXPLODE_2; // fallingdust
var p3 = SPELL_CONFIG.PARTICLE_EXPLODE_3; // portal
var t = animTick / maxAnimTick; // 0.0 to 1.0
var R = SPELL_CONFIG.CRATER_RADIUS; // 10 blocks
// Create 8 vertically spaced tiered layers of rings
var layersCount = 8;
for (var l = 0; l <= layersCount; l++) {
// --- START SHAPE (Stepped Dome / Hemisphere - exactly like the user's image) ---
var relYStart = l / layersCount; // 0.0 to 1.0
var dyStart = relYStart * R; // Spaced upwards from 0 to R
var rStart = Math.sqrt(R * R - dyStart * dyStart);
// --- END SHAPE (Complete 3D Hollow Sphere) ---
var relYEnd = (l / layersCount) * 2.0 - 1.0; // -1.0 to 1.0
var dyEnd = relYEnd * R; // Spaced from -R to +R
var rEnd = Math.sqrt(R * R - dyEnd * dyEnd);
// --- MORPH INTERPOLATION ---
var dyCurrent = (1.0 - t) * dyStart + t * dyEnd;
var rCurrent = (1.0 - t) * rStart + t * rEnd;
// Expand the shape slightly
var expansion = 1.0 + 0.12 * t;
var currentRadius = rCurrent * expansion;
```