@adatechnology/game-destruction-three 0.3.3 → 0.5.0
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/README.md +6 -3
- package/dist/index.d.ts +30 -7
- package/dist/index.global.js +8190 -538
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +284 -454
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ package draws them on your meshes: vertex dents, bullet-hole and crack decals, c
|
|
|
5
5
|
physics, loose pieces after a part comes off, and pooled particles (fire, smoke, sparks, dust, shards, splinters, ...).
|
|
6
6
|
|
|
7
7
|
- Nothing is changed in place: geometry and materials are cloned on the first visual change of a mesh, and `restore` / `clear` give the originals back.
|
|
8
|
-
-
|
|
8
|
+
- Blasts and the fires of burning parts are drawn by the effects world of [`@adatechnology/game-vfx`](../game-vfx) (an `explode` event plays `ev.effect ?? 'generic'`, scaled by the radius when it names none). Pass the world the host shares in `vfx`; without it the renderer makes its own world and its own `game-vfx-three` layer and steps them in `update`. Debris, sparks, drips and leaks still use two pooled `THREE.Points` (additive and normal blending), with a soft sprite computed in the shader (no texture asset); they move to the shared sprite pool when `game-vfx` gets one.
|
|
9
9
|
- `three` is a peer dependency used for types only: you pass your own `THREE` instance at runtime.
|
|
10
10
|
- Sounds are not played: you get keys (`impact_metal`, `shatter_glass`, ...) through `onSound`.
|
|
11
11
|
|
|
@@ -102,6 +102,9 @@ loose meshes. An invalid range (outside the geometry or empty) throws from `bind
|
|
|
102
102
|
| `ricochet` | sparks along the reflected direction | `ricochet` |
|
|
103
103
|
| `debris` | a burst of the requested kind (`sparks`, `dust`, `shards`, `splinters`, `chips`, `fibers`, `leaves`, `drips`, `ash`, `smoke`, `steam`) | |
|
|
104
104
|
| `fracture` | part hidden; fragments (boxes, thin irregular prisms for shards) with gravity, ground bounce, settling, sleep and shrink-away; debris burst by style | `shatter_glass`, `crumble`, `splinter`, `impact_*` |
|
|
105
|
+
| `spall` | opaque patch (disc decal) in the colour of the part's core material where a coat came off, under the holes; sits on the face of the mesh the point is nearest to (the thin axis of its world box) | |
|
|
106
|
+
| `stage` (2, with `fragments`) | the unit-sized fragments of the breach fly out with the same physics as `fracture` fragments, the holes of `Fragment.marks` ride on them as dark discs, a dust burst; the part stays drawn (cutting the opening in its faces is left to the house renderer) | `crumble`, `impact_*` |
|
|
107
|
+
| `expose` | the bars as instanced cylinders (radius 4 mm), one mesh per part, replaced by each new `expose`; empty `bars` removes the cage; `renderer.rebarCount()` | |
|
|
105
108
|
| `detach` | with `autoSplit`, each loose group becomes its own `Group` (world transforms kept) and a `Piece` (`onPiece`) | `detach` |
|
|
106
109
|
| `disassemble_progress` | | `unscrew` (throttled) |
|
|
107
110
|
| `ignite` / `extinguish` / `burnout` | fire and smoke from the surface while `part.burning`; steam when put out; ash at burnout; char lerps the colour to the material `charColor`; status `ashes` hides the part and leaves an ash pile | `ignite`, `burn_loop`, `extinguish` |
|
|
@@ -142,9 +145,9 @@ heatColor(temperatureC: number): number // 0xRRGGBB, 0 below ~450 C, dark red ~5
|
|
|
142
145
|
```
|
|
143
146
|
|
|
144
147
|
`RendererOptions`: `scene`, `world`, `quality`, `maxFragments`, `maxParticles`, `fragmentLife`, `groundAt`, `gravity`, `autoSplit`, `onPiece`, `onSound`,
|
|
145
|
-
`
|
|
148
|
+
`vfx` (shared effects world), `camera` (of the own world, when `vfx` is not given), `pointScale` (point size in pixels per metre at 1 m; about `viewportHeight / (2 tan(fov / 2))`, default 700).
|
|
146
149
|
|
|
147
|
-
`DestructionRenderer`: `bind`, `unbind`, `makePiece`, `pieces`, `piece`, `impulse`, `update`, `emit`, `explode
|
|
150
|
+
`DestructionRenderer`: `bind`, `unbind`, `makePiece`, `pieces`, `piece`, `impulse`, `update`, `emit`, `explode(point, energy, radius, { effect?, direction?, visual? })` (`visual: false` keeps only the shove and the sound, for a host that played the effect itself), `clear`, `restore`, `stats`, `dispose`.
|
|
148
151
|
`clear()` removes fragments, decals, puddles and particles from the scene and restores every bound mesh; `dispose()` also unsubscribes from the world.
|
|
149
152
|
|
|
150
153
|
## Português
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as THREE_NS from 'three';
|
|
2
2
|
import { Vec3, DebrisKind, DestructionWorld, MaterialId, DestructibleSpec } from '@adatechnology/game-destruction';
|
|
3
3
|
export { Quat, Vec3 } from '@adatechnology/game-destruction';
|
|
4
|
+
import { VfxWorld, SpriteKind } from '@adatechnology/game-vfx';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Public types of @adatechnology/game-destruction-three.
|
|
@@ -35,8 +36,15 @@ interface RendererOptions {
|
|
|
35
36
|
onPiece?: (piece: Piece) => void;
|
|
36
37
|
/** Called when a sound should play; the host maps keys to audio (e.g. `impact_metal`, `shatter_glass`, `ignite`, `explode`). */
|
|
37
38
|
onSound?: (key: string, point: Vec3, volume: number) => void;
|
|
38
|
-
/**
|
|
39
|
-
|
|
39
|
+
/**
|
|
40
|
+
* The effects world that draws blasts and fires. Pass the one the host shares with the other renderers (and step it, through its
|
|
41
|
+
* `VfxRenderer.update`, once per frame); without it the renderer makes its own world and its own three layer and steps them in `update`.
|
|
42
|
+
*/
|
|
43
|
+
vfx?: VfxWorld;
|
|
44
|
+
/** Which effect each destruction event plays (default `EVENT_EFFECTS_MAP` of `@adatechnology/game-vfx`): `spall`, `stage`, `expose`, `collapse`. Add, change or take out entries to tune it. */
|
|
45
|
+
eventEffects?: Readonly<Record<string, string | Readonly<Record<string, string>>>>;
|
|
46
|
+
/** Camera of the own effects world (distance LOD, shake); only read when `vfx` is not given. Default: a camera at the origin. */
|
|
47
|
+
camera?: THREE_NS.Camera;
|
|
40
48
|
/**
|
|
41
49
|
* Particle size scale in pixels per metre at one metre from the camera, roughly `viewportHeight / (2 * tan(fov / 2))` (default 700). Set it
|
|
42
50
|
* when the viewport is much smaller or larger than about 720 px tall so smoke and fire keep their physical size.
|
|
@@ -85,6 +93,15 @@ interface Piece {
|
|
|
85
93
|
/** While held by a player the renderer does not integrate it. */
|
|
86
94
|
held: boolean;
|
|
87
95
|
}
|
|
96
|
+
/** Options of `DestructionRenderer.explode`. */
|
|
97
|
+
interface ExplodeOptions {
|
|
98
|
+
/** Id of the effect to play (an explosive id of the effects catalogue). Default `generic`. */
|
|
99
|
+
readonly effect?: string;
|
|
100
|
+
/** Where the blast is aimed (a shaped charge). */
|
|
101
|
+
readonly direction?: Vec3;
|
|
102
|
+
/** `false`: the host drew the blast, only the shove and the sound are left. Default `true`. */
|
|
103
|
+
readonly visual?: boolean;
|
|
104
|
+
}
|
|
88
105
|
interface DestructionRenderer {
|
|
89
106
|
/** Attach a world object to its three.js root. */
|
|
90
107
|
bind(objectId: string, root: Object3D, options?: BindOptions): void;
|
|
@@ -102,8 +119,12 @@ interface DestructionRenderer {
|
|
|
102
119
|
update(dt: number): void;
|
|
103
120
|
/** Emit particles directly (muzzle flashes, extinguisher foam, tool sparks). */
|
|
104
121
|
emit(kind: DebrisKind | 'fire' | 'flash' | 'foam', point: Vec3, normal: Vec3, count: number, speed?: number): void;
|
|
105
|
-
/**
|
|
106
|
-
|
|
122
|
+
/**
|
|
123
|
+
* Draw a blast that has no exploding part (a grenade, a rocket): the effect (`options.effect`, an id of the effects catalogue, else `generic`
|
|
124
|
+
* scaled by the radius), sound and a shove on pieces in range. Call it next to `world.explode`, which emits no event of its own. A host that
|
|
125
|
+
* already played the effect itself passes `visual: false` and keeps only the shove and the sound.
|
|
126
|
+
*/
|
|
127
|
+
explode(point: Vec3, energy: number, radius: number, options?: ExplodeOptions): void;
|
|
107
128
|
/** Remove every fragment, decal and particle, restore every bound mesh to its original geometry and colours. */
|
|
108
129
|
clear(): void;
|
|
109
130
|
/** Restore one object (after `world.reset`). */
|
|
@@ -114,6 +135,8 @@ interface DestructionRenderer {
|
|
|
114
135
|
pieces: number;
|
|
115
136
|
decals: number;
|
|
116
137
|
};
|
|
138
|
+
/** Bars of exposed rebar drawn now (`expose` events; one instanced mesh per part). */
|
|
139
|
+
rebarCount(): number;
|
|
117
140
|
dispose(): void;
|
|
118
141
|
}
|
|
119
142
|
interface SpecFromObjectOptions {
|
|
@@ -164,7 +187,7 @@ declare function specFromObject3D(THREE: ThreeNamespace, root: Object3D, options
|
|
|
164
187
|
*/
|
|
165
188
|
declare function heatColor(temperatureC: number): number;
|
|
166
189
|
|
|
167
|
-
/** Every particle kind the renderer can emit. */
|
|
168
|
-
type ParticleKind =
|
|
190
|
+
/** Every particle kind the renderer can emit (the game's sprite kinds, see `@adatechnology/game-vfx`). */
|
|
191
|
+
type ParticleKind = SpriteKind;
|
|
169
192
|
|
|
170
|
-
export { type BindOptions, type DestructionRenderer, type Mesh, type MeshRange, type Object3D, type PartHint, type ParticleKind, type Piece, type Quality, type RendererOptions, type SpecFromObjectOptions, type SpecFromObjectResult, type ThreeNamespace, createDestructionRenderer, heatColor, specFromObject3D };
|
|
193
|
+
export { type BindOptions, type DestructionRenderer, type ExplodeOptions, type Mesh, type MeshRange, type Object3D, type PartHint, type ParticleKind, type Piece, type Quality, type RendererOptions, type SpecFromObjectOptions, type SpecFromObjectResult, type ThreeNamespace, createDestructionRenderer, heatColor, specFromObject3D };
|