@adatechnology/game-destruction-three 0.6.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +6 -1
- package/dist/index.global.js +12 -4
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as THREE_NS from 'three';
|
|
2
|
-
import { Vec3, DebrisKind, DestructionWorld, MaterialId, DestructibleSpec } from '@adatechnology/game-destruction';
|
|
2
|
+
import { Vec3, DebrisKind, HitResult, DestructionWorld, MaterialId, DestructibleSpec } from '@adatechnology/game-destruction';
|
|
3
3
|
export { Quat, Vec3 } from '@adatechnology/game-destruction';
|
|
4
4
|
import { VfxWorld, SpriteKind } from '@adatechnology/game-vfx';
|
|
5
5
|
import { LoopRecipe, SoundBank, SoundRecipe, AudioEngine } from '@adatechnology/game-audio';
|
|
@@ -103,6 +103,11 @@ interface ExplodeOptions {
|
|
|
103
103
|
readonly direction?: Vec3;
|
|
104
104
|
/** `false`: the host drew the blast, only the shove and the sound are left. Default `true`. */
|
|
105
105
|
readonly visual?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* What `world.explode` returned for this blast. When its results carry a `blast` report (`shelter`, `confinement`), the shove on each piece uses
|
|
108
|
+
* the energy that reached it (`energy * confinement * shelter` of the piece's object) instead of the raw energy. Without it the old formula.
|
|
109
|
+
*/
|
|
110
|
+
readonly report?: readonly HitResult[];
|
|
106
111
|
}
|
|
107
112
|
interface DestructionRenderer {
|
|
108
113
|
/** Attach a world object to its three.js root. */
|
package/dist/index.global.js
CHANGED
|
@@ -8976,7 +8976,8 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
8976
8976
|
0.25
|
|
8977
8977
|
],
|
|
8978
8978
|
damageScale: {
|
|
8979
|
-
blunt: 1.5
|
|
8979
|
+
blunt: 1.5,
|
|
8980
|
+
shelter: 3
|
|
8980
8981
|
},
|
|
8981
8982
|
hitDebris: "shards",
|
|
8982
8983
|
breakDebris: "shards",
|
|
@@ -9027,7 +9028,10 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9027
9028
|
"glass",
|
|
9028
9029
|
"brittle"
|
|
9029
9030
|
],
|
|
9030
|
-
compressive: 2e5
|
|
9031
|
+
compressive: 2e5,
|
|
9032
|
+
damageScale: {
|
|
9033
|
+
shelter: 3
|
|
9034
|
+
}
|
|
9031
9035
|
},
|
|
9032
9036
|
{
|
|
9033
9037
|
id: "ceramic",
|
|
@@ -11461,6 +11465,9 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
11461
11465
|
if (options.visual !== false) this.playExplosion(ev, options);
|
|
11462
11466
|
this.vfx.push(p, ev.radius, 4);
|
|
11463
11467
|
const c = this.v1;
|
|
11468
|
+
const report = options.report;
|
|
11469
|
+
const confinement = report?.find((r) => r.blast !== void 0)?.blast?.confinement ?? 1;
|
|
11470
|
+
const energy = ev.energy * confinement;
|
|
11464
11471
|
for (const pc of this.pieceSys.list) {
|
|
11465
11472
|
this.pieceSys.centerOf(pc, c);
|
|
11466
11473
|
const dx = c.x - p[0];
|
|
@@ -11469,13 +11476,14 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
11469
11476
|
const d = Math.hypot(dx, dy, dz);
|
|
11470
11477
|
if (d > ev.radius) continue;
|
|
11471
11478
|
const fall = (1 - d / ev.radius) ** 2;
|
|
11472
|
-
const
|
|
11479
|
+
const reach = report?.find((r) => r.object === pc.objectId)?.blast?.shelter ?? 1;
|
|
11480
|
+
const speed = Math.min(30, Math.sqrt(2 * energy * reach * 0.02 / pc.mass)) * fall;
|
|
11473
11481
|
const inv = d > 1e-4 ? 1 / d : 0;
|
|
11474
11482
|
const dir = d > 1e-4 ? [dx * inv, dy * inv + 0.3, dz * inv] : [0, 1, 0];
|
|
11475
11483
|
const spread = pc.halfExtents[0];
|
|
11476
11484
|
this.pieceSys.impulse(pc, [dir[0] * speed * pc.mass, dir[1] * speed * pc.mass, dir[2] * speed * pc.mass], [c.x + (this.rng() - 0.5) * spread, c.y + spread * 0.5, c.z + (this.rng() - 0.5) * spread]);
|
|
11477
11485
|
}
|
|
11478
|
-
this.fragments.blast(p, ev.radius, Math.min(20, Math.sqrt(
|
|
11486
|
+
this.fragments.blast(p, ev.radius, Math.min(20, Math.sqrt(energy) * 0.08));
|
|
11479
11487
|
this.sound("explode", p, clamp6(0.5 + ev.radius / 10, 0.5, 1));
|
|
11480
11488
|
}
|
|
11481
11489
|
playExplosion(ev, options) {
|