@threenative/physics 0.3.15 → 0.3.16

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.
@@ -1,6 +1,199 @@
1
- export { A as Area3D, $ as AreaEvent, a0 as AreaHandler, B as Buoyancy3D, h as BuoyancyPointPosition, i as CharacterBody3D, C as CollisionShape3D, a1 as CollisionShapeKind, a2 as IArea3DOptions, a3 as IAreaContact, j as IBuoyancy3DOptions, k as IBuoyancyHullPoint, l as IBuoyancySurface, m as IBuoyancySurfaceSample, a4 as ICharacterBody3DOptions, o as IIntersectPointOptions, p as IIntersectRayOptions, q as IIntersectShapeOptions, r as IPhysicsBodyCreateOptions, b as IPhysicsBodyHandle, s as IPhysicsCharacterOptions, f as IPhysicsColliderHandle, I as IPhysicsContext, t as IPhysicsHandle, u as IPhysicsInputSnapshot, v as IPhysicsJointCreateOptions, e as IPhysicsJointLimit, a5 as IPhysicsOptions, w as IPhysicsPointQuery, x as IPhysicsQueryHit, y as IPhysicsRayHit, z as IPhysicsRayQuery, d as IPhysicsRotation, D as IPhysicsRuntimeSimulation, E as IPhysicsShapeDescriptor, F as IPhysicsShapeQuery, G as IPhysicsSimulation, c as IPhysicsVector3, H as IPhysicsVehicleCreateOptions, J as IPhysicsVehicleInput, K as IPhysicsVehicleState, a as IPhysicsWorldHandle, L as IPointHit, M as IRayHit, N as IRigidBody3DOptions, O as IShapeHit, Q as MAX_PHYSICS_QUERY_RESULTS, S as PHYSICS_COLLISION_EVENT_STRIDE, T as PHYSICS_TRANSFORM_STRIDE, U as PHYSICS_VEHICLE_WHEEL_STRIDE, P as PhysicsBody3D, V as PhysicsDirectSpaceState3D, W as PhysicsJointKind, a6 as PhysicsPlugin, X as PhysicsQueryVector3, Y as PhysicsShapeKind, R as RigidBody3D, Z as RigidBodyType, _ as rapier } from '../Area3D-BI0ynKEY.js';
1
+ import { I as IPhysicsSimulation, a as IPhysicsJointCreateOptions, b as IPhysicsVector3, c as IPhysicsVehicleInput, d as IPhysicsInputSnapshot } from '../Area3D-BqLJBY6B.js';
2
+ export { A as Area3D, e as AreaEvent, f as AreaHandler, B as Buoyancy3D, g as BuoyancyPointPosition, C as CharacterBody3D, h as CollisionShape3D, i as CollisionShapeKind, j as IArea3DOptions, k as IAreaContact, l as IBuoyancy3DOptions, m as IBuoyancyHullPoint, n as IBuoyancySurface, o as IBuoyancySurfaceSample, p as ICharacterBody3DOptions, q as IIntersectPointOptions, r as IIntersectRayOptions, s as IIntersectShapeOptions, t as IPhysicsBodyCreateOptions, u as IPhysicsBodyHandle, v as IPhysicsCharacterOptions, w as IPhysicsColliderHandle, x as IPhysicsContext, y as IPhysicsHandle, z as IPhysicsJointLimit, D as IPhysicsOptions, E as IPhysicsPointQuery, F as IPhysicsQueryHit, G as IPhysicsRayHit, H as IPhysicsRayQuery, J as IPhysicsRotation, K as IPhysicsRuntimeSimulation, L as IPhysicsShapeDescriptor, M as IPhysicsShapeQuery, N as IPhysicsVehicleCreateOptions, O as IPhysicsVehicleState, P as IPhysicsWorldHandle, Q as IPointHit, R as IRayHit, S as IRigidBody3DOptions, T as IShapeHit, U as MAX_PHYSICS_QUERY_RESULTS, V as PHYSICS_COLLISION_EVENT_STRIDE, W as PHYSICS_TRANSFORM_STRIDE, X as PHYSICS_VEHICLE_WHEEL_STRIDE, Y as PhysicsBody3D, Z as PhysicsDirectSpaceState3D, _ as PhysicsJointKind, $ as PhysicsPlugin, a0 as PhysicsQueryVector3, a1 as PhysicsShapeKind, a2 as RigidBody3D, a3 as RigidBodyType, a4 as rapier } from '../Area3D-BqLJBY6B.js';
2
3
  export { IBuildStaticCollidersOptions, IFixedJoint3DOptions, IHingeJoint3DOptions, IJoint3DOptions, IPinJoint3DOptions, IScatterColliderInstance, IScatterCollidersOptions, IScatterCollidersStats, ISnowPhysicsBinding, ISnowPhysicsObservation, ISnowPhysicsOptions, IStaticColliderContext, IVehicleBody3DOptions, IVehicleWheel3D, Joint3D, PhysicsJointBody, ScatterColliders, ScatterCollision, StaticColliderPredicate, VehicleBody3D, VehicleForwardAxis, attachSnowPhysics, boxFootprint, buildStaticColliders, capsuleFootprint, interactionGroups, softBodyCollision } from '../index.js';
