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