@adatechnology/game-destruction-three 0.20.0 → 0.22.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 CHANGED
@@ -126,6 +126,14 @@ loose meshes. An invalid range (outside the geometry or empty) throws from `bind
126
126
 
127
127
  `world.explode` emits no event of its own (only a part with `explodes` does), so a host that detonates a grenade or rocket calls `renderer.explode(point, energy, radius)` next to it to get the same flash, fire, smoke, light, sound and shove.
128
128
 
129
+ Round pieces roll and knock each other. A piece whose drawing is round about one axis (a can, a bottle) or all three (a ball) rolls on the lowest point of each ring of its
130
+ profile (`PieceRound.profile`: a straight can rolls straight, a tapered bottle rounds its narrow end), with I = k m r^2 about its axis: hollow walls of known thickness
131
+ (`userData.hollow`, `userData.destructionThickness`) weigh as a thin shell (k 1), the rest of the mass as a solid (k 1/2), or `makePiece(id, { inertia })` says k. Down a slope
132
+ of angle t it rolls at g (sin t - C_rr cos t) / (1 + k), C_rr the rolling resistance of the softer surface (`friction.ts`). Pieces meet each other when one of them is round:
133
+ a capsule round its axis against the other's capsule or the boxes of its parts, and they trade an impulse with the restitution of their two materials (geometric mean),
134
+ momentum kept; candidates come from a sweep and prune along x, and an update is split into steps while a round piece moves fast enough to pass through another. Against what
135
+ is not a piece (a wall, a table's leg) a piece bounces by the restitution of the two materials (`PieceSweepHit.restitution`).
136
+
129
137
  Pieces report hard landings: above 3 m/s the renderer calls `world.hit(id, { type: 'blunt', energy: 0.5 m v^2, radius: 0.08, direction: [0, -1, 0], source: 'fall' })`
130
138
  (throttled to once per 0.15 s per piece; the object's transform is synced to the world first, so the hit lands on the right spot), so a dropped glass
131
139
  pane shatters and a thrown chair can lose a leg. `Piece.localCenter` is the centre of mass relative to the root origin (it moves when a part breaks off).
package/dist/index.d.ts CHANGED
@@ -148,6 +148,8 @@ interface Piece {
148
148
  sleeping: boolean;
149
149
  /** While held by a player the renderer does not integrate it. */
150
150
  held: boolean;
151
+ /** Held but standing on the floor (a pushed table): what rests on it still rests on it, as on a piece that is not held. */
152
+ carrying?: boolean;
151
153
  }
152
154
  /** Options of `DestructionRenderer.explode`. */
153
155
  interface ExplodeOptions {
@@ -179,15 +181,23 @@ interface LooseBody {
179
181
  /** Gives it this speed on the floor (m/s). */
180
182
  push(velocityX: number, velocityZ: number): void;
181
183
  }
184
+ /** How `makePiece` makes a bound object a piece. */
185
+ interface MakePieceOptions {
186
+ /** Kg; default the mass of its parts in the world. */
187
+ mass?: number;
188
+ velocity?: Vec3;
189
+ /**
190
+ * k of its moment of inertia about the axis it rolls on, I = k m r^2, when it is round (a can, a bottle, a ball): 0.5 a solid cylinder, 1 a thin shell, 0.4 a solid ball.
191
+ * Default from its drawing: hollow walls of known thickness weigh as a shell, the rest of its mass as a solid.
192
+ */
193
+ inertia?: number;
194
+ }
182
195
  interface DestructionRenderer {
183
196
  /** Attach a world object to its three.js root. */
184
197
  bind(objectId: string, root: Object3D, options?: BindOptions): void;
185
198
  unbind(objectId: string): void;
186
199
  /** Make a bound object a physical piece (bench items that can be thrown). */
187
- makePiece(objectId: string, options?: {
188
- mass?: number;
189
- velocity?: Vec3;
190
- }): Piece;
200
+ makePiece(objectId: string, options?: MakePieceOptions): Piece;
191
201
  pieces(): Piece[];
192
202
  /** What lies in the disc looks at the ground again (`groundAt` changed under it: a crater, a heap). */
193
203
  wakeRegion(x: number, z: number, radius: number): void;
@@ -515,4 +525,4 @@ declare function blastFireSampleBank(manifest: SfxManifest, options?: BlastFireS
515
525
  /** Every particle kind the renderer can emit (the game's sprite kinds, see `@adatechnology/game-vfx`). */
516
526
  type ParticleKind = SpriteKind;
517
527
 
518
- export { BIG_BLAST_RADIUS, BLAST_FALLOFF, BLAST_FAR_DISTANCE, BLAST_FAR_FALLOFF, BLAST_FIRE_SAMPLES, BLAST_KINDS, BLAST_KIND_OF, BLAST_SOUNDS, BLAST_SOUND_OF, BURN_LOOP, type BindOptions, type BlastFireSampleBankOptions, type BlastFireSampleDefaults, type BlastKind, DEFAULT_CRACKLES, DEFAULT_FIRE, DEFAULT_INDOOR_CONFINEMENT, DESTRUCTION_SOUND_BANK, DESTRUCTION_SOUND_KEYS, DRAG_SOUNDS, type DestructionRenderer, type DestructionSound, type DestructionSoundOptions, type DestructionSoundStyle, EXPLOSION_BOOM, type ExplodeOptions, FIRE_FALLOFF, FIRE_LOOP, FIRE_SOUNDS, type FragmentLifeRule, GRENADE_PIN_PULL, IMPACT_FAMILY_TAGS, IMPACT_SOUNDS, IMPACT_SOUND_KEYS, type ImpactFamily, type ImpactKeys, type LooseBody, type Mesh, type MeshRange, type Object3D, type PartHint, type ParticleKind, type Piece, type Quality, ROCKET_MOTOR_LOOP, type RendererOptions, SCENE_SOUNDS, SMOKE_HISS_LOOP, type SolidBox, type SoundDetail, type SoundKeyRule, type SpecFromObjectOptions, type SpecFromObjectResult, type ThreeNamespace, blastFireSampleBank, breakSoundKeys, createDestructionRenderer, createDestructionSound, dragSoundKey, heatColor, impactFamily, impactKey, impactSoundIds, impactSoundKeys, ricochetSoundKeys, shotKey, specFromObject3D };
528
+ export { BIG_BLAST_RADIUS, BLAST_FALLOFF, BLAST_FAR_DISTANCE, BLAST_FAR_FALLOFF, BLAST_FIRE_SAMPLES, BLAST_KINDS, BLAST_KIND_OF, BLAST_SOUNDS, BLAST_SOUND_OF, BURN_LOOP, type BindOptions, type BlastFireSampleBankOptions, type BlastFireSampleDefaults, type BlastKind, DEFAULT_CRACKLES, DEFAULT_FIRE, DEFAULT_INDOOR_CONFINEMENT, DESTRUCTION_SOUND_BANK, DESTRUCTION_SOUND_KEYS, DRAG_SOUNDS, type DestructionRenderer, type DestructionSound, type DestructionSoundOptions, type DestructionSoundStyle, EXPLOSION_BOOM, type ExplodeOptions, FIRE_FALLOFF, FIRE_LOOP, FIRE_SOUNDS, type FragmentLifeRule, GRENADE_PIN_PULL, IMPACT_FAMILY_TAGS, IMPACT_SOUNDS, IMPACT_SOUND_KEYS, type ImpactFamily, type ImpactKeys, type LooseBody, type MakePieceOptions, type Mesh, type MeshRange, type Object3D, type PartHint, type ParticleKind, type Piece, type Quality, ROCKET_MOTOR_LOOP, type RendererOptions, SCENE_SOUNDS, SMOKE_HISS_LOOP, type SolidBox, type SoundDetail, type SoundKeyRule, type SpecFromObjectOptions, type SpecFromObjectResult, type ThreeNamespace, blastFireSampleBank, breakSoundKeys, createDestructionRenderer, createDestructionSound, dragSoundKey, heatColor, impactFamily, impactKey, impactSoundIds, impactSoundKeys, ricochetSoundKeys, shotKey, specFromObject3D };