@newkrok/nape-js 3.5.1 → 3.5.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/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/llms-full.txt +1620 -0
- package/llms.txt +103 -0
- package/package.json +6 -2
package/llms.txt
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# @newkrok/nape-js
|
|
2
|
+
|
|
3
|
+
> Modern TypeScript 2D physics engine for the web. Fully typed, tree-shakeable, with object pooling and dual ESM/CJS exports. Originally ported from the Haxe Nape engine by Luca Deltodesco.
|
|
4
|
+
|
|
5
|
+
Install: `npm install @newkrok/nape-js`
|
|
6
|
+
|
|
7
|
+
- [GitHub Repository](https://github.com/NewKrok/nape-js): Source code, issues, contributing guide
|
|
8
|
+
- [npm Package](https://www.npmjs.com/package/@newkrok/nape-js): Published package with TypeScript declarations
|
|
9
|
+
- [API Reference](https://newkrok.github.io/nape-js/api/index.html): Full TypeDoc-generated API docs
|
|
10
|
+
- [Interactive Demos](https://newkrok.github.io/nape-js/examples.html): Live physics demos with source code
|
|
11
|
+
- [Full LLM Documentation](https://raw.githubusercontent.com/NewKrok/nape-js/master/llms-full.txt): Complete API reference in a single file
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { Space, Body, BodyType, Vec2, Circle, Polygon } from "@newkrok/nape-js";
|
|
17
|
+
|
|
18
|
+
const space = new Space(new Vec2(0, 600));
|
|
19
|
+
|
|
20
|
+
const floor = new Body(BodyType.STATIC, new Vec2(400, 550));
|
|
21
|
+
floor.shapes.add(new Polygon(Polygon.box(800, 20)));
|
|
22
|
+
floor.space = space;
|
|
23
|
+
|
|
24
|
+
const ball = new Body(BodyType.DYNAMIC, new Vec2(400, 100));
|
|
25
|
+
ball.shapes.add(new Circle(20));
|
|
26
|
+
ball.space = space;
|
|
27
|
+
|
|
28
|
+
function update() {
|
|
29
|
+
space.step(1 / 60);
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Core Classes
|
|
34
|
+
|
|
35
|
+
- [Space](https://newkrok.github.io/nape-js/api/classes/Space.html): Physics world — create with gravity, add bodies, call `step(dt)` to simulate
|
|
36
|
+
- [Body](https://newkrok.github.io/nape-js/api/classes/Body.html): Rigid body with position, velocity, rotation, mass, shapes list
|
|
37
|
+
- [Vec2](https://newkrok.github.io/nape-js/api/classes/Vec2.html): 2D vector with pooling (`Vec2.get()`, `Vec2.weak()`) and arithmetic methods
|
|
38
|
+
- [AABB](https://newkrok.github.io/nape-js/api/classes/AABB.html): Axis-aligned bounding box for spatial queries
|
|
39
|
+
|
|
40
|
+
## Shapes
|
|
41
|
+
|
|
42
|
+
- [Circle](https://newkrok.github.io/nape-js/api/classes/Circle.html): Circular collision shape with radius
|
|
43
|
+
- [Polygon](https://newkrok.github.io/nape-js/api/classes/Polygon.html): Convex polygon with factories: `Polygon.box()`, `Polygon.rect()`, `Polygon.regular()`
|
|
44
|
+
- [Shape](https://newkrok.github.io/nape-js/api/classes/Shape.html): Base class — material, filter, sensor support, cbTypes
|
|
45
|
+
- [Edge](https://newkrok.github.io/nape-js/api/classes/Edge.html): Read-only polygon edge with normal and projection data
|
|
46
|
+
|
|
47
|
+
## Physics Properties
|
|
48
|
+
|
|
49
|
+
- [Material](https://newkrok.github.io/nape-js/api/classes/Material.html): Elasticity, friction, density — presets: `wood()`, `steel()`, `ice()`, `rubber()`, `glass()`, `sand()`
|
|
50
|
+
- [FluidProperties](https://newkrok.github.io/nape-js/api/classes/FluidProperties.html): Density, viscosity for fluid interaction shapes
|
|
51
|
+
- [InteractionFilter](https://newkrok.github.io/nape-js/api/classes/InteractionFilter.html): Bit-mask collision/sensor/fluid filtering
|
|
52
|
+
- [InteractionGroup](https://newkrok.github.io/nape-js/api/classes/InteractionGroup.html): Group-based interaction management
|
|
53
|
+
|
|
54
|
+
## Constraints (Joints)
|
|
55
|
+
|
|
56
|
+
- [PivotJoint](https://newkrok.github.io/nape-js/api/classes/PivotJoint.html): Pin two bodies at a shared anchor point
|
|
57
|
+
- [DistanceJoint](https://newkrok.github.io/nape-js/api/classes/DistanceJoint.html): Constrain distance between two anchors to [min, max]
|
|
58
|
+
- [WeldJoint](https://newkrok.github.io/nape-js/api/classes/WeldJoint.html): Fix relative position and rotation angle
|
|
59
|
+
- [AngleJoint](https://newkrok.github.io/nape-js/api/classes/AngleJoint.html): Constrain relative angle to [min, max] with optional ratio
|
|
60
|
+
- [MotorJoint](https://newkrok.github.io/nape-js/api/classes/MotorJoint.html): Drive relative angular velocity to a target rate
|
|
61
|
+
- [LineJoint](https://newkrok.github.io/nape-js/api/classes/LineJoint.html): Constrain anchor to slide along a line direction
|
|
62
|
+
- [PulleyJoint](https://newkrok.github.io/nape-js/api/classes/PulleyJoint.html): Constrain weighted sum of two distances (pulley/rope)
|
|
63
|
+
- [Constraint](https://newkrok.github.io/nape-js/api/classes/Constraint.html): Base class — stiff/soft, frequency, damping, breaking, maxForce
|
|
64
|
+
|
|
65
|
+
## Callbacks & Events
|
|
66
|
+
|
|
67
|
+
- [InteractionListener](https://newkrok.github.io/nape-js/api/classes/InteractionListener.html): Listen for BEGIN/ONGOING/END collision, sensor, or fluid events
|
|
68
|
+
- [BodyListener](https://newkrok.github.io/nape-js/api/classes/BodyListener.html): Listen for WAKE/SLEEP body state changes
|
|
69
|
+
- [ConstraintListener](https://newkrok.github.io/nape-js/api/classes/ConstraintListener.html): Listen for BREAK constraint events
|
|
70
|
+
- [PreListener](https://newkrok.github.io/nape-js/api/classes/PreListener.html): Pre-collision handler — filter or modify collisions before solving
|
|
71
|
+
- [CbType](https://newkrok.github.io/nape-js/api/classes/CbType.html): Tag bodies/shapes/constraints for selective callback filtering
|
|
72
|
+
- [CbEvent](https://newkrok.github.io/nape-js/api/classes/CbEvent.html): Event types — BEGIN, ONGOING, END, WAKE, SLEEP, BREAK, PRE
|
|
73
|
+
|
|
74
|
+
## Collision & Dynamics
|
|
75
|
+
|
|
76
|
+
- [Arbiter](https://newkrok.github.io/nape-js/api/classes/Arbiter.html): Interaction data between two shapes (base class)
|
|
77
|
+
- [CollisionArbiter](https://newkrok.github.io/nape-js/api/classes/CollisionArbiter.html): Collision contacts, normal, impulses, kinetic energy
|
|
78
|
+
- [FluidArbiter](https://newkrok.github.io/nape-js/api/classes/FluidArbiter.html): Fluid overlap, buoyancy/drag impulses
|
|
79
|
+
- [Contact](https://newkrok.github.io/nape-js/api/classes/Contact.html): Single contact point — position, penetration, friction
|
|
80
|
+
|
|
81
|
+
## Geometry Utilities
|
|
82
|
+
|
|
83
|
+
- [Ray](https://newkrok.github.io/nape-js/api/classes/Ray.html): Ray for raycasting queries with origin, direction, maxDistance
|
|
84
|
+
- [Mat23](https://newkrok.github.io/nape-js/api/classes/Mat23.html): 2x3 affine transform matrix — rotation, translation, scale
|
|
85
|
+
- [Geom](https://newkrok.github.io/nape-js/api/classes/Geom.html): Static utilities — distance queries, ray tests, polygon operations
|
|
86
|
+
- [MarchingSquares](https://newkrok.github.io/nape-js/api/classes/MarchingSquares.html): Contour extraction from scalar fields
|
|
87
|
+
|
|
88
|
+
## Enums
|
|
89
|
+
|
|
90
|
+
- [BodyType](https://newkrok.github.io/nape-js/api/classes/BodyType.html): STATIC, DYNAMIC, KINEMATIC
|
|
91
|
+
- [ShapeType](https://newkrok.github.io/nape-js/api/classes/ShapeType.html): CIRCLE, POLYGON
|
|
92
|
+
- [Broadphase](https://newkrok.github.io/nape-js/api/classes/Broadphase.html): SWEEP_AND_PRUNE, DYNAMIC_AABB_TREE
|
|
93
|
+
- [InteractionType](https://newkrok.github.io/nape-js/api/classes/InteractionType.html): COLLISION, SENSOR, FLUID, ANY
|
|
94
|
+
- [ArbiterType](https://newkrok.github.io/nape-js/api/classes/ArbiterType.html): COLLISION, SENSOR, FLUID
|
|
95
|
+
|
|
96
|
+
## Grouping & Hierarchy
|
|
97
|
+
|
|
98
|
+
- [Compound](https://newkrok.github.io/nape-js/api/classes/Compound.html): Hierarchical grouping of bodies, constraints, and sub-compounds
|
|
99
|
+
- [Interactor](https://newkrok.github.io/nape-js/api/classes/Interactor.html): Base class for Body, Shape, Compound — type casting, cbTypes
|
|
100
|
+
|
|
101
|
+
## Collections
|
|
102
|
+
|
|
103
|
+
- [NapeList](https://newkrok.github.io/nape-js/api/classes/NapeList.html): Generic iterable list with `for...of` support, add/remove/push/pop
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newkrok/nape-js",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.2",
|
|
4
4
|
"description": "Nape Physics Engine - Modern TypeScript wrapper for 2D physics simulation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -36,9 +36,13 @@
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
|
+
"llms": "https://newkrok.github.io/nape-js/llms.txt",
|
|
40
|
+
"llmsFull": "https://newkrok.github.io/nape-js/llms-full.txt",
|
|
39
41
|
"files": [
|
|
40
42
|
"dist",
|
|
41
|
-
"!dist/**/*.map"
|
|
43
|
+
"!dist/**/*.map",
|
|
44
|
+
"llms.txt",
|
|
45
|
+
"llms-full.txt"
|
|
42
46
|
],
|
|
43
47
|
"scripts": {
|
|
44
48
|
"build": "tsup",
|