@galacean/engine-physics-physx 1.3.24 → 1.4.0-alpha.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/browser.js +219 -206
- package/dist/browser.js.map +1 -1
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +1 -1
- package/dist/main.js +219 -206
- package/dist/main.js.map +1 -1
- package/dist/module.js +212 -200
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/PhysXDynamicCollider.d.ts +36 -0
- package/types/PhysXPhysicsScene.d.ts +0 -9
- package/types/joint/PhysXHingeJoint.d.ts +5 -5
- package/types/joint/PhysXJoint.d.ts +15 -9
- package/types/joint/PhysXSpringJoint.d.ts +0 -6
- package/types/shape/PhysXBoxColliderShape.d.ts +0 -1
- package/types/shape/PhysXCapsuleColliderShape.d.ts +0 -1
- package/dist/miniprogram.js +0 -1406
package/dist/module.js
CHANGED
|
@@ -6,6 +6,12 @@ function _instanceof(left, right) {
|
|
|
6
6
|
} else return left instanceof right;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
function _type_of(obj) {
|
|
10
|
+
"@swc/helpers - typeof";
|
|
11
|
+
|
|
12
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
function _set_prototype_of(o, p) {
|
|
10
16
|
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
11
17
|
o.__proto__ = p;
|
|
@@ -26,17 +32,12 @@ function _inherits(subClass, superClass) {
|
|
|
26
32
|
if (superClass) _set_prototype_of(subClass, superClass);
|
|
27
33
|
}
|
|
28
34
|
|
|
29
|
-
var ShapeFlag;
|
|
30
|
-
(function(ShapeFlag) {
|
|
31
|
-
ShapeFlag[ShapeFlag[/** The shape will partake in collision in the physical simulation. */ "SIMULATION_SHAPE"] = 1] = "SIMULATION_SHAPE";
|
|
32
|
-
ShapeFlag[ShapeFlag[/** The shape will partake in scene queries (ray casts, overlap tests, sweeps, ...). */ "SCENE_QUERY_SHAPE"] = 2] = "SCENE_QUERY_SHAPE";
|
|
33
|
-
ShapeFlag[ShapeFlag[/** The shape is a trigger which can send reports whenever other shapes enter/leave its volume. */ "TRIGGER_SHAPE"] = 4] = "TRIGGER_SHAPE";
|
|
34
|
-
})(ShapeFlag || (ShapeFlag = {}));
|
|
35
35
|
/**
|
|
36
36
|
* Abstract class for collider shapes.
|
|
37
37
|
*/ var PhysXColliderShape = /*#__PURE__*/ function() {
|
|
38
38
|
function PhysXColliderShape(physXPhysics) {
|
|
39
39
|
/** @internal */ this._controllers = new DisorderedArray();
|
|
40
|
+
/** @internal */ this._contractOffset = 0.02;
|
|
40
41
|
this._worldScale = new Vector3(1, 1, 1);
|
|
41
42
|
this._position = new Vector3();
|
|
42
43
|
this._rotation = null;
|
|
@@ -70,7 +71,7 @@ var ShapeFlag;
|
|
|
70
71
|
/**
|
|
71
72
|
* {@inheritDoc IColliderShape.setWorldScale }
|
|
72
73
|
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
73
|
-
this._worldScale.
|
|
74
|
+
this._worldScale.set(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z));
|
|
74
75
|
this._setLocalPose();
|
|
75
76
|
var controllers = this._controllers;
|
|
76
77
|
for(var i = 0, n = controllers.length; i < n; i++){
|
|
@@ -81,11 +82,15 @@ var ShapeFlag;
|
|
|
81
82
|
* {@inheritDoc IColliderShape.setContactOffset }
|
|
82
83
|
* @default 0.02f * PxTolerancesScale::length
|
|
83
84
|
*/ _proto.setContactOffset = function setContactOffset(offset) {
|
|
84
|
-
this.
|
|
85
|
+
this._contractOffset = offset;
|
|
85
86
|
var controllers = this._controllers;
|
|
86
|
-
|
|
87
|
-
var
|
|
88
|
-
|
|
87
|
+
if (controllers.length) {
|
|
88
|
+
for(var i = 0, n = controllers.length; i < n; i++){
|
|
89
|
+
var _controllers_get__pxController;
|
|
90
|
+
(_controllers_get__pxController = controllers.get(i)._pxController) == null ? void 0 : _controllers_get__pxController.setContactOffset(offset);
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
this._pxShape.setContactOffset(offset);
|
|
89
94
|
}
|
|
90
95
|
};
|
|
91
96
|
/**
|
|
@@ -129,25 +134,19 @@ var ShapeFlag;
|
|
|
129
134
|
};
|
|
130
135
|
return PhysXColliderShape;
|
|
131
136
|
}();
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
translation: new Vector3(),
|
|
138
|
-
rotation: null
|
|
139
|
-
};
|
|
140
|
-
})();
|
|
137
|
+
PhysXColliderShape.halfSqrt = 0.70710678118655;
|
|
138
|
+
PhysXColliderShape.transform = {
|
|
139
|
+
translation: new Vector3(),
|
|
140
|
+
rotation: null
|
|
141
|
+
};
|
|
141
142
|
|
|
142
143
|
/**
|
|
143
144
|
* Box collider shape in PhysX.
|
|
144
|
-
*/ var PhysXBoxColliderShape = /*#__PURE__*/ function(
|
|
145
|
-
_inherits(PhysXBoxColliderShape,
|
|
145
|
+
*/ var PhysXBoxColliderShape = /*#__PURE__*/ function(PhysXColliderShape) {
|
|
146
|
+
_inherits(PhysXBoxColliderShape, PhysXColliderShape);
|
|
146
147
|
function PhysXBoxColliderShape(physXPhysics, uniqueID, size, material) {
|
|
147
148
|
var _this;
|
|
148
|
-
_this =
|
|
149
|
-
/** @internal */ _this._halfSize = new Vector3();
|
|
150
|
-
_this._sizeScale = new Vector3(1, 1, 1);
|
|
149
|
+
_this = PhysXColliderShape.call(this, physXPhysics) || this, /** @internal */ _this._halfSize = new Vector3();
|
|
151
150
|
var halfSize = _this._halfSize;
|
|
152
151
|
halfSize.set(size.x * 0.5, size.y * 0.5, size.z * 0.5);
|
|
153
152
|
_this._pxGeometry = new physXPhysics._physX.PxBoxGeometry(halfSize.x, halfSize.y, halfSize.z);
|
|
@@ -162,7 +161,7 @@ var ShapeFlag;
|
|
|
162
161
|
var halfSize = this._halfSize;
|
|
163
162
|
var tempExtents = PhysXBoxColliderShape._tempHalfExtents;
|
|
164
163
|
halfSize.set(value.x * 0.5, value.y * 0.5, value.z * 0.5);
|
|
165
|
-
Vector3.multiply(halfSize, this.
|
|
164
|
+
Vector3.multiply(halfSize, this._worldScale, tempExtents);
|
|
166
165
|
this._pxGeometry.halfExtents = tempExtents;
|
|
167
166
|
this._pxShape.setGeometry(this._pxGeometry);
|
|
168
167
|
this._updateController(tempExtents);
|
|
@@ -170,10 +169,9 @@ var ShapeFlag;
|
|
|
170
169
|
/**
|
|
171
170
|
* {@inheritDoc IColliderShape.setWorldScale }
|
|
172
171
|
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
173
|
-
|
|
174
|
-
this._sizeScale.set(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z));
|
|
172
|
+
PhysXColliderShape.prototype.setWorldScale.call(this, scale);
|
|
175
173
|
var tempExtents = PhysXBoxColliderShape._tempHalfExtents;
|
|
176
|
-
Vector3.multiply(this._halfSize, this.
|
|
174
|
+
Vector3.multiply(this._halfSize, this._worldScale, tempExtents);
|
|
177
175
|
this._pxGeometry.halfExtents = tempExtents;
|
|
178
176
|
this._pxShape.setGeometry(this._pxGeometry);
|
|
179
177
|
this._updateController(tempExtents);
|
|
@@ -191,9 +189,7 @@ var ShapeFlag;
|
|
|
191
189
|
};
|
|
192
190
|
return PhysXBoxColliderShape;
|
|
193
191
|
}(PhysXColliderShape);
|
|
194
|
-
(
|
|
195
|
-
PhysXBoxColliderShape._tempHalfExtents = new Vector3();
|
|
196
|
-
})();
|
|
192
|
+
PhysXBoxColliderShape._tempHalfExtents = new Vector3();
|
|
197
193
|
|
|
198
194
|
/**
|
|
199
195
|
* Capsule collider shape in PhysX.
|
|
@@ -201,9 +197,7 @@ var ShapeFlag;
|
|
|
201
197
|
_inherits(PhysXCapsuleColliderShape, PhysXColliderShape1);
|
|
202
198
|
function PhysXCapsuleColliderShape(physXPhysics, uniqueID, radius, height, material) {
|
|
203
199
|
var _this;
|
|
204
|
-
_this = PhysXColliderShape1.call(this, physXPhysics) || this;
|
|
205
|
-
_this._upAxis = /** Up axis is Y. */ 1;
|
|
206
|
-
_this._sizeScale = new Vector3(1, 1, 1);
|
|
200
|
+
_this = PhysXColliderShape1.call(this, physXPhysics) || this, _this._upAxis = 1;
|
|
207
201
|
_this._radius = radius;
|
|
208
202
|
_this._halfHeight = height * 0.5;
|
|
209
203
|
_this._axis = new Quaternion(0, 0, PhysXColliderShape.halfSqrt, PhysXColliderShape.halfSqrt);
|
|
@@ -218,15 +212,15 @@ var ShapeFlag;
|
|
|
218
212
|
* {@inheritDoc ICapsuleColliderShape.setRadius }
|
|
219
213
|
*/ _proto.setRadius = function setRadius(value) {
|
|
220
214
|
this._radius = value;
|
|
221
|
-
var sizeScale = this.
|
|
215
|
+
var sizeScale = this._worldScale;
|
|
222
216
|
switch(this._upAxis){
|
|
223
|
-
case
|
|
217
|
+
case 0:
|
|
224
218
|
this._pxGeometry.radius = this._radius * Math.max(sizeScale.y, sizeScale.z);
|
|
225
219
|
break;
|
|
226
220
|
case 1:
|
|
227
221
|
this._pxGeometry.radius = this._radius * Math.max(sizeScale.x, sizeScale.z);
|
|
228
222
|
break;
|
|
229
|
-
case
|
|
223
|
+
case 2:
|
|
230
224
|
this._pxGeometry.radius = this._radius * Math.max(sizeScale.x, sizeScale.y);
|
|
231
225
|
break;
|
|
232
226
|
}
|
|
@@ -242,7 +236,7 @@ var ShapeFlag;
|
|
|
242
236
|
* {@inheritDoc ICapsuleColliderShape.setHeight }
|
|
243
237
|
*/ _proto.setHeight = function setHeight(value) {
|
|
244
238
|
this._halfHeight = value * 0.5;
|
|
245
|
-
var sizeScale = this.
|
|
239
|
+
var sizeScale = this._worldScale;
|
|
246
240
|
switch(this._upAxis){
|
|
247
241
|
case 0:
|
|
248
242
|
this._pxGeometry.halfHeight = this._halfHeight * sizeScale.x;
|
|
@@ -290,7 +284,7 @@ var ShapeFlag;
|
|
|
290
284
|
* {@inheritDoc IColliderShape.setWorldScale }
|
|
291
285
|
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
292
286
|
PhysXColliderShape1.prototype.setWorldScale.call(this, scale);
|
|
293
|
-
var sizeScale = this.
|
|
287
|
+
var sizeScale = this._worldScale;
|
|
294
288
|
var geometry = this._pxGeometry;
|
|
295
289
|
switch(this._upAxis){
|
|
296
290
|
case 0:
|
|
@@ -320,19 +314,12 @@ var ShapeFlag;
|
|
|
320
314
|
};
|
|
321
315
|
return PhysXCapsuleColliderShape;
|
|
322
316
|
}(PhysXColliderShape);
|
|
323
|
-
var /**
|
|
324
|
-
* The up axis of the collider shape.
|
|
325
|
-
*/ ColliderShapeUpAxis;
|
|
326
|
-
(function(ColliderShapeUpAxis) {
|
|
327
|
-
ColliderShapeUpAxis[ColliderShapeUpAxis["X"] = 0] = "X";
|
|
328
|
-
ColliderShapeUpAxis[ColliderShapeUpAxis["Y"] = 1] = "Y";
|
|
329
|
-
ColliderShapeUpAxis[ColliderShapeUpAxis["Z"] = 2] = "Z";
|
|
330
|
-
})(ColliderShapeUpAxis || (ColliderShapeUpAxis = {}));
|
|
331
317
|
|
|
332
318
|
/**
|
|
333
319
|
* Base class for character controllers.
|
|
334
320
|
*/ var PhysXCharacterController = /*#__PURE__*/ function() {
|
|
335
321
|
function PhysXCharacterController(physXPhysics) {
|
|
322
|
+
/** @internal */ this._scene = null;
|
|
336
323
|
this._shapeScaledPosition = new Vector3();
|
|
337
324
|
this._worldPosition = null;
|
|
338
325
|
this._physXPhysics = physXPhysics;
|
|
@@ -386,17 +373,22 @@ var /**
|
|
|
386
373
|
/**
|
|
387
374
|
* {@inheritDoc ICharacterController.addShape }
|
|
388
375
|
*/ _proto.addShape = function addShape(shape) {
|
|
376
|
+
var _this__pxController, _this__scene;
|
|
389
377
|
// When CharacterController is disabled, set shape property need check pxController whether exist because of this._pxManager is null and won't create pxController
|
|
390
378
|
this._pxManager && this._createPXController(this._pxManager, shape);
|
|
391
379
|
this._shape = shape;
|
|
392
380
|
shape._controllers.add(this);
|
|
381
|
+
(_this__pxController = this._pxController) == null ? void 0 : _this__pxController.setContactOffset(shape._contractOffset);
|
|
382
|
+
(_this__scene = this._scene) == null ? void 0 : _this__scene._addColliderShape(shape._id);
|
|
393
383
|
};
|
|
394
384
|
/**
|
|
395
385
|
* {@inheritDoc ICharacterController.removeShape }
|
|
396
386
|
*/ _proto.removeShape = function removeShape(shape) {
|
|
387
|
+
var _this__scene;
|
|
397
388
|
this._destroyPXController();
|
|
398
389
|
this._shape = null;
|
|
399
390
|
shape._controllers.delete(this);
|
|
391
|
+
(_this__scene = this._scene) == null ? void 0 : _this__scene._removeColliderShape(shape._id);
|
|
400
392
|
};
|
|
401
393
|
/**
|
|
402
394
|
* {@inheritDoc ICharacterController.destroy }
|
|
@@ -447,26 +439,33 @@ var /**
|
|
|
447
439
|
};
|
|
448
440
|
return PhysXCharacterController;
|
|
449
441
|
}();
|
|
450
|
-
(
|
|
451
|
-
PhysXCharacterController._tempVec = new Vector3();
|
|
452
|
-
})();
|
|
442
|
+
PhysXCharacterController._tempVec = new Vector3();
|
|
453
443
|
|
|
454
444
|
/**
|
|
455
445
|
* Abstract class of physical collider.
|
|
456
446
|
*/ var PhysXCollider = /*#__PURE__*/ function() {
|
|
457
447
|
function PhysXCollider(physXPhysics) {
|
|
448
|
+
/** @internal */ this._scene = null;
|
|
449
|
+
/** @internal */ this._shapes = new Array();
|
|
458
450
|
this._physXPhysics = physXPhysics;
|
|
459
451
|
}
|
|
460
452
|
var _proto = PhysXCollider.prototype;
|
|
461
453
|
/**
|
|
462
454
|
* {@inheritDoc ICollider.addShape }
|
|
463
455
|
*/ _proto.addShape = function addShape(shape) {
|
|
456
|
+
var _this__scene;
|
|
464
457
|
this._pxActor.attachShape(shape._pxShape);
|
|
458
|
+
this._shapes.push(shape);
|
|
459
|
+
(_this__scene = this._scene) == null ? void 0 : _this__scene._addColliderShape(shape._id);
|
|
465
460
|
};
|
|
466
461
|
/**
|
|
467
462
|
* {@inheritDoc ICollider.removeShape }
|
|
468
463
|
*/ _proto.removeShape = function removeShape(shape) {
|
|
464
|
+
var _this__scene;
|
|
469
465
|
this._pxActor.detachShape(shape._pxShape, true);
|
|
466
|
+
var shapes = this._shapes;
|
|
467
|
+
shapes.splice(shapes.indexOf(shape), 1);
|
|
468
|
+
(_this__scene = this._scene) == null ? void 0 : _this__scene._removeColliderShape(shape._id);
|
|
470
469
|
};
|
|
471
470
|
/**
|
|
472
471
|
* {@inheritDoc ICollider.setWorldTransform }
|
|
@@ -495,48 +494,61 @@ var /**
|
|
|
495
494
|
};
|
|
496
495
|
return PhysXCollider;
|
|
497
496
|
}();
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
};
|
|
503
|
-
})();
|
|
497
|
+
PhysXCollider._tempTransform = {
|
|
498
|
+
translation: null,
|
|
499
|
+
rotation: null
|
|
500
|
+
};
|
|
504
501
|
|
|
505
|
-
var CollisionDetectionMode;
|
|
506
|
-
(function(CollisionDetectionMode) {
|
|
507
|
-
CollisionDetectionMode[CollisionDetectionMode[/** Continuous collision detection is off for this dynamic collider. */ "Discrete"] = 0] = "Discrete";
|
|
508
|
-
CollisionDetectionMode[CollisionDetectionMode[/** Continuous collision detection is on for colliding with static mesh geometry. */ "Continuous"] = 1] = "Continuous";
|
|
509
|
-
CollisionDetectionMode[CollisionDetectionMode[/** Continuous collision detection is on for colliding with static and dynamic geometry. */ "ContinuousDynamic"] = 2] = "ContinuousDynamic";
|
|
510
|
-
CollisionDetectionMode[CollisionDetectionMode[/** Speculative continuous collision detection is on for static and dynamic geometries */ "ContinuousSpeculative"] = 3] = "ContinuousSpeculative";
|
|
511
|
-
})(CollisionDetectionMode || (CollisionDetectionMode = {}));
|
|
512
502
|
/**
|
|
513
503
|
* A dynamic collider can act with self-defined movement or physical force
|
|
514
|
-
*/ var PhysXDynamicCollider = /*#__PURE__*/ function(
|
|
515
|
-
_inherits(PhysXDynamicCollider,
|
|
504
|
+
*/ var PhysXDynamicCollider = /*#__PURE__*/ function(PhysXCollider) {
|
|
505
|
+
_inherits(PhysXDynamicCollider, PhysXCollider);
|
|
516
506
|
function PhysXDynamicCollider(physXPhysics, position, rotation) {
|
|
517
507
|
var _this;
|
|
518
|
-
_this =
|
|
508
|
+
_this = PhysXCollider.call(this, physXPhysics) || this;
|
|
519
509
|
var transform = _this._transform(position, rotation);
|
|
520
510
|
_this._pxActor = physXPhysics._pxPhysics.createRigidDynamic(transform);
|
|
521
511
|
return _this;
|
|
522
512
|
}
|
|
523
513
|
var _proto = PhysXDynamicCollider.prototype;
|
|
524
514
|
/**
|
|
515
|
+
* {@inheritDoc IDynamicCollider.getLinearDamping }
|
|
516
|
+
*/ _proto.getLinearDamping = function getLinearDamping() {
|
|
517
|
+
return this._pxActor.getLinearDamping();
|
|
518
|
+
};
|
|
519
|
+
/**
|
|
525
520
|
* {@inheritDoc IDynamicCollider.setLinearDamping }
|
|
526
521
|
*/ _proto.setLinearDamping = function setLinearDamping(value) {
|
|
527
522
|
this._pxActor.setLinearDamping(value);
|
|
528
523
|
};
|
|
529
524
|
/**
|
|
525
|
+
* {@inheritDoc IDynamicCollider.getAngularDamping }
|
|
526
|
+
*/ _proto.getAngularDamping = function getAngularDamping() {
|
|
527
|
+
return this._pxActor.getAngularDamping();
|
|
528
|
+
};
|
|
529
|
+
/**
|
|
530
530
|
* {@inheritDoc IDynamicCollider.setAngularDamping }
|
|
531
531
|
*/ _proto.setAngularDamping = function setAngularDamping(value) {
|
|
532
532
|
this._pxActor.setAngularDamping(value);
|
|
533
533
|
};
|
|
534
534
|
/**
|
|
535
|
+
* {@inheritDoc IDynamicCollider.getLinearVelocity }
|
|
536
|
+
*/ _proto.getLinearVelocity = function getLinearVelocity(out) {
|
|
537
|
+
var velocity = this._pxActor.getLinearVelocity();
|
|
538
|
+
return out.set(velocity.x, velocity.y, velocity.z);
|
|
539
|
+
};
|
|
540
|
+
/**
|
|
535
541
|
* {@inheritDoc IDynamicCollider.setLinearVelocity }
|
|
536
542
|
*/ _proto.setLinearVelocity = function setLinearVelocity(value) {
|
|
537
543
|
this._pxActor.setLinearVelocity(value, true);
|
|
538
544
|
};
|
|
539
545
|
/**
|
|
546
|
+
* {@inheritDoc IDynamicCollider.getAngularVelocity }
|
|
547
|
+
*/ _proto.getAngularVelocity = function getAngularVelocity(out) {
|
|
548
|
+
var velocity = this._pxActor.getAngularVelocity();
|
|
549
|
+
return out.set(velocity.x, velocity.y, velocity.z);
|
|
550
|
+
};
|
|
551
|
+
/**
|
|
540
552
|
* {@inheritDoc IDynamicCollider.setAngularVelocity }
|
|
541
553
|
*/ _proto.setAngularVelocity = function setAngularVelocity(value) {
|
|
542
554
|
this._pxActor.setAngularVelocity(value, true);
|
|
@@ -547,6 +559,12 @@ var CollisionDetectionMode;
|
|
|
547
559
|
this._pxActor.setMass(value);
|
|
548
560
|
};
|
|
549
561
|
/**
|
|
562
|
+
* {@inheritDoc IDynamicCollider.getCenterOfMass }
|
|
563
|
+
*/ _proto.getCenterOfMass = function getCenterOfMass(out) {
|
|
564
|
+
var translation = this._pxActor.getCMassLocalPose().translation;
|
|
565
|
+
return out.set(translation.x, translation.y, translation.z);
|
|
566
|
+
};
|
|
567
|
+
/**
|
|
550
568
|
* {@inheritDoc IDynamicCollider.setCenterOfMass }
|
|
551
569
|
*/ _proto.setCenterOfMass = function setCenterOfMass(position) {
|
|
552
570
|
this._pxActor.setCMassLocalPose(position);
|
|
@@ -557,11 +575,27 @@ var CollisionDetectionMode;
|
|
|
557
575
|
this._pxActor.setMassSpaceInertiaTensor(value);
|
|
558
576
|
};
|
|
559
577
|
/**
|
|
578
|
+
* {@inheritDoc IDynamicCollider.getInertiaTensor }
|
|
579
|
+
*/ _proto.getInertiaTensor = function getInertiaTensor(out) {
|
|
580
|
+
var inertia = this._pxActor.getMassSpaceInertiaTensor();
|
|
581
|
+
return out.set(inertia.x, inertia.y, inertia.z);
|
|
582
|
+
};
|
|
583
|
+
/**
|
|
584
|
+
* {@inheritDoc IDynamicCollider.setMassAndUpdateInertia }
|
|
585
|
+
*/ _proto.setMassAndUpdateInertia = function setMassAndUpdateInertia(mass) {
|
|
586
|
+
this._pxActor.setMassAndUpdateInertia(mass);
|
|
587
|
+
};
|
|
588
|
+
/**
|
|
560
589
|
* {@inheritDoc IDynamicCollider.setMaxAngularVelocity }
|
|
561
590
|
*/ _proto.setMaxAngularVelocity = function setMaxAngularVelocity(value) {
|
|
562
591
|
this._pxActor.setMaxAngularVelocity(value);
|
|
563
592
|
};
|
|
564
593
|
/**
|
|
594
|
+
* {@inheritDoc IDynamicCollider.getMaxDepenetrationVelocity }
|
|
595
|
+
*/ _proto.getMaxDepenetrationVelocity = function getMaxDepenetrationVelocity() {
|
|
596
|
+
return this._pxActor.getMaxDepenetrationVelocity();
|
|
597
|
+
};
|
|
598
|
+
/**
|
|
565
599
|
* {@inheritDoc IDynamicCollider.setMaxDepenetrationVelocity }
|
|
566
600
|
*/ _proto.setMaxDepenetrationVelocity = function setMaxDepenetrationVelocity(value) {
|
|
567
601
|
this._pxActor.setMaxDepenetrationVelocity(value);
|
|
@@ -580,18 +614,20 @@ var CollisionDetectionMode;
|
|
|
580
614
|
/**
|
|
581
615
|
* {@inheritDoc IDynamicCollider.setCollisionDetectionMode }
|
|
582
616
|
*/ _proto.setCollisionDetectionMode = function setCollisionDetectionMode(value) {
|
|
617
|
+
var physX = this._physXPhysics._physX;
|
|
583
618
|
switch(value){
|
|
584
619
|
case 1:
|
|
585
|
-
this._pxActor.setRigidBodyFlag(
|
|
620
|
+
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_CCD, true);
|
|
586
621
|
break;
|
|
587
622
|
case 2:
|
|
588
|
-
this._pxActor.setRigidBodyFlag(
|
|
623
|
+
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_CCD, false);
|
|
624
|
+
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_CCD_FRICTION, true);
|
|
589
625
|
break;
|
|
590
626
|
case 3:
|
|
591
|
-
this._pxActor.setRigidBodyFlag(
|
|
627
|
+
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_CCD, false);
|
|
628
|
+
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_SPECULATIVE_CCD, true);
|
|
592
629
|
break;
|
|
593
630
|
case 0:
|
|
594
|
-
var physX = this._physXPhysics._physX;
|
|
595
631
|
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_CCD, false);
|
|
596
632
|
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_CCD_FRICTION, false);
|
|
597
633
|
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_SPECULATIVE_CCD, false);
|
|
@@ -652,18 +688,19 @@ var CollisionDetectionMode;
|
|
|
652
688
|
return this._pxActor.putToSleep();
|
|
653
689
|
};
|
|
654
690
|
/**
|
|
691
|
+
* {@inheritDoc IDynamicCollider.isSleeping }
|
|
692
|
+
*/ _proto.isSleeping = function isSleeping() {
|
|
693
|
+
return this._pxActor.isSleeping();
|
|
694
|
+
};
|
|
695
|
+
/**
|
|
655
696
|
* {@inheritDoc IDynamicCollider.wakeUp }
|
|
656
697
|
*/ _proto.wakeUp = function wakeUp() {
|
|
657
698
|
return this._pxActor.wakeUp();
|
|
658
699
|
};
|
|
659
700
|
return PhysXDynamicCollider;
|
|
660
701
|
}(PhysXCollider);
|
|
661
|
-
(
|
|
662
|
-
|
|
663
|
-
})();
|
|
664
|
-
(function() {
|
|
665
|
-
PhysXDynamicCollider._tempRotation = new Quaternion();
|
|
666
|
-
})();
|
|
702
|
+
PhysXDynamicCollider._tempTranslation = new Vector3();
|
|
703
|
+
PhysXDynamicCollider._tempRotation = new Quaternion();
|
|
667
704
|
|
|
668
705
|
var PhysXPhysicsManager = function PhysXPhysicsManager() {
|
|
669
706
|
/** @internal */ this._eventMap = {};
|
|
@@ -712,15 +749,6 @@ var PhysXPhysicsManager = function PhysXPhysicsManager() {
|
|
|
712
749
|
};
|
|
713
750
|
return PhysXPhysicsMaterial;
|
|
714
751
|
}();
|
|
715
|
-
var /**
|
|
716
|
-
* Describes how physics materials of the colliding objects are combined.
|
|
717
|
-
*/ CombineMode;
|
|
718
|
-
(function(CombineMode) {
|
|
719
|
-
CombineMode[CombineMode[/** Averages the friction/bounce of the two colliding materials. */ "Average"] = 0] = "Average";
|
|
720
|
-
CombineMode[CombineMode[/** Uses the smaller friction/bounce of the two colliding materials. */ "Minimum"] = 1] = "Minimum";
|
|
721
|
-
CombineMode[CombineMode[/** Multiplies the friction/bounce of the two colliding materials. */ "Multiply"] = 2] = "Multiply";
|
|
722
|
-
CombineMode[CombineMode[/** Uses the larger friction/bounce of the two colliding materials. */ "Maximum"] = 3] = "Maximum";
|
|
723
|
-
})(CombineMode || (CombineMode = {}));
|
|
724
752
|
|
|
725
753
|
/**
|
|
726
754
|
* A manager is a collection of colliders and constraints which can interact.
|
|
@@ -783,42 +811,29 @@ var /**
|
|
|
783
811
|
this._pxScene.setGravity(value);
|
|
784
812
|
};
|
|
785
813
|
/**
|
|
786
|
-
* {@inheritDoc IPhysicsManager.addColliderShape }
|
|
787
|
-
*/ _proto.addColliderShape = function addColliderShape(colliderShape) {
|
|
788
|
-
this._physXManager._eventMap[colliderShape._id] = {};
|
|
789
|
-
};
|
|
790
|
-
/**
|
|
791
|
-
* {@inheritDoc IPhysicsManager.removeColliderShape }
|
|
792
|
-
*/ _proto.removeColliderShape = function removeColliderShape(colliderShape) {
|
|
793
|
-
var _this = this, eventPool = _this._eventPool, currentEvents = _this._currentEvents;
|
|
794
|
-
var id = colliderShape._id;
|
|
795
|
-
var _this__physXManager = this._physXManager, eventMap = _this__physXManager._eventMap;
|
|
796
|
-
currentEvents.forEach(function(event, i) {
|
|
797
|
-
if (event.index1 == id) {
|
|
798
|
-
currentEvents.deleteByIndex(i);
|
|
799
|
-
eventPool.push(event);
|
|
800
|
-
} else if (event.index2 == id) {
|
|
801
|
-
currentEvents.deleteByIndex(i);
|
|
802
|
-
eventPool.push(event);
|
|
803
|
-
// If the shape is big index, should clear from the small index shape subMap
|
|
804
|
-
eventMap[event.index1][id] = undefined;
|
|
805
|
-
}
|
|
806
|
-
});
|
|
807
|
-
delete eventMap[id];
|
|
808
|
-
};
|
|
809
|
-
/**
|
|
810
814
|
* {@inheritDoc IPhysicsManager.addCollider }
|
|
811
815
|
*/ _proto.addCollider = function addCollider(collider) {
|
|
816
|
+
collider._scene = this;
|
|
812
817
|
this._pxScene.addActor(collider._pxActor, null);
|
|
818
|
+
var shapes = collider._shapes;
|
|
819
|
+
for(var i = 0, n = shapes.length; i < n; i++){
|
|
820
|
+
this._addColliderShape(shapes[i]._id);
|
|
821
|
+
}
|
|
813
822
|
};
|
|
814
823
|
/**
|
|
815
824
|
* {@inheritDoc IPhysicsManager.removeCollider }
|
|
816
825
|
*/ _proto.removeCollider = function removeCollider(collider) {
|
|
826
|
+
collider._scene = null;
|
|
817
827
|
this._pxScene.removeActor(collider._pxActor, true);
|
|
828
|
+
var shapes = collider._shapes;
|
|
829
|
+
for(var i = 0, n = shapes.length; i < n; i++){
|
|
830
|
+
this._removeColliderShape(shapes[i]._id);
|
|
831
|
+
}
|
|
818
832
|
};
|
|
819
833
|
/**
|
|
820
834
|
* {@inheritDoc IPhysicsManager.addCharacterController }
|
|
821
835
|
*/ _proto.addCharacterController = function addCharacterController(characterController) {
|
|
836
|
+
characterController._scene = this;
|
|
822
837
|
// Physx have no API to remove/readd cct into scene.
|
|
823
838
|
if (!characterController._pxController) {
|
|
824
839
|
var shape = characterController._shape;
|
|
@@ -828,6 +843,7 @@ var /**
|
|
|
828
843
|
lastPXManager && characterController._destroyPXController();
|
|
829
844
|
characterController._createPXController(this, shape);
|
|
830
845
|
}
|
|
846
|
+
this._addColliderShape(shape._id);
|
|
831
847
|
}
|
|
832
848
|
}
|
|
833
849
|
characterController._pxManager = this;
|
|
@@ -835,7 +851,11 @@ var /**
|
|
|
835
851
|
/**
|
|
836
852
|
* {@inheritDoc IPhysicsManager.removeCharacterController }
|
|
837
853
|
*/ _proto.removeCharacterController = function removeCharacterController(characterController) {
|
|
854
|
+
characterController._scene = null;
|
|
838
855
|
characterController._pxManager = null;
|
|
856
|
+
characterController._destroyPXController();
|
|
857
|
+
var shape = characterController._shape;
|
|
858
|
+
shape && this._removeColliderShape(shape._id);
|
|
839
859
|
};
|
|
840
860
|
/**
|
|
841
861
|
* {@inheritDoc IPhysicsManager.update }
|
|
@@ -878,6 +898,29 @@ var /**
|
|
|
878
898
|
}
|
|
879
899
|
return pxControllerManager;
|
|
880
900
|
};
|
|
901
|
+
/**
|
|
902
|
+
* @internal
|
|
903
|
+
*/ _proto._addColliderShape = function _addColliderShape(id) {
|
|
904
|
+
this._physXManager._eventMap[id] = {};
|
|
905
|
+
};
|
|
906
|
+
/**
|
|
907
|
+
* @internal
|
|
908
|
+
*/ _proto._removeColliderShape = function _removeColliderShape(id) {
|
|
909
|
+
var _this = this, eventPool = _this._eventPool, currentEvents = _this._currentEvents;
|
|
910
|
+
var _this__physXManager = this._physXManager, eventMap = _this__physXManager._eventMap;
|
|
911
|
+
currentEvents.forEach(function(event, i) {
|
|
912
|
+
if (event.index1 == id) {
|
|
913
|
+
currentEvents.deleteByIndex(i);
|
|
914
|
+
eventPool.push(event);
|
|
915
|
+
} else if (event.index2 == id) {
|
|
916
|
+
currentEvents.deleteByIndex(i);
|
|
917
|
+
eventPool.push(event);
|
|
918
|
+
// If the shape is big index, should clear from the small index shape subMap
|
|
919
|
+
eventMap[event.index1][id] = undefined;
|
|
920
|
+
}
|
|
921
|
+
});
|
|
922
|
+
delete eventMap[id];
|
|
923
|
+
};
|
|
881
924
|
_proto._simulate = function _simulate(elapsedTime) {
|
|
882
925
|
this._pxScene.simulate(elapsedTime, true);
|
|
883
926
|
};
|
|
@@ -915,31 +958,8 @@ var /**
|
|
|
915
958
|
};
|
|
916
959
|
return PhysXPhysicsScene;
|
|
917
960
|
}();
|
|
918
|
-
(
|
|
919
|
-
|
|
920
|
-
})();
|
|
921
|
-
(function() {
|
|
922
|
-
PhysXPhysicsScene._tempNormal = new Vector3();
|
|
923
|
-
})();
|
|
924
|
-
var /**
|
|
925
|
-
* Filtering flags for scene queries.
|
|
926
|
-
*/ QueryFlag;
|
|
927
|
-
(function(QueryFlag) {
|
|
928
|
-
QueryFlag[QueryFlag["STATIC"] = 1] = "STATIC";
|
|
929
|
-
QueryFlag[QueryFlag["DYNAMIC"] = 2] = "DYNAMIC";
|
|
930
|
-
QueryFlag[QueryFlag["PRE_FILTER"] = 4] = "PRE_FILTER";
|
|
931
|
-
QueryFlag[QueryFlag["POST_FILTER"] = 8] = "POST_FILTER";
|
|
932
|
-
QueryFlag[QueryFlag["ANY_HIT"] = 16] = "ANY_HIT";
|
|
933
|
-
QueryFlag[QueryFlag["NO_BLOCK"] = 32] = "NO_BLOCK";
|
|
934
|
-
})(QueryFlag || (QueryFlag = {}));
|
|
935
|
-
var /**
|
|
936
|
-
* Physics state
|
|
937
|
-
*/ TriggerEventState;
|
|
938
|
-
(function(TriggerEventState) {
|
|
939
|
-
TriggerEventState[TriggerEventState["Enter"] = 0] = "Enter";
|
|
940
|
-
TriggerEventState[TriggerEventState["Stay"] = 1] = "Stay";
|
|
941
|
-
TriggerEventState[TriggerEventState["Exit"] = 2] = "Exit";
|
|
942
|
-
})(TriggerEventState || (TriggerEventState = {}));
|
|
961
|
+
PhysXPhysicsScene._tempPosition = new Vector3();
|
|
962
|
+
PhysXPhysicsScene._tempNormal = new Vector3();
|
|
943
963
|
/**
|
|
944
964
|
* Trigger event to store interactive object ids and state.
|
|
945
965
|
*/ var TriggerEvent = function TriggerEvent(index1, index2) {
|
|
@@ -950,11 +970,11 @@ var /**
|
|
|
950
970
|
/**
|
|
951
971
|
* A static collider component that will not move.
|
|
952
972
|
* @remarks Mostly used for object which always stays at the same place and never moves around.
|
|
953
|
-
*/ var PhysXStaticCollider = /*#__PURE__*/ function(
|
|
954
|
-
_inherits(PhysXStaticCollider,
|
|
973
|
+
*/ var PhysXStaticCollider = /*#__PURE__*/ function(PhysXCollider) {
|
|
974
|
+
_inherits(PhysXStaticCollider, PhysXCollider);
|
|
955
975
|
function PhysXStaticCollider(physXPhysics, position, rotation) {
|
|
956
976
|
var _this;
|
|
957
|
-
_this =
|
|
977
|
+
_this = PhysXCollider.call(this, physXPhysics) || this;
|
|
958
978
|
_this._pxActor = physXPhysics._pxPhysics.createRigidStatic(_this._transform(position, rotation));
|
|
959
979
|
return _this;
|
|
960
980
|
}
|
|
@@ -963,18 +983,17 @@ var /**
|
|
|
963
983
|
|
|
964
984
|
/**
|
|
965
985
|
* PhysX runtime mode.
|
|
966
|
-
*/ var PhysXRuntimeMode
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
PhysXRuntimeMode
|
|
971
|
-
}
|
|
986
|
+
*/ var PhysXRuntimeMode = /*#__PURE__*/ function(PhysXRuntimeMode) {
|
|
987
|
+
/** Use webAssembly mode first, if WebAssembly mode is not supported, roll back to JavaScript mode. */ PhysXRuntimeMode[PhysXRuntimeMode["Auto"] = 0] = "Auto";
|
|
988
|
+
/** WebAssembly mode. */ PhysXRuntimeMode[PhysXRuntimeMode["WebAssembly"] = 1] = "WebAssembly";
|
|
989
|
+
/** JavaScript mode. */ PhysXRuntimeMode[PhysXRuntimeMode["JavaScript"] = 2] = "JavaScript";
|
|
990
|
+
return PhysXRuntimeMode;
|
|
991
|
+
}({});
|
|
972
992
|
|
|
973
993
|
/**
|
|
974
994
|
* a base interface providing common functionality for PhysX joints
|
|
975
995
|
*/ var PhysXJoint = /*#__PURE__*/ function() {
|
|
976
996
|
function PhysXJoint(physXPhysics) {
|
|
977
|
-
this._connectedAnchor = new Vector3();
|
|
978
997
|
this._breakForce = Number.MAX_VALUE;
|
|
979
998
|
this._breakTorque = Number.MAX_VALUE;
|
|
980
999
|
this._physXPhysics = physXPhysics;
|
|
@@ -983,34 +1002,38 @@ var /**
|
|
|
983
1002
|
/**
|
|
984
1003
|
* {@inheritDoc IJoint.setConnectedCollider }
|
|
985
1004
|
*/ _proto.setConnectedCollider = function setConnectedCollider(value) {
|
|
986
|
-
var
|
|
987
|
-
this._pxJoint.setActors(((
|
|
1005
|
+
var _this__collider;
|
|
1006
|
+
this._pxJoint.setActors(((_this__collider = this._collider) == null ? void 0 : _this__collider._pxActor) || null, (value == null ? void 0 : value._pxActor) || null);
|
|
988
1007
|
};
|
|
989
1008
|
/**
|
|
990
1009
|
* {@inheritDoc IJoint.setConnectedAnchor }
|
|
991
|
-
*/ _proto.
|
|
992
|
-
this._connectedAnchor.copyFrom(value);
|
|
1010
|
+
*/ _proto.setAnchor = function setAnchor(value) {
|
|
993
1011
|
this._setLocalPose(0, value, PhysXJoint._defaultQuat);
|
|
994
1012
|
};
|
|
995
1013
|
/**
|
|
996
|
-
* {@inheritDoc IJoint.
|
|
997
|
-
*/ _proto.
|
|
998
|
-
this.
|
|
999
|
-
};
|
|
1000
|
-
/**
|
|
1001
|
-
* {@inheritDoc IJoint.setConnectedInertiaScale }
|
|
1002
|
-
*/ _proto.setConnectedInertiaScale = function setConnectedInertiaScale(value) {
|
|
1003
|
-
this._pxJoint.setInvInertiaScale0(1 / value);
|
|
1014
|
+
* {@inheritDoc IJoint.setConnectedAnchor }
|
|
1015
|
+
*/ _proto.setConnectedAnchor = function setConnectedAnchor(value) {
|
|
1016
|
+
this._setLocalPose(1, value, PhysXJoint._defaultQuat);
|
|
1004
1017
|
};
|
|
1005
1018
|
/**
|
|
1006
1019
|
* {@inheritDoc IJoint.setMassScale }
|
|
1007
1020
|
*/ _proto.setMassScale = function setMassScale(value) {
|
|
1021
|
+
this._pxJoint.setInvMassScale0(1 / value);
|
|
1022
|
+
};
|
|
1023
|
+
/**
|
|
1024
|
+
* {@inheritDoc IJoint.setConnectedMassScale }
|
|
1025
|
+
*/ _proto.setConnectedMassScale = function setConnectedMassScale(value) {
|
|
1008
1026
|
this._pxJoint.setInvMassScale1(1 / value);
|
|
1009
1027
|
};
|
|
1010
1028
|
/**
|
|
1011
1029
|
* {@inheritDoc IJoint.setInertiaScale }
|
|
1012
1030
|
*/ _proto.setInertiaScale = function setInertiaScale(value) {
|
|
1013
|
-
this._pxJoint.
|
|
1031
|
+
this._pxJoint.setInvInertiaScale0(value);
|
|
1032
|
+
};
|
|
1033
|
+
/**
|
|
1034
|
+
* {@inheritDoc IJoint.setConnectedInertiaScale }
|
|
1035
|
+
*/ _proto.setConnectedInertiaScale = function setConnectedInertiaScale(value) {
|
|
1036
|
+
this._pxJoint.setInvInertiaScale1(value);
|
|
1014
1037
|
};
|
|
1015
1038
|
/**
|
|
1016
1039
|
* {@inheritDoc IJoint.setBreakForce }
|
|
@@ -1025,6 +1048,14 @@ var /**
|
|
|
1025
1048
|
this._pxJoint.setBreakForce(this._breakForce, this._breakTorque);
|
|
1026
1049
|
};
|
|
1027
1050
|
/**
|
|
1051
|
+
* {@inheritDoc IJoint.destroy }
|
|
1052
|
+
*/ _proto.destroy = function destroy() {
|
|
1053
|
+
if (!this._pxJoint) return;
|
|
1054
|
+
this._pxJoint.release();
|
|
1055
|
+
this._pxJoint = null;
|
|
1056
|
+
this._collider = null;
|
|
1057
|
+
};
|
|
1058
|
+
/**
|
|
1028
1059
|
* Set the joint local pose for an actor.
|
|
1029
1060
|
* @param actor 0 for the first actor, 1 for the second actor.
|
|
1030
1061
|
* @param position the local position for the actor this joint
|
|
@@ -1034,15 +1065,8 @@ var /**
|
|
|
1034
1065
|
};
|
|
1035
1066
|
return PhysXJoint;
|
|
1036
1067
|
}();
|
|
1037
|
-
(
|
|
1038
|
-
|
|
1039
|
-
})();
|
|
1040
|
-
(function() {
|
|
1041
|
-
PhysXJoint._defaultVec = new Vector3();
|
|
1042
|
-
})();
|
|
1043
|
-
(function() {
|
|
1044
|
-
PhysXJoint._defaultQuat = new Quaternion();
|
|
1045
|
-
})();
|
|
1068
|
+
PhysXJoint._defaultVec = new Vector3();
|
|
1069
|
+
PhysXJoint._defaultQuat = new Quaternion();
|
|
1046
1070
|
|
|
1047
1071
|
/**
|
|
1048
1072
|
* A fixed joint permits no relative movement between two colliders. ie the bodies are glued together.
|
|
@@ -1052,7 +1076,7 @@ var /**
|
|
|
1052
1076
|
var _this;
|
|
1053
1077
|
_this = PhysXJoint1.call(this, physXPhysics) || this;
|
|
1054
1078
|
_this._collider = collider;
|
|
1055
|
-
_this._pxJoint = physXPhysics._pxPhysics.createFixedJoint(
|
|
1079
|
+
_this._pxJoint = physXPhysics._pxPhysics.createFixedJoint(collider._pxActor, PhysXJoint._defaultVec, PhysXJoint._defaultQuat, null, PhysXJoint._defaultVec, PhysXJoint._defaultQuat);
|
|
1056
1080
|
return _this;
|
|
1057
1081
|
}
|
|
1058
1082
|
return PhysXFixedJoint;
|
|
@@ -1064,31 +1088,32 @@ var /**
|
|
|
1064
1088
|
_inherits(PhysXHingeJoint, PhysXJoint1);
|
|
1065
1089
|
function PhysXHingeJoint(physXPhysics, collider) {
|
|
1066
1090
|
var _this;
|
|
1067
|
-
_this = PhysXJoint1.call(this, physXPhysics) || this;
|
|
1068
|
-
_this._axisRotationQuaternion = new Quaternion();
|
|
1069
|
-
_this._swingOffset = new Vector3();
|
|
1091
|
+
_this = PhysXJoint1.call(this, physXPhysics) || this, _this._axisRotationQuaternion = new Quaternion();
|
|
1070
1092
|
_this._collider = collider;
|
|
1071
|
-
_this._pxJoint = physXPhysics._pxPhysics.createRevoluteJoint(
|
|
1093
|
+
_this._pxJoint = physXPhysics._pxPhysics.createRevoluteJoint(collider._pxActor, PhysXJoint._defaultVec, PhysXJoint._defaultQuat, null, PhysXJoint._defaultVec, PhysXJoint._defaultQuat);
|
|
1072
1094
|
return _this;
|
|
1073
1095
|
}
|
|
1074
1096
|
var _proto = PhysXHingeJoint.prototype;
|
|
1075
1097
|
/**
|
|
1076
1098
|
* {@inheritDoc IHingeJoint.setAxis }
|
|
1077
1099
|
*/ _proto.setAxis = function setAxis(value) {
|
|
1078
|
-
var xAxis =
|
|
1100
|
+
var xAxis = PhysXHingeJoint._xAxis;
|
|
1079
1101
|
var axisRotationQuaternion = this._axisRotationQuaternion;
|
|
1080
1102
|
xAxis.set(1, 0, 0);
|
|
1081
1103
|
value.normalize();
|
|
1082
1104
|
var angle = Math.acos(Vector3.dot(xAxis, value));
|
|
1083
1105
|
Vector3.cross(xAxis, value, xAxis);
|
|
1084
1106
|
Quaternion.rotationAxisAngle(xAxis, angle, axisRotationQuaternion);
|
|
1085
|
-
this._setLocalPose(0, this.
|
|
1107
|
+
this._setLocalPose(0, this._anchor, axisRotationQuaternion);
|
|
1108
|
+
this._setLocalPose(1, this._connectedAnchor, axisRotationQuaternion);
|
|
1086
1109
|
};
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1110
|
+
_proto.setAnchor = function setAnchor(value) {
|
|
1111
|
+
this._setLocalPose(0, value, this._axisRotationQuaternion);
|
|
1112
|
+
this._anchor = value;
|
|
1113
|
+
};
|
|
1114
|
+
_proto.setConnectedAnchor = function setConnectedAnchor(value) {
|
|
1115
|
+
this._setLocalPose(1, value, this._axisRotationQuaternion);
|
|
1116
|
+
this._connectedAnchor = value;
|
|
1092
1117
|
};
|
|
1093
1118
|
/**
|
|
1094
1119
|
* {@inheritDoc IHingeJoint.getAngle }
|
|
@@ -1133,6 +1158,7 @@ var /**
|
|
|
1133
1158
|
};
|
|
1134
1159
|
return PhysXHingeJoint;
|
|
1135
1160
|
}(PhysXJoint);
|
|
1161
|
+
PhysXHingeJoint._xAxis = new Vector3(1, 0, 0);
|
|
1136
1162
|
|
|
1137
1163
|
/**
|
|
1138
1164
|
* a joint that maintains an upper or lower bound (or both) on the distance between two points on different objects
|
|
@@ -1141,7 +1167,6 @@ var /**
|
|
|
1141
1167
|
function PhysXSpringJoint(physXPhysics, collider) {
|
|
1142
1168
|
var _this;
|
|
1143
1169
|
_this = PhysXJoint1.call(this, physXPhysics) || this;
|
|
1144
|
-
_this._swingOffset = new Vector3();
|
|
1145
1170
|
_this._collider = collider;
|
|
1146
1171
|
_this._pxJoint = physXPhysics._pxPhysics.createDistanceJoint(null, PhysXJoint._defaultVec, PhysXJoint._defaultQuat, collider._pxActor, PhysXJoint._defaultVec, PhysXJoint._defaultQuat);
|
|
1147
1172
|
_this._pxJoint.setDistanceJointFlag(2, true); // enable max distance;
|
|
@@ -1151,12 +1176,6 @@ var /**
|
|
|
1151
1176
|
}
|
|
1152
1177
|
var _proto = PhysXSpringJoint.prototype;
|
|
1153
1178
|
/**
|
|
1154
|
-
* {@inheritDoc ISpringJoint.setSwingOffset }
|
|
1155
|
-
*/ _proto.setSwingOffset = function setSwingOffset(value) {
|
|
1156
|
-
this._swingOffset.copyFrom(value);
|
|
1157
|
-
this._setLocalPose(1, value, PhysXJoint._defaultQuat);
|
|
1158
|
-
};
|
|
1159
|
-
/**
|
|
1160
1179
|
* {@inheritDoc ISpringJoint.setMinDistance }
|
|
1161
1180
|
*/ _proto.setMinDistance = function setMinDistance(distance) {
|
|
1162
1181
|
this._pxJoint.setMinDistance(distance);
|
|
@@ -1203,12 +1222,11 @@ var /**
|
|
|
1203
1222
|
|
|
1204
1223
|
/**
|
|
1205
1224
|
* Sphere collider shape in PhysX.
|
|
1206
|
-
*/ var PhysXSphereColliderShape = /*#__PURE__*/ function(
|
|
1207
|
-
_inherits(PhysXSphereColliderShape,
|
|
1225
|
+
*/ var PhysXSphereColliderShape = /*#__PURE__*/ function(PhysXColliderShape) {
|
|
1226
|
+
_inherits(PhysXSphereColliderShape, PhysXColliderShape);
|
|
1208
1227
|
function PhysXSphereColliderShape(physXPhysics, uniqueID, radius, material) {
|
|
1209
1228
|
var _this;
|
|
1210
|
-
_this =
|
|
1211
|
-
_this._maxScale = 1;
|
|
1229
|
+
_this = PhysXColliderShape.call(this, physXPhysics) || this, _this._maxScale = 1;
|
|
1212
1230
|
_this._radius = radius;
|
|
1213
1231
|
_this._pxGeometry = new physXPhysics._physX.PxSphereGeometry(_this._radius * _this._maxScale);
|
|
1214
1232
|
_this._initialize(material, uniqueID);
|
|
@@ -1226,7 +1244,7 @@ var /**
|
|
|
1226
1244
|
/**
|
|
1227
1245
|
* {@inheritDoc IColliderShape.setWorldScale }
|
|
1228
1246
|
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
1229
|
-
|
|
1247
|
+
PhysXColliderShape.prototype.setWorldScale.call(this, scale);
|
|
1230
1248
|
this._maxScale = Math.max(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z));
|
|
1231
1249
|
this._pxGeometry.radius = this._radius * this._maxScale;
|
|
1232
1250
|
this._pxShape.setGeometry(this._pxGeometry);
|
|
@@ -1264,7 +1282,7 @@ var /**
|
|
|
1264
1282
|
if (runtimeMode == PhysXRuntimeMode.Auto) {
|
|
1265
1283
|
var supported = function() {
|
|
1266
1284
|
try {
|
|
1267
|
-
if (typeof WebAssembly === "object" && typeof WebAssembly.instantiate === "function") {
|
|
1285
|
+
if ((typeof WebAssembly === "undefined" ? "undefined" : _type_of(WebAssembly)) === "object" && typeof WebAssembly.instantiate === "function") {
|
|
1268
1286
|
var module = new WebAssembly.Module(Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00));
|
|
1269
1287
|
if (_instanceof(module, WebAssembly.Module)) return _instanceof(new WebAssembly.Instance(module), WebAssembly.Instance);
|
|
1270
1288
|
}
|
|
@@ -1280,7 +1298,7 @@ var /**
|
|
|
1280
1298
|
if (runtimeMode == PhysXRuntimeMode.JavaScript) {
|
|
1281
1299
|
script.src = "https://mdn.alipayobjects.com/rms/afts/file/A*rnDeR58NNGoAAAAAAAAAAAAAARQnAQ/physx.release.js.js";
|
|
1282
1300
|
} else if (runtimeMode == PhysXRuntimeMode.WebAssembly) {
|
|
1283
|
-
script.src = "https://mdn.alipayobjects.com/rms/afts/file/A*
|
|
1301
|
+
script.src = "https://mdn.alipayobjects.com/rms/afts/file/A*rP-bRKBDf0YAAAAAAAAAAAAAARQnAQ/physx.release.js";
|
|
1284
1302
|
}
|
|
1285
1303
|
});
|
|
1286
1304
|
var initializePromise = new Promise(function(resolve, reject) {
|
|
@@ -1386,15 +1404,9 @@ var /**
|
|
|
1386
1404
|
};
|
|
1387
1405
|
return PhysXPhysics;
|
|
1388
1406
|
}();
|
|
1389
|
-
var InitializeState;
|
|
1390
|
-
(function(InitializeState) {
|
|
1391
|
-
InitializeState[InitializeState["Uninitialized"] = 0] = "Uninitialized";
|
|
1392
|
-
InitializeState[InitializeState["Initializing"] = 1] = "Initializing";
|
|
1393
|
-
InitializeState[InitializeState["Initialized"] = 2] = "Initialized";
|
|
1394
|
-
})(InitializeState || (InitializeState = {}));
|
|
1395
1407
|
|
|
1396
1408
|
//@ts-ignore
|
|
1397
|
-
var version = "1.
|
|
1409
|
+
var version = "1.4.0-alpha.1";
|
|
1398
1410
|
console.log("Galacean PhysX version: " + version);
|
|
1399
1411
|
|
|
1400
1412
|
export { PhysXPhysics, PhysXRuntimeMode, version };
|