@khr3/core 0.2.0 → 0.2.2
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 +7 -7
- package/dist/AssemblyRootBody.d.ts +2 -3
- package/dist/KhrAssembly.d.ts +3 -5
- package/dist/assemblyPlan.d.ts +8 -9
- package/dist/index.d.ts +2 -2
- package/dist/index.js +266 -202
- package/dist/index.js.map +1 -1
- package/dist/jointDynamics.d.ts +23 -17
- package/dist/khrExtras.d.ts +2 -1
- package/dist/khrGlb.d.ts +0 -5
- package/dist/khrTypes.d.ts +5 -0
- package/dist/khrVehicleJointHelpers.d.ts +13 -15
- package/dist/khrVehicleJoints.d.ts +7 -1
- package/dist/khrVehicleSlots.d.ts +7 -9
- package/dist/{BundleSceneHost-DUqqPtJF.js → physicsEcs-B9XGoZtl.js} +407 -358
- package/dist/physicsEcs-B9XGoZtl.js.map +1 -0
- package/dist/physicsEcs.d.ts +12 -40
- package/dist/vehicle.js +279 -208
- package/dist/vehicle.js.map +1 -1
- package/docs/api-reference.md +15 -15
- package/package.json +1 -1
- package/dist/BundleSceneHost-DUqqPtJF.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# `@khr3/core` (`khr3`)
|
|
2
2
|
|
|
3
|
-
`KHR_physics_rigid_bodies` + `KHR_implicit_shapes` runtime loader, binary `.glb` exporter, `@react-three/rapier` multi-body assembly synchronizer, and `@pinkaphant/ecctrl` vehicle rig + monotone Pacejka curve presets for React Three Fiber.
|
|
3
|
+
`KHR_physics_rigid_bodies` + `KHR_implicit_shapes` + `OMI_vehicle_wheel` runtime loader, binary `.glb` exporter, `@react-three/rapier` multi-body `ImpulseJoint` assembly & contact-impulse breakaway synchronizer ([src/KhrAssembly.tsx](./src/KhrAssembly.tsx), [src/KhrCollider.tsx](./src/KhrCollider.tsx), [src/PhysicsWorld.tsx](./src/PhysicsWorld.tsx)), and `@pinkaphant/ecctrl` vehicle rig ([src/KhrVehicle.tsx](./src/KhrVehicle.tsx)) + monotone Pacejka curve presets ([src/pacejka.ts](./src/pacejka.ts)) for React Three Fiber.
|
|
4
4
|
|
|
5
5
|
- Full API & configuration reference: [docs/api-reference.md](./docs/api-reference.md)
|
|
6
6
|
- Runnable example: [example/App.tsx](./example/App.tsx) & [example/headless.ts](./example/headless.ts)
|
|
7
7
|
|
|
8
8
|
## Subpath Exports
|
|
9
9
|
|
|
10
|
-
| Subpath | Exports |
|
|
11
|
-
| --- | --- |
|
|
12
|
-
| `@khr3/core` | `PhysicsWorld`, `createKhrGltfPlugin`, `useKhrGlb`, `loadKhrGlb`, `cloneKhrBundle`, `disposeKhrBundle`, `claimBundleMount`, `releaseBundleMount`, `exportKhrGlb`, `patchGlbJsonChunk`, `KhrCollider`, `KhrAssembly`, `JointRegistryContext`, `assertUnitScale`, `assertIdentityWorldScale`, `assertSceneIdentityWorldScale`, `KhrValidationError`, KHR & rotor tag types |
|
|
13
|
-
| `@khr3/core/vehicle` | `KhrVehicle`, `solveWheelLoads`, `KhrPropellerConfig`, `KhrVehicleJointsHandle`, `KhrVehicleProps`, `KhrWheelConfig`, `SolvedWheel` |
|
|
14
|
-
| `@khr3/core/curves` | `compilePacejkaCurve`, `tireGripForSurface`, `engineHorsepowerForPeakTorque`, `TIRE_ARCHETYPES`, `TIRE_SLIP_CURVES`, `ENGINE_TORQUE_CURVES`, `STEER_SPEED_CURVES`, `TireArchetypePreset`, `CurveData`, `CurvePoint` |
|
|
10
|
+
| Subpath | Source | Exports |
|
|
11
|
+
| --- | --- | --- |
|
|
12
|
+
| `@khr3/core` | [src/index.ts](./src/index.ts), [src/PhysicsWorld.tsx](./src/PhysicsWorld.tsx), [src/KhrAssembly.tsx](./src/KhrAssembly.tsx), [src/KhrCollider.tsx](./src/KhrCollider.tsx) | `PhysicsWorld`, `createKhrGltfPlugin`, `useKhrGlb`, `loadKhrGlb`, `cloneKhrBundle`, `disposeKhrBundle`, `claimBundleMount`, `releaseBundleMount`, `exportKhrGlb`, `patchGlbJsonChunk`, `KhrCollider`, `KhrAssembly`, `JointRegistryContext`, `assertUnitScale`, `assertIdentityWorldScale`, `assertSceneIdentityWorldScale`, `KhrValidationError`, KHR, `KhrBreakawaySpec` & rotor tag types |
|
|
13
|
+
| `@khr3/core/vehicle` | [src/KhrVehicle.tsx](./src/KhrVehicle.tsx), [src/khrVehicleJoints.tsx](./src/khrVehicleJoints.tsx), [src/wheelLoads.ts](./src/wheelLoads.ts) | `KhrVehicle`, `solveWheelLoads`, `KhrPropellerConfig`, `KhrVehicleJointsHandle`, `KhrVehicleProps`, `KhrWheelConfig`, `SolvedWheel` |
|
|
14
|
+
| `@khr3/core/curves` | [src/curves.ts](./src/curves.ts), [src/pacejka.ts](./src/pacejka.ts) | `compilePacejkaCurve`, `tireGripForSurface`, `engineHorsepowerForPeakTorque`, `TIRE_ARCHETYPES`, `TIRE_SLIP_CURVES`, `ENGINE_TORQUE_CURVES`, `STEER_SPEED_CURVES`, `TireArchetypePreset`, `CurveData`, `CurvePoint` |
|
|
15
15
|
|
|
16
|
-
See [docs/api-reference.md](./docs/api-reference.md) for the complete API, `.glb` KHR + `extras` schema, custom gravity, transmission, and curve reference.
|
|
16
|
+
See [docs/api-reference.md](./docs/api-reference.md) for the complete API, `.glb` KHR + `OMI_vehicle_wheel` + `extras` schema, custom gravity, transmission, and curve reference.
|
|
@@ -5,13 +5,12 @@ import { type JointRuntime } from "./physicsEcs.js";
|
|
|
5
5
|
export type AssemblyRigidBodyProps = Omit<RigidBodyProps, "type" | "position" | "rotation" | "quaternion" | "colliders" | "children" | "ref">;
|
|
6
6
|
export interface AssemblyRootBodyProps {
|
|
7
7
|
plan: RootPlan;
|
|
8
|
-
assemblyId: number;
|
|
9
8
|
position: [number, number, number];
|
|
10
9
|
quaternion: [number, number, number, number];
|
|
11
10
|
fixedRoot: boolean;
|
|
12
11
|
rigidBodyProps?: AssemblyRigidBodyProps;
|
|
13
|
-
onBody: (
|
|
12
|
+
onBody: (nodeName: string, rb: React.RefObject<RapierRigidBody | null> | null) => void;
|
|
14
13
|
onJoints: (rootName: string, joints: Map<string, JointRuntime> | null) => void;
|
|
15
14
|
children?: React.ReactNode;
|
|
16
15
|
}
|
|
17
|
-
export declare function AssemblyRootBody({ plan,
|
|
16
|
+
export declare function AssemblyRootBody({ plan, position, quaternion, fixedRoot, rigidBodyProps, onBody, onJoints, children, }: AssemblyRootBodyProps): React.JSX.Element;
|
package/dist/KhrAssembly.d.ts
CHANGED
|
@@ -4,11 +4,11 @@ import type { RapierRigidBody } from "@react-three/rapier";
|
|
|
4
4
|
import { type AssemblyRigidBodyProps } from "./AssemblyRootBody.js";
|
|
5
5
|
import { type KhrAssetBundle } from "./khrTypes.js";
|
|
6
6
|
export interface KhrAssemblyHandle {
|
|
7
|
-
/** RigidBody
|
|
7
|
+
/** RigidBody owning `nodeName`, or null if no KHR body has that name. */
|
|
8
8
|
getBody: (nodeName: string) => RapierRigidBody | null;
|
|
9
|
-
/** Sets the authored
|
|
9
|
+
/** Sets the authored Rapier motor position target on one articulated node. */
|
|
10
10
|
setJointTarget: (nodeName: string, target: number) => void;
|
|
11
|
-
/** Sets the position target on every articulated node whose `extras.role` matches. */
|
|
11
|
+
/** Sets the motor position target on every articulated node whose `extras.role` matches. */
|
|
12
12
|
setRoleTarget: (role: string, target: number) => void;
|
|
13
13
|
}
|
|
14
14
|
type GroupProps = Omit<ThreeElements["group"], "ref" | "position" | "rotation" | "quaternion" | "scale" | "children">;
|
|
@@ -18,9 +18,7 @@ export interface KhrAssemblyProps extends GroupProps {
|
|
|
18
18
|
position?: [number, number, number];
|
|
19
19
|
rotation?: [number, number, number];
|
|
20
20
|
quaternion?: [number, number, number, number];
|
|
21
|
-
/** Must be 1: assets are baked to identity scale by the importer gate. */
|
|
22
21
|
scale?: ThreeElements["group"]["scale"];
|
|
23
|
-
/** Kinematic roots become `fixed` bodies instead of `kinematicPosition`. */
|
|
24
22
|
fixedRoot?: boolean;
|
|
25
23
|
rigidBodyProps?: AssemblyRigidBodyProps;
|
|
26
24
|
children?: React.ReactNode;
|
package/dist/assemblyPlan.d.ts
CHANGED
|
@@ -24,39 +24,38 @@ export interface ColliderMass {
|
|
|
24
24
|
}
|
|
25
25
|
export interface PlannedCollider {
|
|
26
26
|
spec: KhrColliderSpec;
|
|
27
|
-
/** Pose in the owning body's local frame. */
|
|
28
27
|
local: THREE.Matrix4;
|
|
29
|
-
/** Rest pose in the root body frame. */
|
|
30
28
|
position: Vec3;
|
|
31
29
|
quaternion: Quat;
|
|
32
|
-
/** Composite mass properties carried by the stationary root's first collider; moving child colliders stay massless. */
|
|
33
30
|
massProperties?: ColliderMass;
|
|
34
31
|
}
|
|
35
32
|
export interface PartPlan {
|
|
36
33
|
spec: KhrBodySpec;
|
|
37
34
|
joint: KhrJointSpec;
|
|
38
35
|
parent: PartPlan | null;
|
|
39
|
-
|
|
36
|
+
restRelParentPos: Vec3;
|
|
37
|
+
restRelParentQuat: Quat;
|
|
38
|
+
restRelRootPos: Vec3;
|
|
39
|
+
restRelRootQuat: Quat;
|
|
40
|
+
axisParent: Vec3;
|
|
41
|
+
axisChild: Vec3;
|
|
40
42
|
inertia: number;
|
|
43
|
+
partMass?: ColliderMass;
|
|
41
44
|
colliders: PlannedCollider[];
|
|
42
45
|
}
|
|
43
46
|
export interface RootPlan {
|
|
44
47
|
spec: KhrBodySpec;
|
|
45
|
-
/** Pose of `bundle.scene` in this root body's local frame (used when `plans.length === 1`). */
|
|
46
48
|
sceneInRootPos: Vec3;
|
|
47
49
|
sceneInRootQuat: Quat;
|
|
48
|
-
/** Disjoint glTF subtree root that rides on this body when `plans.length > 1`. */
|
|
49
50
|
mountNode: THREE.Object3D;
|
|
50
51
|
mountInRoot: THREE.Matrix4;
|
|
51
52
|
mountPosition: Vec3;
|
|
52
53
|
mountQuaternion: Quat;
|
|
53
|
-
/** Composite mass properties in the root RigidBody frame when `colliders` is empty on a dynamic root. */
|
|
54
54
|
rootMass?: ColliderMass;
|
|
55
55
|
colliders: PlannedCollider[];
|
|
56
|
-
/** Parent-first order. */
|
|
57
56
|
parts: PartPlan[];
|
|
58
57
|
}
|
|
59
58
|
export declare function toColliderMass(lumped: LumpedMassProps, colMat?: THREE.Matrix4, colQuat?: THREE.Quaternion): ColliderMass;
|
|
60
|
-
/**
|
|
59
|
+
/** Plans independent Rapier bodies for roots and jointed dynamic children connected by Rapier ImpulseJoints. */
|
|
61
60
|
export declare function planAssembly(bundle: KhrAssetBundle): RootPlan[];
|
|
62
61
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { PhysicsWorld, type PhysicsWorldProps, type TimeControlValue } from "./PhysicsWorld.js";
|
|
2
|
-
export { KhrValidationError, createKhrGltfPlugin, loadKhrGlb, type EcctrlPropellerTag, type EcctrlWheelTag, type KhrAssetBundle, type KhrBodySpec, type KhrCarConfig, type KhrColliderShape, type KhrColliderSpec, type KhrCombineMode, type KhrDroneConfig, type KhrExportNodeSpec, type KhrImplicitShape, type KhrJointDriveSpec, type KhrJointSpec, type KhrPluginOptions, type LoadKhrGlbOptions, type OmiVehicleWheelSpec, type UseKhrGlbOptions, } from "./khrLoader.js";
|
|
2
|
+
export { KhrValidationError, createKhrGltfPlugin, loadKhrGlb, type EcctrlPropellerTag, type EcctrlWheelTag, type KhrAssetBundle, type KhrBodySpec, type KhrBreakawaySpec, type KhrCarConfig, type KhrColliderShape, type KhrColliderSpec, type KhrCombineMode, type KhrDroneConfig, type KhrExportNodeSpec, type KhrImplicitShape, type KhrJointDriveSpec, type KhrJointSpec, type KhrPluginOptions, type LoadKhrGlbOptions, type OmiVehicleWheelSpec, type UseKhrGlbOptions, } from "./khrLoader.js";
|
|
3
3
|
export { exportKhrGlb, patchGlbJsonChunk } from "./khrExporter.js";
|
|
4
4
|
export type { MutableGltfJson, RawGltfJson } from "./khrGlb.js";
|
|
5
5
|
export { claimBundleMount, cloneKhrBundle, disposeKhrBundle, releaseBundleMount } from "./khrClone.js";
|
|
@@ -7,4 +7,4 @@ export { assertIdentityWorldScale, assertSceneIdentityWorldScale, assertUnitScal
|
|
|
7
7
|
export { KhrCollider } from "./KhrCollider.js";
|
|
8
8
|
export { KhrAssembly, type KhrAssemblyHandle, type KhrAssemblyProps } from "./KhrAssembly.js";
|
|
9
9
|
export { useKhrGlb } from "./useKhrGlb.js";
|
|
10
|
-
export { JointRegistryContext, type
|
|
10
|
+
export { JointRegistryContext, type JointRegistry, type JointRuntime } from "./physicsEcs.js";
|