@galacean/engine-physics-physx 0.9.20 → 1.0.0-alpha.7
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 -194
- package/dist/browser.min.js +1 -1
- package/dist/main.js +222 -194
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +282 -36489
- package/dist/module.js +221 -195
- package/dist/module.js.map +1 -1
- package/libs/.DS_Store +0 -0
- package/libs/physx.release.js +1 -1
- package/libs/physx.release.js.js +31 -30
- package/libs/physx.release.js.mem +0 -0
- package/libs/physx.release.wasm +0 -0
- package/package.json +8 -8
- 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 +4 -8
- 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/LICENSE +0 -21
package/dist/browser.js
CHANGED
|
@@ -10,28 +10,6 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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
|
/**
|
|
@@ -1007,11 +1033,10 @@
|
|
|
1007
1033
|
/**
|
|
1008
1034
|
* {@inheritDoc IPhysicsManager.raycast }
|
|
1009
1035
|
*/ _proto.raycast = function raycast(ray, distance, onRaycast, hit) {
|
|
1010
|
-
var pxHitResult =
|
|
1036
|
+
var _this = this, pxHitResult = _this._pxRaycastHit;
|
|
1011
1037
|
distance = Math.min(distance, 3.4e38); // float32 max value limit in physx raycast.
|
|
1012
1038
|
var raycastCallback = {
|
|
1013
|
-
preFilter: function(filterData,
|
|
1014
|
-
var index = shape.getQueryFilterData().word0;
|
|
1039
|
+
preFilter: function(filterData, index, actor) {
|
|
1015
1040
|
if (onRaycast(index)) {
|
|
1016
1041
|
return 2; // eBLOCK
|
|
1017
1042
|
} else {
|
|
@@ -1020,13 +1045,13 @@
|
|
|
1020
1045
|
},
|
|
1021
1046
|
postFilter: function(filterData, hit) {}
|
|
1022
1047
|
};
|
|
1023
|
-
var result = this._pxScene.raycastSingle(ray.origin, ray.direction, distance, pxHitResult,
|
|
1048
|
+
var result = this._pxScene.raycastSingle(ray.origin, ray.direction, distance, pxHitResult, this._pxFilterData, this._physXPhysics._physX.PxQueryFilterCallback.implement(raycastCallback));
|
|
1024
1049
|
if (result && hit != undefined) {
|
|
1025
1050
|
var position = PhysXPhysicsManager._tempPosition, normal = PhysXPhysicsManager._tempNormal;
|
|
1026
1051
|
var pxPosition = pxHitResult.position, pxNormal = pxHitResult.normal;
|
|
1027
1052
|
position.set(pxPosition.x, pxPosition.y, pxPosition.z);
|
|
1028
1053
|
normal.set(pxNormal.x, pxNormal.y, pxNormal.z);
|
|
1029
|
-
hit(pxHitResult.getShape().
|
|
1054
|
+
hit(pxHitResult.getShape().getUUID(), pxHitResult.distance, position, normal);
|
|
1030
1055
|
}
|
|
1031
1056
|
return result;
|
|
1032
1057
|
};
|
|
@@ -1074,11 +1099,6 @@
|
|
|
1074
1099
|
}
|
|
1075
1100
|
}
|
|
1076
1101
|
};
|
|
1077
|
-
PhysXPhysicsManager._init = function _init() {
|
|
1078
|
-
PhysXPhysicsManager._pxRaycastHit = new exports.PhysXPhysics._physX.PxRaycastHit();
|
|
1079
|
-
PhysXPhysicsManager._pxFilterData = new exports.PhysXPhysics._physX.PxQueryFilterData();
|
|
1080
|
-
PhysXPhysicsManager._pxFilterData.flags = new exports.PhysXPhysics._physX.PxQueryFlags(1 | 2 | 4);
|
|
1081
|
-
};
|
|
1082
1102
|
return PhysXPhysicsManager;
|
|
1083
1103
|
}();
|
|
1084
1104
|
(function() {
|
|
@@ -1116,8 +1136,9 @@
|
|
|
1116
1136
|
/**
|
|
1117
1137
|
* Physics material describes how to handle colliding objects (friction, bounciness).
|
|
1118
1138
|
*/ var PhysXPhysicsMaterial = /*#__PURE__*/ function() {
|
|
1119
|
-
function PhysXPhysicsMaterial(staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine) {
|
|
1120
|
-
|
|
1139
|
+
function PhysXPhysicsMaterial(physXPhysics, staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine) {
|
|
1140
|
+
this._physXPhysics = physXPhysics;
|
|
1141
|
+
var pxMaterial = physXPhysics._pxPhysics.createMaterial(staticFriction, dynamicFriction, bounciness);
|
|
1121
1142
|
pxMaterial.setFrictionCombineMode(frictionCombine);
|
|
1122
1143
|
pxMaterial.setRestitutionCombineMode(bounceCombine);
|
|
1123
1144
|
this._pxMaterial = pxMaterial;
|
|
@@ -1170,10 +1191,10 @@
|
|
|
1170
1191
|
* @remarks Mostly used for object which always stays at the same place and never moves around.
|
|
1171
1192
|
*/ var PhysXStaticCollider = /*#__PURE__*/ function(PhysXCollider) {
|
|
1172
1193
|
_inherits(PhysXStaticCollider, PhysXCollider);
|
|
1173
|
-
function PhysXStaticCollider(position, rotation) {
|
|
1194
|
+
function PhysXStaticCollider(physXPhysics, position, rotation) {
|
|
1174
1195
|
var _this;
|
|
1175
|
-
_this = PhysXCollider.call(this) || this;
|
|
1176
|
-
_this._pxActor =
|
|
1196
|
+
_this = PhysXCollider.call(this, physXPhysics) || this;
|
|
1197
|
+
_this._pxActor = physXPhysics._pxPhysics.createRigidStatic(_this._transform(position, rotation));
|
|
1177
1198
|
return _this;
|
|
1178
1199
|
}
|
|
1179
1200
|
return PhysXStaticCollider;
|
|
@@ -1183,23 +1204,16 @@
|
|
|
1183
1204
|
* Plane collider shape in PhysX.
|
|
1184
1205
|
*/ var PhysXPlaneColliderShape = /*#__PURE__*/ function(PhysXColliderShape1) {
|
|
1185
1206
|
_inherits(PhysXPlaneColliderShape, PhysXColliderShape1);
|
|
1186
|
-
function PhysXPlaneColliderShape(uniqueID, material) {
|
|
1207
|
+
function PhysXPlaneColliderShape(physXPhysics, uniqueID, material) {
|
|
1187
1208
|
var _this;
|
|
1188
|
-
_this = PhysXColliderShape1.call(this) || this;
|
|
1209
|
+
_this = PhysXColliderShape1.call(this, physXPhysics) || this;
|
|
1189
1210
|
_this._axis = new engine.Quaternion(0, 0, PhysXColliderShape.halfSqrt, PhysXColliderShape.halfSqrt);
|
|
1190
|
-
_this.
|
|
1191
|
-
_this._pxGeometry = new
|
|
1211
|
+
_this._physXRotation.copyFrom(_this._axis);
|
|
1212
|
+
_this._pxGeometry = new physXPhysics._physX.PxPlaneGeometry();
|
|
1192
1213
|
_this._initialize(material, uniqueID);
|
|
1193
1214
|
_this._setLocalPose();
|
|
1194
1215
|
return _this;
|
|
1195
1216
|
}
|
|
1196
|
-
var _proto = PhysXPlaneColliderShape.prototype;
|
|
1197
|
-
/**
|
|
1198
|
-
* {@inheritDoc IColliderShape.setWorldScale }
|
|
1199
|
-
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
1200
|
-
this._scale.copyFrom(scale);
|
|
1201
|
-
this._setLocalPose();
|
|
1202
|
-
};
|
|
1203
1217
|
return PhysXPlaneColliderShape;
|
|
1204
1218
|
}(PhysXColliderShape);
|
|
1205
1219
|
|
|
@@ -1207,12 +1221,12 @@
|
|
|
1207
1221
|
* Sphere collider shape in PhysX.
|
|
1208
1222
|
*/ var PhysXSphereColliderShape = /*#__PURE__*/ function(PhysXColliderShape) {
|
|
1209
1223
|
_inherits(PhysXSphereColliderShape, PhysXColliderShape);
|
|
1210
|
-
function PhysXSphereColliderShape(uniqueID, radius, material) {
|
|
1224
|
+
function PhysXSphereColliderShape(physXPhysics, uniqueID, radius, material) {
|
|
1211
1225
|
var _this;
|
|
1212
|
-
_this = PhysXColliderShape.call(this) || this;
|
|
1226
|
+
_this = PhysXColliderShape.call(this, physXPhysics) || this;
|
|
1213
1227
|
_this._maxScale = 1;
|
|
1214
1228
|
_this._radius = radius;
|
|
1215
|
-
_this._pxGeometry = new
|
|
1229
|
+
_this._pxGeometry = new physXPhysics._physX.PxSphereGeometry(_this._radius * _this._maxScale);
|
|
1216
1230
|
_this._initialize(material, uniqueID);
|
|
1217
1231
|
_this._setLocalPose();
|
|
1218
1232
|
return _this;
|
|
@@ -1228,9 +1242,8 @@
|
|
|
1228
1242
|
/**
|
|
1229
1243
|
* {@inheritDoc IColliderShape.setWorldScale }
|
|
1230
1244
|
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
1231
|
-
|
|
1232
|
-
this.
|
|
1233
|
-
this._maxScale = Math.max(scale.x, Math.max(scale.x, scale.y));
|
|
1245
|
+
PhysXColliderShape.prototype.setWorldScale.call(this, scale);
|
|
1246
|
+
this._maxScale = Math.max(scale.x, scale.y);
|
|
1234
1247
|
this._pxGeometry.radius = this._radius * this._maxScale;
|
|
1235
1248
|
this._pxShape.setGeometry(this._pxGeometry);
|
|
1236
1249
|
};
|
|
@@ -1238,21 +1251,26 @@
|
|
|
1238
1251
|
}(PhysXColliderShape);
|
|
1239
1252
|
|
|
1240
1253
|
/**
|
|
1241
|
-
*
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
function PhysXPhysics1() {}
|
|
1254
|
+
* PhysX object creation.
|
|
1255
|
+
*/ var PhysXPhysics = /*#__PURE__*/ function() {
|
|
1256
|
+
function PhysXPhysics(runtimeMode) {
|
|
1257
|
+
if (runtimeMode === void 0) runtimeMode = exports.PhysXRuntimeMode.Auto;
|
|
1258
|
+
this._initializeState = 0;
|
|
1259
|
+
this._runTimeMode = runtimeMode;
|
|
1260
|
+
}
|
|
1261
|
+
var _proto = PhysXPhysics.prototype;
|
|
1250
1262
|
/**
|
|
1251
1263
|
* Initialize PhysXPhysics.
|
|
1252
1264
|
* @param runtimeMode - Runtime mode
|
|
1253
1265
|
* @returns Promise object
|
|
1254
|
-
*/
|
|
1255
|
-
|
|
1266
|
+
*/ _proto.initialize = function initialize() {
|
|
1267
|
+
var _this = this;
|
|
1268
|
+
if (this._initializeState === 2) {
|
|
1269
|
+
return Promise.resolve();
|
|
1270
|
+
} else if (this._initializeState === 1) {
|
|
1271
|
+
return this._initializePromise;
|
|
1272
|
+
}
|
|
1273
|
+
var runtimeMode = this._runTimeMode;
|
|
1256
1274
|
var scriptPromise = new Promise(function(resolve, reject) {
|
|
1257
1275
|
var script = document.createElement("script");
|
|
1258
1276
|
document.body.appendChild(script);
|
|
@@ -1276,107 +1294,117 @@
|
|
|
1276
1294
|
}
|
|
1277
1295
|
}
|
|
1278
1296
|
if (runtimeMode == exports.PhysXRuntimeMode.JavaScript) {
|
|
1279
|
-
script.src = "https://gw.alipayobjects.com/os/lib/oasis-engine/physics-physx/
|
|
1297
|
+
script.src = "https://gw.alipayobjects.com/os/lib/oasis-engine/physics-physx/" + engine.version + "/libs/physx.release.js.js";
|
|
1280
1298
|
} else if (runtimeMode == exports.PhysXRuntimeMode.WebAssembly) {
|
|
1281
|
-
script.src = "https://gw.alipayobjects.com/os/lib/
|
|
1299
|
+
script.src = "https://gw.alipayobjects.com/os/lib/galacean/engine-physics-physx/" + engine.version + "/libs/physx.release.js";
|
|
1282
1300
|
}
|
|
1283
1301
|
});
|
|
1284
|
-
|
|
1302
|
+
var initializePromise = new Promise(function(resolve, reject) {
|
|
1285
1303
|
scriptPromise.then(function() {
|
|
1286
1304
|
return window.PHYSX().then(function(PHYSX) {
|
|
1287
|
-
|
|
1305
|
+
_this._init(PHYSX);
|
|
1306
|
+
_this._initializeState = 2;
|
|
1307
|
+
_this._initializePromise = null;
|
|
1288
1308
|
console.log("PhysX loaded.");
|
|
1289
1309
|
resolve();
|
|
1290
1310
|
}, reject);
|
|
1291
1311
|
}, reject).catch(reject);
|
|
1292
1312
|
});
|
|
1313
|
+
this._initializePromise = initializePromise;
|
|
1314
|
+
return initializePromise;
|
|
1293
1315
|
};
|
|
1294
1316
|
/**
|
|
1295
1317
|
* Destroy PhysXPhysics.
|
|
1296
|
-
*/
|
|
1297
|
-
this.
|
|
1318
|
+
*/ _proto.destroy = function destroy() {
|
|
1319
|
+
this._physX.PxCloseExtensions();
|
|
1298
1320
|
this._pxPhysics.release();
|
|
1321
|
+
this._pxFoundation.release();
|
|
1299
1322
|
this._physX = null;
|
|
1300
1323
|
this._pxFoundation = null;
|
|
1301
1324
|
this._pxPhysics = null;
|
|
1302
1325
|
};
|
|
1303
1326
|
/**
|
|
1304
1327
|
* {@inheritDoc IPhysics.createPhysicsManager }
|
|
1305
|
-
*/
|
|
1306
|
-
|
|
1328
|
+
*/ _proto.createPhysicsManager = function createPhysicsManager(onContactBegin, onContactEnd, onContactStay, onTriggerBegin, onTriggerEnd, onTriggerStay) {
|
|
1329
|
+
var manager = new PhysXPhysicsManager(this, onContactBegin, onContactEnd, onContactStay, onTriggerBegin, onTriggerEnd, onTriggerStay);
|
|
1330
|
+
return manager;
|
|
1307
1331
|
};
|
|
1308
1332
|
/**
|
|
1309
1333
|
* {@inheritDoc IPhysics.createStaticCollider }
|
|
1310
|
-
*/
|
|
1311
|
-
return new PhysXStaticCollider(position, rotation);
|
|
1334
|
+
*/ _proto.createStaticCollider = function createStaticCollider(position, rotation) {
|
|
1335
|
+
return new PhysXStaticCollider(this, position, rotation);
|
|
1312
1336
|
};
|
|
1313
1337
|
/**
|
|
1314
1338
|
* {@inheritDoc IPhysics.createDynamicCollider }
|
|
1315
|
-
*/
|
|
1316
|
-
return new PhysXDynamicCollider(position, rotation);
|
|
1339
|
+
*/ _proto.createDynamicCollider = function createDynamicCollider(position, rotation) {
|
|
1340
|
+
return new PhysXDynamicCollider(this, position, rotation);
|
|
1317
1341
|
};
|
|
1318
1342
|
/**
|
|
1319
1343
|
* {@inheritDoc IPhysics.createCharacterController }
|
|
1320
|
-
*/
|
|
1321
|
-
return new PhysXCharacterController();
|
|
1344
|
+
*/ _proto.createCharacterController = function createCharacterController() {
|
|
1345
|
+
return new PhysXCharacterController(this);
|
|
1322
1346
|
};
|
|
1323
1347
|
/**
|
|
1324
1348
|
* {@inheritDoc IPhysics.createPhysicsMaterial }
|
|
1325
|
-
*/
|
|
1326
|
-
return new PhysXPhysicsMaterial(staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine);
|
|
1349
|
+
*/ _proto.createPhysicsMaterial = function createPhysicsMaterial(staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine) {
|
|
1350
|
+
return new PhysXPhysicsMaterial(this, staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine);
|
|
1327
1351
|
};
|
|
1328
1352
|
/**
|
|
1329
1353
|
* {@inheritDoc IPhysics.createBoxColliderShape }
|
|
1330
|
-
*/
|
|
1331
|
-
return new PhysXBoxColliderShape(uniqueID, size, material);
|
|
1354
|
+
*/ _proto.createBoxColliderShape = function createBoxColliderShape(uniqueID, size, material) {
|
|
1355
|
+
return new PhysXBoxColliderShape(this, uniqueID, size, material);
|
|
1332
1356
|
};
|
|
1333
1357
|
/**
|
|
1334
1358
|
* {@inheritDoc IPhysics.createSphereColliderShape }
|
|
1335
|
-
*/
|
|
1336
|
-
return new PhysXSphereColliderShape(uniqueID, radius, material);
|
|
1359
|
+
*/ _proto.createSphereColliderShape = function createSphereColliderShape(uniqueID, radius, material) {
|
|
1360
|
+
return new PhysXSphereColliderShape(this, uniqueID, radius, material);
|
|
1337
1361
|
};
|
|
1338
1362
|
/**
|
|
1339
1363
|
* {@inheritDoc IPhysics.createPlaneColliderShape }
|
|
1340
|
-
*/
|
|
1341
|
-
return new PhysXPlaneColliderShape(uniqueID, material);
|
|
1364
|
+
*/ _proto.createPlaneColliderShape = function createPlaneColliderShape(uniqueID, material) {
|
|
1365
|
+
return new PhysXPlaneColliderShape(this, uniqueID, material);
|
|
1342
1366
|
};
|
|
1343
1367
|
/**
|
|
1344
1368
|
* {@inheritDoc IPhysics.createCapsuleColliderShape }
|
|
1345
|
-
*/
|
|
1346
|
-
return new PhysXCapsuleColliderShape(uniqueID, radius, height, material);
|
|
1369
|
+
*/ _proto.createCapsuleColliderShape = function createCapsuleColliderShape(uniqueID, radius, height, material) {
|
|
1370
|
+
return new PhysXCapsuleColliderShape(this, uniqueID, radius, height, material);
|
|
1347
1371
|
};
|
|
1348
1372
|
/**
|
|
1349
1373
|
* {@inheritDoc IPhysics.createFixedJoint }
|
|
1350
|
-
*/
|
|
1351
|
-
return new PhysXFixedJoint(collider);
|
|
1374
|
+
*/ _proto.createFixedJoint = function createFixedJoint(collider) {
|
|
1375
|
+
return new PhysXFixedJoint(this, collider);
|
|
1352
1376
|
};
|
|
1353
1377
|
/**
|
|
1354
1378
|
* {@inheritDoc IPhysics.createHingeJoint }
|
|
1355
|
-
*/
|
|
1356
|
-
return new PhysXHingeJoint(collider);
|
|
1379
|
+
*/ _proto.createHingeJoint = function createHingeJoint(collider) {
|
|
1380
|
+
return new PhysXHingeJoint(this, collider);
|
|
1357
1381
|
};
|
|
1358
1382
|
/**
|
|
1359
1383
|
* {@inheritDoc IPhysics.createSpringJoint }
|
|
1360
|
-
*/
|
|
1361
|
-
return new PhysXSpringJoint(collider);
|
|
1384
|
+
*/ _proto.createSpringJoint = function createSpringJoint(collider) {
|
|
1385
|
+
return new PhysXSpringJoint(this, collider);
|
|
1362
1386
|
};
|
|
1363
|
-
|
|
1387
|
+
_proto._init = function _init(physX) {
|
|
1364
1388
|
var version = physX.PX_PHYSICS_VERSION;
|
|
1365
1389
|
var defaultErrorCallback = new physX.PxDefaultErrorCallback();
|
|
1366
1390
|
var allocator = new physX.PxDefaultAllocator();
|
|
1367
1391
|
var pxFoundation = physX.PxCreateFoundation(version, allocator, defaultErrorCallback);
|
|
1368
1392
|
var pxPhysics = physX.PxCreatePhysics(version, pxFoundation, new physX.PxTolerancesScale(), false, null);
|
|
1369
1393
|
physX.PxInitExtensions(pxPhysics, null);
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
PhysXPhysicsManager._init();
|
|
1394
|
+
this._physX = physX;
|
|
1395
|
+
this._pxFoundation = pxFoundation;
|
|
1396
|
+
this._pxPhysics = pxPhysics;
|
|
1374
1397
|
};
|
|
1375
|
-
return
|
|
1398
|
+
return PhysXPhysics;
|
|
1376
1399
|
}();
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1400
|
+
var InitializeState;
|
|
1401
|
+
(function(InitializeState) {
|
|
1402
|
+
InitializeState[InitializeState["Uninitialized"] = 0] = "Uninitialized";
|
|
1403
|
+
InitializeState[InitializeState["Initializing"] = 1] = "Initializing";
|
|
1404
|
+
InitializeState[InitializeState["Initialized"] = 2] = "Initialized";
|
|
1405
|
+
})(InitializeState || (InitializeState = {}));
|
|
1406
|
+
|
|
1407
|
+
exports.PhysXPhysics = PhysXPhysics;
|
|
1380
1408
|
|
|
1381
1409
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1382
1410
|
|