@khr3/core 0.2.11 → 0.2.13

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,13 @@
1
1
  import * as THREE from "three";
2
+ import type { RapierRigidBody } from "@react-three/rapier";
2
3
  import { type KhrBodySpec, type KhrColliderShape, type KhrColliderSpec } from "./types.js";
3
4
  export type Vec3Tuple = [number, number, number];
4
5
  export type QuatTuple = [number, number, number, number];
5
6
  export interface LumpedMassProps {
6
- mass: number;
7
- com: Vec3Tuple;
8
- inertia: Vec3Tuple;
9
- inertiaFrame: QuatTuple;
7
+ readonly mass: number;
8
+ readonly com: Vec3Tuple;
9
+ readonly inertia: Vec3Tuple;
10
+ readonly inertiaFrame: QuatTuple;
10
11
  }
11
12
  export declare function assertUnitScale(scale: unknown, owner: string): void;
12
13
  export declare function readFiniteVec3(val: unknown, fieldLabel: string): Vec3Tuple;
@@ -18,15 +19,35 @@ export declare function computeRelativePose(ownerObj: THREE.Object3D, childObj:
18
19
  localQuaternion: QuatTuple;
19
20
  };
20
21
  export declare function extractMeshColliderShape(targetObj: THREE.Object3D, meshNodeName: string, convexHull: boolean): KhrColliderShape;
22
+ /**
23
+ * Exact 3x3 symmetric Jacobi eigendecomposition returning positive principal inertia diagonal
24
+ * and right-handed `SO(3)` principal frame quaternion `[x, y, z, w]`.
25
+ */
21
26
  export declare function jacobiPrincipalInertia(ixx: number, iyy: number, izz: number, ixy: number, ixz: number, iyz: number): {
22
27
  inertia: Vec3Tuple;
23
28
  inertiaFrame: QuatTuple;
24
29
  };
30
+ /**
31
+ * Computes exact principal inertia diagonal `[I1, I2, I3]` for a single `KhrColliderShape` of `mass` kg
32
+ * about its centroid.
33
+ */
25
34
  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;
35
+ /**
36
+ * Resolves exact center of mass, full 3x3 Steiner parallel-axis inertia tensor, and Jacobi principal frame
37
+ * for a dynamic `KhrBodySpec` from its colliders when `motion.inertiaDiagonal` is omitted in the `.glb`.
38
+ */
39
+ export declare function resolveBodyMassFromColliders(colliders: readonly KhrColliderSpec[], mass: number, explicitCom: Vec3Tuple | null, explicitInertiaOrientation: QuatTuple | null, nodeName: string): {
40
+ centerOfMass: Vec3Tuple;
41
+ inertiaDiagonal: Vec3Tuple;
42
+ inertiaOrientation: QuatTuple;
43
+ };
27
44
  export declare function computeAssemblyMassAndCom(bodies: readonly KhrBodySpec[]): {
28
45
  totalDynamicMass: number;
29
46
  centerOfMass: Vec3Tuple;
30
47
  };
31
48
  export declare function bodyPoseMatrix(body: KhrBodySpec, target?: THREE.Matrix4): THREE.Matrix4;
32
49
  export declare function computeLumpedMassProps(bodies: readonly KhrBodySpec[], invFrame?: THREE.Matrix4): LumpedMassProps | null;
50
+ /**
51
+ * Applies exact `LumpedMassProps` directly in `RigidBody` local space (`density = 0` on colliders).
52
+ */
53
+ export declare function applyRapierBodyMass(rb: RapierRigidBody, lumped: LumpedMassProps | null): void;