3
4
  import 'three';
4
5
  import '@threenative/core';
5
6
  import 'recast-navigation';
6
7
  import '@threenative/core/world';
8
+
9
+ interface INativeShapeDescriptor {
10
+ readonly kind: "box" | "capsule" | "heightfield" | "sphere" | "trimesh";
11
+ readonly x: number;
12
+ readonly y: number;
13
+ readonly z: number;
14
+ /** Present for `trimesh` only: a flat xyz vertex buffer and a flat triangle-index buffer. */
15
+ readonly vertices?: Float32Array;
16
+ readonly indices?: Uint32Array;
17
+ /** Present for `heightfield` only: column-major samples, the grid and its full extent. */
18
+ readonly heights?: Float32Array;
19
+ readonly rows?: number;
20
+ readonly columns?: number;
21
+ readonly scale?: {
22
+ readonly x: number;
23
+ readonly y: number;
24
+ readonly z: number;
25
+ };
26
+ collisionLayer: number;
27
+ collisionMask: number;
28
+ sensor: boolean;
29
+ }
30
+ interface INativeBodyOptions {
31
+ readonly collisionLayer: number;
32
+ readonly collisionMask: number;
33
+ readonly entity?: string;
34
+ readonly mass: number;
35
+ readonly position: {
36
+ readonly x: number;
37
+ readonly y: number;
38
+ readonly z: number;
39
+ };
40
+ readonly rotation: {
41
+ readonly w: number;
42
+ readonly x: number;
43
+ readonly y: number;
44
+ readonly z: number;
45
+ };
46
+ readonly sensor: boolean;
47
+ readonly shape: INativeShapeDescriptor;
48
+ readonly type: "character" | "dynamic" | "fixed" | "kinematic";
49
+ readonly continuousCollision: boolean;
50
+ }
51
+ type INativeJointOptions = IPhysicsJointCreateOptions;
52
+ interface INativeRayHit {
53
+ readonly bodyId: number;
54
+ readonly distance: number;
55
+ readonly normal: {
56
+ readonly x: number;
57
+ readonly y: number;
58
+ readonly z: number;
59
+ };
60
+ readonly position: {
61
+ readonly x: number;
62
+ readonly y: number;
63
+ readonly z: number;
64
+ };
65
+ }
66
+ interface INativeRayQuery {
67
+ readonly from: {
68
+ readonly x: number;
69
+ readonly y: number;
70
+ readonly z: number;
71
+ };
72
+ readonly to: {
73
+ readonly x: number;
74
+ readonly y: number;
75
+ readonly z: number;
76
+ };
77
+ readonly collisionMask: number;
78
+ }
79
+ interface INativeShapeQuery {
80
+ readonly shape: INativeShapeDescriptor;
81
+ readonly position: {
82
+ readonly x: number;
83
+ readonly y: number;
84
+ readonly z: number;
85
+ };
86
+ readonly rotation: {
87
+ readonly w: number;
88
+ readonly x: number;
89
+ readonly y: number;
90
+ readonly z: number;
91
+ };
92
+ readonly collisionMask: number;
93
+ readonly maxResults: number;
94
+ }
95
+ interface INativePointQuery {
96
+ readonly position: {
97
+ readonly x: number;
98
+ readonly y: number;
99
+ readonly z: number;
100
+ };
101
+ readonly collisionMask: number;
102
+ readonly maxResults: number;
103
+ }
104
+ interface INativeQueryHit {
105
+ readonly bodyId: number;
106
+ readonly position: {
107
+ readonly x: number;
108
+ readonly y: number;
109
+ readonly z: number;
110
+ };
111
+ }
112
+ /**
113
+ * The flat wheel record the C ABI takes: twelve floats per wheel, in the order
114
+ * `physics_native.h` documents. Flattening here rather than in the binding keeps the optional
115
+ * `maxSuspensionTravel` decision on the TypeScript side of the seam.
116
+ */
117
+ interface INativeVehicleOptions {
118
+ readonly bodyId: number;
119
+ readonly forwardAxis: 0 | 2;
120
+ readonly axle: IPhysicsVector3;
121
+ readonly wheels: Float32Array;
122
+ }
123
+ /** Raw object installed by the C++ runtime. It is wrapped before shared nodes see it. */
124
+ interface INativeSimulation {
125
+ configureCharacter(id: number, options: Parameters<IPhysicsSimulation["configureCharacter"]>[1]): void;
126
+ createBody(options: INativeBodyOptions): number;
127
+ createJoint?(options: INativeJointOptions): number;
128
+ dispose(): void;
129
+ drainCollisionEvents(buffer: Uint32Array): number;
130
+ removeBody(id: number): void;
131
+ removeJoint?(id: number): void;
132
+ setBodyTransform?(id: number, position: {
133
+ readonly x: number;
134
+ readonly y: number;
135
+ readonly z: number;
136
+ }): void;
137
+ /** Optional so old runtimes fail loudly through the adapter instead of silently diverging. */
138
+ applyBodyImpulse?(id: number, impulse: IPhysicsVector3): void;
139
+ applyBodyForce?(id: number, force: IPhysicsVector3): void;
140
+ applyBodyForceAtPoint?(id: number, force: IPhysicsVector3, point: IPhysicsVector3): void;
141
+ setBodyLinearVelocity?(id: number, velocity: IPhysicsVector3): void;
142
+ readBodyLinearVelocity?(id: number): IPhysicsVector3;
143
+ readVisibleTransforms(renderBuffer: Float32Array): number;
144
+ readBodySleepStates(buffer: Float32Array): number;
145
+ readCharacterStates(buffer: Float32Array): number;
146
+ /** Optional so a runtime built before vehicles still fails loudly through the adapter. */
147
+ createVehicle?(options: INativeVehicleOptions): number;
148
+ setVehicleInput?(id: number, input: IPhysicsVehicleInput): void;
149
+ setVehicleWheelFriction?(id: number, wheel: number, frictionSlip: number): void;
150
+ readVehicleState?(id: number, output: Float32Array): number;
151
+ resetVehicle?(id: number, position: IPhysicsVector3, yaw: number): void;
152
+ readAreaIntersections(buffer: Uint32Array): number;
153
+ /** Optional so old runtimes fail loudly through the adapter instead of reporting no contact. */
154
+ readContacts?(target: number, candidates: Uint32Array, output: Float32Array): number;
155
+ setColliderShape?(id: number, shape: INativeShapeDescriptor): void;
156
+ intersectRay(query: INativeRayQuery, output?: Float32Array): INativeRayHit | number | null | undefined;
157
+ intersectShape(query: INativeShapeQuery): readonly INativeQueryHit[];
158
+ intersectPoint(query: INativePointQuery): readonly INativeQueryHit[];
159
+ step(deltaTime: number, inputSnapshot?: IPhysicsInputSnapshot): void;
160
+ }
161
+ interface INativePhysicsHost {
162
+ readonly version: string;
163
+ createSimulation(options?: unknown): INativeSimulation;
164
+ }
165
+ /**
166
+ * The MetaHuman facial rig resident, installed by
167
+ * `packages/runtime-native/src/metahuman/native_bindings.cpp` when the runtime is built with
168
+ * `TN_ENABLE_METAHUMAN=ON`. Declared here because this file owns the global; the interface
169
+ * itself, and the accessor that fails closed with `TN_NATIVE_METAHUMAN_MISSING`, live in
170
+ * `@threenative/metahuman` (`src/native/host.ts`), which must not declare the global twice.
171
+ */
172
+ interface INativeMetaHumanResident {
173
+ readonly version: string;
174
+ create(dna: ArrayBuffer | Uint8Array): number;
175
+ count(id: number, kind: number): number;
176
+ name(id: number, kind: number, index: number): string;
177
+ setLod(id: number, lod: number): void;
178
+ setGui(id: number, values: Float32Array): void;
179
+ setRaw(id: number, values: Float32Array): void;
180
+ evaluate(id: number, useGui: boolean): void;
181
+ jointOutputs(id: number): Float32Array;
182
+ blendShapeOutputs(id: number): Float32Array;
183
+ animatedMapOutputs(id: number): Float32Array;
184
+ neutralJoints(id: number): Float32Array;
185
+ destroy(id: number): void;
186
+ lastError(): string;
187
+ }
188
+ declare global {
189
+ var __THREENATIVE_NATIVE__: {
190
+ readonly physics?: INativePhysicsHost;
191
+ readonly metahuman?: INativeMetaHumanResident;
192
+ readonly playtest?: {
193
+ receive?(path: string): string | undefined;
194
+ respond?(path: string, payload: string): boolean;
195
+ };
196
+ } | undefined;
197
+ }
198
+
199
+ export { IPhysicsInputSnapshot, IPhysicsJointCreateOptions, IPhysicsSimulation, IPhysicsVector3, IPhysicsVehicleInput };
@@ -907,28 +907,30 @@ function createNativePhysicsSimulation(raw, version) {
907
907
  }
