@khr3/core 0.2.12 → 0.2.14

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
@@ -1,8 +1,59 @@
1
1
  # `@khr3/core`
2
2
 
3
- Khronos `KHR_physics_rigid_bodies` + `KHR_implicit_shapes` + `OMI_vehicle_wheel` loader, exporter, Rapier WASM assembly, and `@pinkaphant/ecctrl` vehicle rig for React Three Fiber.
3
+ Khronos `KHR_physics_rigid_bodies` + `KHR_implicit_shapes` + `OMI_vehicle_wheel` + `KOLMO_emitter` loader, binary `.glb` exporter, exact solid/surface inertia solver, column-major Rapier WASM heightfields, articulated multi-body assemblies, and `@pinkaphant/ecctrl` vehicle rigs for React Three Fiber.
4
+
5
+ - **SI Right-Handed Frame**: `1.0 unit === 1.0 metre`, `+Y` up, `+Z` forward. Every node must have baked unit scale `[1, 1, 1]`.
6
+ - **Zero Silent Fallbacks**: Malformed `.glb` schemas, non-unit scales, or degenerate zero-area colliders throw `KhrValidationError`.
7
+ - **Full API Reference**: [`docs/api-reference.md`](./docs/api-reference.md)
8
+
9
+ ## Quick Start
10
+
11
+ ```tsx
12
+ import { Suspense } from "react";
13
+ import { Canvas } from "@react-three/fiber";
14
+ import {
15
+ PhysicsWorld,
16
+ KhrAssembly,
17
+ KhrHeightfield,
18
+ createHeightfieldGeometry,
19
+ sampleRapierHeightfield,
20
+ useKhrGlb,
21
+ } from "@khr3/core";
22
+ import { KhrVehicle } from "@khr3/core/vehicle";
23
+
24
+ const VAULT = "https://khr3.optimuspi.workers.dev/assets";
25
+ const heights = sampleRapierHeightfield((x, z) => 2 * Math.sin(x * 0.04) * Math.cos(z * 0.04), -100, -100, 200, 200, 128);
26
+ const terrainGeo = createHeightfieldGeometry(heights, 200, 200, 128);
27
+
28
+ function Scene() {
29
+ const car = useKhrGlb(`${VAULT}/cars/nissan_skyline_r34.glb`);
30
+ const door = useKhrGlb(`${VAULT}/city/door_hinged_single_900x2100.glb`);
31
+
32
+ return (
33
+ <PhysicsWorld gravity={[0, -9.81, 0]}>
34
+ <KhrHeightfield heights={heights} segments={128} size={[200, 200]}>
35
+ <mesh geometry={terrainGeo} receiveShadow>
36
+ <meshStandardMaterial color="#3c4a3e" roughness={0.92} />
37
+ </mesh>
38
+ </KhrHeightfield>
39
+ <KhrVehicle bundle={car} position={[0, 2.5, 0]} />
40
+ <KhrAssembly bundle={door} position={[4, 0, 4]} fixedRoot />
41
+ </PhysicsWorld>
42
+ );
43
+ }
44
+
45
+ export default function App() {
46
+ return (
47
+ <Canvas shadows camera={{ position: [0, 6, -12], fov: 55 }}>
48
+ <Suspense fallback={null}>
49
+ <Scene />
50
+ </Suspense>
51
+ </Canvas>
52
+ );
53
+ }
54
+ ```
4
55
 
5
56
  ## Entrypoints
6
57
 
7
- - `@khr3/core` — `loadKhrGlb`, `useKhrGlb`, `exportKhrGlb`, `cloneKhrBundle`, `disposeKhrBundle`, `PhysicsWorld`, `KhrAssembly`, `KhrCollider`, `JointRegistryContext`
8
- - `@khr3/core/vehicle` — `KhrVehicle`, `solveWheelLoads`
58
+ - `@khr3/core` — `PhysicsWorld`, `loadKhrGlb`, `useKhrGlb`, `exportKhrGlb`, `cloneKhrBundle`, `disposeKhrBundle`, `KhrAssembly`, `KhrCollider`, `KhrHeightfield`, `sampleRapierHeightfield`, `transposeHeightfieldForRapier`, `createHeightfieldGeometry`, `computeShapeInertia`, `resolveBodyMassFromColliders`, `jacobiPrincipalInertia`, `computeLumpedMassProps`, `applyRapierBodyMass`, `JointRegistryContext`
59
+ - `@khr3/core/vehicle` — `KhrVehicle`, `solveWheelLoads`, `mergeVehiclePanelUserData`