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