@adatechnology/game-destruction-three 1.0.0 → 1.1.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
@@ -98,6 +98,14 @@ material, into a new mesh that becomes the loose piece, and the range is collaps
98
98
  melted or burnt-out part vanishes the same way. `restore` and `clear` put the merged mesh's original geometry and material back and remove the
99
99
  loose meshes. An invalid range (outside the geometry or empty) throws from `bind`.
100
100
 
101
+ ### A mesh that says what it was built from (`userData.solids`)
102
+
103
+ A mesh of its own (not a range of a merged one) may list the solids it was built from in `userData.solids`: `{ center, half, rotation }` each, in the mesh's
104
+ space (`ShapeSolid` of `@adatechnology/game-shapes`; the mesh api of `@adatechnology/game-interactables-three` writes it). The renderer then holds the mesh by
105
+ that list, fixed (one box of the engine per solid) and let go (the boxes of the piece), and reads no vertex back: a kennel is its boards with its doorway open,
106
+ a stool is its four legs and its seat with the floor free under it. The list is read as data: one entry that is not a solid and the mesh is measured from what
107
+ is drawn, as a mesh with no list is (a house, a vehicle). CLAUDE.md §12 and spec 019.
108
+
101
109
  ## What each event draws
102
110
 
103
111
  | Event | Visual | Sound key |
