@khr3/core 0.2.11 → 0.2.12

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/inertia.d.ts CHANGED
@@ -1,12 +1,15 @@
1
1
  import * as THREE from "three";
2
- import { type KhrBodySpec, type KhrColliderShape, type KhrColliderSpec } from "./types.js";
2
+ import type { RapierRigidBody } from "@react-three/rapier";
3
+ import { type KhrBodySpec, type KhrColliderShape } from "./types.js";
3
4
  export type Vec3Tuple = [number, number, number];
4
5
  export type QuatTuple = [number, number, number, number];
5
- export interface LumpedMassProps {
6
- mass: number;
7
- com: Vec3Tuple;
8
- inertia: Vec3Tuple;
9
- inertiaFrame: QuatTuple;
6
+ export interface RapierBodyMassTarget {
7
+ readonly mass: number;
8
+ readonly com: Vec3Tuple;
9
+ readonly hasExplicitCom: boolean;
10
+ readonly inertiaDiagonal: Vec3Tuple;
11
+ readonly inertiaFrame: QuatTuple;
12
+ readonly hasExplicitInertia: boolean;
10
13
  }
11
14
  export declare function assertUnitScale(scale: unknown, owner: string): void;
12
15
  export declare function readFiniteVec3(val: unknown, fieldLabel: string): Vec3Tuple;
@@ -18,15 +21,21 @@ export declare function computeRelativePose(ownerObj: THREE.Object3D, childObj:
18
21
  localQuaternion: QuatTuple;
19
22
  };
20
23
  export declare function extractMeshColliderShape(targetObj: THREE.Object3D, meshNodeName: string, convexHull: boolean): KhrColliderShape;
21
- export declare function jacobiPrincipalInertia(ixx: number, iyy: number, izz: number, ixy: number, ixz: number, iyz: number): {
22
- inertia: Vec3Tuple;
23
- inertiaFrame: QuatTuple;
24
- };
25
- export declare function computeShapeInertia(shape: KhrColliderShape, mass: number): Vec3Tuple;
26
- export declare function computeBodyInertia(colliders: readonly KhrColliderSpec[], mass: number, centerOfMass: readonly [number, number, number], inertiaOrientation: readonly [number, number, number, number], nodeName: string): Vec3Tuple;
24
+ export declare function bodyPoseMatrix(body: KhrBodySpec, target?: THREE.Matrix4): THREE.Matrix4;
27
25
  export declare function computeAssemblyMassAndCom(bodies: readonly KhrBodySpec[]): {
28
26
  totalDynamicMass: number;
29
27
  centerOfMass: Vec3Tuple;
30
28
  };
31
- export declare function bodyPoseMatrix(body: KhrBodySpec, target?: THREE.Matrix4): THREE.Matrix4;
32
- export declare function computeLumpedMassProps(bodies: readonly KhrBodySpec[], invFrame?: THREE.Matrix4): LumpedMassProps | null;
29
+ /**
30
+ * Builds a `RigidBody`-local mass specification from a `KhrBodySpec`.
31
+ * When `hasExplicitInertia` is false, Rapier WASM (`parry3d`) computes exact volume, CoM,
32
+ * parallel-axis tensor, and principal inertia directly from the attached colliders.
33
+ */
34
+ export declare function buildBodyMassTarget(body: KhrBodySpec, bodyRotInRigidBody?: readonly [number, number, number, number], bodyOffsetInRigidBody?: readonly [number, number, number]): RapierBodyMassTarget | null;
35
+ /**
36
+ * Applies `KHR_physics_rigid_bodies` mass properties to a live Rapier WASM `RigidBody`:
37
+ * - Explicit `motion.inertiaDiagonal`: passes authored `{ mass, com, inertiaDiagonal, inertiaFrame }` directly to Rapier.
38
+ * - Omitted `motion.inertiaDiagonal`: delegates volume, CoM, parallel-axis lumping, and Jacobi principal-axis inertia
39
+ * to Rapier's Rust `parry3d` engine across all attached colliders, preserving explicit `motion.centerOfMass` if authored.
40
+ */
41
+ export declare function applyRapierBodyMass(rb: RapierRigidBody, target: RapierBodyMassTarget | null): void;