@galacean/engine-physics-physx 0.9.0 → 1.0.0-beta.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 +2 -2
- package/dist/browser.js +222 -197
- package/dist/browser.min.js +1 -1
- package/dist/main.js +222 -197
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +38526 -7553
- package/dist/module.js +220 -197
- package/dist/module.js.map +1 -1
- package/libs/physx.release.js +1 -1
- package/libs/physx.release.js.js +32 -31
- package/libs/physx.release.js.mem +0 -0
- package/package.json +4 -4
- package/types/PhysXCharacterController.d.ts +6 -0
- package/types/PhysXCollider.d.ts +3 -0
- package/types/PhysXDynamicCollider.d.ts +2 -1
- package/types/PhysXPhysics.d.ts +21 -17
- package/types/PhysXPhysicsManager.d.ts +5 -4
- package/types/PhysXPhysicsMaterial.d.ts +3 -1
- package/types/PhysXStaticCollider.d.ts +3 -7
- package/types/joint/PhysXFixedJoint.d.ts +3 -2
- package/types/joint/PhysXHingeJoint.d.ts +4 -3
- package/types/joint/PhysXJoint.d.ts +4 -1
- package/types/joint/PhysXSpringJoint.d.ts +2 -1
- package/types/shape/PhysXBoxColliderShape.d.ts +3 -7
- package/types/shape/PhysXCapsuleColliderShape.d.ts +2 -8
- package/types/shape/PhysXColliderShape.d.ts +5 -2
- package/types/shape/PhysXPlaneColliderShape.d.ts +2 -11
- package/types/shape/PhysXSphereColliderShape.d.ts +4 -9
- package/types/StaticInterfaceImplement.d.ts +0 -5
package/dist/main.js
CHANGED
|
@@ -10,28 +10,6 @@ function _instanceof(left, right) {
|
|
|
10
10
|
} else return left instanceof right;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
/******************************************************************************
|
|
14
|
-
Copyright (c) Microsoft Corporation.
|
|
15
|
-
|
|
16
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
17
|
-
purpose with or without fee is hereby granted.
|
|
18
|
-
|
|
19
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
20
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
21
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
22
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
23
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
24
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
25
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
26
|
-
***************************************************************************** */
|
|
27
|
-
|
|
28
|
-
function __decorate(decorators, target, key, desc) {
|
|
29
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
30
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
31
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
32
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
13
|
/**
|
|
36
14
|
* PhysX runtime mode.
|
|
37
15
|
*/ exports.PhysXRuntimeMode = void 0;
|
|
@@ -64,10 +42,11 @@ function _inherits(subClass, superClass) {
|
|
|
64
42
|
/**
|
|
65
43
|
* a base interface providing common functionality for PhysX joints
|
|
66
44
|
*/ var PhysXJoint = /*#__PURE__*/ function() {
|
|
67
|
-
function PhysXJoint() {
|
|
45
|
+
function PhysXJoint(physXPhysics) {
|
|
68
46
|
this._connectedAnchor = new engine.Vector3();
|
|
69
47
|
this._breakForce = Number.MAX_VALUE;
|
|
70
48
|
this._breakTorque = Number.MAX_VALUE;
|
|
49
|
+
this._physXPhysics = physXPhysics;
|
|
71
50
|
}
|
|
72
51
|
var _proto = PhysXJoint.prototype;
|
|
73
52
|
/**
|
|
@@ -138,11 +117,11 @@ function _inherits(subClass, superClass) {
|
|
|
138
117
|
* A fixed joint permits no relative movement between two colliders. ie the bodies are glued together.
|
|
139
118
|
*/ var PhysXFixedJoint = /*#__PURE__*/ function(PhysXJoint1) {
|
|
140
119
|
_inherits(PhysXFixedJoint, PhysXJoint1);
|
|
141
|
-
function PhysXFixedJoint(collider) {
|
|
120
|
+
function PhysXFixedJoint(physXPhysics, collider) {
|
|
142
121
|
var _this;
|
|
143
|
-
_this = PhysXJoint1.call(this) || this;
|
|
122
|
+
_this = PhysXJoint1.call(this, physXPhysics) || this;
|
|
144
123
|
_this._collider = collider;
|
|
145
|
-
_this._pxJoint =
|
|
124
|
+
_this._pxJoint = physXPhysics._pxPhysics.createFixedJoint(null, PhysXJoint._defaultVec, PhysXJoint._defaultQuat, collider._pxActor, PhysXJoint._defaultVec, PhysXJoint._defaultQuat);
|
|
146
125
|
return _this;
|
|
147
126
|
}
|
|
148
127
|
return PhysXFixedJoint;
|
|
@@ -152,14 +131,14 @@ function _inherits(subClass, superClass) {
|
|
|
152
131
|
* A joint which behaves in a similar way to a hinge or axle.
|
|
153
132
|
*/ var PhysXHingeJoint = /*#__PURE__*/ function(PhysXJoint1) {
|
|
154
133
|
_inherits(PhysXHingeJoint, PhysXJoint1);
|
|
155
|
-
function PhysXHingeJoint(collider) {
|
|
134
|
+
function PhysXHingeJoint(physXPhysics, collider) {
|
|
156
135
|
var _this;
|
|
157
|
-
_this = PhysXJoint1.call(this) || this;
|
|
136
|
+
_this = PhysXJoint1.call(this, physXPhysics) || this;
|
|
158
137
|
_this._axisRotationQuaternion = new engine.Quaternion();
|
|
159
138
|
_this._swingOffset = new engine.Vector3();
|
|
160
139
|
_this._velocity = new engine.Vector3();
|
|
161
140
|
_this._collider = collider;
|
|
162
|
-
_this._pxJoint =
|
|
141
|
+
_this._pxJoint = physXPhysics._pxPhysics.createRevoluteJoint(null, PhysXJoint._defaultVec, PhysXJoint._defaultQuat, collider._pxActor, PhysXJoint._defaultVec, PhysXJoint._defaultQuat);
|
|
163
142
|
return _this;
|
|
164
143
|
}
|
|
165
144
|
var _proto = PhysXHingeJoint.prototype;
|
|
@@ -230,12 +209,12 @@ function _inherits(subClass, superClass) {
|
|
|
230
209
|
* a joint that maintains an upper or lower bound (or both) on the distance between two points on different objects
|
|
231
210
|
*/ var PhysXSpringJoint = /*#__PURE__*/ function(PhysXJoint1) {
|
|
232
211
|
_inherits(PhysXSpringJoint, PhysXJoint1);
|
|
233
|
-
function PhysXSpringJoint(collider) {
|
|
212
|
+
function PhysXSpringJoint(physXPhysics, collider) {
|
|
234
213
|
var _this;
|
|
235
|
-
_this = PhysXJoint1.call(this) || this;
|
|
214
|
+
_this = PhysXJoint1.call(this, physXPhysics) || this;
|
|
236
215
|
_this._swingOffset = new engine.Vector3();
|
|
237
216
|
_this._collider = collider;
|
|
238
|
-
_this._pxJoint =
|
|
217
|
+
_this._pxJoint = physXPhysics._pxPhysics.createDistanceJoint(null, PhysXJoint._defaultVec, PhysXJoint._defaultQuat, collider._pxActor, PhysXJoint._defaultVec, PhysXJoint._defaultQuat);
|
|
239
218
|
_this._pxJoint.setDistanceJointFlag(2, true); // enable max distance;
|
|
240
219
|
_this._pxJoint.setDistanceJointFlag(4, true); // enable min distance;
|
|
241
220
|
_this._pxJoint.setDistanceJointFlag(8, true); // enable spring;
|
|
@@ -331,24 +310,25 @@ var ShapeFlag;
|
|
|
331
310
|
/**
|
|
332
311
|
* Abstract class for collider shapes.
|
|
333
312
|
*/ var PhysXColliderShape = /*#__PURE__*/ function() {
|
|
334
|
-
function PhysXColliderShape() {
|
|
313
|
+
function PhysXColliderShape(physXPhysics) {
|
|
335
314
|
/** @internal */ this._controllers = new DisorderedArray();
|
|
336
315
|
this._scale = new engine.Vector3(1, 1, 1);
|
|
337
316
|
this._position = new engine.Vector3();
|
|
338
317
|
this._rotation = null;
|
|
339
318
|
this._axis = null;
|
|
340
|
-
this.
|
|
319
|
+
this._physXRotation = new engine.Quaternion();
|
|
341
320
|
this._shapeFlags = 2 | 1;
|
|
342
321
|
/** @internal */ this._pxMaterials = new Array(1);
|
|
322
|
+
this._physXPhysics = physXPhysics;
|
|
343
323
|
}
|
|
344
324
|
var _proto = PhysXColliderShape.prototype;
|
|
345
325
|
/**
|
|
346
326
|
* {@inheritDoc IColliderShape.setRotation }
|
|
347
327
|
*/ _proto.setRotation = function setRotation(value) {
|
|
348
328
|
this._rotation = value;
|
|
349
|
-
engine.Quaternion.rotationYawPitchRoll(value.x, value.y, value.z, this.
|
|
350
|
-
this._axis && engine.Quaternion.multiply(this.
|
|
351
|
-
this.
|
|
329
|
+
engine.Quaternion.rotationYawPitchRoll(value.x, value.y, value.z, this._physXRotation);
|
|
330
|
+
this._axis && engine.Quaternion.multiply(this._physXRotation, this._axis, this._physXRotation);
|
|
331
|
+
this._physXRotation.normalize();
|
|
352
332
|
this._setLocalPose();
|
|
353
333
|
};
|
|
354
334
|
/**
|
|
@@ -357,7 +337,21 @@ var ShapeFlag;
|
|
|
357
337
|
if (value !== this._position) {
|
|
358
338
|
this._position.copyFrom(value);
|
|
359
339
|
}
|
|
340
|
+
var controllers = this._controllers;
|
|
341
|
+
for(var i = 0, n = controllers.length; i < n; i++){
|
|
342
|
+
controllers.get(i)._pxController.setLocalPosition(this._position, this._scale);
|
|
343
|
+
}
|
|
344
|
+
this._setLocalPose();
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* {@inheritDoc IColliderShape.setWorldScale }
|
|
348
|
+
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
349
|
+
this._scale.copyFrom(scale);
|
|
360
350
|
this._setLocalPose();
|
|
351
|
+
var controllers = this._controllers;
|
|
352
|
+
for(var i = 0, n = controllers.length; i < n; i++){
|
|
353
|
+
controllers.get(i)._setLocalPosition(this._position, this._scale);
|
|
354
|
+
}
|
|
361
355
|
};
|
|
362
356
|
/**
|
|
363
357
|
* {@inheritDoc IColliderShape.setContactOffset }
|
|
@@ -391,19 +385,19 @@ var ShapeFlag;
|
|
|
391
385
|
* @internal
|
|
392
386
|
*/ _proto._setShapeFlags = function _setShapeFlags(flags) {
|
|
393
387
|
this._shapeFlags = flags;
|
|
394
|
-
this._pxShape.setFlags(new
|
|
388
|
+
this._pxShape.setFlags(new this._physXPhysics._physX.PxShapeFlags(this._shapeFlags));
|
|
395
389
|
};
|
|
396
390
|
_proto._setLocalPose = function _setLocalPose() {
|
|
397
391
|
var transform = PhysXColliderShape.transform;
|
|
398
392
|
engine.Vector3.multiply(this._position, this._scale, transform.translation);
|
|
399
|
-
transform.rotation = this.
|
|
393
|
+
transform.rotation = this._physXRotation;
|
|
400
394
|
this._pxShape.setLocalPose(transform);
|
|
401
395
|
};
|
|
402
396
|
_proto._initialize = function _initialize(material, id) {
|
|
403
397
|
this._id = id;
|
|
404
398
|
this._pxMaterials[0] = material._pxMaterial;
|
|
405
|
-
this._pxShape =
|
|
406
|
-
this._pxShape.
|
|
399
|
+
this._pxShape = this._physXPhysics._pxPhysics.createShape(this._pxGeometry, material._pxMaterial, true, new this._physXPhysics._physX.PxShapeFlags(this._shapeFlags));
|
|
400
|
+
this._pxShape.setUUID(id);
|
|
407
401
|
};
|
|
408
402
|
_proto._modifyFlag = function _modifyFlag(flag, value) {
|
|
409
403
|
this._shapeFlags = value ? this._shapeFlags | flag : this._shapeFlags & ~flag;
|
|
@@ -424,12 +418,12 @@ var ShapeFlag;
|
|
|
424
418
|
* Box collider shape in PhysX.
|
|
425
419
|
*/ var PhysXBoxColliderShape = /*#__PURE__*/ function(PhysXColliderShape) {
|
|
426
420
|
_inherits(PhysXBoxColliderShape, PhysXColliderShape);
|
|
427
|
-
function PhysXBoxColliderShape(uniqueID, size, material) {
|
|
421
|
+
function PhysXBoxColliderShape(physXPhysics, uniqueID, size, material) {
|
|
428
422
|
var _this;
|
|
429
|
-
_this = PhysXColliderShape.call(this) || this;
|
|
423
|
+
_this = PhysXColliderShape.call(this, physXPhysics) || this;
|
|
430
424
|
/** @internal */ _this._halfSize = new engine.Vector3();
|
|
431
425
|
_this._halfSize.set(size.x * 0.5, size.y * 0.5, size.z * 0.5);
|
|
432
|
-
_this._pxGeometry = new
|
|
426
|
+
_this._pxGeometry = new physXPhysics._physX.PxBoxGeometry(_this._halfSize.x * _this._scale.x, _this._halfSize.y * _this._scale.y, _this._halfSize.z * _this._scale.z);
|
|
433
427
|
_this._initialize(material, uniqueID);
|
|
434
428
|
_this._setLocalPose();
|
|
435
429
|
return _this;
|
|
@@ -438,26 +432,31 @@ var ShapeFlag;
|
|
|
438
432
|
/**
|
|
439
433
|
* {@inheritDoc IBoxColliderShape.setSize }
|
|
440
434
|
*/ _proto.setSize = function setSize(value) {
|
|
435
|
+
var tempExtents = PhysXBoxColliderShape._tempHalfExtents;
|
|
441
436
|
this._halfSize.set(value.x * 0.5, value.y * 0.5, value.z * 0.5);
|
|
442
|
-
engine.Vector3.multiply(this._halfSize, this._scale,
|
|
443
|
-
this._pxGeometry.halfExtents =
|
|
437
|
+
engine.Vector3.multiply(this._halfSize, this._scale, tempExtents);
|
|
438
|
+
this._pxGeometry.halfExtents = tempExtents;
|
|
444
439
|
this._pxShape.setGeometry(this._pxGeometry);
|
|
445
|
-
|
|
446
|
-
for(var i = 0, n = controllers.length; i < n; i++){
|
|
447
|
-
var pxController = controllers.get(i)._pxController;
|
|
448
|
-
pxController.setHalfHeight(this._halfSize.x);
|
|
449
|
-
pxController.setHalfSideExtent(this._halfSize.y);
|
|
450
|
-
pxController.setHalfForwardExtent(this._halfSize.z);
|
|
451
|
-
}
|
|
440
|
+
this._updateController(tempExtents);
|
|
452
441
|
};
|
|
453
442
|
/**
|
|
454
443
|
* {@inheritDoc IColliderShape.setWorldScale }
|
|
455
444
|
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
engine.Vector3.multiply(this._halfSize, this._scale,
|
|
459
|
-
this._pxGeometry.halfExtents =
|
|
445
|
+
PhysXColliderShape.prototype.setWorldScale.call(this, scale);
|
|
446
|
+
var tempExtents = PhysXBoxColliderShape._tempHalfExtents;
|
|
447
|
+
engine.Vector3.multiply(this._halfSize, this._scale, tempExtents);
|
|
448
|
+
this._pxGeometry.halfExtents = tempExtents;
|
|
460
449
|
this._pxShape.setGeometry(this._pxGeometry);
|
|
450
|
+
this._updateController(tempExtents);
|
|
451
|
+
};
|
|
452
|
+
_proto._updateController = function _updateController(extents) {
|
|
453
|
+
var controllers = this._controllers;
|
|
454
|
+
for(var i = 0, n = controllers.length; i < n; i++){
|
|
455
|
+
var pxController = controllers.get(i)._pxController;
|
|
456
|
+
pxController.setHalfHeight(extents.x);
|
|
457
|
+
pxController.setHalfSideExtent(extents.y);
|
|
458
|
+
pxController.setHalfForwardExtent(extents.z);
|
|
459
|
+
}
|
|
461
460
|
};
|
|
462
461
|
return PhysXBoxColliderShape;
|
|
463
462
|
}(PhysXColliderShape);
|
|
@@ -469,15 +468,15 @@ var ShapeFlag;
|
|
|
469
468
|
* Capsule collider shape in PhysX.
|
|
470
469
|
*/ var PhysXCapsuleColliderShape = /*#__PURE__*/ function(PhysXColliderShape1) {
|
|
471
470
|
_inherits(PhysXCapsuleColliderShape, PhysXColliderShape1);
|
|
472
|
-
function PhysXCapsuleColliderShape(uniqueID, radius, height, material) {
|
|
471
|
+
function PhysXCapsuleColliderShape(physXPhysics, uniqueID, radius, height, material) {
|
|
473
472
|
var _this;
|
|
474
|
-
_this = PhysXColliderShape1.call(this) || this;
|
|
473
|
+
_this = PhysXColliderShape1.call(this, physXPhysics) || this;
|
|
475
474
|
_this._upAxis = /** Up axis is Y. */ 1;
|
|
476
475
|
_this._radius = radius;
|
|
477
476
|
_this._halfHeight = height * 0.5;
|
|
478
477
|
_this._axis = new engine.Quaternion(0, 0, PhysXColliderShape.halfSqrt, PhysXColliderShape.halfSqrt);
|
|
479
|
-
_this.
|
|
480
|
-
_this._pxGeometry = new
|
|
478
|
+
_this._physXRotation.copyFrom(_this._axis);
|
|
479
|
+
_this._pxGeometry = new physXPhysics._physX.PxCapsuleGeometry(_this._radius, _this._halfHeight);
|
|
481
480
|
_this._initialize(material, uniqueID);
|
|
482
481
|
_this._setLocalPose();
|
|
483
482
|
return _this;
|
|
@@ -499,9 +498,10 @@ var ShapeFlag;
|
|
|
499
498
|
break;
|
|
500
499
|
}
|
|
501
500
|
this._pxShape.setGeometry(this._pxGeometry);
|
|
501
|
+
var radius = this._pxGeometry.radius;
|
|
502
502
|
var controllers = this._controllers;
|
|
503
503
|
for(var i = 0, n = controllers.length; i < n; i++){
|
|
504
|
-
controllers.get(i)._pxController.setRadius(
|
|
504
|
+
controllers.get(i)._pxController.setRadius(radius);
|
|
505
505
|
}
|
|
506
506
|
};
|
|
507
507
|
/**
|
|
@@ -520,15 +520,16 @@ var ShapeFlag;
|
|
|
520
520
|
break;
|
|
521
521
|
}
|
|
522
522
|
this._pxShape.setGeometry(this._pxGeometry);
|
|
523
|
+
var height = this._pxGeometry.halfHeight * 2;
|
|
523
524
|
var controllers = this._controllers;
|
|
524
525
|
for(var i = 0, n = controllers.length; i < n; i++){
|
|
525
|
-
controllers.get(i)._pxController.setHeight(
|
|
526
|
+
controllers.get(i)._pxController.setHeight(height);
|
|
526
527
|
}
|
|
527
528
|
};
|
|
528
529
|
/**
|
|
529
530
|
* {@inheritDoc ICapsuleColliderShape.setUpAxis }
|
|
530
531
|
*/ _proto.setUpAxis = function setUpAxis(upAxis) {
|
|
531
|
-
var _this = this, rotation = _this._rotation, axis = _this._axis,
|
|
532
|
+
var _this = this, rotation = _this._rotation, axis = _this._axis, physXRotation = _this._physXRotation;
|
|
532
533
|
this._upAxis = upAxis;
|
|
533
534
|
switch(this._upAxis){
|
|
534
535
|
case 0:
|
|
@@ -542,33 +543,41 @@ var ShapeFlag;
|
|
|
542
543
|
break;
|
|
543
544
|
}
|
|
544
545
|
if (rotation) {
|
|
545
|
-
engine.Quaternion.rotationYawPitchRoll(rotation.x, rotation.y, rotation.z,
|
|
546
|
-
engine.Quaternion.multiply(
|
|
546
|
+
engine.Quaternion.rotationYawPitchRoll(rotation.x, rotation.y, rotation.z, physXRotation);
|
|
547
|
+
engine.Quaternion.multiply(physXRotation, axis, physXRotation);
|
|
547
548
|
} else {
|
|
548
|
-
|
|
549
|
+
physXRotation.copyFrom(axis);
|
|
549
550
|
}
|
|
550
551
|
this._setLocalPose();
|
|
551
552
|
};
|
|
552
553
|
/**
|
|
553
554
|
* {@inheritDoc IColliderShape.setWorldScale }
|
|
554
555
|
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
555
|
-
|
|
556
|
-
this.
|
|
556
|
+
PhysXColliderShape1.prototype.setWorldScale.call(this, scale);
|
|
557
|
+
var geometry = this._pxGeometry;
|
|
557
558
|
switch(this._upAxis){
|
|
558
559
|
case 0:
|
|
559
|
-
|
|
560
|
-
|
|
560
|
+
geometry.radius = this._radius * Math.max(scale.y, scale.z);
|
|
561
|
+
geometry.halfHeight = this._halfHeight * scale.x;
|
|
561
562
|
break;
|
|
562
563
|
case 1:
|
|
563
|
-
|
|
564
|
-
|
|
564
|
+
geometry.radius = this._radius * Math.max(scale.x, scale.z);
|
|
565
|
+
geometry.halfHeight = this._halfHeight * scale.y;
|
|
565
566
|
break;
|
|
566
567
|
case 2:
|
|
567
|
-
|
|
568
|
-
|
|
568
|
+
geometry.radius = this._radius * Math.max(scale.x, scale.y);
|
|
569
|
+
geometry.halfHeight = this._halfHeight * scale.z;
|
|
569
570
|
break;
|
|
570
571
|
}
|
|
571
|
-
this._pxShape.setGeometry(
|
|
572
|
+
this._pxShape.setGeometry(geometry);
|
|
573
|
+
var radius = geometry.radius;
|
|
574
|
+
var height = geometry.halfHeight * 2;
|
|
575
|
+
var controllers = this._controllers;
|
|
576
|
+
for(var i = 0, n = controllers.length; i < n; i++){
|
|
577
|
+
var pxController = controllers.get(i)._pxController;
|
|
578
|
+
pxController.setRadius(radius);
|
|
579
|
+
pxController.setHeight(height);
|
|
580
|
+
}
|
|
572
581
|
};
|
|
573
582
|
return PhysXCapsuleColliderShape;
|
|
574
583
|
}(PhysXColliderShape);
|
|
@@ -584,7 +593,11 @@ var /**
|
|
|
584
593
|
/**
|
|
585
594
|
* Base class for character controllers.
|
|
586
595
|
*/ var PhysXCharacterController = /*#__PURE__*/ function() {
|
|
587
|
-
function PhysXCharacterController() {
|
|
596
|
+
function PhysXCharacterController(physXPhysics) {
|
|
597
|
+
this._scaledOffset = new engine.Vector3();
|
|
598
|
+
this._position = null;
|
|
599
|
+
this._physXPhysics = physXPhysics;
|
|
600
|
+
}
|
|
588
601
|
var _proto = PhysXCharacterController.prototype;
|
|
589
602
|
/**
|
|
590
603
|
* {@inheritDoc ICharacterController.move }
|
|
@@ -594,12 +607,17 @@ var /**
|
|
|
594
607
|
/**
|
|
595
608
|
* {@inheritDoc ICharacterController.setWorldPosition }
|
|
596
609
|
*/ _proto.setWorldPosition = function setWorldPosition(position) {
|
|
597
|
-
this.
|
|
610
|
+
this._position = position;
|
|
611
|
+
if (this._pxController) {
|
|
612
|
+
engine.Vector3.add(position, this._scaledOffset, PhysXCharacterController._tempVec);
|
|
613
|
+
this._pxController.setPosition(PhysXCharacterController._tempVec);
|
|
614
|
+
}
|
|
598
615
|
};
|
|
599
616
|
/**
|
|
600
617
|
* {@inheritDoc ICharacterController.getWorldPosition }
|
|
601
618
|
*/ _proto.getWorldPosition = function getWorldPosition(position) {
|
|
602
619
|
position.copyFrom(this._pxController.getPosition());
|
|
620
|
+
position.subtract(this._scaledOffset);
|
|
603
621
|
};
|
|
604
622
|
/**
|
|
605
623
|
* {@inheritDoc ICharacterController.setStepOffset }
|
|
@@ -645,12 +663,12 @@ var /**
|
|
|
645
663
|
*/ _proto._createPXController = function _createPXController(pxManager, shape) {
|
|
646
664
|
var desc;
|
|
647
665
|
if (_instanceof(shape, PhysXBoxColliderShape)) {
|
|
648
|
-
desc = new
|
|
666
|
+
desc = new this._physXPhysics._physX.PxBoxControllerDesc();
|
|
649
667
|
desc.halfHeight = shape._halfSize.x;
|
|
650
668
|
desc.halfSideExtent = shape._halfSize.y;
|
|
651
669
|
desc.halfForwardExtent = shape._halfSize.z;
|
|
652
670
|
} else if (_instanceof(shape, PhysXCapsuleColliderShape)) {
|
|
653
|
-
desc = new
|
|
671
|
+
desc = new this._physXPhysics._physX.PxCapsuleControllerDesc();
|
|
654
672
|
desc.radius = shape._radius;
|
|
655
673
|
desc.height = shape._halfHeight * 2;
|
|
656
674
|
desc.climbingMode = 1; // constraint mode
|
|
@@ -659,7 +677,7 @@ var /**
|
|
|
659
677
|
}
|
|
660
678
|
desc.setMaterial(shape._pxMaterials[0]);
|
|
661
679
|
this._pxController = pxManager._getControllerManager().createController(desc);
|
|
662
|
-
this._pxController.
|
|
680
|
+
this._pxController.setUUID(shape._id);
|
|
663
681
|
};
|
|
664
682
|
/**
|
|
665
683
|
* @internal
|
|
@@ -669,13 +687,24 @@ var /**
|
|
|
669
687
|
this._pxController = null;
|
|
670
688
|
}
|
|
671
689
|
};
|
|
690
|
+
/**
|
|
691
|
+
* @internal
|
|
692
|
+
*/ _proto._setLocalPosition = function _setLocalPosition(position, scale) {
|
|
693
|
+
engine.Vector3.multiply(position, scale, this._scaledOffset);
|
|
694
|
+
this.setWorldPosition(this._position);
|
|
695
|
+
};
|
|
672
696
|
return PhysXCharacterController;
|
|
673
697
|
}();
|
|
698
|
+
(function() {
|
|
699
|
+
PhysXCharacterController._tempVec = new engine.Vector3();
|
|
700
|
+
})();
|
|
674
701
|
|
|
675
702
|
/**
|
|
676
703
|
* Abstract class of physical collider.
|
|
677
704
|
*/ var PhysXCollider = /*#__PURE__*/ function() {
|
|
678
|
-
function PhysXCollider() {
|
|
705
|
+
function PhysXCollider(physXPhysics) {
|
|
706
|
+
this._physXPhysics = physXPhysics;
|
|
707
|
+
}
|
|
679
708
|
var _proto = PhysXCollider.prototype;
|
|
680
709
|
/**
|
|
681
710
|
* {@inheritDoc ICollider.addShape }
|
|
@@ -732,11 +761,11 @@ var CollisionDetectionMode;
|
|
|
732
761
|
* A dynamic collider can act with self-defined movement or physical force
|
|
733
762
|
*/ var PhysXDynamicCollider = /*#__PURE__*/ function(PhysXCollider) {
|
|
734
763
|
_inherits(PhysXDynamicCollider, PhysXCollider);
|
|
735
|
-
function PhysXDynamicCollider(position, rotation) {
|
|
764
|
+
function PhysXDynamicCollider(physXPhysics, position, rotation) {
|
|
736
765
|
var _this;
|
|
737
|
-
_this = PhysXCollider.call(this) || this;
|
|
766
|
+
_this = PhysXCollider.call(this, physXPhysics) || this;
|
|
738
767
|
var transform = _this._transform(position, rotation);
|
|
739
|
-
_this._pxActor =
|
|
768
|
+
_this._pxActor = physXPhysics._pxPhysics.createRigidDynamic(transform);
|
|
740
769
|
return _this;
|
|
741
770
|
}
|
|
742
771
|
var _proto = PhysXDynamicCollider.prototype;
|
|
@@ -801,18 +830,19 @@ var CollisionDetectionMode;
|
|
|
801
830
|
*/ _proto.setCollisionDetectionMode = function setCollisionDetectionMode(value) {
|
|
802
831
|
switch(value){
|
|
803
832
|
case 1:
|
|
804
|
-
this._pxActor.setRigidBodyFlag(
|
|
833
|
+
this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eENABLE_CCD, true);
|
|
805
834
|
break;
|
|
806
835
|
case 2:
|
|
807
|
-
this._pxActor.setRigidBodyFlag(
|
|
836
|
+
this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eENABLE_CCD_FRICTION, true);
|
|
808
837
|
break;
|
|
809
838
|
case 3:
|
|
810
|
-
this._pxActor.setRigidBodyFlag(
|
|
839
|
+
this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eENABLE_SPECULATIVE_CCD, true);
|
|
811
840
|
break;
|
|
812
841
|
case 0:
|
|
813
|
-
this.
|
|
814
|
-
this._pxActor.setRigidBodyFlag(
|
|
815
|
-
this._pxActor.setRigidBodyFlag(
|
|
842
|
+
var physX = this._physXPhysics._physX;
|
|
843
|
+
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_CCD, false);
|
|
844
|
+
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_CCD_FRICTION, false);
|
|
845
|
+
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_SPECULATIVE_CCD, false);
|
|
816
846
|
break;
|
|
817
847
|
}
|
|
818
848
|
};
|
|
@@ -820,9 +850,9 @@ var CollisionDetectionMode;
|
|
|
820
850
|
* {@inheritDoc IDynamicCollider.setIsKinematic }
|
|
821
851
|
*/ _proto.setIsKinematic = function setIsKinematic(value) {
|
|
822
852
|
if (value) {
|
|
823
|
-
this._pxActor.setRigidBodyFlag(
|
|
853
|
+
this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eKINEMATIC, true);
|
|
824
854
|
} else {
|
|
825
|
-
this._pxActor.setRigidBodyFlag(
|
|
855
|
+
this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eKINEMATIC, false);
|
|
826
856
|
}
|
|
827
857
|
};
|
|
828
858
|
/**
|
|
@@ -886,12 +916,17 @@ var CollisionDetectionMode;
|
|
|
886
916
|
/**
|
|
887
917
|
* A manager is a collection of colliders and constraints which can interact.
|
|
888
918
|
*/ var PhysXPhysicsManager = /*#__PURE__*/ function() {
|
|
889
|
-
function PhysXPhysicsManager(onContactEnter, onContactExit, onContactStay, onTriggerEnter, onTriggerExit, onTriggerStay) {
|
|
919
|
+
function PhysXPhysicsManager(physXPhysics, onContactEnter, onContactExit, onContactStay, onTriggerEnter, onTriggerExit, onTriggerStay) {
|
|
890
920
|
var _this = this;
|
|
891
921
|
/** @internal */ this._pxControllerManager = null;
|
|
892
922
|
this._currentEvents = new DisorderedArray();
|
|
893
923
|
this._eventMap = {};
|
|
894
924
|
this._eventPool = [];
|
|
925
|
+
this._physXPhysics = physXPhysics;
|
|
926
|
+
var physX = physXPhysics._physX;
|
|
927
|
+
this._pxRaycastHit = new physX.PxRaycastHit();
|
|
928
|
+
this._pxFilterData = new physX.PxQueryFilterData();
|
|
929
|
+
this._pxFilterData.flags = new physX.PxQueryFlags(1 | 2 | 4);
|
|
895
930
|
this._onContactEnter = onContactEnter;
|
|
896
931
|
this._onContactExit = onContactExit;
|
|
897
932
|
this._onContactStay = onContactStay;
|
|
@@ -899,31 +934,21 @@ var CollisionDetectionMode;
|
|
|
899
934
|
this._onTriggerExit = onTriggerExit;
|
|
900
935
|
this._onTriggerStay = onTriggerStay;
|
|
901
936
|
var triggerCallback = {
|
|
902
|
-
onContactBegin: function(
|
|
903
|
-
var index1 = obj1.getQueryFilterData().word0;
|
|
904
|
-
var index2 = obj2.getQueryFilterData().word0;
|
|
937
|
+
onContactBegin: function(index1, index2) {
|
|
905
938
|
_this._onContactEnter(index1, index2);
|
|
906
939
|
},
|
|
907
|
-
onContactEnd: function(
|
|
908
|
-
var index1 = obj1.getQueryFilterData().word0;
|
|
909
|
-
var index2 = obj2.getQueryFilterData().word0;
|
|
940
|
+
onContactEnd: function(index1, index2) {
|
|
910
941
|
_this._onContactExit(index1, index2);
|
|
911
942
|
},
|
|
912
|
-
onContactPersist: function(
|
|
913
|
-
var index1 = obj1.getQueryFilterData().word0;
|
|
914
|
-
var index2 = obj2.getQueryFilterData().word0;
|
|
943
|
+
onContactPersist: function(index1, index2) {
|
|
915
944
|
_this._onContactStay(index1, index2);
|
|
916
945
|
},
|
|
917
|
-
onTriggerBegin: function(
|
|
918
|
-
var index1 = obj1.getQueryFilterData().word0;
|
|
919
|
-
var index2 = obj2.getQueryFilterData().word0;
|
|
946
|
+
onTriggerBegin: function(index1, index2) {
|
|
920
947
|
var event = index1 < index2 ? _this._getTrigger(index1, index2) : _this._getTrigger(index2, index1);
|
|
921
948
|
event.state = 0;
|
|
922
949
|
_this._currentEvents.add(event);
|
|
923
950
|
},
|
|
924
|
-
onTriggerEnd: function(
|
|
925
|
-
var index1 = obj1.getQueryFilterData().word0;
|
|
926
|
-
var index2 = obj2.getQueryFilterData().word0;
|
|
951
|
+
onTriggerEnd: function(index1, index2) {
|
|
927
952
|
var event;
|
|
928
953
|
if (index1 < index2) {
|
|
929
954
|
var subMap = _this._eventMap[index1];
|
|
@@ -937,9 +962,10 @@ var CollisionDetectionMode;
|
|
|
937
962
|
event.state = 2;
|
|
938
963
|
}
|
|
939
964
|
};
|
|
940
|
-
var
|
|
941
|
-
var
|
|
942
|
-
|
|
965
|
+
var pxPhysics = physXPhysics._pxPhysics;
|
|
966
|
+
var physXSimulationCallbackInstance = physX.PxSimulationEventCallback.implement(triggerCallback);
|
|
967
|
+
var sceneDesc = physX.getDefaultSceneDesc(pxPhysics.getTolerancesScale(), 0, physXSimulationCallbackInstance);
|
|
968
|
+
this._pxScene = pxPhysics.createScene(sceneDesc);
|
|
943
969
|
}
|
|
944
970
|
var _proto = PhysXPhysicsManager.prototype;
|
|
945
971
|
/**
|
|
@@ -986,16 +1012,13 @@ var CollisionDetectionMode;
|
|
|
986
1012
|
lastPXManager && characterController._destroyPXController();
|
|
987
1013
|
characterController._createPXController(this, shape);
|
|
988
1014
|
}
|
|
989
|
-
this._pxScene.addController(characterController._pxController);
|
|
990
1015
|
}
|
|
991
1016
|
characterController._pxManager = this;
|
|
992
1017
|
};
|
|
993
1018
|
/**
|
|
994
1019
|
* {@inheritDoc IPhysicsManager.removeCharacterController }
|
|
995
1020
|
*/ _proto.removeCharacterController = function removeCharacterController(characterController) {
|
|
996
|
-
|
|
997
|
-
this._pxScene.removeController(characterController._pxController);
|
|
998
|
-
}
|
|
1021
|
+
characterController._pxController = null;
|
|
999
1022
|
characterController._pxManager = null;
|
|
1000
1023
|
};
|
|
1001
1024
|
/**
|
|
@@ -1008,11 +1031,10 @@ var CollisionDetectionMode;
|
|
|
1008
1031
|
/**
|
|
1009
1032
|
* {@inheritDoc IPhysicsManager.raycast }
|
|
1010
1033
|
*/ _proto.raycast = function raycast(ray, distance, onRaycast, hit) {
|
|
1011
|
-
var pxHitResult =
|
|
1034
|
+
var _this = this, pxHitResult = _this._pxRaycastHit;
|
|
1012
1035
|
distance = Math.min(distance, 3.4e38); // float32 max value limit in physx raycast.
|
|
1013
1036
|
var raycastCallback = {
|
|
1014
|
-
preFilter: function(filterData,
|
|
1015
|
-
var index = shape.getQueryFilterData().word0;
|
|
1037
|
+
preFilter: function(filterData, index, actor) {
|
|
1016
1038
|
if (onRaycast(index)) {
|
|
1017
1039
|
return 2; // eBLOCK
|
|
1018
1040
|
} else {
|
|
@@ -1021,13 +1043,13 @@ var CollisionDetectionMode;
|
|
|
1021
1043
|
},
|
|
1022
1044
|
postFilter: function(filterData, hit) {}
|
|
1023
1045
|
};
|
|
1024
|
-
var result = this._pxScene.raycastSingle(ray.origin, ray.direction, distance, pxHitResult,
|
|
1046
|
+
var result = this._pxScene.raycastSingle(ray.origin, ray.direction, distance, pxHitResult, this._pxFilterData, this._physXPhysics._physX.PxQueryFilterCallback.implement(raycastCallback));
|
|
1025
1047
|
if (result && hit != undefined) {
|
|
1026
1048
|
var position = PhysXPhysicsManager._tempPosition, normal = PhysXPhysicsManager._tempNormal;
|
|
1027
1049
|
var pxPosition = pxHitResult.position, pxNormal = pxHitResult.normal;
|
|
1028
1050
|
position.set(pxPosition.x, pxPosition.y, pxPosition.z);
|
|
1029
1051
|
normal.set(pxNormal.x, pxNormal.y, pxNormal.z);
|
|
1030
|
-
hit(pxHitResult.getShape().
|
|
1052
|
+
hit(pxHitResult.getShape().getUUID(), pxHitResult.distance, position, normal);
|
|
1031
1053
|
}
|
|
1032
1054
|
return result;
|
|
1033
1055
|
};
|
|
@@ -1075,11 +1097,6 @@ var CollisionDetectionMode;
|
|
|
1075
1097
|
}
|
|
1076
1098
|
}
|
|
1077
1099
|
};
|
|
1078
|
-
PhysXPhysicsManager._init = function _init() {
|
|
1079
|
-
PhysXPhysicsManager._pxRaycastHit = new exports.PhysXPhysics._physX.PxRaycastHit();
|
|
1080
|
-
PhysXPhysicsManager._pxFilterData = new exports.PhysXPhysics._physX.PxQueryFilterData();
|
|
1081
|
-
PhysXPhysicsManager._pxFilterData.flags = new exports.PhysXPhysics._physX.PxQueryFlags(1 | 2 | 4);
|
|
1082
|
-
};
|
|
1083
1100
|
return PhysXPhysicsManager;
|
|
1084
1101
|
}();
|
|
1085
1102
|
(function() {
|
|
@@ -1117,8 +1134,9 @@ var /**
|
|
|
1117
1134
|
/**
|
|
1118
1135
|
* Physics material describes how to handle colliding objects (friction, bounciness).
|
|
1119
1136
|
*/ var PhysXPhysicsMaterial = /*#__PURE__*/ function() {
|
|
1120
|
-
function PhysXPhysicsMaterial(staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine) {
|
|
1121
|
-
|
|
1137
|
+
function PhysXPhysicsMaterial(physXPhysics, staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine) {
|
|
1138
|
+
this._physXPhysics = physXPhysics;
|
|
1139
|
+
var pxMaterial = physXPhysics._pxPhysics.createMaterial(staticFriction, dynamicFriction, bounciness);
|
|
1122
1140
|
pxMaterial.setFrictionCombineMode(frictionCombine);
|
|
1123
1141
|
pxMaterial.setRestitutionCombineMode(bounceCombine);
|
|
1124
1142
|
this._pxMaterial = pxMaterial;
|
|
@@ -1171,10 +1189,10 @@ var /**
|
|
|
1171
1189
|
* @remarks Mostly used for object which always stays at the same place and never moves around.
|
|
1172
1190
|
*/ var PhysXStaticCollider = /*#__PURE__*/ function(PhysXCollider) {
|
|
1173
1191
|
_inherits(PhysXStaticCollider, PhysXCollider);
|
|
1174
|
-
function PhysXStaticCollider(position, rotation) {
|
|
1192
|
+
function PhysXStaticCollider(physXPhysics, position, rotation) {
|
|
1175
1193
|
var _this;
|
|
1176
|
-
_this = PhysXCollider.call(this) || this;
|
|
1177
|
-
_this._pxActor =
|
|
1194
|
+
_this = PhysXCollider.call(this, physXPhysics) || this;
|
|
1195
|
+
_this._pxActor = physXPhysics._pxPhysics.createRigidStatic(_this._transform(position, rotation));
|
|
1178
1196
|
return _this;
|
|
1179
1197
|
}
|
|
1180
1198
|
return PhysXStaticCollider;
|
|
@@ -1184,23 +1202,16 @@ var /**
|
|
|
1184
1202
|
* Plane collider shape in PhysX.
|
|
1185
1203
|
*/ var PhysXPlaneColliderShape = /*#__PURE__*/ function(PhysXColliderShape1) {
|
|
1186
1204
|
_inherits(PhysXPlaneColliderShape, PhysXColliderShape1);
|
|
1187
|
-
function PhysXPlaneColliderShape(uniqueID, material) {
|
|
1205
|
+
function PhysXPlaneColliderShape(physXPhysics, uniqueID, material) {
|
|
1188
1206
|
var _this;
|
|
1189
|
-
_this = PhysXColliderShape1.call(this) || this;
|
|
1207
|
+
_this = PhysXColliderShape1.call(this, physXPhysics) || this;
|
|
1190
1208
|
_this._axis = new engine.Quaternion(0, 0, PhysXColliderShape.halfSqrt, PhysXColliderShape.halfSqrt);
|
|
1191
|
-
_this.
|
|
1192
|
-
_this._pxGeometry = new
|
|
1209
|
+
_this._physXRotation.copyFrom(_this._axis);
|
|
1210
|
+
_this._pxGeometry = new physXPhysics._physX.PxPlaneGeometry();
|
|
1193
1211
|
_this._initialize(material, uniqueID);
|
|
1194
1212
|
_this._setLocalPose();
|
|
1195
1213
|
return _this;
|
|
1196
1214
|
}
|
|
1197
|
-
var _proto = PhysXPlaneColliderShape.prototype;
|
|
1198
|
-
/**
|
|
1199
|
-
* {@inheritDoc IColliderShape.setWorldScale }
|
|
1200
|
-
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
1201
|
-
this._scale.copyFrom(scale);
|
|
1202
|
-
this._setLocalPose();
|
|
1203
|
-
};
|
|
1204
1215
|
return PhysXPlaneColliderShape;
|
|
1205
1216
|
}(PhysXColliderShape);
|
|
1206
1217
|
|
|
@@ -1208,12 +1219,12 @@ var /**
|
|
|
1208
1219
|
* Sphere collider shape in PhysX.
|
|
1209
1220
|
*/ var PhysXSphereColliderShape = /*#__PURE__*/ function(PhysXColliderShape) {
|
|
1210
1221
|
_inherits(PhysXSphereColliderShape, PhysXColliderShape);
|
|
1211
|
-
function PhysXSphereColliderShape(uniqueID, radius, material) {
|
|
1222
|
+
function PhysXSphereColliderShape(physXPhysics, uniqueID, radius, material) {
|
|
1212
1223
|
var _this;
|
|
1213
|
-
_this = PhysXColliderShape.call(this) || this;
|
|
1224
|
+
_this = PhysXColliderShape.call(this, physXPhysics) || this;
|
|
1214
1225
|
_this._maxScale = 1;
|
|
1215
1226
|
_this._radius = radius;
|
|
1216
|
-
_this._pxGeometry = new
|
|
1227
|
+
_this._pxGeometry = new physXPhysics._physX.PxSphereGeometry(_this._radius * _this._maxScale);
|
|
1217
1228
|
_this._initialize(material, uniqueID);
|
|
1218
1229
|
_this._setLocalPose();
|
|
1219
1230
|
return _this;
|
|
@@ -1229,8 +1240,7 @@ var /**
|
|
|
1229
1240
|
/**
|
|
1230
1241
|
* {@inheritDoc IColliderShape.setWorldScale }
|
|
1231
1242
|
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
1232
|
-
|
|
1233
|
-
this._setLocalPose();
|
|
1243
|
+
PhysXColliderShape.prototype.setWorldScale.call(this, scale);
|
|
1234
1244
|
this._maxScale = Math.max(scale.x, Math.max(scale.x, scale.y));
|
|
1235
1245
|
this._pxGeometry.radius = this._radius * this._maxScale;
|
|
1236
1246
|
this._pxShape.setGeometry(this._pxGeometry);
|
|
@@ -1239,21 +1249,26 @@ var /**
|
|
|
1239
1249
|
}(PhysXColliderShape);
|
|
1240
1250
|
|
|
1241
1251
|
/**
|
|
1242
|
-
*
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
function PhysXPhysics1() {}
|
|
1252
|
+
* PhysX object creation.
|
|
1253
|
+
*/ var PhysXPhysics = /*#__PURE__*/ function() {
|
|
1254
|
+
function PhysXPhysics(runtimeMode) {
|
|
1255
|
+
if (runtimeMode === void 0) runtimeMode = exports.PhysXRuntimeMode.Auto;
|
|
1256
|
+
this._initializeState = 0;
|
|
1257
|
+
this._runTimeMode = runtimeMode;
|
|
1258
|
+
}
|
|
1259
|
+
var _proto = PhysXPhysics.prototype;
|
|
1251
1260
|
/**
|
|
1252
1261
|
* Initialize PhysXPhysics.
|
|
1253
1262
|
* @param runtimeMode - Runtime mode
|
|
1254
1263
|
* @returns Promise object
|
|
1255
|
-
*/
|
|
1256
|
-
|
|
1264
|
+
*/ _proto.initialize = function initialize() {
|
|
1265
|
+
var _this = this;
|
|
1266
|
+
if (this._initializeState === 2) {
|
|
1267
|
+
return Promise.resolve();
|
|
1268
|
+
} else if (this._initializeState === 1) {
|
|
1269
|
+
return this._initializePromise;
|
|
1270
|
+
}
|
|
1271
|
+
var runtimeMode = this._runTimeMode;
|
|
1257
1272
|
var scriptPromise = new Promise(function(resolve, reject) {
|
|
1258
1273
|
var script = document.createElement("script");
|
|
1259
1274
|
document.body.appendChild(script);
|
|
@@ -1277,105 +1292,115 @@ exports.PhysXPhysics = /*#__PURE__*/ function() {
|
|
|
1277
1292
|
}
|
|
1278
1293
|
}
|
|
1279
1294
|
if (runtimeMode == exports.PhysXRuntimeMode.JavaScript) {
|
|
1280
|
-
script.src = "https://gw.alipayobjects.com/os/lib/oasis-engine/physics-physx/0.
|
|
1295
|
+
script.src = "https://gw.alipayobjects.com/os/lib/oasis-engine/physics-physx/1.0.0-alpha.4/libs/physx.release.js.js";
|
|
1281
1296
|
} else if (runtimeMode == exports.PhysXRuntimeMode.WebAssembly) {
|
|
1282
|
-
script.src = "https://gw.alipayobjects.com/os/lib/oasis-engine/physics-physx/0.
|
|
1297
|
+
script.src = "https://gw.alipayobjects.com/os/lib/oasis-engine/physics-physx/1.0.0-alpha.4/libs/physx.release.js";
|
|
1283
1298
|
}
|
|
1284
1299
|
});
|
|
1285
|
-
|
|
1300
|
+
var initializePromise = new Promise(function(resolve, reject) {
|
|
1286
1301
|
scriptPromise.then(function() {
|
|
1287
1302
|
return window.PHYSX().then(function(PHYSX) {
|
|
1288
|
-
|
|
1303
|
+
_this._init(PHYSX);
|
|
1304
|
+
_this._initializeState = 2;
|
|
1305
|
+
_this._initializePromise = null;
|
|
1289
1306
|
console.log("PhysX loaded.");
|
|
1290
1307
|
resolve();
|
|
1291
1308
|
}, reject);
|
|
1292
1309
|
}, reject).catch(reject);
|
|
1293
1310
|
});
|
|
1311
|
+
this._initializePromise = initializePromise;
|
|
1312
|
+
return initializePromise;
|
|
1294
1313
|
};
|
|
1295
1314
|
/**
|
|
1296
1315
|
* Destroy PhysXPhysics.
|
|
1297
|
-
*/
|
|
1298
|
-
this.
|
|
1316
|
+
*/ _proto.destroy = function destroy() {
|
|
1317
|
+
this._physX.PxCloseExtensions();
|
|
1299
1318
|
this._pxPhysics.release();
|
|
1319
|
+
this._pxFoundation.release();
|
|
1300
1320
|
this._physX = null;
|
|
1301
1321
|
this._pxFoundation = null;
|
|
1302
1322
|
this._pxPhysics = null;
|
|
1303
1323
|
};
|
|
1304
1324
|
/**
|
|
1305
1325
|
* {@inheritDoc IPhysics.createPhysicsManager }
|
|
1306
|
-
*/
|
|
1307
|
-
|
|
1326
|
+
*/ _proto.createPhysicsManager = function createPhysicsManager(onContactBegin, onContactEnd, onContactStay, onTriggerBegin, onTriggerEnd, onTriggerStay) {
|
|
1327
|
+
var manager = new PhysXPhysicsManager(this, onContactBegin, onContactEnd, onContactStay, onTriggerBegin, onTriggerEnd, onTriggerStay);
|
|
1328
|
+
return manager;
|
|
1308
1329
|
};
|
|
1309
1330
|
/**
|
|
1310
1331
|
* {@inheritDoc IPhysics.createStaticCollider }
|
|
1311
|
-
*/
|
|
1312
|
-
return new PhysXStaticCollider(position, rotation);
|
|
1332
|
+
*/ _proto.createStaticCollider = function createStaticCollider(position, rotation) {
|
|
1333
|
+
return new PhysXStaticCollider(this, position, rotation);
|
|
1313
1334
|
};
|
|
1314
1335
|
/**
|
|
1315
1336
|
* {@inheritDoc IPhysics.createDynamicCollider }
|
|
1316
|
-
*/
|
|
1317
|
-
return new PhysXDynamicCollider(position, rotation);
|
|
1337
|
+
*/ _proto.createDynamicCollider = function createDynamicCollider(position, rotation) {
|
|
1338
|
+
return new PhysXDynamicCollider(this, position, rotation);
|
|
1318
1339
|
};
|
|
1319
1340
|
/**
|
|
1320
1341
|
* {@inheritDoc IPhysics.createCharacterController }
|
|
1321
|
-
*/
|
|
1322
|
-
return new PhysXCharacterController();
|
|
1342
|
+
*/ _proto.createCharacterController = function createCharacterController() {
|
|
1343
|
+
return new PhysXCharacterController(this);
|
|
1323
1344
|
};
|
|
1324
1345
|
/**
|
|
1325
1346
|
* {@inheritDoc IPhysics.createPhysicsMaterial }
|
|
1326
|
-
*/
|
|
1327
|
-
return new PhysXPhysicsMaterial(staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine);
|
|
1347
|
+
*/ _proto.createPhysicsMaterial = function createPhysicsMaterial(staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine) {
|
|
1348
|
+
return new PhysXPhysicsMaterial(this, staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine);
|
|
1328
1349
|
};
|
|
1329
1350
|
/**
|
|
1330
1351
|
* {@inheritDoc IPhysics.createBoxColliderShape }
|
|
1331
|
-
*/
|
|
1332
|
-
return new PhysXBoxColliderShape(uniqueID, size, material);
|
|
1352
|
+
*/ _proto.createBoxColliderShape = function createBoxColliderShape(uniqueID, size, material) {
|
|
1353
|
+
return new PhysXBoxColliderShape(this, uniqueID, size, material);
|
|
1333
1354
|
};
|
|
1334
1355
|
/**
|
|
1335
1356
|
* {@inheritDoc IPhysics.createSphereColliderShape }
|
|
1336
|
-
*/
|
|
1337
|
-
return new PhysXSphereColliderShape(uniqueID, radius, material);
|
|
1357
|
+
*/ _proto.createSphereColliderShape = function createSphereColliderShape(uniqueID, radius, material) {
|
|
1358
|
+
return new PhysXSphereColliderShape(this, uniqueID, radius, material);
|
|
1338
1359
|
};
|
|
1339
1360
|
/**
|
|
1340
1361
|
* {@inheritDoc IPhysics.createPlaneColliderShape }
|
|
1341
|
-
*/
|
|
1342
|
-
return new PhysXPlaneColliderShape(uniqueID, material);
|
|
1362
|
+
*/ _proto.createPlaneColliderShape = function createPlaneColliderShape(uniqueID, material) {
|
|
1363
|
+
return new PhysXPlaneColliderShape(this, uniqueID, material);
|
|
1343
1364
|
};
|
|
1344
1365
|
/**
|
|
1345
1366
|
* {@inheritDoc IPhysics.createCapsuleColliderShape }
|
|
1346
|
-
*/
|
|
1347
|
-
return new PhysXCapsuleColliderShape(uniqueID, radius, height, material);
|
|
1367
|
+
*/ _proto.createCapsuleColliderShape = function createCapsuleColliderShape(uniqueID, radius, height, material) {
|
|
1368
|
+
return new PhysXCapsuleColliderShape(this, uniqueID, radius, height, material);
|
|
1348
1369
|
};
|
|
1349
1370
|
/**
|
|
1350
1371
|
* {@inheritDoc IPhysics.createFixedJoint }
|
|
1351
|
-
*/
|
|
1352
|
-
return new PhysXFixedJoint(collider);
|
|
1372
|
+
*/ _proto.createFixedJoint = function createFixedJoint(collider) {
|
|
1373
|
+
return new PhysXFixedJoint(this, collider);
|
|
1353
1374
|
};
|
|
1354
1375
|
/**
|
|
1355
1376
|
* {@inheritDoc IPhysics.createHingeJoint }
|
|
1356
|
-
*/
|
|
1357
|
-
return new PhysXHingeJoint(collider);
|
|
1377
|
+
*/ _proto.createHingeJoint = function createHingeJoint(collider) {
|
|
1378
|
+
return new PhysXHingeJoint(this, collider);
|
|
1358
1379
|
};
|
|
1359
1380
|
/**
|
|
1360
1381
|
* {@inheritDoc IPhysics.createSpringJoint }
|
|
1361
|
-
*/
|
|
1362
|
-
return new PhysXSpringJoint(collider);
|
|
1382
|
+
*/ _proto.createSpringJoint = function createSpringJoint(collider) {
|
|
1383
|
+
return new PhysXSpringJoint(this, collider);
|
|
1363
1384
|
};
|
|
1364
|
-
|
|
1385
|
+
_proto._init = function _init(physX) {
|
|
1365
1386
|
var version = physX.PX_PHYSICS_VERSION;
|
|
1366
1387
|
var defaultErrorCallback = new physX.PxDefaultErrorCallback();
|
|
1367
1388
|
var allocator = new physX.PxDefaultAllocator();
|
|
1368
1389
|
var pxFoundation = physX.PxCreateFoundation(version, allocator, defaultErrorCallback);
|
|
1369
1390
|
var pxPhysics = physX.PxCreatePhysics(version, pxFoundation, new physX.PxTolerancesScale(), false, null);
|
|
1370
1391
|
physX.PxInitExtensions(pxPhysics, null);
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
PhysXPhysicsManager._init();
|
|
1392
|
+
this._physX = physX;
|
|
1393
|
+
this._pxFoundation = pxFoundation;
|
|
1394
|
+
this._pxPhysics = pxPhysics;
|
|
1375
1395
|
};
|
|
1376
|
-
return
|
|
1396
|
+
return PhysXPhysics;
|
|
1377
1397
|
}();
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
]
|
|
1398
|
+
var InitializeState;
|
|
1399
|
+
(function(InitializeState) {
|
|
1400
|
+
InitializeState[InitializeState["Uninitialized"] = 0] = "Uninitialized";
|
|
1401
|
+
InitializeState[InitializeState["Initializing"] = 1] = "Initializing";
|
|
1402
|
+
InitializeState[InitializeState["Initialized"] = 2] = "Initialized";
|
|
1403
|
+
})(InitializeState || (InitializeState = {}));
|
|
1404
|
+
|
|
1405
|
+
exports.PhysXPhysics = PhysXPhysics;
|
|
1381
1406
|
//# sourceMappingURL=main.js.map
|