908
908
 
909
909
  // src/native.ts
910
- var simulations = /* @__PURE__ */ new WeakMap();
911
- function wrapNativeSimulation(raw, version) {
912
- const simulation = createNativePhysicsSimulation(raw, version);
913
- simulations.set(raw, simulation);
914
- return simulation;
910
+ function createNativePhysicsBackend(hostOf, initialize = async () => void 0) {
911
+ const simulations = /* @__PURE__ */ new WeakMap();
912
+ const wrap = (raw, version) => {
913
+ const simulation = createNativePhysicsSimulation(raw, version);
914
+ simulations.set(raw, simulation);
915
+ return simulation;
916
+ };
917
+ return {
918
+ initialize,
919
+ createSimulation: (options = {}) => {
920
+ const host = hostOf();
921
+ return wrap(nativeSimulation(host.createSimulation(options)), host.version);
922
+ },
923
+ createShape: (shape) => Object.freeze({ backend: "native", kind: shape.kind }),
924
+ simulationForWorld: (world) => {
925
+ if (typeof world !== "object" || world === null)
926
+ throw new Error("TN_NATIVE_PHYSICS_INVALID: native world must be an object");
927
+ const existing = simulations.get(world);
928
+ if (existing !== void 0) return existing;
929
+ return wrap(nativeSimulation(world), hostOf().version);
930
+ }
931
+ };
915
932
  }
916
- installPhysicsSimulationBackend({
917
- initialize: async () => void 0,
918
- createSimulation: (options = {}) => {
919
- const host = nativePhysicsHost();
920
- return wrapNativeSimulation(nativeSimulation(host.createSimulation(options)), host.version);
921
- },
922
- createShape: (shape) => Object.freeze({ backend: "native", kind: shape.kind }),
923
- simulationForWorld: (world) => {
924
- if (typeof world !== "object" || world === null)
925
- throw new Error("TN_NATIVE_PHYSICS_INVALID: native world must be an object");
926
- const existing = simulations.get(world);
927
- if (existing !== void 0) return existing;
928
- const host = nativePhysicsHost();
929
- return wrapNativeSimulation(nativeSimulation(world), host.version);
930
- }
931
- });
933
+ installPhysicsSimulationBackend(createNativePhysicsBackend(nativePhysicsHost));
932
934
 
933
935
  // src/transformRecord.ts
934
936
  function bulkTransformValue(values, index) {
@@ -1,4 +1,4 @@
1
1
  import '@threenative/core';
2
2
  import 'recast-navigation';
3
- export { a7 as INavigationAgent3DOptions, a8 as INavigationContext, a9 as INavigationObstacle3DOptions, aa as INavigationRegion3DOptions, ab as NavigationAgent3D, ac as NavigationAgentEvent, ad as NavigationAgentHandler, ae as NavigationObstacle3D, af as NavigationPlugin, ag as NavigationRegion3D, ah as recast } from '../Area3D-BI0ynKEY.js';
3
+ export { a7 as INavigationAgent3DOptions, a8 as INavigationContext, a9 as INavigationObstacle3DOptions, aa as INavigationRegion3DOptions, ab as NavigationAgent3D, ac as NavigationAgentEvent, ad as NavigationAgentHandler, ae as NavigationObstacle3D, af as NavigationPlugin, ag as NavigationRegion3D, ah as recast } from '../Area3D-BqLJBY6B.js';
4
4
  import 'three';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threenative/physics",
3
- "version": "0.3.15",
3
+ "version": "0.3.16",
4
4
  "license": "MIT",
5
5
  "description": "Thin Rapier physics bindings for ThreeNative games.",
6
6
  "keywords": [
@@ -24,6 +24,7 @@
24
24
  "type": "module",
25
25
  "files": [
26
26
  "dist",
27
+ "wasm",
27
28
  "README.md"
28
29
  ],
29
30
  "main": "./dist/index.js",
@@ -55,7 +56,7 @@
55
56
  "recast-navigation": "0.43.1"
56
57
  },
57
58
  "peerDependencies": {
58
- "@threenative/core": ">=0.3.15 <0.4.0",
59
+ "@threenative/core": ">=0.3.16 <0.4.0",
59
60
  "three": ">=0.187.0 <0.188.0"
60
61
  },
61
62
  "devDependencies": {
@@ -65,7 +66,7 @@
65
66
  "tsup": "8.5.1",
66
67
  "typescript": "npm:@typescript/typescript6@6.0.2",
67
68
  "@typescript/native": "npm:typescript@7.0.2",
68
- "@threenative/core": "0.3.15"
69
+ "@threenative/core": "0.3.16"
69
70
  },
70
71
  "scripts": {
71
72
  "build": "tsup --config tsup.config.ts && publint",
@@ -0,0 +1,6 @@
1
+ {
2
+ "rustc": "rustc 1.96.0 (ac68faa20 2026-05-25)",
3
+ "files": {
4
+ "threenative_native_physics.wasm": "917c1c510b43f102576acd477062e7863688c3c8200978372bf9b359a15284b2"
5
+ }
6
+ }