@newkrok/nape-js 3.23.0 → 3.24.1
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/{chunk-BGYJWPQX.cjs → chunk-OFVSWS4I.cjs} +2 -2
- package/dist/{chunk-XFL4PQ5L.js → chunk-ZNBQE3PX.js} +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +65 -1
- package/dist/index.d.ts +65 -1
- package/dist/index.js +1 -1
- package/dist/serialization/index.cjs +1 -1
- package/dist/serialization/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1169,6 +1169,70 @@ declare class PulleyJoint extends Constraint {
|
|
|
1169
1169
|
visitBodies(lambda: (body: Body) => void): void;
|
|
1170
1170
|
}
|
|
1171
1171
|
|
|
1172
|
+
/**
|
|
1173
|
+
* A spring/damper constraint between two anchor points on two bodies.
|
|
1174
|
+
*
|
|
1175
|
+
* Applies a spring force that pulls or pushes the anchors toward a target
|
|
1176
|
+
* `restLength`. The spring behavior is controlled by `frequency` (Hz) and
|
|
1177
|
+
* `damping` (ratio), inherited from {@link Constraint}.
|
|
1178
|
+
*
|
|
1179
|
+
* Unlike {@link DistanceJoint}, a SpringJoint:
|
|
1180
|
+
* - Is **always soft** — there is no rigid/stiff mode.
|
|
1181
|
+
* - Has a single `restLength` instead of a `[jointMin, jointMax]` range.
|
|
1182
|
+
* - Applies force in **both directions** (compression and extension).
|
|
1183
|
+
* - Never goes slack — the spring always exerts a restorative force.
|
|
1184
|
+
*
|
|
1185
|
+
* Ideal for: vehicle suspension, soft-body connections, ragdoll hair/cloth,
|
|
1186
|
+
* bouncy UI animations, bridge/rope segments, trampolines.
|
|
1187
|
+
*
|
|
1188
|
+
* @example
|
|
1189
|
+
* ```ts
|
|
1190
|
+
* const spring = new SpringJoint(
|
|
1191
|
+
* body1, body2,
|
|
1192
|
+
* Vec2.weak(0, 0), // anchor on body1 (local)
|
|
1193
|
+
* Vec2.weak(0, 0), // anchor on body2 (local)
|
|
1194
|
+
* 100, // rest length (pixels)
|
|
1195
|
+
* );
|
|
1196
|
+
* spring.frequency = 5; // 5 Hz oscillation
|
|
1197
|
+
* spring.damping = 0.5; // underdamped (bouncy)
|
|
1198
|
+
* spring.space = space;
|
|
1199
|
+
* ```
|
|
1200
|
+
*/
|
|
1201
|
+
declare class SpringJoint extends Constraint {
|
|
1202
|
+
/**
|
|
1203
|
+
* @param body1 - First body, or `null` for a static world anchor.
|
|
1204
|
+
* @param body2 - Second body, or `null` for a static world anchor.
|
|
1205
|
+
* @param anchor1 - Anchor point in `body1`'s local space (disposed if weak).
|
|
1206
|
+
* @param anchor2 - Anchor point in `body2`'s local space (disposed if weak).
|
|
1207
|
+
* @param restLength - Equilibrium distance between anchors (must be `>= 0`).
|
|
1208
|
+
*/
|
|
1209
|
+
constructor(body1: Body | null, body2: Body | null, anchor1: Vec2, anchor2: Vec2, restLength: number);
|
|
1210
|
+
/** First body. `null` treats the anchor as a static world point. */
|
|
1211
|
+
get body1(): Body;
|
|
1212
|
+
set body1(value: Body | null);
|
|
1213
|
+
/** Second body. `null` treats the anchor as a static world point. */
|
|
1214
|
+
get body2(): Body;
|
|
1215
|
+
set body2(value: Body | null);
|
|
1216
|
+
/** Anchor point on `body1` in local coordinates. */
|
|
1217
|
+
get anchor1(): Vec2;
|
|
1218
|
+
set anchor1(value: Vec2);
|
|
1219
|
+
/** Anchor point on `body2` in local coordinates. */
|
|
1220
|
+
get anchor2(): Vec2;
|
|
1221
|
+
set anchor2(value: Vec2);
|
|
1222
|
+
/** Equilibrium distance between anchors (pixels, must be `>= 0`). */
|
|
1223
|
+
get restLength(): number;
|
|
1224
|
+
set restLength(value: number);
|
|
1225
|
+
/**
|
|
1226
|
+
* SpringJoint is always soft — setting `stiff` to `true` is not allowed.
|
|
1227
|
+
* Use {@link DistanceJoint} if you need a rigid distance constraint.
|
|
1228
|
+
*/
|
|
1229
|
+
get stiff(): boolean;
|
|
1230
|
+
set stiff(_value: boolean);
|
|
1231
|
+
impulse(): MatMN;
|
|
1232
|
+
bodyImpulse(body: Body): Vec3;
|
|
1233
|
+
visitBodies(lambda: (body: Body) => void): void;
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1172
1236
|
/**
|
|
1173
1237
|
* ZPP_Constraint — Internal base class for all constraints / joints.
|
|
1174
1238
|
*
|
|
@@ -1798,4 +1862,4 @@ declare function fractureBody(body: Body, impactPoint: Vec2, options?: FractureO
|
|
|
1798
1862
|
|
|
1799
1863
|
declare const VERSION: string;
|
|
1800
1864
|
|
|
1801
|
-
export { AABB, AngleJoint, Arbiter, Body, BodyCallback, BodyListener, BodyType, Callback, Capsule, CbEvent, CbType, CharacterController, type CharacterControllerOptions, Circle, CollisionArbiter, type ConcaveBodyOptions, Constraint, ConstraintCallback, ConstraintListener, Contact, DebugDrawFlags, DistanceJoint, type FractureOptions, type FractureResult, Geom, GeomPoly, InteractionCallback, InteractionFilter, InteractionListener, InteractionType, Interactor, LineJoint, Listener, MarchingSquares, MatMN, Material, MotorJoint, type MoveResult, OptionType, PivotJoint, PreCallback, PreFlag, PreListener, PulleyJoint, Shape, ShapeType, Space, type TriggerHandler, TriggerZone, type TriggerZoneOptions, UserConstraint, VERSION, ValidationResult, Vec2, Vec3, type VoronoiCell, type VoronoiPoint, type VoronoiResult, WeldJoint, Winding, computeVoronoi, createConcaveBody, fractureBody, generateFractureSites };
|
|
1865
|
+
export { AABB, AngleJoint, Arbiter, Body, BodyCallback, BodyListener, BodyType, Callback, Capsule, CbEvent, CbType, CharacterController, type CharacterControllerOptions, Circle, CollisionArbiter, type ConcaveBodyOptions, Constraint, ConstraintCallback, ConstraintListener, Contact, DebugDrawFlags, DistanceJoint, type FractureOptions, type FractureResult, Geom, GeomPoly, InteractionCallback, InteractionFilter, InteractionListener, InteractionType, Interactor, LineJoint, Listener, MarchingSquares, MatMN, Material, MotorJoint, type MoveResult, OptionType, PivotJoint, PreCallback, PreFlag, PreListener, PulleyJoint, Shape, ShapeType, Space, SpringJoint, type TriggerHandler, TriggerZone, type TriggerZoneOptions, UserConstraint, VERSION, ValidationResult, Vec2, Vec3, type VoronoiCell, type VoronoiPoint, type VoronoiResult, WeldJoint, Winding, computeVoronoi, createConcaveBody, fractureBody, generateFractureSites };
|
package/dist/index.d.ts
CHANGED
|
@@ -1169,6 +1169,70 @@ declare class PulleyJoint extends Constraint {
|
|
|
1169
1169
|
visitBodies(lambda: (body: Body) => void): void;
|
|
1170
1170
|
}
|
|
1171
1171
|
|
|
1172
|
+
/**
|
|
1173
|
+
* A spring/damper constraint between two anchor points on two bodies.
|
|
1174
|
+
*
|
|
1175
|
+
* Applies a spring force that pulls or pushes the anchors toward a target
|
|
1176
|
+
* `restLength`. The spring behavior is controlled by `frequency` (Hz) and
|
|
1177
|
+
* `damping` (ratio), inherited from {@link Constraint}.
|
|
1178
|
+
*
|
|
1179
|
+
* Unlike {@link DistanceJoint}, a SpringJoint:
|
|
1180
|
+
* - Is **always soft** — there is no rigid/stiff mode.
|
|
1181
|
+
* - Has a single `restLength` instead of a `[jointMin, jointMax]` range.
|
|
1182
|
+
* - Applies force in **both directions** (compression and extension).
|
|
1183
|
+
* - Never goes slack — the spring always exerts a restorative force.
|
|
1184
|
+
*
|
|
1185
|
+
* Ideal for: vehicle suspension, soft-body connections, ragdoll hair/cloth,
|
|
1186
|
+
* bouncy UI animations, bridge/rope segments, trampolines.
|
|
1187
|
+
*
|
|
1188
|
+
* @example
|
|
1189
|
+
* ```ts
|
|
1190
|
+
* const spring = new SpringJoint(
|
|
1191
|
+
* body1, body2,
|
|
1192
|
+
* Vec2.weak(0, 0), // anchor on body1 (local)
|
|
1193
|
+
* Vec2.weak(0, 0), // anchor on body2 (local)
|
|
1194
|
+
* 100, // rest length (pixels)
|
|
1195
|
+
* );
|
|
1196
|
+
* spring.frequency = 5; // 5 Hz oscillation
|
|
1197
|
+
* spring.damping = 0.5; // underdamped (bouncy)
|
|
1198
|
+
* spring.space = space;
|
|
1199
|
+
* ```
|
|
1200
|
+
*/
|
|
1201
|
+
declare class SpringJoint extends Constraint {
|
|
1202
|
+
/**
|
|
1203
|
+
* @param body1 - First body, or `null` for a static world anchor.
|
|
1204
|
+
* @param body2 - Second body, or `null` for a static world anchor.
|
|
1205
|
+
* @param anchor1 - Anchor point in `body1`'s local space (disposed if weak).
|
|
1206
|
+
* @param anchor2 - Anchor point in `body2`'s local space (disposed if weak).
|
|
1207
|
+
* @param restLength - Equilibrium distance between anchors (must be `>= 0`).
|
|
1208
|
+
*/
|
|
1209
|
+
constructor(body1: Body | null, body2: Body | null, anchor1: Vec2, anchor2: Vec2, restLength: number);
|
|
1210
|
+
/** First body. `null` treats the anchor as a static world point. */
|
|
1211
|
+
get body1(): Body;
|
|
1212
|
+
set body1(value: Body | null);
|
|
1213
|
+
/** Second body. `null` treats the anchor as a static world point. */
|
|
1214
|
+
get body2(): Body;
|
|
1215
|
+
set body2(value: Body | null);
|
|
1216
|
+
/** Anchor point on `body1` in local coordinates. */
|
|
1217
|
+
get anchor1(): Vec2;
|
|
1218
|
+
set anchor1(value: Vec2);
|
|
1219
|
+
/** Anchor point on `body2` in local coordinates. */
|
|
1220
|
+
get anchor2(): Vec2;
|
|
1221
|
+
set anchor2(value: Vec2);
|
|
1222
|
+
/** Equilibrium distance between anchors (pixels, must be `>= 0`). */
|
|
1223
|
+
get restLength(): number;
|
|
1224
|
+
set restLength(value: number);
|
|
1225
|
+
/**
|
|
1226
|
+
* SpringJoint is always soft — setting `stiff` to `true` is not allowed.
|
|
1227
|
+
* Use {@link DistanceJoint} if you need a rigid distance constraint.
|
|
1228
|
+
*/
|
|
1229
|
+
get stiff(): boolean;
|
|
1230
|
+
set stiff(_value: boolean);
|
|
1231
|
+
impulse(): MatMN;
|
|
1232
|
+
bodyImpulse(body: Body): Vec3;
|
|
1233
|
+
visitBodies(lambda: (body: Body) => void): void;
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1172
1236
|
/**
|
|
1173
1237
|
* ZPP_Constraint — Internal base class for all constraints / joints.
|
|
1174
1238
|
*
|
|
@@ -1798,4 +1862,4 @@ declare function fractureBody(body: Body, impactPoint: Vec2, options?: FractureO
|
|
|
1798
1862
|
|
|
1799
1863
|
declare const VERSION: string;
|
|
1800
1864
|
|
|
1801
|
-
export { AABB, AngleJoint, Arbiter, Body, BodyCallback, BodyListener, BodyType, Callback, Capsule, CbEvent, CbType, CharacterController, type CharacterControllerOptions, Circle, CollisionArbiter, type ConcaveBodyOptions, Constraint, ConstraintCallback, ConstraintListener, Contact, DebugDrawFlags, DistanceJoint, type FractureOptions, type FractureResult, Geom, GeomPoly, InteractionCallback, InteractionFilter, InteractionListener, InteractionType, Interactor, LineJoint, Listener, MarchingSquares, MatMN, Material, MotorJoint, type MoveResult, OptionType, PivotJoint, PreCallback, PreFlag, PreListener, PulleyJoint, Shape, ShapeType, Space, type TriggerHandler, TriggerZone, type TriggerZoneOptions, UserConstraint, VERSION, ValidationResult, Vec2, Vec3, type VoronoiCell, type VoronoiPoint, type VoronoiResult, WeldJoint, Winding, computeVoronoi, createConcaveBody, fractureBody, generateFractureSites };
|
|
1865
|
+
export { AABB, AngleJoint, Arbiter, Body, BodyCallback, BodyListener, BodyType, Callback, Capsule, CbEvent, CbType, CharacterController, type CharacterControllerOptions, Circle, CollisionArbiter, type ConcaveBodyOptions, Constraint, ConstraintCallback, ConstraintListener, Contact, DebugDrawFlags, DistanceJoint, type FractureOptions, type FractureResult, Geom, GeomPoly, InteractionCallback, InteractionFilter, InteractionListener, InteractionType, Interactor, LineJoint, Listener, MarchingSquares, MatMN, Material, MotorJoint, type MoveResult, OptionType, PivotJoint, PreCallback, PreFlag, PreListener, PulleyJoint, Shape, ShapeType, Space, SpringJoint, type TriggerHandler, TriggerZone, type TriggerZoneOptions, UserConstraint, VERSION, ValidationResult, Vec2, Vec3, type VoronoiCell, type VoronoiPoint, type VoronoiResult, WeldJoint, Winding, computeVoronoi, createConcaveBody, fractureBody, generateFractureSites };
|