@threenative/physics 0.3.13 → 0.3.15
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.
|
@@ -301,6 +301,11 @@ interface IPhysicsSimulation {
|
|
|
301
301
|
*/
|
|
302
302
|
createVehicle?(options: IPhysicsVehicleCreateOptions): number;
|
|
303
303
|
setVehicleInput?(id: number, input: IPhysicsVehicleInput): void;
|
|
304
|
+
/**
|
|
305
|
+
* Godot's `VehicleWheel3D.wheel_friction_slip` for one wheel, at runtime: the grip cap that a
|
|
306
|
+
* handbrake drops on the rear pair. Cold path, called on a change of grip, not per frame.
|
|
307
|
+
*/
|
|
308
|
+
setVehicleWheelFriction?(id: number, wheel: number, frictionSlip: number): void;
|
|
304
309
|
readVehicleState?(id: number): IPhysicsVehicleState | undefined;
|
|
305
310
|
/** Cold-path respawn: move the chassis, drop both velocities, and face the given yaw in radians. */
|
|
306
311
|
resetVehicle?(id: number, position: IPhysicsVector3, yaw: number): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as IPhysicsContext, a as IPhysicsWorldHandle, b as IPhysicsBodyHandle, c as IPhysicsVector3, d as IPhysicsRotation, e as IPhysicsJointLimit, R as RigidBody3D, f as IPhysicsColliderHandle, P as PhysicsBody3D, C as CollisionShape3D, g as IPhysicsVehicleWheelOptions } from './Area3D-
|
|
2
|
-
export { A as Area3D, B as Buoyancy3D, h as BuoyancyPointPosition, i as CharacterBody3D, j as IBuoyancy3DOptions, k as IBuoyancyHullPoint, l as IBuoyancySurface, m as IBuoyancySurfaceSample, n as ICollisionShapeHandle, o as IIntersectPointOptions, p as IIntersectRayOptions, q as IIntersectShapeOptions, r as IPhysicsBodyCreateOptions, s as IPhysicsCharacterOptions, t as IPhysicsHandle, u as IPhysicsInputSnapshot, v as IPhysicsJointCreateOptions, w as IPhysicsPointQuery, x as IPhysicsQueryHit, y as IPhysicsRayHit, z as IPhysicsRayQuery, D as IPhysicsRuntimeSimulation, E as IPhysicsShapeDescriptor, F as IPhysicsShapeQuery, G as IPhysicsSimulation, H as IPhysicsVehicleCreateOptions, J as IPhysicsVehicleInput, K as IPhysicsVehicleState, 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, V as PhysicsDirectSpaceState3D, W as PhysicsJointKind, X as PhysicsQueryVector3, Y as PhysicsShapeKind, Z as RigidBodyType, _ as rapier } from './Area3D-
|
|
1
|
+
import { I as IPhysicsContext, a as IPhysicsWorldHandle, b as IPhysicsBodyHandle, c as IPhysicsVector3, d as IPhysicsRotation, e as IPhysicsJointLimit, R as RigidBody3D, f as IPhysicsColliderHandle, P as PhysicsBody3D, C as CollisionShape3D, g as IPhysicsVehicleWheelOptions } from './Area3D-BI0ynKEY.js';
|
|
2
|
+
export { A as Area3D, B as Buoyancy3D, h as BuoyancyPointPosition, i as CharacterBody3D, j as IBuoyancy3DOptions, k as IBuoyancyHullPoint, l as IBuoyancySurface, m as IBuoyancySurfaceSample, n as ICollisionShapeHandle, o as IIntersectPointOptions, p as IIntersectRayOptions, q as IIntersectShapeOptions, r as IPhysicsBodyCreateOptions, s as IPhysicsCharacterOptions, t as IPhysicsHandle, u as IPhysicsInputSnapshot, v as IPhysicsJointCreateOptions, w as IPhysicsPointQuery, x as IPhysicsQueryHit, y as IPhysicsRayHit, z as IPhysicsRayQuery, D as IPhysicsRuntimeSimulation, E as IPhysicsShapeDescriptor, F as IPhysicsShapeQuery, G as IPhysicsSimulation, H as IPhysicsVehicleCreateOptions, J as IPhysicsVehicleInput, K as IPhysicsVehicleState, 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, V as PhysicsDirectSpaceState3D, W as PhysicsJointKind, X as PhysicsQueryVector3, Y as PhysicsShapeKind, Z as RigidBodyType, _ as rapier } from './Area3D-BI0ynKEY.js';
|
|
3
3
|
import { Object3D, BufferGeometry, Matrix4 } from 'three';
|
|
4
4
|
import { ISoftBodyCollision } from '@threenative/core';
|
|
5
5
|
import { ISnowFootprint, SnowField } from '@threenative/core/world';
|
|
@@ -309,6 +309,14 @@ declare class VehicleBody3D extends RigidBody3D {
|
|
|
309
309
|
* the last completed step, so read it after the physics update.
|
|
310
310
|
*/
|
|
311
311
|
get speed(): number;
|
|
312
|
+
/**
|
|
313
|
+
* Godot's `VehicleWheel3D.wheel_friction_slip`, changed while the car drives: the cap on the
|
|
314
|
+
* tyre's combined grip impulse, as a multiple of the load on it. Dropping the rear pair is a
|
|
315
|
+
* handbrake slide; restoring it is the catch. Cold path: call it when the grip changes.
|
|
316
|
+
*/
|
|
317
|
+
setWheelFrictionSlip(index: number, frictionSlip: number): void;
|
|
318
|
+
/** The wheel's current grip cap: its construction value until `setWheelFrictionSlip` moves it. */
|
|
319
|
+
wheelFrictionSlip(index: number): number;
|
|
312
320
|
/** Whether this wheel's suspension ray found ground on the last completed step. */
|
|
313
321
|
wheelContact(index: number): boolean;
|
|
314
322
|
/** How far the wheel hangs below its attachment point, in metres. Below the rest length while loaded. */
|
package/dist/index.js
CHANGED
|
@@ -1066,6 +1066,12 @@ function createWebPhysicsSimulation(options) {
|
|
|
1066
1066
|
for (let wheel = 0; wheel < controller.numWheels(); wheel += 1)
|
|
1067
1067
|
controller.setWheelBrake(wheel, input.brake);
|
|
1068
1068
|
},
|
|
1069
|
+
setVehicleWheelFriction: (id, wheel, frictionSlip) => {
|
|
1070
|
+
requireLive();
|
|
1071
|
+
const { controller } = requireVehicle(id, "setVehicleWheelFriction");
|
|
1072
|
+
requireWheelFriction(wheel, frictionSlip, controller.numWheels());
|
|
1073
|
+
controller.setWheelFrictionSlip(wheel, frictionSlip);
|
|
1074
|
+
},
|
|
1069
1075
|
readVehicleState: (id) => {
|
|
1070
1076
|
requireLive();
|
|
1071
1077
|
const record = requireVehicle(id, "readVehicleState");
|
|
@@ -1157,6 +1163,14 @@ function requirePhysicsSimulation(physics, world) {
|
|
|
1157
1163
|
"Physics nodes require an IPhysicsContext. Passing a raw backend world is deprecated and backend-specific."
|
|
1158
1164
|
);
|
|
1159
1165
|
}
|
|
1166
|
+
function requireWheelFriction(wheel, frictionSlip, wheels) {
|
|
1167
|
+
if (!Number.isSafeInteger(wheel) || wheel < 0 || wheel >= wheels)
|
|
1168
|
+
throw new Error(
|
|
1169
|
+
`TN_VEHICLE_INVALID: wheel index ${String(wheel)} is outside 0 through ${wheels - 1}.`
|
|
1170
|
+
);
|
|
1171
|
+
if (typeof frictionSlip !== "number" || !Number.isFinite(frictionSlip) || frictionSlip < 0)
|
|
1172
|
+
throw new Error("TN_PHYSICS_NON_FINITE: wheel friction slip must be a finite number >= 0.");
|
|
1173
|
+
}
|
|
1160
1174
|
|
|
1161
1175
|
// src/web.ts
|
|
1162
1176
|
var loaded;
|
|
@@ -3609,6 +3623,7 @@ var VehicleBody3D = class extends RigidBody3D {
|
|
|
3609
3623
|
#brake = 0;
|
|
3610
3624
|
#steering = 0;
|
|
3611
3625
|
#disposed = false;
|
|
3626
|
+
#friction;
|
|
3612
3627
|
constructor(options) {
|
|
3613
3628
|
const forward = FORWARD_AXES[options.forwardAxis ?? "-z"];
|
|
3614
3629
|
if (forward === void 0)
|
|
@@ -3635,6 +3650,7 @@ var VehicleBody3D = class extends RigidBody3D {
|
|
|
3635
3650
|
world: options.world
|
|
3636
3651
|
});
|
|
3637
3652
|
this.wheels = options.wheels;
|
|
3653
|
+
this.#friction = options.wheels.map((wheel) => wheel.wheelFrictionSlip);
|
|
3638
3654
|
this.#object = options.object;
|
|
3639
3655
|
this.#simulation = simulation;
|
|
3640
3656
|
this.#readState = readVehicleState;
|
|
@@ -3694,6 +3710,26 @@ var VehicleBody3D = class extends RigidBody3D {
|
|
|
3694
3710
|
get speed() {
|
|
3695
3711
|
return this.#state().speed;
|
|
3696
3712
|
}
|
|
3713
|
+
/**
|
|
3714
|
+
* Godot's `VehicleWheel3D.wheel_friction_slip`, changed while the car drives: the cap on the
|
|
3715
|
+
* tyre's combined grip impulse, as a multiple of the load on it. Dropping the rear pair is a
|
|
3716
|
+
* handbrake slide; restoring it is the catch. Cold path: call it when the grip changes.
|
|
3717
|
+
*/
|
|
3718
|
+
setWheelFrictionSlip(index, frictionSlip) {
|
|
3719
|
+
this.#requireLive("setWheelFrictionSlip");
|
|
3720
|
+
const set = this.#simulation.setVehicleWheelFriction;
|
|
3721
|
+
if (set === void 0)
|
|
3722
|
+
throw new Error(
|
|
3723
|
+
"TN_VEHICLE_NATIVE_UNAVAILABLE: the active physics backend cannot change wheel grip."
|
|
3724
|
+
);
|
|
3725
|
+
set.call(this.#simulation, this.#vehicle, index, frictionSlip);
|
|
3726
|
+
this.#friction[index] = frictionSlip;
|
|
3727
|
+
}
|
|
3728
|
+
/** The wheel's current grip cap: its construction value until `setWheelFrictionSlip` moves it. */
|
|
3729
|
+
wheelFrictionSlip(index) {
|
|
3730
|
+
this.#wheel(index, 0);
|
|
3731
|
+
return this.#friction[index];
|
|
3732
|
+
}
|
|
3697
3733
|
/** Whether this wheel's suspension ray found ground on the last completed step. */
|
|
3698
3734
|
wheelContact(index) {
|
|
3699
3735
|
return this.#wheel(index, 0) === 1;
|
package/dist/native/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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';
|
|
2
2
|
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
3
|
import 'three';
|
|
4
4
|
import '@threenative/core';
|
package/dist/native/index.js
CHANGED
|
@@ -285,6 +285,14 @@ function requirePhysicsSimulation(physics, world) {
|
|
|
285
285
|
"Physics nodes require an IPhysicsContext. Passing a raw backend world is deprecated and backend-specific."
|
|
286
286
|
);
|
|
287
287
|
}
|
|
288
|
+
function requireWheelFriction(wheel, frictionSlip, wheels) {
|
|
289
|
+
if (!Number.isSafeInteger(wheel) || wheel < 0 || wheel >= wheels)
|
|
290
|
+
throw new Error(
|
|
291
|
+
`TN_VEHICLE_INVALID: wheel index ${String(wheel)} is outside 0 through ${wheels - 1}.`
|
|
292
|
+
);
|
|
293
|
+
if (typeof frictionSlip !== "number" || !Number.isFinite(frictionSlip) || frictionSlip < 0)
|
|
294
|
+
throw new Error("TN_PHYSICS_NON_FINITE: wheel friction slip must be a finite number >= 0.");
|
|
295
|
+
}
|
|
288
296
|
|
|
289
297
|
// src/native/host.ts
|
|
290
298
|
function nativePhysicsHost() {
|
|
@@ -838,6 +846,18 @@ function createNativePhysicsSimulation(raw, version) {
|
|
|
838
846
|
requireVehicle(id, "setVehicleInput");
|
|
839
847
|
raw.setVehicleInput(id, input);
|
|
840
848
|
},
|
|
849
|
+
setVehicleWheelFriction: (id, wheel, frictionSlip) => {
|
|
850
|
+
requireLive();
|
|
851
|
+
if (raw.setVehicleWheelFriction === void 0)
|
|
852
|
+
throw new Error("TN_NATIVE_PHYSICS_VEHICLE_MISSING: runtime ABI is too old");
|
|
853
|
+
const record = requireVehicle(id, "setVehicleWheelFriction");
|
|
854
|
+
requireWheelFriction(
|
|
855
|
+
wheel,
|
|
856
|
+
frictionSlip,
|
|
857
|
+
(record.buffer.length - 1) / PHYSICS_VEHICLE_WHEEL_STRIDE
|
|
858
|
+
);
|
|
859
|
+
raw.setVehicleWheelFriction(id, wheel, frictionSlip);
|
|
860
|
+
},
|
|
841
861
|
readVehicleState: (id) => {
|
|
842
862
|
requireLive();
|
|
843
863
|
if (raw.readVehicleState === void 0)
|
|
@@ -2901,6 +2921,7 @@ var VehicleBody3D = class extends RigidBody3D {
|
|
|
2901
2921
|
#brake = 0;
|
|
2902
2922
|
#steering = 0;
|
|
2903
2923
|
#disposed = false;
|
|
2924
|
+
#friction;
|
|
2904
2925
|
constructor(options) {
|
|
2905
2926
|
const forward = FORWARD_AXES[options.forwardAxis ?? "-z"];
|
|
2906
2927
|
if (forward === void 0)
|
|
@@ -2927,6 +2948,7 @@ var VehicleBody3D = class extends RigidBody3D {
|
|
|
2927
2948
|
world: options.world
|
|
2928
2949
|
});
|
|
2929
2950
|
this.wheels = options.wheels;
|
|
2951
|
+
this.#friction = options.wheels.map((wheel) => wheel.wheelFrictionSlip);
|
|
2930
2952
|
this.#object = options.object;
|
|
2931
2953
|
this.#simulation = simulation;
|
|
2932
2954
|
this.#readState = readVehicleState;
|
|
@@ -2986,6 +3008,26 @@ var VehicleBody3D = class extends RigidBody3D {
|
|
|
2986
3008
|
get speed() {
|
|
2987
3009
|
return this.#state().speed;
|
|
2988
3010
|
}
|
|
3011
|
+
/**
|
|
3012
|
+
* Godot's `VehicleWheel3D.wheel_friction_slip`, changed while the car drives: the cap on the
|
|
3013
|
+
* tyre's combined grip impulse, as a multiple of the load on it. Dropping the rear pair is a
|
|
3014
|
+
* handbrake slide; restoring it is the catch. Cold path: call it when the grip changes.
|
|
3015
|
+
*/
|
|
3016
|
+
setWheelFrictionSlip(index, frictionSlip) {
|
|
3017
|
+
this.#requireLive("setWheelFrictionSlip");
|
|
3018
|
+
const set = this.#simulation.setVehicleWheelFriction;
|
|
3019
|
+
if (set === void 0)
|
|
3020
|
+
throw new Error(
|
|
3021
|
+
"TN_VEHICLE_NATIVE_UNAVAILABLE: the active physics backend cannot change wheel grip."
|
|
3022
|
+
);
|
|
3023
|
+
set.call(this.#simulation, this.#vehicle, index, frictionSlip);
|
|
3024
|
+
this.#friction[index] = frictionSlip;
|
|
3025
|
+
}
|
|
3026
|
+
/** The wheel's current grip cap: its construction value until `setWheelFrictionSlip` moves it. */
|
|
3027
|
+
wheelFrictionSlip(index) {
|
|
3028
|
+
this.#wheel(index, 0);
|
|
3029
|
+
return this.#friction[index];
|
|
3030
|
+
}
|
|
2989
3031
|
/** Whether this wheel's suspension ray found ground on the last completed step. */
|
|
2990
3032
|
wheelContact(index) {
|
|
2991
3033
|
return this.#wheel(index, 0) === 1;
|
|
@@ -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-
|
|
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';
|
|
4
4
|
import 'three';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@threenative/physics",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.15",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Thin Rapier physics bindings for ThreeNative games.",
|
|
6
6
|
"keywords": [
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"recast-navigation": "0.43.1"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@threenative/core": ">=0.3.
|
|
58
|
+
"@threenative/core": ">=0.3.15 <0.4.0",
|
|
59
59
|
"three": ">=0.187.0 <0.188.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"tsup": "8.5.1",
|
|
66
66
|
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
67
67
|
"@typescript/native": "npm:typescript@7.0.2",
|
|
68
|
-
"@threenative/core": "0.3.
|
|
68
|
+
"@threenative/core": "0.3.15"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"build": "tsup --config tsup.config.ts && publint",
|