package/dist/index.d.ts CHANGED
@@ -127,6 +127,8 @@ interface StaticSolid {
127
127
  readonly mesh?: StaticMesh;
128
128
  /** Names the part across lists (a part measured again is the same part): without it, the place in the list. */
129
129
  readonly key?: string;
130
+ /** A round primitive: a cylinder along the solid's own y, its radius the mean of its x and z halves (see `PartBox.round`). */
131
+ readonly round?: true;
130
132
  /** The Coulomb friction and rolling resistance of the part's material; without it the body has the ground's. */
131
133
  readonly friction?: {
132
134
  readonly static: number;
@@ -339,6 +341,8 @@ type ThreeNamespace = typeof THREE_NS;
339
341
  type Object3D = THREE_NS.Object3D;
340
342
  type Mesh = THREE_NS.Mesh;
341
343
  type Quality = 'low' | 'medium' | 'high';
344
+ /** Why the renderer made a bound object a piece on its own (`RendererOptions.onLoosened`). */
345
+ type LoosenCause = 'blast' | 'apart' | 'ground';
342
346
  /** What a sound key carries besides the point and the volume: the named explosion and its size, how enclosed it was, how long a leak lasts. */
343
347
  interface SoundDetail {
344
348
  /** An impact or a break: the keys to try before the key itself, most specific first (material and blow, material, family and blow, family). */
@@ -523,8 +527,11 @@ interface RendererOptions {
523
527
  * reaches with enough speed, the renderer makes it a piece (`makePiece`) and shoves it, and tells `onLoosened`. Without it only the pieces move. Never answer true for a wall or a fixture.
524
528
  */
525
529
  shoveable?: (objectId: string) => boolean;
526
- /** Called when the renderer made a bound object a piece on its own: a blast shoved it (`blast`, see `shoveable`), or furniture came apart and what stayed is loose too (`apart`). */
527
- onLoosened?: (objectId: string, piece: Piece, cause: 'blast' | 'apart') => void;
530
+ /**
531
+ * Called when the renderer made a bound object a piece on its own: a blast shoved it (`blast`, see `shoveable`), furniture came apart and what stayed is loose too (`apart`),
532
+ * or the ground under its feet went (`ground`: a hole dug or blown under a leg of a bed, see `wakeRegion`) and it goes over into the gap.
533
+ */
534
+ onLoosened?: (objectId: string, piece: Piece, cause: LoosenCause) => void;
528
535
  /**
529
536
  * After each break of a bound object (a part broke, came off, burned out or the object fell apart) the renderer checks it on the next update: what is left of an object that
530
537
  * is not a piece must stand on something (the ground, a fixed top, a piece). One left over air is made a piece on the spot and falls (`released` true); either way the host
@@ -928,6 +935,18 @@ type BlastPacer = {
928
935
  */
929
936
  declare function createBlastPacer(options: BlastPacerOptions): BlastPacer;
930
937
 
938
+ /**
939
+ * One solid a mesh was built from (spec 019): its own box in the mesh's space, turned as it was drawn (`rotation`: x, y, z, w). The builder of the mesh lists them in
940
+ * `userData.solids` (`ShapeSolid` of game-shapes, by the mesh api of game-interactables-three): the piece is then held by what was drawn, with no vertex read back.
941
+ */
942
+ interface BuiltSolid {
943
+ readonly center: readonly [number, number, number];
944
+ readonly half: readonly [number, number, number];
945
+ readonly rotation: readonly [number, number, number, number];
946
+ /** What drew it (`'box'`, `'cylinder'`...): a cylinder is held as a cylinder along its own y. */
947
+ readonly kind?: string;
948
+ }
949
+
931
950
  /**
932
951
  * One fixed drawn part to measure (`measureStaticPart`): plain arrays, so it crosses to a worker (`destruction.static-colliders`). The main thread reads the vertices,
933
952
  * the triangles and the mesh's world matrix (with three's own `decompose` of it); the measuring is here.
@@ -944,10 +963,12 @@ interface StaticPartJob {
944
963
  /** The triangles of the part as vertex numbers of the host (three each), `from` its first vertex. */
945
964
  readonly found: Uint32Array;
946
965
  readonly from: number;
966
+ /** The solids the mesh was built from (`builtSolidsOf`), in the mesh's frame: with them the part is those boxes, and nothing is measured. */
967
+ readonly solids?: readonly BuiltSolid[];
947
968
  }
948
969
  /**
949
- * What a fixed drawn part collides as, in world space, for an engine: one box turned as drawn where a box fits it (every corner has a vertex within `FIT` and its
950
- * triangles cover its faces), else the box turned to fit the world vertices where that one fits, else the triangles as drawn (`mesh`, static only). A part collapsed to
970
+ * What a fixed drawn part collides as, in world space, for an engine: one box turned as drawn where a box fits it (every corner has a vertex within `FIT`, its
971
+ * triangles cover its faces and enclose `SOLID` of it), else the box turned to fit the world vertices where that one fits, else the triangles as drawn (`mesh`, static only). A part collapsed to
951
972
  * a point is nothing (`CLAUDE.md` §12). A pure function of the job: the worker and the main thread give the same bits (`staticCollidersKind`).
952
973
  */
953
974
  declare function measureStaticPart(job: StaticPartJob): StaticSolid[];
@@ -1226,4 +1247,4 @@ declare function blastFireSampleBank(manifest: SfxManifest, options?: BlastFireS
1226
1247
  /** Every particle kind the renderer can emit (the game's sprite kinds, see `@adatechnology/game-vfx`). */
1227
1248
  type ParticleKind = SpriteKind;
1228
1249
 
1229
- export { BIG_BLAST_RADIUS, BLAST_DEBRIS_DEFAULTS, BLAST_FALLOFF, BLAST_FAR_DISTANCE, BLAST_FAR_FALLOFF, BLAST_FIRE_SAMPLES, BLAST_KINDS, BLAST_KIND_OF, BLAST_RAYS_PER_FRAME, BLAST_SOUNDS, BLAST_SOUND_OF, BLAST_WAVE_PARTS_PER_FRAME, BURN_LOOP, type BindOptions, type BlastDebrisOptions, type BlastFireSampleBankOptions, type BlastFireSampleDefaults, type BlastKind, type BlastPacer, type BlastPacerOptions, type BlastWake, DEFAULT_CRACKLES, DEFAULT_FIRE, DEFAULT_INDOOR_CONFINEMENT, DESTRUCTION_SOUND_BANK, DESTRUCTION_SOUND_KEYS, DESTRUCTION_VOICE_GROUPS, DRAG_SOUNDS, type DebrisCostOptions, type DebrisCostSample, type DeferredQueueRegistration, type DestructionRenderer, type DestructionSound, type DestructionSoundOptions, type DestructionSoundStyle, EVENT_APPLY_WEIGHT, EVENT_CLASS, EXPLOSION_BOOM, type EventClass, type ExplodeOptions, type ExplosionWorkOptions, FIRE_FADE_SECONDS, FIRE_FALLOFF, FIRE_LOOP, FIRE_SOUNDS, type FarDebrisAction, type FarDebrisOptions, type FragmentLifeRule, GRENADE_PIN_PULL, GROUND_WORKER_FRAMES, type GroundPatchRead, type GroundTileJob, type GroundTileResult, type GroundWorkerPort, IMPACT_BURST_GROUP, IMPACT_FAMILY_TAGS, IMPACT_SOUNDS, IMPACT_SOUND_KEYS, type ImpactFamily, type ImpactKeys, type JitWarmUpOptions, type JitWarmUpReport, type LooseBody, MIN_PIECE_MASS_KG, type MakePieceOptions, type Mesh, type MeshRange, type Object3D, type PacedBlast, type PartHint, type ParticleKind, PhysicsOptionError, type Piece, type PiecePhysics, type Quality, ROCKET_MOTOR_LOOP, type RendererOptions, type ResolvedBlastDebris, SCENE_SOUNDS, SETTLED_BATCH_DEFAULTS, SETTLED_BATCH_ORIGIN, SMOKE_HISS_LOOP, STRUCTURAL_UNITS_PER_FRAME, SUGGESTED_MAX_AWAKE_FRAGMENTS, SUGGESTED_MAX_AWAKE_PIECES, type SettledBatchOptions, type SettledBatchStats, type SolidBox, type SoundDetail, type SoundKeyRule, type SpecFromObjectOptions, type SpecFromObjectResult, type StaticPartJob, type ThreeNamespace, WORK_UNIT_DEFAULTS, type WorkUnitCosts, bandLength, blastFireSampleBank, blastSoundIds, breakSoundKeys, computeGroundTile, createBlastPacer, createCoordinatorGroundPort, createDestructionRenderer, createDestructionSound, createInlineGroundPort, createMainThreadGroundPort, createWorkerGroundPort, dragSoundKey, eventApplyWeight, groundTilesKind, heatColor, impactFamily, impactKey, impactSoundIds, impactSoundKeys, installGroundWorker, measureStaticPart, readGroundBand, readGroundPatch, resolveBlastDebris, resolveWorkUnitCosts, ricochetSoundKeys, shotKey, specFromObject3D, splitWorkUnits, staticCollidersKind, warmUpDestructionJit };
1250
+ export { BIG_BLAST_RADIUS, BLAST_DEBRIS_DEFAULTS, BLAST_FALLOFF, BLAST_FAR_DISTANCE, BLAST_FAR_FALLOFF, BLAST_FIRE_SAMPLES, BLAST_KINDS, BLAST_KIND_OF, BLAST_RAYS_PER_FRAME, BLAST_SOUNDS, BLAST_SOUND_OF, BLAST_WAVE_PARTS_PER_FRAME, BURN_LOOP, type BindOptions, type BlastDebrisOptions, type BlastFireSampleBankOptions, type BlastFireSampleDefaults, type BlastKind, type BlastPacer, type BlastPacerOptions, type BlastWake, DEFAULT_CRACKLES, DEFAULT_FIRE, DEFAULT_INDOOR_CONFINEMENT, DESTRUCTION_SOUND_BANK, DESTRUCTION_SOUND_KEYS, DESTRUCTION_VOICE_GROUPS, DRAG_SOUNDS, type DebrisCostOptions, type DebrisCostSample, type DeferredQueueRegistration, type DestructionRenderer, type DestructionSound, type DestructionSoundOptions, type DestructionSoundStyle, EVENT_APPLY_WEIGHT, EVENT_CLASS, EXPLOSION_BOOM, type EventClass, type ExplodeOptions, type ExplosionWorkOptions, FIRE_FADE_SECONDS, FIRE_FALLOFF, FIRE_LOOP, FIRE_SOUNDS, type FarDebrisAction, type FarDebrisOptions, type FragmentLifeRule, GRENADE_PIN_PULL, GROUND_WORKER_FRAMES, type GroundPatchRead, type GroundTileJob, type GroundTileResult, type GroundWorkerPort, IMPACT_BURST_GROUP, IMPACT_FAMILY_TAGS, IMPACT_SOUNDS, IMPACT_SOUND_KEYS, type ImpactFamily, type ImpactKeys, type JitWarmUpOptions, type JitWarmUpReport, type LooseBody, type LoosenCause, MIN_PIECE_MASS_KG, type MakePieceOptions, type Mesh, type MeshRange, type Object3D, type PacedBlast, type PartHint, type ParticleKind, PhysicsOptionError, type Piece, type PiecePhysics, type Quality, ROCKET_MOTOR_LOOP, type RendererOptions, type ResolvedBlastDebris, SCENE_SOUNDS, SETTLED_BATCH_DEFAULTS, SETTLED_BATCH_ORIGIN, SMOKE_HISS_LOOP, STRUCTURAL_UNITS_PER_FRAME, SUGGESTED_MAX_AWAKE_FRAGMENTS, SUGGESTED_MAX_AWAKE_PIECES, type SettledBatchOptions, type SettledBatchStats, type SolidBox, type SoundDetail, type SoundKeyRule, type SpecFromObjectOptions, type SpecFromObjectResult, type StaticPartJob, type ThreeNamespace, WORK_UNIT_DEFAULTS, type WorkUnitCosts, bandLength, blastFireSampleBank, blastSoundIds, breakSoundKeys, computeGroundTile, createBlastPacer, createCoordinatorGroundPort, createDestructionRenderer, createDestructionSound, createInlineGroundPort, createMainThreadGroundPort, createWorkerGroundPort, dragSoundKey, eventApplyWeight, groundTilesKind, heatColor, impactFamily, impactKey, impactSoundIds, impactSoundKeys, installGroundWorker, measureStaticPart, readGroundBand, readGroundPatch, resolveBlastDebris, resolveWorkUnitCosts, ricochetSoundKeys, shotKey, specFromObject3D, splitWorkUnits, staticCollidersKind, warmUpDestructionJit };