@newkrok/nape-js 2.1.0 → 3.1.0
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 +7 -1
- package/dist/index.cjs +317 -418
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +153 -189
- package/dist/index.d.ts +153 -189
- package/dist/index.js +317 -418
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -128746,18 +128746,30 @@ function getNape() {
|
|
|
128746
128746
|
return nape_compiled_default;
|
|
128747
128747
|
}
|
|
128748
128748
|
|
|
128749
|
+
// src/core/cache.ts
|
|
128750
|
+
var cache = /* @__PURE__ */ new WeakMap();
|
|
128751
|
+
function getOrCreate(inner, create) {
|
|
128752
|
+
if (!inner) return null;
|
|
128753
|
+
let wrapper = cache.get(inner);
|
|
128754
|
+
if (!wrapper) {
|
|
128755
|
+
wrapper = create(inner);
|
|
128756
|
+
cache.set(inner, wrapper);
|
|
128757
|
+
}
|
|
128758
|
+
return wrapper;
|
|
128759
|
+
}
|
|
128760
|
+
|
|
128749
128761
|
// src/geom/Vec2.ts
|
|
128750
128762
|
var Vec2 = class _Vec2 {
|
|
128751
128763
|
constructor(x = 0, y = 0) {
|
|
128752
|
-
|
|
128753
|
-
this._inner = new nape.geom.Vec2(x, y);
|
|
128764
|
+
this._inner = new (getNape()).geom.Vec2(x, y);
|
|
128754
128765
|
}
|
|
128755
|
-
/** @internal Wrap an existing Haxe Vec2
|
|
128766
|
+
/** @internal Wrap an existing Haxe Vec2 with caching. */
|
|
128756
128767
|
static _wrap(inner) {
|
|
128757
|
-
|
|
128758
|
-
|
|
128759
|
-
|
|
128760
|
-
|
|
128768
|
+
return getOrCreate(inner, (raw) => {
|
|
128769
|
+
const v = Object.create(_Vec2.prototype);
|
|
128770
|
+
v._inner = raw;
|
|
128771
|
+
return v;
|
|
128772
|
+
});
|
|
128761
128773
|
}
|
|
128762
128774
|
// ---------------------------------------------------------------------------
|
|
128763
128775
|
// Properties
|
|
@@ -128896,19 +128908,16 @@ var Vec2 = class _Vec2 {
|
|
|
128896
128908
|
// src/geom/AABB.ts
|
|
128897
128909
|
var AABB = class _AABB {
|
|
128898
128910
|
constructor(x, y, width, height) {
|
|
128899
|
-
|
|
128900
|
-
this._inner = new nape.geom.AABB(x, y, width, height);
|
|
128911
|
+
this._inner = new (getNape()).geom.AABB(x, y, width, height);
|
|
128901
128912
|
}
|
|
128902
128913
|
/** @internal */
|
|
128903
128914
|
static _wrap(inner) {
|
|
128904
|
-
|
|
128905
|
-
|
|
128906
|
-
|
|
128907
|
-
|
|
128915
|
+
return getOrCreate(inner, (raw) => {
|
|
128916
|
+
const a = Object.create(_AABB.prototype);
|
|
128917
|
+
a._inner = raw;
|
|
128918
|
+
return a;
|
|
128919
|
+
});
|
|
128908
128920
|
}
|
|
128909
|
-
// ---------------------------------------------------------------------------
|
|
128910
|
-
// Properties
|
|
128911
|
-
// ---------------------------------------------------------------------------
|
|
128912
128921
|
get min() {
|
|
128913
128922
|
return Vec2._wrap(this._inner.get_min());
|
|
128914
128923
|
}
|
|
@@ -128945,9 +128954,6 @@ var AABB = class _AABB {
|
|
|
128945
128954
|
set height(value) {
|
|
128946
128955
|
this._inner.set_height(value);
|
|
128947
128956
|
}
|
|
128948
|
-
// ---------------------------------------------------------------------------
|
|
128949
|
-
// Methods
|
|
128950
|
-
// ---------------------------------------------------------------------------
|
|
128951
128957
|
copy() {
|
|
128952
128958
|
return _AABB._wrap(this._inner.copy());
|
|
128953
128959
|
}
|
|
@@ -128956,18 +128962,6 @@ var AABB = class _AABB {
|
|
|
128956
128962
|
}
|
|
128957
128963
|
};
|
|
128958
128964
|
|
|
128959
|
-
// src/core/registry.ts
|
|
128960
|
-
var registry = /* @__PURE__ */ new Map();
|
|
128961
|
-
function registerWrapper(name, wrapFn) {
|
|
128962
|
-
registry.set(name, wrapFn);
|
|
128963
|
-
}
|
|
128964
|
-
function wrapWith(name, inner) {
|
|
128965
|
-
if (!inner) return null;
|
|
128966
|
-
const fn = registry.get(name);
|
|
128967
|
-
if (!fn) throw new Error(`Wrapper not registered: ${name}`);
|
|
128968
|
-
return fn(inner);
|
|
128969
|
-
}
|
|
128970
|
-
|
|
128971
128965
|
// src/util/NapeList.ts
|
|
128972
128966
|
var NapeList = class {
|
|
128973
128967
|
/** @internal */
|
|
@@ -129043,8 +129037,7 @@ var NapeList = class {
|
|
|
129043
129037
|
// src/phys/Material.ts
|
|
129044
129038
|
var Material = class _Material {
|
|
129045
129039
|
constructor(elasticity = 0, dynamicFriction = 1, staticFriction = 2, density = 1, rollingFriction = 1e-3) {
|
|
129046
|
-
|
|
129047
|
-
this._inner = new nape.phys.Material(
|
|
129040
|
+
this._inner = new (getNape()).phys.Material(
|
|
129048
129041
|
elasticity,
|
|
129049
129042
|
dynamicFriction,
|
|
129050
129043
|
staticFriction,
|
|
@@ -129054,10 +129047,11 @@ var Material = class _Material {
|
|
|
129054
129047
|
}
|
|
129055
129048
|
/** @internal */
|
|
129056
129049
|
static _wrap(inner) {
|
|
129057
|
-
|
|
129058
|
-
|
|
129059
|
-
|
|
129060
|
-
|
|
129050
|
+
return getOrCreate(inner, (raw) => {
|
|
129051
|
+
const m = Object.create(_Material.prototype);
|
|
129052
|
+
m._inner = raw;
|
|
129053
|
+
return m;
|
|
129054
|
+
});
|
|
129061
129055
|
}
|
|
129062
129056
|
get elasticity() {
|
|
129063
129057
|
return this._inner.get_elasticity();
|
|
@@ -129103,15 +129097,15 @@ var Material = class _Material {
|
|
|
129103
129097
|
// src/phys/FluidProperties.ts
|
|
129104
129098
|
var FluidProperties = class _FluidProperties {
|
|
129105
129099
|
constructor(density = 1, viscosity = 1) {
|
|
129106
|
-
|
|
129107
|
-
this._inner = new nape.phys.FluidProperties(density, viscosity);
|
|
129100
|
+
this._inner = new (getNape()).phys.FluidProperties(density, viscosity);
|
|
129108
129101
|
}
|
|
129109
129102
|
/** @internal */
|
|
129110
129103
|
static _wrap(inner) {
|
|
129111
|
-
|
|
129112
|
-
|
|
129113
|
-
|
|
129114
|
-
|
|
129104
|
+
return getOrCreate(inner, (raw) => {
|
|
129105
|
+
const f = Object.create(_FluidProperties.prototype);
|
|
129106
|
+
f._inner = raw;
|
|
129107
|
+
return f;
|
|
129108
|
+
});
|
|
129115
129109
|
}
|
|
129116
129110
|
get density() {
|
|
129117
129111
|
return this._inner.get_density();
|
|
@@ -129145,8 +129139,7 @@ var FluidProperties = class _FluidProperties {
|
|
|
129145
129139
|
// src/dynamics/InteractionFilter.ts
|
|
129146
129140
|
var InteractionFilter = class _InteractionFilter {
|
|
129147
129141
|
constructor(collisionGroup = 1, collisionMask = -1, sensorGroup = 1, sensorMask = -1, fluidGroup = 1, fluidMask = -1) {
|
|
129148
|
-
|
|
129149
|
-
this._inner = new nape.dynamics.InteractionFilter(
|
|
129142
|
+
this._inner = new (getNape()).dynamics.InteractionFilter(
|
|
129150
129143
|
collisionGroup,
|
|
129151
129144
|
collisionMask,
|
|
129152
129145
|
sensorGroup,
|
|
@@ -129157,10 +129150,11 @@ var InteractionFilter = class _InteractionFilter {
|
|
|
129157
129150
|
}
|
|
129158
129151
|
/** @internal */
|
|
129159
129152
|
static _wrap(inner) {
|
|
129160
|
-
|
|
129161
|
-
|
|
129162
|
-
|
|
129163
|
-
|
|
129153
|
+
return getOrCreate(inner, (raw) => {
|
|
129154
|
+
const f = Object.create(_InteractionFilter.prototype);
|
|
129155
|
+
f._inner = raw;
|
|
129156
|
+
return f;
|
|
129157
|
+
});
|
|
129164
129158
|
}
|
|
129165
129159
|
get collisionGroup() {
|
|
129166
129160
|
return this._inner.get_collisionGroup();
|
|
@@ -129201,15 +129195,12 @@ var InteractionFilter = class _InteractionFilter {
|
|
|
129201
129195
|
get userData() {
|
|
129202
129196
|
return this._inner.get_userData();
|
|
129203
129197
|
}
|
|
129204
|
-
/** Check if two filters should produce a collision interaction. */
|
|
129205
129198
|
shouldCollide(other) {
|
|
129206
129199
|
return this._inner.shouldCollide(other._inner);
|
|
129207
129200
|
}
|
|
129208
|
-
/** Check if two filters should produce a sensor interaction. */
|
|
129209
129201
|
shouldSense(other) {
|
|
129210
129202
|
return this._inner.shouldSense(other._inner);
|
|
129211
129203
|
}
|
|
129212
|
-
/** Check if two filters should produce a fluid interaction. */
|
|
129213
129204
|
shouldFlow(other) {
|
|
129214
129205
|
return this._inner.shouldFlow(other._inner);
|
|
129215
129206
|
}
|
|
@@ -129235,24 +129226,29 @@ function fromNativeShapeType(native) {
|
|
|
129235
129226
|
}
|
|
129236
129227
|
|
|
129237
129228
|
// src/shape/Shape.ts
|
|
129238
|
-
var
|
|
129239
|
-
var
|
|
129240
|
-
function
|
|
129241
|
-
|
|
129229
|
+
var _circleWrap;
|
|
129230
|
+
var _polygonWrap;
|
|
129231
|
+
function _bindCircleWrap(fn) {
|
|
129232
|
+
_circleWrap = fn;
|
|
129242
129233
|
}
|
|
129243
|
-
function
|
|
129244
|
-
|
|
129234
|
+
function _bindPolygonWrap(fn) {
|
|
129235
|
+
_polygonWrap = fn;
|
|
129245
129236
|
}
|
|
129246
129237
|
var Shape = class _Shape {
|
|
129247
129238
|
/** @internal – shapes are created via Circle or Polygon constructors. */
|
|
129248
129239
|
constructor() {
|
|
129240
|
+
this._inner = void 0;
|
|
129249
129241
|
}
|
|
129250
129242
|
/** @internal */
|
|
129251
129243
|
static _wrap(inner) {
|
|
129252
129244
|
if (!inner) return null;
|
|
129253
|
-
|
|
129254
|
-
|
|
129255
|
-
return
|
|
129245
|
+
if (inner.isCircle() && _circleWrap) return _circleWrap(inner);
|
|
129246
|
+
if (inner.isPolygon() && _polygonWrap) return _polygonWrap(inner);
|
|
129247
|
+
return getOrCreate(inner, (raw) => {
|
|
129248
|
+
const s = Object.create(_Shape.prototype);
|
|
129249
|
+
s._inner = raw;
|
|
129250
|
+
return s;
|
|
129251
|
+
});
|
|
129256
129252
|
}
|
|
129257
129253
|
// ---------------------------------------------------------------------------
|
|
129258
129254
|
// Properties
|
|
@@ -129260,9 +129256,8 @@ var Shape = class _Shape {
|
|
|
129260
129256
|
get type() {
|
|
129261
129257
|
return fromNativeShapeType(this._inner.get_type());
|
|
129262
129258
|
}
|
|
129263
|
-
/** The body this shape is attached to (null if none). */
|
|
129264
129259
|
get body() {
|
|
129265
|
-
return
|
|
129260
|
+
return Body._wrap(this._inner.get_body());
|
|
129266
129261
|
}
|
|
129267
129262
|
set body(value) {
|
|
129268
129263
|
this._inner.set_body(value?._inner ?? null);
|
|
@@ -129309,13 +129304,13 @@ var Shape = class _Shape {
|
|
|
129309
129304
|
return {
|
|
129310
129305
|
_inner: raw,
|
|
129311
129306
|
add(cbType) {
|
|
129312
|
-
raw.add(cbType._inner
|
|
129307
|
+
raw.add(cbType._inner);
|
|
129313
129308
|
},
|
|
129314
129309
|
remove(cbType) {
|
|
129315
|
-
raw.remove(cbType._inner
|
|
129310
|
+
raw.remove(cbType._inner);
|
|
129316
129311
|
},
|
|
129317
129312
|
has(cbType) {
|
|
129318
|
-
return raw.has(cbType._inner
|
|
129313
|
+
return raw.has(cbType._inner);
|
|
129319
129314
|
},
|
|
129320
129315
|
clear() {
|
|
129321
129316
|
raw.clear();
|
|
@@ -129343,14 +129338,14 @@ var Shape = class _Shape {
|
|
|
129343
129338
|
/** Cast to Circle — returns the Circle wrapper or null if not a circle. */
|
|
129344
129339
|
get castCircle() {
|
|
129345
129340
|
const raw = this._inner.get_castCircle();
|
|
129346
|
-
if (!raw || !
|
|
129347
|
-
return
|
|
129341
|
+
if (!raw || !_circleWrap) return null;
|
|
129342
|
+
return _circleWrap(raw);
|
|
129348
129343
|
}
|
|
129349
129344
|
/** Cast to Polygon — returns the Polygon wrapper or null if not a polygon. */
|
|
129350
129345
|
get castPolygon() {
|
|
129351
129346
|
const raw = this._inner.get_castPolygon();
|
|
129352
|
-
if (!raw || !
|
|
129353
|
-
return
|
|
129347
|
+
if (!raw || !_polygonWrap) return null;
|
|
129348
|
+
return _polygonWrap(raw);
|
|
129354
129349
|
}
|
|
129355
129350
|
// ---------------------------------------------------------------------------
|
|
129356
129351
|
// Methods
|
|
@@ -129371,7 +129366,7 @@ var Shape = class _Shape {
|
|
|
129371
129366
|
this._inner.rotate(angle);
|
|
129372
129367
|
}
|
|
129373
129368
|
transform(matrix) {
|
|
129374
|
-
this._inner.transform(matrix
|
|
129369
|
+
this._inner.transform(matrix._inner);
|
|
129375
129370
|
}
|
|
129376
129371
|
contains(point) {
|
|
129377
129372
|
return this._inner.contains(point._inner);
|
|
@@ -129384,6 +129379,130 @@ var Shape = class _Shape {
|
|
|
129384
129379
|
}
|
|
129385
129380
|
};
|
|
129386
129381
|
|
|
129382
|
+
// src/space/Space.ts
|
|
129383
|
+
var Space = class _Space {
|
|
129384
|
+
constructor(gravity) {
|
|
129385
|
+
this._inner = new (getNape()).space.Space(gravity?._inner);
|
|
129386
|
+
}
|
|
129387
|
+
/** @internal */
|
|
129388
|
+
static _wrap(inner) {
|
|
129389
|
+
return getOrCreate(inner, (raw) => {
|
|
129390
|
+
const s = Object.create(_Space.prototype);
|
|
129391
|
+
s._inner = raw;
|
|
129392
|
+
return s;
|
|
129393
|
+
});
|
|
129394
|
+
}
|
|
129395
|
+
// ---------------------------------------------------------------------------
|
|
129396
|
+
// Properties
|
|
129397
|
+
// ---------------------------------------------------------------------------
|
|
129398
|
+
get gravity() {
|
|
129399
|
+
return Vec2._wrap(this._inner.get_gravity());
|
|
129400
|
+
}
|
|
129401
|
+
set gravity(value) {
|
|
129402
|
+
this._inner.set_gravity(value._inner);
|
|
129403
|
+
}
|
|
129404
|
+
get worldLinearDrag() {
|
|
129405
|
+
return this._inner.get_worldLinearDrag();
|
|
129406
|
+
}
|
|
129407
|
+
set worldLinearDrag(value) {
|
|
129408
|
+
this._inner.set_worldLinearDrag(value);
|
|
129409
|
+
}
|
|
129410
|
+
get worldAngularDrag() {
|
|
129411
|
+
return this._inner.get_worldAngularDrag();
|
|
129412
|
+
}
|
|
129413
|
+
set worldAngularDrag(value) {
|
|
129414
|
+
this._inner.set_worldAngularDrag(value);
|
|
129415
|
+
}
|
|
129416
|
+
get sortContacts() {
|
|
129417
|
+
return this._inner.get_sortContacts();
|
|
129418
|
+
}
|
|
129419
|
+
set sortContacts(value) {
|
|
129420
|
+
this._inner.set_sortContacts(value);
|
|
129421
|
+
}
|
|
129422
|
+
get bodies() {
|
|
129423
|
+
return new NapeList(this._inner.get_bodies(), Body._wrap);
|
|
129424
|
+
}
|
|
129425
|
+
get liveBodies() {
|
|
129426
|
+
return new NapeList(this._inner.get_liveBodies(), Body._wrap);
|
|
129427
|
+
}
|
|
129428
|
+
get constraints() {
|
|
129429
|
+
return this._inner.get_constraints();
|
|
129430
|
+
}
|
|
129431
|
+
get liveConstraints() {
|
|
129432
|
+
return this._inner.get_liveConstraints();
|
|
129433
|
+
}
|
|
129434
|
+
get arbiters() {
|
|
129435
|
+
return this._inner.get_arbiters();
|
|
129436
|
+
}
|
|
129437
|
+
get listeners() {
|
|
129438
|
+
return this._inner.get_listeners();
|
|
129439
|
+
}
|
|
129440
|
+
get compounds() {
|
|
129441
|
+
return this._inner.get_compounds();
|
|
129442
|
+
}
|
|
129443
|
+
/** The static world body (always present, immovable). */
|
|
129444
|
+
get world() {
|
|
129445
|
+
return Body._wrap(this._inner.get_world());
|
|
129446
|
+
}
|
|
129447
|
+
get timeStamp() {
|
|
129448
|
+
return this._inner.get_timeStamp();
|
|
129449
|
+
}
|
|
129450
|
+
get elapsedTime() {
|
|
129451
|
+
return this._inner.get_elapsedTime();
|
|
129452
|
+
}
|
|
129453
|
+
get broadphase() {
|
|
129454
|
+
return this._inner.get_broadphase();
|
|
129455
|
+
}
|
|
129456
|
+
get userData() {
|
|
129457
|
+
return this._inner.get_userData();
|
|
129458
|
+
}
|
|
129459
|
+
// ---------------------------------------------------------------------------
|
|
129460
|
+
// Simulation
|
|
129461
|
+
// ---------------------------------------------------------------------------
|
|
129462
|
+
step(deltaTime, velocityIterations = 10, positionIterations = 10) {
|
|
129463
|
+
this._inner.step(deltaTime, velocityIterations, positionIterations);
|
|
129464
|
+
}
|
|
129465
|
+
clear() {
|
|
129466
|
+
this._inner.clear();
|
|
129467
|
+
}
|
|
129468
|
+
// ---------------------------------------------------------------------------
|
|
129469
|
+
// Visitors
|
|
129470
|
+
// ---------------------------------------------------------------------------
|
|
129471
|
+
visitBodies(fn) {
|
|
129472
|
+
this._inner.visitBodies((raw) => fn(Body._wrap(raw)));
|
|
129473
|
+
}
|
|
129474
|
+
visitConstraints(fn) {
|
|
129475
|
+
this._inner.visitConstraints(fn);
|
|
129476
|
+
}
|
|
129477
|
+
visitCompounds(fn) {
|
|
129478
|
+
this._inner.visitCompounds(fn);
|
|
129479
|
+
}
|
|
129480
|
+
// ---------------------------------------------------------------------------
|
|
129481
|
+
// Queries
|
|
129482
|
+
// ---------------------------------------------------------------------------
|
|
129483
|
+
shapesUnderPoint(point, filter, output) {
|
|
129484
|
+
return this._inner.shapesUnderPoint(point._inner, filter?._inner ?? filter, output);
|
|
129485
|
+
}
|
|
129486
|
+
bodiesUnderPoint(point, filter, output) {
|
|
129487
|
+
return this._inner.bodiesUnderPoint(point._inner, filter?._inner ?? filter, output);
|
|
129488
|
+
}
|
|
129489
|
+
shapesInAABB(aabb, containment, strict, filter, output) {
|
|
129490
|
+
return this._inner.shapesInAABB(aabb._inner, containment, strict, filter?._inner ?? filter, output);
|
|
129491
|
+
}
|
|
129492
|
+
bodiesInAABB(aabb, containment, strict, filter, output) {
|
|
129493
|
+
return this._inner.bodiesInAABB(aabb._inner, containment, strict, filter?._inner ?? filter, output);
|
|
129494
|
+
}
|
|
129495
|
+
rayCast(ray, inner, filter) {
|
|
129496
|
+
return this._inner.rayCast(ray?._inner ?? ray, inner, filter?._inner ?? filter);
|
|
129497
|
+
}
|
|
129498
|
+
rayMultiCast(ray, inner, filter, output) {
|
|
129499
|
+
return this._inner.rayMultiCast(ray?._inner ?? ray, inner, filter?._inner ?? filter, output);
|
|
129500
|
+
}
|
|
129501
|
+
toString() {
|
|
129502
|
+
return `Space(bodies=${this.bodies.length})`;
|
|
129503
|
+
}
|
|
129504
|
+
};
|
|
129505
|
+
|
|
129387
129506
|
// src/phys/BodyType.ts
|
|
129388
129507
|
var BodyType = /* @__PURE__ */ ((BodyType2) => {
|
|
129389
129508
|
BodyType2["STATIC"] = "STATIC";
|
|
@@ -129413,18 +129532,18 @@ function fromNativeBodyType(native) {
|
|
|
129413
129532
|
// src/phys/Body.ts
|
|
129414
129533
|
var Body = class _Body {
|
|
129415
129534
|
constructor(type = "DYNAMIC" /* DYNAMIC */, position) {
|
|
129416
|
-
|
|
129417
|
-
this._inner = new nape.phys.Body(
|
|
129535
|
+
this._inner = new (getNape()).phys.Body(
|
|
129418
129536
|
toNativeBodyType(type),
|
|
129419
129537
|
position?._inner
|
|
129420
129538
|
);
|
|
129421
129539
|
}
|
|
129422
129540
|
/** @internal */
|
|
129423
129541
|
static _wrap(inner) {
|
|
129424
|
-
|
|
129425
|
-
|
|
129426
|
-
|
|
129427
|
-
|
|
129542
|
+
return getOrCreate(inner, (raw) => {
|
|
129543
|
+
const b = Object.create(_Body.prototype);
|
|
129544
|
+
b._inner = raw;
|
|
129545
|
+
return b;
|
|
129546
|
+
});
|
|
129428
129547
|
}
|
|
129429
129548
|
// ---------------------------------------------------------------------------
|
|
129430
129549
|
// Type
|
|
@@ -129577,7 +129696,7 @@ var Body = class _Body {
|
|
|
129577
129696
|
return new NapeList(this._inner.get_shapes(), Shape._wrap);
|
|
129578
129697
|
}
|
|
129579
129698
|
get space() {
|
|
129580
|
-
return
|
|
129699
|
+
return Space._wrap(this._inner.get_space());
|
|
129581
129700
|
}
|
|
129582
129701
|
set space(value) {
|
|
129583
129702
|
this._inner.set_space(value?._inner ?? null);
|
|
@@ -129606,79 +129725,57 @@ var Body = class _Body {
|
|
|
129606
129725
|
// ---------------------------------------------------------------------------
|
|
129607
129726
|
// Methods
|
|
129608
129727
|
// ---------------------------------------------------------------------------
|
|
129609
|
-
/** Integrate the body forward by deltaTime seconds. */
|
|
129610
129728
|
integrate(deltaTime) {
|
|
129611
129729
|
this._inner.integrate(deltaTime);
|
|
129612
129730
|
}
|
|
129613
|
-
/** Apply a linear impulse at an optional world-space point. */
|
|
129614
129731
|
applyImpulse(impulse, pos, sleepable) {
|
|
129615
129732
|
this._inner.applyImpulse(impulse._inner, pos?._inner, sleepable);
|
|
129616
129733
|
}
|
|
129617
|
-
/** Apply an angular impulse (torque × dt). */
|
|
129618
129734
|
applyAngularImpulse(impulse, sleepable) {
|
|
129619
129735
|
this._inner.applyAngularImpulse(impulse, sleepable);
|
|
129620
129736
|
}
|
|
129621
|
-
/** Set velocity so the body reaches the target position/rotation in deltaTime. */
|
|
129622
129737
|
setVelocityFromTarget(targetPosition, targetRotation, deltaTime) {
|
|
129623
|
-
this._inner.setVelocityFromTarget(
|
|
129624
|
-
targetPosition._inner,
|
|
129625
|
-
targetRotation,
|
|
129626
|
-
deltaTime
|
|
129627
|
-
);
|
|
129738
|
+
this._inner.setVelocityFromTarget(targetPosition._inner, targetRotation, deltaTime);
|
|
129628
129739
|
}
|
|
129629
|
-
/** Transform a point from local to world coordinates. */
|
|
129630
129740
|
localPointToWorld(point, weak = false) {
|
|
129631
129741
|
return Vec2._wrap(this._inner.localPointToWorld(point._inner, weak));
|
|
129632
129742
|
}
|
|
129633
|
-
/** Transform a point from world to local coordinates. */
|
|
129634
129743
|
worldPointToLocal(point, weak = false) {
|
|
129635
129744
|
return Vec2._wrap(this._inner.worldPointToLocal(point._inner, weak));
|
|
129636
129745
|
}
|
|
129637
|
-
/** Transform a direction vector from local to world coordinates. */
|
|
129638
129746
|
localVectorToWorld(vector, weak = false) {
|
|
129639
129747
|
return Vec2._wrap(this._inner.localVectorToWorld(vector._inner, weak));
|
|
129640
129748
|
}
|
|
129641
|
-
/** Transform a direction vector from world to local coordinates. */
|
|
129642
129749
|
worldVectorToLocal(vector, weak = false) {
|
|
129643
129750
|
return Vec2._wrap(this._inner.worldVectorToLocal(vector._inner, weak));
|
|
129644
129751
|
}
|
|
129645
|
-
/** Translate all shapes on this body by the given offset. */
|
|
129646
129752
|
translateShapes(translation) {
|
|
129647
129753
|
this._inner.translateShapes(translation._inner);
|
|
129648
129754
|
}
|
|
129649
|
-
/** Rotate all shapes on this body by the given angle. */
|
|
129650
129755
|
rotateShapes(angle) {
|
|
129651
129756
|
this._inner.rotateShapes(angle);
|
|
129652
129757
|
}
|
|
129653
|
-
/** Scale all shapes on this body. */
|
|
129654
129758
|
scaleShapes(scaleX, scaleY) {
|
|
129655
129759
|
this._inner.scaleShapes(scaleX, scaleY);
|
|
129656
129760
|
}
|
|
129657
|
-
/** Align the body so that its center of mass is at its position. */
|
|
129658
129761
|
align() {
|
|
129659
129762
|
this._inner.align();
|
|
129660
129763
|
}
|
|
129661
|
-
/** Rotate the body about a world-space centre point. */
|
|
129662
129764
|
rotate(centre, angle) {
|
|
129663
129765
|
this._inner.rotate(centre._inner, angle);
|
|
129664
129766
|
}
|
|
129665
|
-
/** Set the material for all shapes on this body. */
|
|
129666
129767
|
setShapeMaterials(material) {
|
|
129667
129768
|
this._inner.setShapeMaterials(material._inner);
|
|
129668
129769
|
}
|
|
129669
|
-
/** Set the interaction filter for all shapes on this body. */
|
|
129670
129770
|
setShapeFilters(filter) {
|
|
129671
129771
|
this._inner.setShapeFilters(filter._inner);
|
|
129672
129772
|
}
|
|
129673
|
-
/** Set the fluid properties for all shapes on this body. */
|
|
129674
129773
|
setShapeFluidProperties(fluidProperties) {
|
|
129675
129774
|
this._inner.setShapeFluidProperties(fluidProperties._inner);
|
|
129676
129775
|
}
|
|
129677
|
-
/** Check if a world-space point is inside this body. */
|
|
129678
129776
|
contains(point) {
|
|
129679
129777
|
return this._inner.contains(point._inner);
|
|
129680
129778
|
}
|
|
129681
|
-
/** Crush factor for resolving inter-penetration. */
|
|
129682
129779
|
crushFactor() {
|
|
129683
129780
|
return this._inner.crushFactor();
|
|
129684
129781
|
}
|
|
@@ -129689,14 +129786,12 @@ var Body = class _Body {
|
|
|
129689
129786
|
return this._inner.toString();
|
|
129690
129787
|
}
|
|
129691
129788
|
};
|
|
129692
|
-
registerWrapper("Body", Body._wrap);
|
|
129693
129789
|
|
|
129694
129790
|
// src/shape/Circle.ts
|
|
129695
129791
|
var Circle = class _Circle extends Shape {
|
|
129696
129792
|
constructor(radius = 50, localCOM, material, filter) {
|
|
129697
129793
|
super();
|
|
129698
|
-
|
|
129699
|
-
this._inner = new nape.shape.Circle(
|
|
129794
|
+
this._inner = new (getNape()).shape.Circle(
|
|
129700
129795
|
radius,
|
|
129701
129796
|
localCOM?._inner,
|
|
129702
129797
|
material?._inner,
|
|
@@ -129705,10 +129800,11 @@ var Circle = class _Circle extends Shape {
|
|
|
129705
129800
|
}
|
|
129706
129801
|
/** @internal */
|
|
129707
129802
|
static _wrap(inner) {
|
|
129708
|
-
|
|
129709
|
-
|
|
129710
|
-
|
|
129711
|
-
|
|
129803
|
+
return getOrCreate(inner, (raw) => {
|
|
129804
|
+
const c = Object.create(_Circle.prototype);
|
|
129805
|
+
c._inner = raw;
|
|
129806
|
+
return c;
|
|
129807
|
+
});
|
|
129712
129808
|
}
|
|
129713
129809
|
get radius() {
|
|
129714
129810
|
return this._inner.get_radius();
|
|
@@ -129717,17 +129813,10 @@ var Circle = class _Circle extends Shape {
|
|
|
129717
129813
|
this._inner.set_radius(value);
|
|
129718
129814
|
}
|
|
129719
129815
|
};
|
|
129720
|
-
|
|
129816
|
+
_bindCircleWrap((inner) => Circle._wrap(inner));
|
|
129721
129817
|
|
|
129722
129818
|
// src/shape/Polygon.ts
|
|
129723
129819
|
var Polygon = class _Polygon extends Shape {
|
|
129724
|
-
/**
|
|
129725
|
-
* Create a polygon from an array of vertices.
|
|
129726
|
-
*
|
|
129727
|
-
* @param vertices Array of Vec2 or raw Haxe vertex list.
|
|
129728
|
-
* @param material Optional material.
|
|
129729
|
-
* @param filter Optional interaction filter.
|
|
129730
|
-
*/
|
|
129731
129820
|
constructor(vertices, material, filter) {
|
|
129732
129821
|
super();
|
|
129733
129822
|
const nape = getNape();
|
|
@@ -129743,49 +129832,27 @@ var Polygon = class _Polygon extends Shape {
|
|
|
129743
129832
|
}
|
|
129744
129833
|
/** @internal */
|
|
129745
129834
|
static _wrap(inner) {
|
|
129746
|
-
|
|
129747
|
-
|
|
129748
|
-
|
|
129749
|
-
|
|
129835
|
+
return getOrCreate(inner, (raw) => {
|
|
129836
|
+
const p = Object.create(_Polygon.prototype);
|
|
129837
|
+
p._inner = raw;
|
|
129838
|
+
return p;
|
|
129839
|
+
});
|
|
129750
129840
|
}
|
|
129751
129841
|
// ---------------------------------------------------------------------------
|
|
129752
|
-
// Static factory methods
|
|
129753
|
-
// Polygon constructor.
|
|
129842
|
+
// Static factory methods
|
|
129754
129843
|
// ---------------------------------------------------------------------------
|
|
129755
|
-
/**
|
|
129756
|
-
* Create vertex list for an axis-aligned box centred at the origin.
|
|
129757
|
-
*
|
|
129758
|
-
* Usage: `new Polygon(Polygon.box(100, 50))`
|
|
129759
|
-
*/
|
|
129760
129844
|
static box(width, height, weak = false) {
|
|
129761
129845
|
return getNape().shape.Polygon.box(width, height, weak);
|
|
129762
129846
|
}
|
|
129763
|
-
/**
|
|
129764
|
-
* Create vertex list for a rectangle at the given offset.
|
|
129765
|
-
*
|
|
129766
|
-
* Usage: `new Polygon(Polygon.rect(x, y, w, h))`
|
|
129767
|
-
*/
|
|
129768
129847
|
static rect(x, y, width, height, weak = false) {
|
|
129769
129848
|
return getNape().shape.Polygon.rect(x, y, width, height, weak);
|
|
129770
129849
|
}
|
|
129771
|
-
/**
|
|
129772
|
-
* Create vertex list for a regular polygon (equilateral triangle, hexagon, etc.).
|
|
129773
|
-
*
|
|
129774
|
-
* @param xRadius Horizontal radius.
|
|
129775
|
-
* @param yRadius Vertical radius.
|
|
129776
|
-
* @param sides Number of sides.
|
|
129777
|
-
* @param angle Starting angle offset (radians).
|
|
129778
|
-
* @param weak Whether returned Vec2s are weak.
|
|
129779
|
-
*/
|
|
129780
129850
|
static regular(xRadius, yRadius, sides, angle = 0, weak = false) {
|
|
129781
|
-
return getNape().shape.Polygon.regular(
|
|
129782
|
-
xRadius,
|
|
129783
|
-
yRadius,
|
|
129784
|
-
sides,
|
|
129785
|
-
angle,
|
|
129786
|
-
weak
|
|
129787
|
-
);
|
|
129851
|
+
return getNape().shape.Polygon.regular(xRadius, yRadius, sides, angle, weak);
|
|
129788
129852
|
}
|
|
129853
|
+
// ---------------------------------------------------------------------------
|
|
129854
|
+
// Properties
|
|
129855
|
+
// ---------------------------------------------------------------------------
|
|
129789
129856
|
/** Read-only list of local-space vertices. */
|
|
129790
129857
|
get localVerts() {
|
|
129791
129858
|
return this._inner.get_localVerts();
|
|
@@ -129803,200 +129870,27 @@ var Polygon = class _Polygon extends Shape {
|
|
|
129803
129870
|
return this._inner.validity();
|
|
129804
129871
|
}
|
|
129805
129872
|
};
|
|
129806
|
-
|
|
129807
|
-
|
|
129808
|
-
// src/space/Space.ts
|
|
129809
|
-
var Space = class _Space {
|
|
129810
|
-
constructor(gravity) {
|
|
129811
|
-
const nape = getNape();
|
|
129812
|
-
this._inner = new nape.space.Space(gravity?._inner);
|
|
129813
|
-
}
|
|
129814
|
-
/** @internal */
|
|
129815
|
-
static _wrap(inner) {
|
|
129816
|
-
if (!inner) return null;
|
|
129817
|
-
const s = Object.create(_Space.prototype);
|
|
129818
|
-
s._inner = inner;
|
|
129819
|
-
return s;
|
|
129820
|
-
}
|
|
129821
|
-
// ---------------------------------------------------------------------------
|
|
129822
|
-
// Properties
|
|
129823
|
-
// ---------------------------------------------------------------------------
|
|
129824
|
-
get gravity() {
|
|
129825
|
-
return Vec2._wrap(this._inner.get_gravity());
|
|
129826
|
-
}
|
|
129827
|
-
set gravity(value) {
|
|
129828
|
-
this._inner.set_gravity(value._inner);
|
|
129829
|
-
}
|
|
129830
|
-
get worldLinearDrag() {
|
|
129831
|
-
return this._inner.get_worldLinearDrag();
|
|
129832
|
-
}
|
|
129833
|
-
set worldLinearDrag(value) {
|
|
129834
|
-
this._inner.set_worldLinearDrag(value);
|
|
129835
|
-
}
|
|
129836
|
-
get worldAngularDrag() {
|
|
129837
|
-
return this._inner.get_worldAngularDrag();
|
|
129838
|
-
}
|
|
129839
|
-
set worldAngularDrag(value) {
|
|
129840
|
-
this._inner.set_worldAngularDrag(value);
|
|
129841
|
-
}
|
|
129842
|
-
get sortContacts() {
|
|
129843
|
-
return this._inner.get_sortContacts();
|
|
129844
|
-
}
|
|
129845
|
-
set sortContacts(value) {
|
|
129846
|
-
this._inner.set_sortContacts(value);
|
|
129847
|
-
}
|
|
129848
|
-
get bodies() {
|
|
129849
|
-
return new NapeList(this._inner.get_bodies(), Body._wrap);
|
|
129850
|
-
}
|
|
129851
|
-
get liveBodies() {
|
|
129852
|
-
return new NapeList(this._inner.get_liveBodies(), Body._wrap);
|
|
129853
|
-
}
|
|
129854
|
-
get constraints() {
|
|
129855
|
-
return this._inner.get_constraints();
|
|
129856
|
-
}
|
|
129857
|
-
get liveConstraints() {
|
|
129858
|
-
return this._inner.get_liveConstraints();
|
|
129859
|
-
}
|
|
129860
|
-
get arbiters() {
|
|
129861
|
-
return this._inner.get_arbiters();
|
|
129862
|
-
}
|
|
129863
|
-
get listeners() {
|
|
129864
|
-
return this._inner.get_listeners();
|
|
129865
|
-
}
|
|
129866
|
-
get compounds() {
|
|
129867
|
-
return this._inner.get_compounds();
|
|
129868
|
-
}
|
|
129869
|
-
/** The static world body (always present, immovable). */
|
|
129870
|
-
get world() {
|
|
129871
|
-
return Body._wrap(this._inner.get_world());
|
|
129872
|
-
}
|
|
129873
|
-
get timeStamp() {
|
|
129874
|
-
return this._inner.get_timeStamp();
|
|
129875
|
-
}
|
|
129876
|
-
get elapsedTime() {
|
|
129877
|
-
return this._inner.get_elapsedTime();
|
|
129878
|
-
}
|
|
129879
|
-
get broadphase() {
|
|
129880
|
-
return this._inner.get_broadphase();
|
|
129881
|
-
}
|
|
129882
|
-
get userData() {
|
|
129883
|
-
return this._inner.get_userData();
|
|
129884
|
-
}
|
|
129885
|
-
// ---------------------------------------------------------------------------
|
|
129886
|
-
// Simulation
|
|
129887
|
-
// ---------------------------------------------------------------------------
|
|
129888
|
-
/**
|
|
129889
|
-
* Advance the simulation by one time step.
|
|
129890
|
-
*
|
|
129891
|
-
* @param deltaTime Time to advance (seconds), e.g. 1/60.
|
|
129892
|
-
* @param velocityIterations Velocity solver iterations (default 10).
|
|
129893
|
-
* @param positionIterations Position solver iterations (default 10).
|
|
129894
|
-
*/
|
|
129895
|
-
step(deltaTime, velocityIterations = 10, positionIterations = 10) {
|
|
129896
|
-
this._inner.step(deltaTime, velocityIterations, positionIterations);
|
|
129897
|
-
}
|
|
129898
|
-
/** Remove all bodies, constraints, and listeners. */
|
|
129899
|
-
clear() {
|
|
129900
|
-
this._inner.clear();
|
|
129901
|
-
}
|
|
129902
|
-
// ---------------------------------------------------------------------------
|
|
129903
|
-
// Visitors
|
|
129904
|
-
// ---------------------------------------------------------------------------
|
|
129905
|
-
/** Call `fn` for every body in the space. */
|
|
129906
|
-
visitBodies(fn) {
|
|
129907
|
-
this._inner.visitBodies((raw) => fn(Body._wrap(raw)));
|
|
129908
|
-
}
|
|
129909
|
-
/** Call `fn` for every constraint in the space. */
|
|
129910
|
-
visitConstraints(fn) {
|
|
129911
|
-
this._inner.visitConstraints(fn);
|
|
129912
|
-
}
|
|
129913
|
-
/** Call `fn` for every compound in the space. */
|
|
129914
|
-
visitCompounds(fn) {
|
|
129915
|
-
this._inner.visitCompounds(fn);
|
|
129916
|
-
}
|
|
129917
|
-
// ---------------------------------------------------------------------------
|
|
129918
|
-
// Queries
|
|
129919
|
-
// ---------------------------------------------------------------------------
|
|
129920
|
-
/** Find shapes under a world-space point. */
|
|
129921
|
-
shapesUnderPoint(point, filter, output) {
|
|
129922
|
-
return this._inner.shapesUnderPoint(
|
|
129923
|
-
point._inner,
|
|
129924
|
-
filter?._inner ?? filter,
|
|
129925
|
-
output
|
|
129926
|
-
);
|
|
129927
|
-
}
|
|
129928
|
-
/** Find bodies under a world-space point. */
|
|
129929
|
-
bodiesUnderPoint(point, filter, output) {
|
|
129930
|
-
return this._inner.bodiesUnderPoint(
|
|
129931
|
-
point._inner,
|
|
129932
|
-
filter?._inner ?? filter,
|
|
129933
|
-
output
|
|
129934
|
-
);
|
|
129935
|
-
}
|
|
129936
|
-
/** Find shapes inside an AABB. */
|
|
129937
|
-
shapesInAABB(aabb, containment, strict, filter, output) {
|
|
129938
|
-
return this._inner.shapesInAABB(
|
|
129939
|
-
aabb._inner,
|
|
129940
|
-
containment,
|
|
129941
|
-
strict,
|
|
129942
|
-
filter?._inner ?? filter,
|
|
129943
|
-
output
|
|
129944
|
-
);
|
|
129945
|
-
}
|
|
129946
|
-
/** Find bodies inside an AABB. */
|
|
129947
|
-
bodiesInAABB(aabb, containment, strict, filter, output) {
|
|
129948
|
-
return this._inner.bodiesInAABB(
|
|
129949
|
-
aabb._inner,
|
|
129950
|
-
containment,
|
|
129951
|
-
strict,
|
|
129952
|
-
filter?._inner ?? filter,
|
|
129953
|
-
output
|
|
129954
|
-
);
|
|
129955
|
-
}
|
|
129956
|
-
/** Cast a ray into the space. */
|
|
129957
|
-
rayCast(ray, inner, filter) {
|
|
129958
|
-
return this._inner.rayCast(
|
|
129959
|
-
ray?._inner ?? ray,
|
|
129960
|
-
inner,
|
|
129961
|
-
filter?._inner ?? filter
|
|
129962
|
-
);
|
|
129963
|
-
}
|
|
129964
|
-
/** Cast a ray and return all hits. */
|
|
129965
|
-
rayMultiCast(ray, inner, filter, output) {
|
|
129966
|
-
return this._inner.rayMultiCast(
|
|
129967
|
-
ray?._inner ?? ray,
|
|
129968
|
-
inner,
|
|
129969
|
-
filter?._inner ?? filter,
|
|
129970
|
-
output
|
|
129971
|
-
);
|
|
129972
|
-
}
|
|
129973
|
-
toString() {
|
|
129974
|
-
return `Space(bodies=${this.bodies.length})`;
|
|
129975
|
-
}
|
|
129976
|
-
};
|
|
129977
|
-
registerWrapper("Space", Space._wrap);
|
|
129873
|
+
_bindPolygonWrap((inner) => Polygon._wrap(inner));
|
|
129978
129874
|
|
|
129979
129875
|
// src/dynamics/InteractionGroup.ts
|
|
129980
129876
|
var InteractionGroup = class _InteractionGroup {
|
|
129981
129877
|
constructor(ignore = false) {
|
|
129982
|
-
|
|
129983
|
-
this._inner = new nape.dynamics.InteractionGroup(ignore);
|
|
129878
|
+
this._inner = new (getNape()).dynamics.InteractionGroup(ignore);
|
|
129984
129879
|
}
|
|
129985
129880
|
/** @internal */
|
|
129986
129881
|
static _wrap(inner) {
|
|
129987
|
-
|
|
129988
|
-
|
|
129989
|
-
|
|
129990
|
-
|
|
129882
|
+
return getOrCreate(inner, (raw) => {
|
|
129883
|
+
const g = Object.create(_InteractionGroup.prototype);
|
|
129884
|
+
g._inner = raw;
|
|
129885
|
+
return g;
|
|
129886
|
+
});
|
|
129991
129887
|
}
|
|
129992
|
-
/** Parent group. */
|
|
129993
129888
|
get group() {
|
|
129994
129889
|
return _InteractionGroup._wrap(this._inner.get_group());
|
|
129995
129890
|
}
|
|
129996
129891
|
set group(value) {
|
|
129997
129892
|
this._inner.set_group(value?._inner ?? null);
|
|
129998
129893
|
}
|
|
129999
|
-
/** If true, interactions between members of this group are ignored. */
|
|
130000
129894
|
get ignore() {
|
|
130001
129895
|
return this._inner.get_ignore();
|
|
130002
129896
|
}
|
|
@@ -130042,15 +129936,15 @@ function toNativeCbEvent(event) {
|
|
|
130042
129936
|
// src/callbacks/CbType.ts
|
|
130043
129937
|
var CbType = class _CbType {
|
|
130044
129938
|
constructor() {
|
|
130045
|
-
|
|
130046
|
-
this._inner = new nape.callbacks.CbType();
|
|
129939
|
+
this._inner = new (getNape()).callbacks.CbType();
|
|
130047
129940
|
}
|
|
130048
129941
|
/** @internal */
|
|
130049
129942
|
static _wrap(inner) {
|
|
130050
|
-
|
|
130051
|
-
|
|
130052
|
-
|
|
130053
|
-
|
|
129943
|
+
return getOrCreate(inner, (raw) => {
|
|
129944
|
+
const c = Object.create(_CbType.prototype);
|
|
129945
|
+
c._inner = raw;
|
|
129946
|
+
return c;
|
|
129947
|
+
});
|
|
130054
129948
|
}
|
|
130055
129949
|
/** Built-in type matching any body. */
|
|
130056
129950
|
static get ANY_BODY() {
|
|
@@ -130131,10 +130025,11 @@ var OptionType = class _OptionType {
|
|
|
130131
130025
|
}
|
|
130132
130026
|
/** @internal */
|
|
130133
130027
|
static _wrap(inner) {
|
|
130134
|
-
|
|
130135
|
-
|
|
130136
|
-
|
|
130137
|
-
|
|
130028
|
+
return getOrCreate(inner, (raw) => {
|
|
130029
|
+
const o = Object.create(_OptionType.prototype);
|
|
130030
|
+
o._inner = raw;
|
|
130031
|
+
return o;
|
|
130032
|
+
});
|
|
130138
130033
|
}
|
|
130139
130034
|
};
|
|
130140
130035
|
|
|
@@ -130142,16 +130037,18 @@ var OptionType = class _OptionType {
|
|
|
130142
130037
|
var Listener = class _Listener {
|
|
130143
130038
|
/** @internal */
|
|
130144
130039
|
constructor() {
|
|
130040
|
+
this._inner = void 0;
|
|
130145
130041
|
}
|
|
130146
130042
|
/** @internal */
|
|
130147
130043
|
static _wrap(inner) {
|
|
130148
|
-
|
|
130149
|
-
|
|
130150
|
-
|
|
130151
|
-
|
|
130044
|
+
return getOrCreate(inner, (raw) => {
|
|
130045
|
+
const l = Object.create(_Listener.prototype);
|
|
130046
|
+
l._inner = raw;
|
|
130047
|
+
return l;
|
|
130048
|
+
});
|
|
130152
130049
|
}
|
|
130153
130050
|
get space() {
|
|
130154
|
-
return
|
|
130051
|
+
return Space._wrap(this._inner.get_space());
|
|
130155
130052
|
}
|
|
130156
130053
|
set space(value) {
|
|
130157
130054
|
this._inner.set_space(value?._inner ?? null);
|
|
@@ -130183,8 +130080,7 @@ var BodyListener = class _BodyListener extends Listener {
|
|
|
130183
130080
|
*/
|
|
130184
130081
|
constructor(event, options, handler, precedence = 0) {
|
|
130185
130082
|
super();
|
|
130186
|
-
|
|
130187
|
-
this._inner = new nape.callbacks.BodyListener(
|
|
130083
|
+
this._inner = new (getNape()).callbacks.BodyListener(
|
|
130188
130084
|
toNativeCbEvent(event),
|
|
130189
130085
|
options._inner,
|
|
130190
130086
|
handler,
|
|
@@ -130193,10 +130089,11 @@ var BodyListener = class _BodyListener extends Listener {
|
|
|
130193
130089
|
}
|
|
130194
130090
|
/** @internal */
|
|
130195
130091
|
static _wrap(inner) {
|
|
130196
|
-
|
|
130197
|
-
|
|
130198
|
-
|
|
130199
|
-
|
|
130092
|
+
return getOrCreate(inner, (raw) => {
|
|
130093
|
+
const l = Object.create(_BodyListener.prototype);
|
|
130094
|
+
l._inner = raw;
|
|
130095
|
+
return l;
|
|
130096
|
+
});
|
|
130200
130097
|
}
|
|
130201
130098
|
};
|
|
130202
130099
|
|
|
@@ -130212,8 +130109,7 @@ var InteractionListener = class _InteractionListener extends Listener {
|
|
|
130212
130109
|
*/
|
|
130213
130110
|
constructor(event, interactionType, options1, options2, handler, precedence = 0) {
|
|
130214
130111
|
super();
|
|
130215
|
-
|
|
130216
|
-
this._inner = new nape.callbacks.InteractionListener(
|
|
130112
|
+
this._inner = new (getNape()).callbacks.InteractionListener(
|
|
130217
130113
|
toNativeCbEvent(event),
|
|
130218
130114
|
toNativeInteractionType(interactionType),
|
|
130219
130115
|
options1._inner,
|
|
@@ -130224,12 +130120,13 @@ var InteractionListener = class _InteractionListener extends Listener {
|
|
|
130224
130120
|
}
|
|
130225
130121
|
/** @internal */
|
|
130226
130122
|
static _wrap(inner) {
|
|
130227
|
-
|
|
130228
|
-
|
|
130229
|
-
|
|
130230
|
-
|
|
130231
|
-
|
|
130232
|
-
|
|
130123
|
+
return getOrCreate(inner, (raw) => {
|
|
130124
|
+
const l = Object.create(
|
|
130125
|
+
_InteractionListener.prototype
|
|
130126
|
+
);
|
|
130127
|
+
l._inner = raw;
|
|
130128
|
+
return l;
|
|
130129
|
+
});
|
|
130233
130130
|
}
|
|
130234
130131
|
};
|
|
130235
130132
|
|
|
@@ -130237,8 +130134,7 @@ var InteractionListener = class _InteractionListener extends Listener {
|
|
|
130237
130134
|
var ConstraintListener = class _ConstraintListener extends Listener {
|
|
130238
130135
|
constructor(event, options, handler, precedence = 0) {
|
|
130239
130136
|
super();
|
|
130240
|
-
|
|
130241
|
-
this._inner = new nape.callbacks.ConstraintListener(
|
|
130137
|
+
this._inner = new (getNape()).callbacks.ConstraintListener(
|
|
130242
130138
|
toNativeCbEvent(event),
|
|
130243
130139
|
options._inner,
|
|
130244
130140
|
handler,
|
|
@@ -130247,12 +130143,13 @@ var ConstraintListener = class _ConstraintListener extends Listener {
|
|
|
130247
130143
|
}
|
|
130248
130144
|
/** @internal */
|
|
130249
130145
|
static _wrap(inner) {
|
|
130250
|
-
|
|
130251
|
-
|
|
130252
|
-
|
|
130253
|
-
|
|
130254
|
-
|
|
130255
|
-
|
|
130146
|
+
return getOrCreate(inner, (raw) => {
|
|
130147
|
+
const l = Object.create(
|
|
130148
|
+
_ConstraintListener.prototype
|
|
130149
|
+
);
|
|
130150
|
+
l._inner = raw;
|
|
130151
|
+
return l;
|
|
130152
|
+
});
|
|
130256
130153
|
}
|
|
130257
130154
|
};
|
|
130258
130155
|
|
|
@@ -130260,7 +130157,6 @@ var ConstraintListener = class _ConstraintListener extends Listener {
|
|
|
130260
130157
|
var PreListener = class _PreListener extends Listener {
|
|
130261
130158
|
constructor(interactionType, options1, options2, handler, precedence = 0, pure = false) {
|
|
130262
130159
|
super();
|
|
130263
|
-
const nape = getNape();
|
|
130264
130160
|
const wrappedHandler = (cb) => {
|
|
130265
130161
|
const result = handler(cb);
|
|
130266
130162
|
if (typeof result === "string" && result in PreFlag) {
|
|
@@ -130268,7 +130164,7 @@ var PreListener = class _PreListener extends Listener {
|
|
|
130268
130164
|
}
|
|
130269
130165
|
return result;
|
|
130270
130166
|
};
|
|
130271
|
-
this._inner = new
|
|
130167
|
+
this._inner = new (getNape()).callbacks.PreListener(
|
|
130272
130168
|
toNativeInteractionType(interactionType),
|
|
130273
130169
|
options1._inner,
|
|
130274
130170
|
options2._inner,
|
|
@@ -130279,10 +130175,11 @@ var PreListener = class _PreListener extends Listener {
|
|
|
130279
130175
|
}
|
|
130280
130176
|
/** @internal */
|
|
130281
130177
|
static _wrap(inner) {
|
|
130282
|
-
|
|
130283
|
-
|
|
130284
|
-
|
|
130285
|
-
|
|
130178
|
+
return getOrCreate(inner, (raw) => {
|
|
130179
|
+
const l = Object.create(_PreListener.prototype);
|
|
130180
|
+
l._inner = raw;
|
|
130181
|
+
return l;
|
|
130182
|
+
});
|
|
130286
130183
|
}
|
|
130287
130184
|
};
|
|
130288
130185
|
|
|
@@ -130290,19 +130187,21 @@ var PreListener = class _PreListener extends Listener {
|
|
|
130290
130187
|
var Constraint = class _Constraint {
|
|
130291
130188
|
/** @internal */
|
|
130292
130189
|
constructor() {
|
|
130190
|
+
this._inner = void 0;
|
|
130293
130191
|
}
|
|
130294
130192
|
/** @internal */
|
|
130295
130193
|
static _wrap(inner) {
|
|
130296
|
-
|
|
130297
|
-
|
|
130298
|
-
|
|
130299
|
-
|
|
130194
|
+
return getOrCreate(inner, (raw) => {
|
|
130195
|
+
const c = Object.create(_Constraint.prototype);
|
|
130196
|
+
c._inner = raw;
|
|
130197
|
+
return c;
|
|
130198
|
+
});
|
|
130300
130199
|
}
|
|
130301
130200
|
// ---------------------------------------------------------------------------
|
|
130302
130201
|
// Properties common to all constraints
|
|
130303
130202
|
// ---------------------------------------------------------------------------
|
|
130304
130203
|
get space() {
|
|
130305
|
-
return
|
|
130204
|
+
return Space._wrap(this._inner.get_space());
|
|
130306
130205
|
}
|
|
130307
130206
|
set space(value) {
|
|
130308
130207
|
this._inner.set_space(value?._inner ?? null);
|
|
@@ -130400,8 +130299,7 @@ var Constraint = class _Constraint {
|
|
|
130400
130299
|
var PivotJoint = class _PivotJoint extends Constraint {
|
|
130401
130300
|
constructor(body1, body2, anchor1, anchor2) {
|
|
130402
130301
|
super();
|
|
130403
|
-
|
|
130404
|
-
this._inner = new nape.constraint.PivotJoint(
|
|
130302
|
+
this._inner = new (getNape()).constraint.PivotJoint(
|
|
130405
130303
|
body1?._inner ?? null,
|
|
130406
130304
|
body2?._inner ?? null,
|
|
130407
130305
|
anchor1._inner,
|
|
@@ -130410,10 +130308,11 @@ var PivotJoint = class _PivotJoint extends Constraint {
|
|
|
130410
130308
|
}
|
|
130411
130309
|
/** @internal */
|
|
130412
130310
|
static _wrap(inner) {
|
|
130413
|
-
|
|
130414
|
-
|
|
130415
|
-
|
|
130416
|
-
|
|
130311
|
+
return getOrCreate(inner, (raw) => {
|
|
130312
|
+
const j = Object.create(_PivotJoint.prototype);
|
|
130313
|
+
j._inner = raw;
|
|
130314
|
+
return j;
|
|
130315
|
+
});
|
|
130417
130316
|
}
|
|
130418
130317
|
get body1() {
|
|
130419
130318
|
return Body._wrap(this._inner.get_body1());
|
|
@@ -130445,8 +130344,7 @@ var PivotJoint = class _PivotJoint extends Constraint {
|
|
|
130445
130344
|
var DistanceJoint = class _DistanceJoint extends Constraint {
|
|
130446
130345
|
constructor(body1, body2, anchor1, anchor2, jointMin, jointMax) {
|
|
130447
130346
|
super();
|
|
130448
|
-
|
|
130449
|
-
this._inner = new nape.constraint.DistanceJoint(
|
|
130347
|
+
this._inner = new (getNape()).constraint.DistanceJoint(
|
|
130450
130348
|
body1?._inner ?? null,
|
|
130451
130349
|
body2?._inner ?? null,
|
|
130452
130350
|
anchor1._inner,
|
|
@@ -130457,10 +130355,11 @@ var DistanceJoint = class _DistanceJoint extends Constraint {
|
|
|
130457
130355
|
}
|
|
130458
130356
|
/** @internal */
|
|
130459
130357
|
static _wrap(inner) {
|
|
130460
|
-
|
|
130461
|
-
|
|
130462
|
-
|
|
130463
|
-
|
|
130358
|
+
return getOrCreate(inner, (raw) => {
|
|
130359
|
+
const j = Object.create(_DistanceJoint.prototype);
|
|
130360
|
+
j._inner = raw;
|
|
130361
|
+
return j;
|
|
130362
|
+
});
|
|
130464
130363
|
}
|
|
130465
130364
|
get body1() {
|
|
130466
130365
|
return Body._wrap(this._inner.get_body1());
|
|
@@ -130504,8 +130403,7 @@ var DistanceJoint = class _DistanceJoint extends Constraint {
|
|
|
130504
130403
|
var AngleJoint = class _AngleJoint extends Constraint {
|
|
130505
130404
|
constructor(body1, body2, jointMin, jointMax, ratio = 1) {
|
|
130506
130405
|
super();
|
|
130507
|
-
|
|
130508
|
-
this._inner = new nape.constraint.AngleJoint(
|
|
130406
|
+
this._inner = new (getNape()).constraint.AngleJoint(
|
|
130509
130407
|
body1?._inner ?? null,
|
|
130510
130408
|
body2?._inner ?? null,
|
|
130511
130409
|
jointMin,
|
|
@@ -130515,10 +130413,11 @@ var AngleJoint = class _AngleJoint extends Constraint {
|
|
|
130515
130413
|
}
|
|
130516
130414
|
/** @internal */
|
|
130517
130415
|
static _wrap(inner) {
|
|
130518
|
-
|
|
130519
|
-
|
|
130520
|
-
|
|
130521
|
-
|
|
130416
|
+
return getOrCreate(inner, (raw) => {
|
|
130417
|
+
const j = Object.create(_AngleJoint.prototype);
|
|
130418
|
+
j._inner = raw;
|
|
130419
|
+
return j;
|
|
130420
|
+
});
|
|
130522
130421
|
}
|
|
130523
130422
|
get body1() {
|
|
130524
130423
|
return Body._wrap(this._inner.get_body1());
|
|
@@ -130556,8 +130455,7 @@ var AngleJoint = class _AngleJoint extends Constraint {
|
|
|
130556
130455
|
var WeldJoint = class _WeldJoint extends Constraint {
|
|
130557
130456
|
constructor(body1, body2, anchor1, anchor2, phase = 0) {
|
|
130558
130457
|
super();
|
|
130559
|
-
|
|
130560
|
-
this._inner = new nape.constraint.WeldJoint(
|
|
130458
|
+
this._inner = new (getNape()).constraint.WeldJoint(
|
|
130561
130459
|
body1?._inner ?? null,
|
|
130562
130460
|
body2?._inner ?? null,
|
|
130563
130461
|
anchor1._inner,
|
|
@@ -130567,10 +130465,11 @@ var WeldJoint = class _WeldJoint extends Constraint {
|
|
|
130567
130465
|
}
|
|
130568
130466
|
/** @internal */
|
|
130569
130467
|
static _wrap(inner) {
|
|
130570
|
-
|
|
130571
|
-
|
|
130572
|
-
|
|
130573
|
-
|
|
130468
|
+
return getOrCreate(inner, (raw) => {
|
|
130469
|
+
const j = Object.create(_WeldJoint.prototype);
|
|
130470
|
+
j._inner = raw;
|
|
130471
|
+
return j;
|
|
130472
|
+
});
|
|
130574
130473
|
}
|
|
130575
130474
|
get body1() {
|
|
130576
130475
|
return Body._wrap(this._inner.get_body1());
|
|
@@ -130608,8 +130507,7 @@ var WeldJoint = class _WeldJoint extends Constraint {
|
|
|
130608
130507
|
var MotorJoint = class _MotorJoint extends Constraint {
|
|
130609
130508
|
constructor(body1, body2, rate, ratio = 1) {
|
|
130610
130509
|
super();
|
|
130611
|
-
|
|
130612
|
-
this._inner = new nape.constraint.MotorJoint(
|
|
130510
|
+
this._inner = new (getNape()).constraint.MotorJoint(
|
|
130613
130511
|
body1?._inner ?? null,
|
|
130614
130512
|
body2?._inner ?? null,
|
|
130615
130513
|
rate,
|
|
@@ -130618,10 +130516,11 @@ var MotorJoint = class _MotorJoint extends Constraint {
|
|
|
130618
130516
|
}
|
|
130619
130517
|
/** @internal */
|
|
130620
130518
|
static _wrap(inner) {
|
|
130621
|
-
|
|
130622
|
-
|
|
130623
|
-
|
|
130624
|
-
|
|
130519
|
+
return getOrCreate(inner, (raw) => {
|
|
130520
|
+
const j = Object.create(_MotorJoint.prototype);
|
|
130521
|
+
j._inner = raw;
|
|
130522
|
+
return j;
|
|
130523
|
+
});
|
|
130625
130524
|
}
|
|
130626
130525
|
get body1() {
|
|
130627
130526
|
return Body._wrap(this._inner.get_body1());
|
|
@@ -130653,8 +130552,7 @@ var MotorJoint = class _MotorJoint extends Constraint {
|
|
|
130653
130552
|
var LineJoint = class _LineJoint extends Constraint {
|
|
130654
130553
|
constructor(body1, body2, anchor1, anchor2, direction, jointMin, jointMax) {
|
|
130655
130554
|
super();
|
|
130656
|
-
|
|
130657
|
-
this._inner = new nape.constraint.LineJoint(
|
|
130555
|
+
this._inner = new (getNape()).constraint.LineJoint(
|
|
130658
130556
|
body1?._inner ?? null,
|
|
130659
130557
|
body2?._inner ?? null,
|
|
130660
130558
|
anchor1._inner,
|
|
@@ -130666,10 +130564,11 @@ var LineJoint = class _LineJoint extends Constraint {
|
|
|
130666
130564
|
}
|
|
130667
130565
|
/** @internal */
|
|
130668
130566
|
static _wrap(inner) {
|
|
130669
|
-
|
|
130670
|
-
|
|
130671
|
-
|
|
130672
|
-
|
|
130567
|
+
return getOrCreate(inner, (raw) => {
|
|
130568
|
+
const j = Object.create(_LineJoint.prototype);
|
|
130569
|
+
j._inner = raw;
|
|
130570
|
+
return j;
|
|
130571
|
+
});
|
|
130673
130572
|
}
|
|
130674
130573
|
get body1() {
|
|
130675
130574
|
return Body._wrap(this._inner.get_body1());
|
|
@@ -130719,8 +130618,7 @@ var LineJoint = class _LineJoint extends Constraint {
|
|
|
130719
130618
|
var PulleyJoint = class _PulleyJoint extends Constraint {
|
|
130720
130619
|
constructor(body1, body2, body3, body4, anchor1, anchor2, anchor3, anchor4, jointMin, jointMax, ratio = 1) {
|
|
130721
130620
|
super();
|
|
130722
|
-
|
|
130723
|
-
this._inner = new nape.constraint.PulleyJoint(
|
|
130621
|
+
this._inner = new (getNape()).constraint.PulleyJoint(
|
|
130724
130622
|
body1?._inner ?? null,
|
|
130725
130623
|
body2?._inner ?? null,
|
|
130726
130624
|
body3?._inner ?? null,
|
|
@@ -130736,10 +130634,11 @@ var PulleyJoint = class _PulleyJoint extends Constraint {
|
|
|
130736
130634
|
}
|
|
130737
130635
|
/** @internal */
|
|
130738
130636
|
static _wrap(inner) {
|
|
130739
|
-
|
|
130740
|
-
|
|
130741
|
-
|
|
130742
|
-
|
|
130637
|
+
return getOrCreate(inner, (raw) => {
|
|
130638
|
+
const j = Object.create(_PulleyJoint.prototype);
|
|
130639
|
+
j._inner = raw;
|
|
130640
|
+
return j;
|
|
130641
|
+
});
|
|
130743
130642
|
}
|
|
130744
130643
|
get body1() {
|
|
130745
130644
|
return Body._wrap(this._inner.get_body1());
|