@galacean/engine-physics-physx 0.0.0-experimental-double11.4 → 0.0.0-experimental-double11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +376 -352
- package/dist/browser.min.js +1 -1
- package/dist/main.js +376 -352
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +376 -352
- package/dist/module.js +379 -356
- package/dist/module.js.map +1 -1
- package/libs/.DS_Store +0 -0
- package/libs/physx.release.js.js +31 -31
- package/libs/physx.release.wasm +0 -0
- package/package.json +4 -4
- package/types/PhysXCharacterController.d.ts +3 -2
- package/types/PhysXPhysics.d.ts +8 -3
- package/types/PhysXPhysicsManager.d.ts +0 -64
- package/types/index.d.ts +1 -0
- package/types/joint/PhysXHingeJoint.d.ts +2 -3
- package/types/shape/PhysXColliderShape.d.ts +2 -2
- package/libs/physx.release.js.mem +0 -0
package/dist/browser.js
CHANGED
|
@@ -10,15 +10,6 @@
|
|
|
10
10
|
} else return left instanceof right;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
* PhysX runtime mode.
|
|
15
|
-
*/ exports.PhysXRuntimeMode = void 0;
|
|
16
|
-
(function(PhysXRuntimeMode) {
|
|
17
|
-
PhysXRuntimeMode[PhysXRuntimeMode[/** Use webAssembly mode first, if WebAssembly mode is not supported, roll back to JavaScript mode. */ "Auto"] = 0] = "Auto";
|
|
18
|
-
PhysXRuntimeMode[PhysXRuntimeMode[/** WebAssembly mode. */ "WebAssembly"] = 1] = "WebAssembly";
|
|
19
|
-
PhysXRuntimeMode[PhysXRuntimeMode[/** JavaScript mode. */ "JavaScript"] = 2] = "JavaScript";
|
|
20
|
-
})(exports.PhysXRuntimeMode || (exports.PhysXRuntimeMode = {}));
|
|
21
|
-
|
|
22
13
|
function _set_prototype_of(o, p) {
|
|
23
14
|
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
24
15
|
o.__proto__ = p;
|
|
@@ -39,222 +30,6 @@
|
|
|
39
30
|
if (superClass) _set_prototype_of(subClass, superClass);
|
|
40
31
|
}
|
|
41
32
|
|
|
42
|
-
/**
|
|
43
|
-
* a base interface providing common functionality for PhysX joints
|
|
44
|
-
*/ var PhysXJoint = /*#__PURE__*/ function() {
|
|
45
|
-
function PhysXJoint(physXPhysics) {
|
|
46
|
-
this._connectedAnchor = new engine.Vector3();
|
|
47
|
-
this._breakForce = Number.MAX_VALUE;
|
|
48
|
-
this._breakTorque = Number.MAX_VALUE;
|
|
49
|
-
this._physXPhysics = physXPhysics;
|
|
50
|
-
}
|
|
51
|
-
var _proto = PhysXJoint.prototype;
|
|
52
|
-
/**
|
|
53
|
-
* {@inheritDoc IJoint.setConnectedCollider }
|
|
54
|
-
*/ _proto.setConnectedCollider = function setConnectedCollider(value) {
|
|
55
|
-
var _this__collider;
|
|
56
|
-
this._pxJoint.setActors((value == null ? void 0 : value._pxActor) || null, ((_this__collider = this._collider) == null ? void 0 : _this__collider._pxActor) || null);
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* {@inheritDoc IJoint.setConnectedAnchor }
|
|
60
|
-
*/ _proto.setConnectedAnchor = function setConnectedAnchor(value) {
|
|
61
|
-
this._connectedAnchor.copyFrom(value);
|
|
62
|
-
this._setLocalPose(0, value, PhysXJoint._defaultQuat);
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* {@inheritDoc IJoint.setConnectedMassScale }
|
|
66
|
-
*/ _proto.setConnectedMassScale = function setConnectedMassScale(value) {
|
|
67
|
-
this._pxJoint.setInvMassScale0(1 / value);
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* {@inheritDoc IJoint.setConnectedInertiaScale }
|
|
71
|
-
*/ _proto.setConnectedInertiaScale = function setConnectedInertiaScale(value) {
|
|
72
|
-
this._pxJoint.setInvInertiaScale0(1 / value);
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* {@inheritDoc IJoint.setMassScale }
|
|
76
|
-
*/ _proto.setMassScale = function setMassScale(value) {
|
|
77
|
-
this._pxJoint.setInvMassScale1(1 / value);
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* {@inheritDoc IJoint.setInertiaScale }
|
|
81
|
-
*/ _proto.setInertiaScale = function setInertiaScale(value) {
|
|
82
|
-
this._pxJoint.setInvInertiaScale1(1 / value);
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* {@inheritDoc IJoint.setBreakForce }
|
|
86
|
-
*/ _proto.setBreakForce = function setBreakForce(value) {
|
|
87
|
-
this._breakForce = value;
|
|
88
|
-
this._pxJoint.setBreakForce(this._breakForce, this._breakTorque);
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* {@inheritDoc IJoint.setBreakTorque }
|
|
92
|
-
*/ _proto.setBreakTorque = function setBreakTorque(value) {
|
|
93
|
-
this._breakTorque = value;
|
|
94
|
-
this._pxJoint.setBreakForce(this._breakForce, this._breakTorque);
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* Set the joint local pose for an actor.
|
|
98
|
-
* @param actor 0 for the first actor, 1 for the second actor.
|
|
99
|
-
* @param position the local position for the actor this joint
|
|
100
|
-
* @param rotation the local rotation for the actor this joint
|
|
101
|
-
*/ _proto._setLocalPose = function _setLocalPose(actor, position, rotation) {
|
|
102
|
-
this._pxJoint.setLocalPose(actor, position, rotation);
|
|
103
|
-
};
|
|
104
|
-
return PhysXJoint;
|
|
105
|
-
}();
|
|
106
|
-
(function() {
|
|
107
|
-
PhysXJoint._xAxis = new engine.Vector3(1, 0, 0);
|
|
108
|
-
})();
|
|
109
|
-
(function() {
|
|
110
|
-
PhysXJoint._defaultVec = new engine.Vector3();
|
|
111
|
-
})();
|
|
112
|
-
(function() {
|
|
113
|
-
PhysXJoint._defaultQuat = new engine.Quaternion();
|
|
114
|
-
})();
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* A fixed joint permits no relative movement between two colliders. ie the bodies are glued together.
|
|
118
|
-
*/ var PhysXFixedJoint = /*#__PURE__*/ function(PhysXJoint1) {
|
|
119
|
-
_inherits(PhysXFixedJoint, PhysXJoint1);
|
|
120
|
-
function PhysXFixedJoint(physXPhysics, collider) {
|
|
121
|
-
var _this;
|
|
122
|
-
_this = PhysXJoint1.call(this, physXPhysics) || this;
|
|
123
|
-
_this._collider = collider;
|
|
124
|
-
_this._pxJoint = physXPhysics._pxPhysics.createFixedJoint(null, PhysXJoint._defaultVec, PhysXJoint._defaultQuat, collider._pxActor, PhysXJoint._defaultVec, PhysXJoint._defaultQuat);
|
|
125
|
-
return _this;
|
|
126
|
-
}
|
|
127
|
-
return PhysXFixedJoint;
|
|
128
|
-
}(PhysXJoint);
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* A joint which behaves in a similar way to a hinge or axle.
|
|
132
|
-
*/ var PhysXHingeJoint = /*#__PURE__*/ function(PhysXJoint1) {
|
|
133
|
-
_inherits(PhysXHingeJoint, PhysXJoint1);
|
|
134
|
-
function PhysXHingeJoint(physXPhysics, collider) {
|
|
135
|
-
var _this;
|
|
136
|
-
_this = PhysXJoint1.call(this, physXPhysics) || this;
|
|
137
|
-
_this._axisRotationQuaternion = new engine.Quaternion();
|
|
138
|
-
_this._swingOffset = new engine.Vector3();
|
|
139
|
-
_this._velocity = new engine.Vector3();
|
|
140
|
-
_this._collider = collider;
|
|
141
|
-
_this._pxJoint = physXPhysics._pxPhysics.createRevoluteJoint(null, PhysXJoint._defaultVec, PhysXJoint._defaultQuat, collider._pxActor, PhysXJoint._defaultVec, PhysXJoint._defaultQuat);
|
|
142
|
-
return _this;
|
|
143
|
-
}
|
|
144
|
-
var _proto = PhysXHingeJoint.prototype;
|
|
145
|
-
/**
|
|
146
|
-
* {@inheritDoc IHingeJoint.setAxis }
|
|
147
|
-
*/ _proto.setAxis = function setAxis(value) {
|
|
148
|
-
var xAxis = PhysXJoint._xAxis;
|
|
149
|
-
var axisRotationQuaternion = this._axisRotationQuaternion;
|
|
150
|
-
xAxis.set(1, 0, 0);
|
|
151
|
-
value.normalize();
|
|
152
|
-
var angle = Math.acos(engine.Vector3.dot(xAxis, value));
|
|
153
|
-
engine.Vector3.cross(xAxis, value, xAxis);
|
|
154
|
-
engine.Quaternion.rotationAxisAngle(xAxis, angle, axisRotationQuaternion);
|
|
155
|
-
this._setLocalPose(0, this._swingOffset, axisRotationQuaternion);
|
|
156
|
-
};
|
|
157
|
-
/**
|
|
158
|
-
* {@inheritDoc IHingeJoint.setSwingOffset }
|
|
159
|
-
*/ _proto.setSwingOffset = function setSwingOffset(value) {
|
|
160
|
-
this._swingOffset.copyFrom(value);
|
|
161
|
-
this._setLocalPose(1, this._swingOffset, this._axisRotationQuaternion);
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* {@inheritDoc IHingeJoint.getAngle }
|
|
165
|
-
*/ _proto.getAngle = function getAngle() {
|
|
166
|
-
return this._pxJoint.getAngle();
|
|
167
|
-
};
|
|
168
|
-
/**
|
|
169
|
-
* {@inheritDoc IHingeJoint.getVelocity }
|
|
170
|
-
*/ _proto.getVelocity = function getVelocity() {
|
|
171
|
-
var velocity = this._velocity;
|
|
172
|
-
velocity.copyFrom(this._pxJoint.getVelocity());
|
|
173
|
-
return velocity;
|
|
174
|
-
};
|
|
175
|
-
/**
|
|
176
|
-
* {@inheritDoc IHingeJoint.setHardLimitCone }
|
|
177
|
-
*/ _proto.setHardLimit = function setHardLimit(lowerLimit, upperLimit, contactDist) {
|
|
178
|
-
this._pxJoint.setHardLimit(lowerLimit, upperLimit, contactDist);
|
|
179
|
-
};
|
|
180
|
-
/**
|
|
181
|
-
* {@inheritDoc IHingeJoint.setHardLimitCone }
|
|
182
|
-
*/ _proto.setSoftLimit = function setSoftLimit(lowerLimit, upperLimit, stiffness, damping) {
|
|
183
|
-
this._pxJoint.setSoftLimit(lowerLimit, upperLimit, stiffness, damping);
|
|
184
|
-
};
|
|
185
|
-
/**
|
|
186
|
-
* {@inheritDoc IHingeJoint.setDriveVelocity }
|
|
187
|
-
*/ _proto.setDriveVelocity = function setDriveVelocity(velocity) {
|
|
188
|
-
this._pxJoint.setDriveVelocity(velocity);
|
|
189
|
-
};
|
|
190
|
-
/**
|
|
191
|
-
* {@inheritDoc IHingeJoint.setDriveForceLimit }
|
|
192
|
-
*/ _proto.setDriveForceLimit = function setDriveForceLimit(limit) {
|
|
193
|
-
this._pxJoint.setDriveForceLimit(limit);
|
|
194
|
-
};
|
|
195
|
-
/**
|
|
196
|
-
* {@inheritDoc IHingeJoint.setDriveGearRatio }
|
|
197
|
-
*/ _proto.setDriveGearRatio = function setDriveGearRatio(ratio) {
|
|
198
|
-
this._pxJoint.setDriveGearRatio(ratio);
|
|
199
|
-
};
|
|
200
|
-
/**
|
|
201
|
-
* {@inheritDoc IHingeJoint.setHingeJointFlag }
|
|
202
|
-
*/ _proto.setHingeJointFlag = function setHingeJointFlag(flag, value) {
|
|
203
|
-
this._pxJoint.setRevoluteJointFlag(flag, value);
|
|
204
|
-
};
|
|
205
|
-
return PhysXHingeJoint;
|
|
206
|
-
}(PhysXJoint);
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* a joint that maintains an upper or lower bound (or both) on the distance between two points on different objects
|
|
210
|
-
*/ var PhysXSpringJoint = /*#__PURE__*/ function(PhysXJoint1) {
|
|
211
|
-
_inherits(PhysXSpringJoint, PhysXJoint1);
|
|
212
|
-
function PhysXSpringJoint(physXPhysics, collider) {
|
|
213
|
-
var _this;
|
|
214
|
-
_this = PhysXJoint1.call(this, physXPhysics) || this;
|
|
215
|
-
_this._swingOffset = new engine.Vector3();
|
|
216
|
-
_this._collider = collider;
|
|
217
|
-
_this._pxJoint = physXPhysics._pxPhysics.createDistanceJoint(null, PhysXJoint._defaultVec, PhysXJoint._defaultQuat, collider._pxActor, PhysXJoint._defaultVec, PhysXJoint._defaultQuat);
|
|
218
|
-
_this._pxJoint.setDistanceJointFlag(2, true); // enable max distance;
|
|
219
|
-
_this._pxJoint.setDistanceJointFlag(4, true); // enable min distance;
|
|
220
|
-
_this._pxJoint.setDistanceJointFlag(8, true); // enable spring;
|
|
221
|
-
return _this;
|
|
222
|
-
}
|
|
223
|
-
var _proto = PhysXSpringJoint.prototype;
|
|
224
|
-
/**
|
|
225
|
-
* {@inheritDoc ISpringJoint.setSwingOffset }
|
|
226
|
-
*/ _proto.setSwingOffset = function setSwingOffset(value) {
|
|
227
|
-
this._swingOffset.copyFrom(value);
|
|
228
|
-
this._setLocalPose(1, value, PhysXJoint._defaultQuat);
|
|
229
|
-
};
|
|
230
|
-
/**
|
|
231
|
-
* {@inheritDoc ISpringJoint.setMinDistance }
|
|
232
|
-
*/ _proto.setMinDistance = function setMinDistance(distance) {
|
|
233
|
-
this._pxJoint.setMinDistance(distance);
|
|
234
|
-
};
|
|
235
|
-
/**
|
|
236
|
-
* {@inheritDoc ISpringJoint.setMaxDistance }
|
|
237
|
-
*/ _proto.setMaxDistance = function setMaxDistance(distance) {
|
|
238
|
-
this._pxJoint.setMaxDistance(distance);
|
|
239
|
-
};
|
|
240
|
-
/**
|
|
241
|
-
* {@inheritDoc ISpringJoint.setTolerance }
|
|
242
|
-
*/ _proto.setTolerance = function setTolerance(tolerance) {
|
|
243
|
-
this._pxJoint.setTolerance(tolerance);
|
|
244
|
-
};
|
|
245
|
-
/**
|
|
246
|
-
* {@inheritDoc ISpringJoint.setStiffness }
|
|
247
|
-
*/ _proto.setStiffness = function setStiffness(stiffness) {
|
|
248
|
-
this._pxJoint.setStiffness(stiffness);
|
|
249
|
-
};
|
|
250
|
-
/**
|
|
251
|
-
* {@inheritDoc ISpringJoint.setDamping }
|
|
252
|
-
*/ _proto.setDamping = function setDamping(damping) {
|
|
253
|
-
this._pxJoint.setDamping(damping);
|
|
254
|
-
};
|
|
255
|
-
return PhysXSpringJoint;
|
|
256
|
-
}(PhysXJoint);
|
|
257
|
-
|
|
258
33
|
/**
|
|
259
34
|
* High-performance unordered array, delete uses exchange method to improve performance, internal capacity only increases.
|
|
260
35
|
*/ var DisorderedArray = /*#__PURE__*/ function() {
|
|
@@ -312,7 +87,7 @@
|
|
|
312
87
|
*/ var PhysXColliderShape = /*#__PURE__*/ function() {
|
|
313
88
|
function PhysXColliderShape(physXPhysics) {
|
|
314
89
|
/** @internal */ this._controllers = new DisorderedArray();
|
|
315
|
-
this.
|
|
90
|
+
this._worldScale = new engine.Vector3(1, 1, 1);
|
|
316
91
|
this._position = new engine.Vector3();
|
|
317
92
|
this._rotation = null;
|
|
318
93
|
this._axis = null;
|
|
@@ -338,18 +113,18 @@
|
|
|
338
113
|
}
|
|
339
114
|
var controllers = this._controllers;
|
|
340
115
|
for(var i = 0, n = controllers.length; i < n; i++){
|
|
341
|
-
controllers.get(i).
|
|
116
|
+
controllers.get(i)._updateShapePosition(this._position, this._worldScale);
|
|
342
117
|
}
|
|
343
118
|
this._setLocalPose();
|
|
344
119
|
};
|
|
345
120
|
/**
|
|
346
121
|
* {@inheritDoc IColliderShape.setWorldScale }
|
|
347
122
|
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
348
|
-
this.
|
|
123
|
+
this._worldScale.copyFrom(scale);
|
|
349
124
|
this._setLocalPose();
|
|
350
125
|
var controllers = this._controllers;
|
|
351
126
|
for(var i = 0, n = controllers.length; i < n; i++){
|
|
352
|
-
controllers.get(i).
|
|
127
|
+
controllers.get(i)._updateShapePosition(this._position, this._worldScale);
|
|
353
128
|
}
|
|
354
129
|
};
|
|
355
130
|
/**
|
|
@@ -388,7 +163,7 @@
|
|
|
388
163
|
};
|
|
389
164
|
_proto._setLocalPose = function _setLocalPose() {
|
|
390
165
|
var transform = PhysXColliderShape.transform;
|
|
391
|
-
engine.Vector3.multiply(this._position, this.
|
|
166
|
+
engine.Vector3.multiply(this._position, this._worldScale, transform.translation);
|
|
392
167
|
transform.rotation = this._physXRotation;
|
|
393
168
|
this._pxShape.setLocalPose(transform);
|
|
394
169
|
};
|
|
@@ -415,14 +190,14 @@
|
|
|
415
190
|
|
|
416
191
|
/**
|
|
417
192
|
* Box collider shape in PhysX.
|
|
418
|
-
*/ var PhysXBoxColliderShape = /*#__PURE__*/ function(
|
|
419
|
-
_inherits(PhysXBoxColliderShape,
|
|
193
|
+
*/ var PhysXBoxColliderShape = /*#__PURE__*/ function(PhysXColliderShape1) {
|
|
194
|
+
_inherits(PhysXBoxColliderShape, PhysXColliderShape1);
|
|
420
195
|
function PhysXBoxColliderShape(physXPhysics, uniqueID, size, material) {
|
|
421
196
|
var _this;
|
|
422
|
-
_this =
|
|
197
|
+
_this = PhysXColliderShape1.call(this, physXPhysics) || this;
|
|
423
198
|
/** @internal */ _this._halfSize = new engine.Vector3();
|
|
424
199
|
_this._halfSize.set(size.x * 0.5, size.y * 0.5, size.z * 0.5);
|
|
425
|
-
_this._pxGeometry = new physXPhysics._physX.PxBoxGeometry(_this._halfSize.x * _this.
|
|
200
|
+
_this._pxGeometry = new physXPhysics._physX.PxBoxGeometry(_this._halfSize.x * _this._worldScale.x, _this._halfSize.y * _this._worldScale.y, _this._halfSize.z * _this._worldScale.z);
|
|
426
201
|
_this._initialize(material, uniqueID);
|
|
427
202
|
_this._setLocalPose();
|
|
428
203
|
return _this;
|
|
@@ -433,7 +208,7 @@
|
|
|
433
208
|
*/ _proto.setSize = function setSize(value) {
|
|
434
209
|
var tempExtents = PhysXBoxColliderShape._tempHalfExtents;
|
|
435
210
|
this._halfSize.set(value.x * 0.5, value.y * 0.5, value.z * 0.5);
|
|
436
|
-
engine.Vector3.multiply(this._halfSize, this.
|
|
211
|
+
engine.Vector3.multiply(this._halfSize, this._worldScale, tempExtents);
|
|
437
212
|
this._pxGeometry.halfExtents = tempExtents;
|
|
438
213
|
this._pxShape.setGeometry(this._pxGeometry);
|
|
439
214
|
this._updateController(tempExtents);
|
|
@@ -441,9 +216,9 @@
|
|
|
441
216
|
/**
|
|
442
217
|
* {@inheritDoc IColliderShape.setWorldScale }
|
|
443
218
|
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
444
|
-
|
|
219
|
+
PhysXColliderShape1.prototype.setWorldScale.call(this, scale);
|
|
445
220
|
var tempExtents = PhysXBoxColliderShape._tempHalfExtents;
|
|
446
|
-
engine.Vector3.multiply(this._halfSize, this.
|
|
221
|
+
engine.Vector3.multiply(this._halfSize, this._worldScale, tempExtents);
|
|
447
222
|
this._pxGeometry.halfExtents = tempExtents;
|
|
448
223
|
this._pxShape.setGeometry(this._pxGeometry);
|
|
449
224
|
this._updateController(tempExtents);
|
|
@@ -487,13 +262,13 @@
|
|
|
487
262
|
this._radius = value;
|
|
488
263
|
switch(this._upAxis){
|
|
489
264
|
case /** Up axis is X. */ 0:
|
|
490
|
-
this._pxGeometry.radius = this._radius * Math.max(this.
|
|
265
|
+
this._pxGeometry.radius = this._radius * Math.max(this._worldScale.y, this._worldScale.z);
|
|
491
266
|
break;
|
|
492
267
|
case 1:
|
|
493
|
-
this._pxGeometry.radius = this._radius * Math.max(this.
|
|
268
|
+
this._pxGeometry.radius = this._radius * Math.max(this._worldScale.x, this._worldScale.z);
|
|
494
269
|
break;
|
|
495
270
|
case /** Up axis is Z. */ 2:
|
|
496
|
-
this._pxGeometry.radius = this._radius * Math.max(this.
|
|
271
|
+
this._pxGeometry.radius = this._radius * Math.max(this._worldScale.x, this._worldScale.y);
|
|
497
272
|
break;
|
|
498
273
|
}
|
|
499
274
|
this._pxShape.setGeometry(this._pxGeometry);
|
|
@@ -509,13 +284,13 @@
|
|
|
509
284
|
this._halfHeight = value * 0.5;
|
|
510
285
|
switch(this._upAxis){
|
|
511
286
|
case 0:
|
|
512
|
-
this._pxGeometry.halfHeight = this._halfHeight * this.
|
|
287
|
+
this._pxGeometry.halfHeight = this._halfHeight * this._worldScale.x;
|
|
513
288
|
break;
|
|
514
289
|
case 1:
|
|
515
|
-
this._pxGeometry.halfHeight = this._halfHeight * this.
|
|
290
|
+
this._pxGeometry.halfHeight = this._halfHeight * this._worldScale.y;
|
|
516
291
|
break;
|
|
517
292
|
case 2:
|
|
518
|
-
this._pxGeometry.halfHeight = this._halfHeight * this.
|
|
293
|
+
this._pxGeometry.halfHeight = this._halfHeight * this._worldScale.z;
|
|
519
294
|
break;
|
|
520
295
|
}
|
|
521
296
|
this._pxShape.setGeometry(this._pxGeometry);
|
|
@@ -593,50 +368,55 @@
|
|
|
593
368
|
* Base class for character controllers.
|
|
594
369
|
*/ var PhysXCharacterController = /*#__PURE__*/ function() {
|
|
595
370
|
function PhysXCharacterController(physXPhysics) {
|
|
596
|
-
this.
|
|
597
|
-
this.
|
|
371
|
+
this._shapeScaledPosition = new engine.Vector3();
|
|
372
|
+
this._worldPosition = null;
|
|
598
373
|
this._physXPhysics = physXPhysics;
|
|
599
374
|
}
|
|
600
375
|
var _proto = PhysXCharacterController.prototype;
|
|
601
376
|
/**
|
|
602
377
|
* {@inheritDoc ICharacterController.move }
|
|
603
378
|
*/ _proto.move = function move(disp, minDist, elapsedTime) {
|
|
604
|
-
|
|
379
|
+
var _this__pxController;
|
|
380
|
+
var _this__pxController_move;
|
|
381
|
+
return (_this__pxController_move = (_this__pxController = this._pxController) == null ? void 0 : _this__pxController.move(disp, minDist, elapsedTime)) != null ? _this__pxController_move : 0;
|
|
605
382
|
};
|
|
606
383
|
/**
|
|
607
384
|
* {@inheritDoc ICharacterController.setWorldPosition }
|
|
608
385
|
*/ _proto.setWorldPosition = function setWorldPosition(position) {
|
|
609
|
-
this.
|
|
610
|
-
|
|
611
|
-
engine.Vector3.add(position, this._scaledOffset, PhysXCharacterController._tempVec);
|
|
612
|
-
this._pxController.setPosition(PhysXCharacterController._tempVec);
|
|
613
|
-
}
|
|
386
|
+
this._worldPosition = position;
|
|
387
|
+
this._updateNativePosition();
|
|
614
388
|
};
|
|
615
389
|
/**
|
|
616
390
|
* {@inheritDoc ICharacterController.getWorldPosition }
|
|
617
391
|
*/ _proto.getWorldPosition = function getWorldPosition(position) {
|
|
618
|
-
|
|
619
|
-
|
|
392
|
+
if (this._pxController) {
|
|
393
|
+
position.copyFrom(this._pxController.getPosition());
|
|
394
|
+
position.subtract(this._shapeScaledPosition);
|
|
395
|
+
}
|
|
620
396
|
};
|
|
621
397
|
/**
|
|
622
398
|
* {@inheritDoc ICharacterController.setStepOffset }
|
|
623
399
|
*/ _proto.setStepOffset = function setStepOffset(offset) {
|
|
624
|
-
|
|
400
|
+
var _this__pxController;
|
|
401
|
+
(_this__pxController = this._pxController) == null ? void 0 : _this__pxController.setStepOffset(offset);
|
|
625
402
|
};
|
|
626
403
|
/**
|
|
627
404
|
* {@inheritDoc ICharacterController.setNonWalkableMode }
|
|
628
405
|
*/ _proto.setNonWalkableMode = function setNonWalkableMode(flag) {
|
|
629
|
-
|
|
406
|
+
var _this__pxController;
|
|
407
|
+
(_this__pxController = this._pxController) == null ? void 0 : _this__pxController.setNonWalkableMode(flag);
|
|
630
408
|
};
|
|
631
409
|
/**
|
|
632
410
|
* {@inheritDoc ICharacterController.setUpDirection }
|
|
633
411
|
*/ _proto.setUpDirection = function setUpDirection(up) {
|
|
634
|
-
|
|
412
|
+
var _this__pxController;
|
|
413
|
+
(_this__pxController = this._pxController) == null ? void 0 : _this__pxController.setUpDirection(up);
|
|
635
414
|
};
|
|
636
415
|
/**
|
|
637
416
|
* {@inheritDoc ICharacterController.setSlopeLimit }
|
|
638
417
|
*/ _proto.setSlopeLimit = function setSlopeLimit(slopeLimit) {
|
|
639
|
-
|
|
418
|
+
var _this__pxController;
|
|
419
|
+
(_this__pxController = this._pxController) == null ? void 0 : _this__pxController.setSlopeLimit(slopeLimit);
|
|
640
420
|
};
|
|
641
421
|
/**
|
|
642
422
|
* {@inheritDoc ICharacterController.addShape }
|
|
@@ -688,9 +468,16 @@
|
|
|
688
468
|
};
|
|
689
469
|
/**
|
|
690
470
|
* @internal
|
|
691
|
-
*/ _proto.
|
|
692
|
-
engine.Vector3.multiply(
|
|
693
|
-
this.
|
|
471
|
+
*/ _proto._updateShapePosition = function _updateShapePosition(shapePosition, worldScale) {
|
|
472
|
+
engine.Vector3.multiply(shapePosition, worldScale, this._shapeScaledPosition);
|
|
473
|
+
this._updateNativePosition();
|
|
474
|
+
};
|
|
475
|
+
_proto._updateNativePosition = function _updateNativePosition() {
|
|
476
|
+
var worldPosition = this._worldPosition;
|
|
477
|
+
if (this._pxController && worldPosition) {
|
|
478
|
+
engine.Vector3.add(worldPosition, this._shapeScaledPosition, PhysXCharacterController._tempVec);
|
|
479
|
+
this._pxController.setPosition(PhysXCharacterController._tempVec);
|
|
480
|
+
}
|
|
694
481
|
};
|
|
695
482
|
return PhysXCharacterController;
|
|
696
483
|
}();
|
|
@@ -758,11 +545,11 @@
|
|
|
758
545
|
})(CollisionDetectionMode || (CollisionDetectionMode = {}));
|
|
759
546
|
/**
|
|
760
547
|
* A dynamic collider can act with self-defined movement or physical force
|
|
761
|
-
*/ var PhysXDynamicCollider = /*#__PURE__*/ function(
|
|
762
|
-
_inherits(PhysXDynamicCollider,
|
|
548
|
+
*/ var PhysXDynamicCollider = /*#__PURE__*/ function(PhysXCollider1) {
|
|
549
|
+
_inherits(PhysXDynamicCollider, PhysXCollider1);
|
|
763
550
|
function PhysXDynamicCollider(physXPhysics, position, rotation) {
|
|
764
551
|
var _this;
|
|
765
|
-
_this =
|
|
552
|
+
_this = PhysXCollider1.call(this, physXPhysics) || this;
|
|
766
553
|
var transform = _this._transform(position, rotation);
|
|
767
554
|
_this._pxActor = physXPhysics._pxPhysics.createRigidDynamic(transform);
|
|
768
555
|
return _this;
|
|
@@ -912,36 +699,93 @@
|
|
|
912
699
|
PhysXDynamicCollider._tempRotation = new engine.Quaternion();
|
|
913
700
|
})();
|
|
914
701
|
|
|
702
|
+
var PhysXPhysicsManager = function PhysXPhysicsManager() {
|
|
703
|
+
/** @internal */ this._eventMap = {};
|
|
704
|
+
};
|
|
705
|
+
|
|
915
706
|
/**
|
|
916
|
-
*
|
|
917
|
-
*/ var
|
|
918
|
-
function
|
|
919
|
-
var _this = this;
|
|
920
|
-
/** @internal */ this._pxControllerManager = null;
|
|
921
|
-
this._currentEvents = new DisorderedArray();
|
|
922
|
-
this._eventMap = {};
|
|
923
|
-
this._eventPool = [];
|
|
707
|
+
* Physics material describes how to handle colliding objects (friction, bounciness).
|
|
708
|
+
*/ var PhysXPhysicsMaterial = /*#__PURE__*/ function() {
|
|
709
|
+
function PhysXPhysicsMaterial(physXPhysics, staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine) {
|
|
924
710
|
this._physXPhysics = physXPhysics;
|
|
925
|
-
var
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
this.
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
this.
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
711
|
+
var pxMaterial = physXPhysics._pxPhysics.createMaterial(staticFriction, dynamicFriction, bounciness);
|
|
712
|
+
pxMaterial.setFrictionCombineMode(frictionCombine);
|
|
713
|
+
pxMaterial.setRestitutionCombineMode(bounceCombine);
|
|
714
|
+
this._pxMaterial = pxMaterial;
|
|
715
|
+
}
|
|
716
|
+
var _proto = PhysXPhysicsMaterial.prototype;
|
|
717
|
+
/**
|
|
718
|
+
* {@inheritDoc IPhysicsMaterial.setBounciness }
|
|
719
|
+
*/ _proto.setBounciness = function setBounciness(value) {
|
|
720
|
+
this._pxMaterial.setRestitution(value);
|
|
721
|
+
};
|
|
722
|
+
/**
|
|
723
|
+
* {@inheritDoc IPhysicsMaterial.setDynamicFriction }
|
|
724
|
+
*/ _proto.setDynamicFriction = function setDynamicFriction(value) {
|
|
725
|
+
this._pxMaterial.setDynamicFriction(value);
|
|
726
|
+
};
|
|
727
|
+
/**
|
|
728
|
+
* {@inheritDoc IPhysicsMaterial.setStaticFriction }
|
|
729
|
+
*/ _proto.setStaticFriction = function setStaticFriction(value) {
|
|
730
|
+
this._pxMaterial.setStaticFriction(value);
|
|
731
|
+
};
|
|
732
|
+
/**
|
|
733
|
+
* {@inheritDoc IPhysicsMaterial.setBounceCombine }
|
|
734
|
+
*/ _proto.setBounceCombine = function setBounceCombine(value) {
|
|
735
|
+
this._pxMaterial.setRestitutionCombineMode(value);
|
|
736
|
+
};
|
|
737
|
+
/**
|
|
738
|
+
* {@inheritDoc IPhysicsMaterial.setFrictionCombine }
|
|
739
|
+
*/ _proto.setFrictionCombine = function setFrictionCombine(value) {
|
|
740
|
+
this._pxMaterial.setFrictionCombineMode(value);
|
|
741
|
+
};
|
|
742
|
+
/**
|
|
743
|
+
* {@inheritDoc IPhysicsMaterial.destroy }
|
|
744
|
+
*/ _proto.destroy = function destroy() {
|
|
745
|
+
this._pxMaterial.release();
|
|
746
|
+
};
|
|
747
|
+
return PhysXPhysicsMaterial;
|
|
748
|
+
}();
|
|
749
|
+
var /**
|
|
750
|
+
* Describes how physics materials of the colliding objects are combined.
|
|
751
|
+
*/ CombineMode;
|
|
752
|
+
(function(CombineMode) {
|
|
753
|
+
CombineMode[CombineMode[/** Averages the friction/bounce of the two colliding materials. */ "Average"] = 0] = "Average";
|
|
754
|
+
CombineMode[CombineMode[/** Uses the smaller friction/bounce of the two colliding materials. */ "Minimum"] = 1] = "Minimum";
|
|
755
|
+
CombineMode[CombineMode[/** Multiplies the friction/bounce of the two colliding materials. */ "Multiply"] = 2] = "Multiply";
|
|
756
|
+
CombineMode[CombineMode[/** Uses the larger friction/bounce of the two colliding materials. */ "Maximum"] = 3] = "Maximum";
|
|
757
|
+
})(CombineMode || (CombineMode = {}));
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* A manager is a collection of colliders and constraints which can interact.
|
|
761
|
+
*/ var PhysXPhysicsScene = /*#__PURE__*/ function() {
|
|
762
|
+
function PhysXPhysicsScene(physXPhysics, physicsManager, onContactEnter, onContactExit, onContactStay, onTriggerEnter, onTriggerExit, onTriggerStay) {
|
|
763
|
+
var _this = this;
|
|
764
|
+
/** @internal */ this._pxControllerManager = null;
|
|
765
|
+
this._currentEvents = new DisorderedArray();
|
|
766
|
+
this._eventPool = [];
|
|
767
|
+
this._physXPhysics = physXPhysics;
|
|
768
|
+
this._physXManager = physicsManager;
|
|
769
|
+
var physX = physXPhysics._physX;
|
|
770
|
+
this._pxRaycastHit = new physX.PxRaycastHit();
|
|
771
|
+
this._pxFilterData = new physX.PxQueryFilterData();
|
|
772
|
+
this._pxFilterData.flags = new physX.PxQueryFlags(1 | 2 | 4);
|
|
773
|
+
this._onContactEnter = onContactEnter;
|
|
774
|
+
this._onContactExit = onContactExit;
|
|
775
|
+
this._onContactStay = onContactStay;
|
|
776
|
+
this._onTriggerEnter = onTriggerEnter;
|
|
777
|
+
this._onTriggerExit = onTriggerExit;
|
|
778
|
+
this._onTriggerStay = onTriggerStay;
|
|
779
|
+
var triggerCallback = {
|
|
780
|
+
onContactBegin: function(index1, index2) {
|
|
781
|
+
_this._onContactEnter(index1, index2);
|
|
782
|
+
},
|
|
783
|
+
onContactEnd: function(index1, index2) {
|
|
784
|
+
_this._onContactExit(index1, index2);
|
|
785
|
+
},
|
|
786
|
+
onContactPersist: function(index1, index2) {
|
|
787
|
+
_this._onContactStay(index1, index2);
|
|
788
|
+
},
|
|
945
789
|
onTriggerBegin: function(index1, index2) {
|
|
946
790
|
var event = index1 < index2 ? _this._getTrigger(index1, index2) : _this._getTrigger(index2, index1);
|
|
947
791
|
event.state = 0;
|
|
@@ -950,11 +794,11 @@
|
|
|
950
794
|
onTriggerEnd: function(index1, index2) {
|
|
951
795
|
var event;
|
|
952
796
|
if (index1 < index2) {
|
|
953
|
-
var subMap = _this._eventMap[index1];
|
|
797
|
+
var subMap = _this._physXManager._eventMap[index1];
|
|
954
798
|
event = subMap[index2];
|
|
955
799
|
subMap[index2] = undefined;
|
|
956
800
|
} else {
|
|
957
|
-
var subMap1 = _this._eventMap[index2];
|
|
801
|
+
var subMap1 = _this._physXManager._eventMap[index2];
|
|
958
802
|
event = subMap1[index1];
|
|
959
803
|
subMap1[index1] = undefined;
|
|
960
804
|
}
|
|
@@ -966,7 +810,7 @@
|
|
|
966
810
|
var sceneDesc = physX.getDefaultSceneDesc(pxPhysics.getTolerancesScale(), 0, physXSimulationCallbackInstance);
|
|
967
811
|
this._pxScene = pxPhysics.createScene(sceneDesc);
|
|
968
812
|
}
|
|
969
|
-
var _proto =
|
|
813
|
+
var _proto = PhysXPhysicsScene.prototype;
|
|
970
814
|
/**
|
|
971
815
|
* {@inheritDoc IPhysicsManager.setGravity }
|
|
972
816
|
*/ _proto.setGravity = function setGravity(value) {
|
|
@@ -975,7 +819,7 @@
|
|
|
975
819
|
/**
|
|
976
820
|
* {@inheritDoc IPhysicsManager.addColliderShape }
|
|
977
821
|
*/ _proto.addColliderShape = function addColliderShape(colliderShape) {
|
|
978
|
-
this._eventMap[colliderShape._id] = {};
|
|
822
|
+
this._physXManager._eventMap[colliderShape._id] = {};
|
|
979
823
|
};
|
|
980
824
|
/**
|
|
981
825
|
* {@inheritDoc IPhysicsManager.removeColliderShape }
|
|
@@ -989,7 +833,7 @@
|
|
|
989
833
|
eventPool.push(event);
|
|
990
834
|
}
|
|
991
835
|
}
|
|
992
|
-
delete this._eventMap[shapeID];
|
|
836
|
+
delete this._physXManager._eventMap[shapeID];
|
|
993
837
|
};
|
|
994
838
|
/**
|
|
995
839
|
* {@inheritDoc IPhysicsManager.addCollider }
|
|
@@ -1046,7 +890,7 @@
|
|
|
1046
890
|
};
|
|
1047
891
|
var result = this._pxScene.raycastSingle(ray.origin, ray.direction, distance, pxHitResult, this._pxFilterData, this._physXPhysics._physX.PxQueryFilterCallback.implement(raycastCallback));
|
|
1048
892
|
if (result && hit != undefined) {
|
|
1049
|
-
var position =
|
|
893
|
+
var position = PhysXPhysicsScene._tempPosition, normal = PhysXPhysicsScene._tempNormal;
|
|
1050
894
|
var pxPosition = pxHitResult.position, pxNormal = pxHitResult.normal;
|
|
1051
895
|
position.set(pxPosition.x, pxPosition.y, pxPosition.z);
|
|
1052
896
|
normal.set(pxNormal.x, pxNormal.y, pxNormal.z);
|
|
@@ -1079,7 +923,7 @@
|
|
|
1079
923
|
} else {
|
|
1080
924
|
event = new TriggerEvent(index1, index2);
|
|
1081
925
|
}
|
|
1082
|
-
this._eventMap[index1][index2] = event;
|
|
926
|
+
this._physXManager._eventMap[index1][index2] = event;
|
|
1083
927
|
return event;
|
|
1084
928
|
};
|
|
1085
929
|
_proto._fireEvent = function _fireEvent() {
|
|
@@ -1098,13 +942,13 @@
|
|
|
1098
942
|
}
|
|
1099
943
|
}
|
|
1100
944
|
};
|
|
1101
|
-
return
|
|
945
|
+
return PhysXPhysicsScene;
|
|
1102
946
|
}();
|
|
1103
947
|
(function() {
|
|
1104
|
-
|
|
948
|
+
PhysXPhysicsScene._tempPosition = new engine.Vector3();
|
|
1105
949
|
})();
|
|
1106
950
|
(function() {
|
|
1107
|
-
|
|
951
|
+
PhysXPhysicsScene._tempNormal = new engine.Vector3();
|
|
1108
952
|
})();
|
|
1109
953
|
var /**
|
|
1110
954
|
* Filtering flags for scene queries.
|
|
@@ -1133,71 +977,241 @@
|
|
|
1133
977
|
};
|
|
1134
978
|
|
|
1135
979
|
/**
|
|
1136
|
-
*
|
|
1137
|
-
|
|
1138
|
-
|
|
980
|
+
* A static collider component that will not move.
|
|
981
|
+
* @remarks Mostly used for object which always stays at the same place and never moves around.
|
|
982
|
+
*/ var PhysXStaticCollider = /*#__PURE__*/ function(PhysXCollider1) {
|
|
983
|
+
_inherits(PhysXStaticCollider, PhysXCollider1);
|
|
984
|
+
function PhysXStaticCollider(physXPhysics, position, rotation) {
|
|
985
|
+
var _this;
|
|
986
|
+
_this = PhysXCollider1.call(this, physXPhysics) || this;
|
|
987
|
+
_this._pxActor = physXPhysics._pxPhysics.createRigidStatic(_this._transform(position, rotation));
|
|
988
|
+
return _this;
|
|
989
|
+
}
|
|
990
|
+
return PhysXStaticCollider;
|
|
991
|
+
}(PhysXCollider);
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
* PhysX runtime mode.
|
|
995
|
+
*/ exports.PhysXRuntimeMode = void 0;
|
|
996
|
+
(function(PhysXRuntimeMode) {
|
|
997
|
+
PhysXRuntimeMode[PhysXRuntimeMode[/** Use webAssembly mode first, if WebAssembly mode is not supported, roll back to JavaScript mode. */ "Auto"] = 0] = "Auto";
|
|
998
|
+
PhysXRuntimeMode[PhysXRuntimeMode[/** WebAssembly mode. */ "WebAssembly"] = 1] = "WebAssembly";
|
|
999
|
+
PhysXRuntimeMode[PhysXRuntimeMode[/** JavaScript mode. */ "JavaScript"] = 2] = "JavaScript";
|
|
1000
|
+
})(exports.PhysXRuntimeMode || (exports.PhysXRuntimeMode = {}));
|
|
1001
|
+
|
|
1002
|
+
/**
|
|
1003
|
+
* a base interface providing common functionality for PhysX joints
|
|
1004
|
+
*/ var PhysXJoint = /*#__PURE__*/ function() {
|
|
1005
|
+
function PhysXJoint(physXPhysics) {
|
|
1006
|
+
this._connectedAnchor = new engine.Vector3();
|
|
1007
|
+
this._breakForce = Number.MAX_VALUE;
|
|
1008
|
+
this._breakTorque = Number.MAX_VALUE;
|
|
1139
1009
|
this._physXPhysics = physXPhysics;
|
|
1140
|
-
var pxMaterial = physXPhysics._pxPhysics.createMaterial(staticFriction, dynamicFriction, bounciness);
|
|
1141
|
-
pxMaterial.setFrictionCombineMode(frictionCombine);
|
|
1142
|
-
pxMaterial.setRestitutionCombineMode(bounceCombine);
|
|
1143
|
-
this._pxMaterial = pxMaterial;
|
|
1144
1010
|
}
|
|
1145
|
-
var _proto =
|
|
1011
|
+
var _proto = PhysXJoint.prototype;
|
|
1146
1012
|
/**
|
|
1147
|
-
* {@inheritDoc
|
|
1148
|
-
*/ _proto.
|
|
1149
|
-
|
|
1013
|
+
* {@inheritDoc IJoint.setConnectedCollider }
|
|
1014
|
+
*/ _proto.setConnectedCollider = function setConnectedCollider(value) {
|
|
1015
|
+
var _value, _this__collider;
|
|
1016
|
+
this._pxJoint.setActors(((_value = value) == null ? void 0 : _value._pxActor) || null, ((_this__collider = this._collider) == null ? void 0 : _this__collider._pxActor) || null);
|
|
1150
1017
|
};
|
|
1151
1018
|
/**
|
|
1152
|
-
* {@inheritDoc
|
|
1153
|
-
*/ _proto.
|
|
1154
|
-
this.
|
|
1019
|
+
* {@inheritDoc IJoint.setConnectedAnchor }
|
|
1020
|
+
*/ _proto.setConnectedAnchor = function setConnectedAnchor(value) {
|
|
1021
|
+
this._connectedAnchor.copyFrom(value);
|
|
1022
|
+
this._setLocalPose(0, value, PhysXJoint._defaultQuat);
|
|
1155
1023
|
};
|
|
1156
1024
|
/**
|
|
1157
|
-
* {@inheritDoc
|
|
1158
|
-
*/ _proto.
|
|
1159
|
-
this.
|
|
1025
|
+
* {@inheritDoc IJoint.setConnectedMassScale }
|
|
1026
|
+
*/ _proto.setConnectedMassScale = function setConnectedMassScale(value) {
|
|
1027
|
+
this._pxJoint.setInvMassScale0(1 / value);
|
|
1160
1028
|
};
|
|
1161
1029
|
/**
|
|
1162
|
-
* {@inheritDoc
|
|
1163
|
-
*/ _proto.
|
|
1164
|
-
this.
|
|
1030
|
+
* {@inheritDoc IJoint.setConnectedInertiaScale }
|
|
1031
|
+
*/ _proto.setConnectedInertiaScale = function setConnectedInertiaScale(value) {
|
|
1032
|
+
this._pxJoint.setInvInertiaScale0(1 / value);
|
|
1165
1033
|
};
|
|
1166
1034
|
/**
|
|
1167
|
-
* {@inheritDoc
|
|
1168
|
-
*/ _proto.
|
|
1169
|
-
this.
|
|
1035
|
+
* {@inheritDoc IJoint.setMassScale }
|
|
1036
|
+
*/ _proto.setMassScale = function setMassScale(value) {
|
|
1037
|
+
this._pxJoint.setInvMassScale1(1 / value);
|
|
1170
1038
|
};
|
|
1171
1039
|
/**
|
|
1172
|
-
* {@inheritDoc
|
|
1173
|
-
*/ _proto.
|
|
1174
|
-
this.
|
|
1040
|
+
* {@inheritDoc IJoint.setInertiaScale }
|
|
1041
|
+
*/ _proto.setInertiaScale = function setInertiaScale(value) {
|
|
1042
|
+
this._pxJoint.setInvInertiaScale1(1 / value);
|
|
1175
1043
|
};
|
|
1176
|
-
|
|
1044
|
+
/**
|
|
1045
|
+
* {@inheritDoc IJoint.setBreakForce }
|
|
1046
|
+
*/ _proto.setBreakForce = function setBreakForce(value) {
|
|
1047
|
+
this._breakForce = value;
|
|
1048
|
+
this._pxJoint.setBreakForce(this._breakForce, this._breakTorque);
|
|
1049
|
+
};
|
|
1050
|
+
/**
|
|
1051
|
+
* {@inheritDoc IJoint.setBreakTorque }
|
|
1052
|
+
*/ _proto.setBreakTorque = function setBreakTorque(value) {
|
|
1053
|
+
this._breakTorque = value;
|
|
1054
|
+
this._pxJoint.setBreakForce(this._breakForce, this._breakTorque);
|
|
1055
|
+
};
|
|
1056
|
+
/**
|
|
1057
|
+
* Set the joint local pose for an actor.
|
|
1058
|
+
* @param actor 0 for the first actor, 1 for the second actor.
|
|
1059
|
+
* @param position the local position for the actor this joint
|
|
1060
|
+
* @param rotation the local rotation for the actor this joint
|
|
1061
|
+
*/ _proto._setLocalPose = function _setLocalPose(actor, position, rotation) {
|
|
1062
|
+
this._pxJoint.setLocalPose(actor, position, rotation);
|
|
1063
|
+
};
|
|
1064
|
+
return PhysXJoint;
|
|
1177
1065
|
}();
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
(function(
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
})(
|
|
1066
|
+
(function() {
|
|
1067
|
+
PhysXJoint._xAxis = new engine.Vector3(1, 0, 0);
|
|
1068
|
+
})();
|
|
1069
|
+
(function() {
|
|
1070
|
+
PhysXJoint._defaultVec = new engine.Vector3();
|
|
1071
|
+
})();
|
|
1072
|
+
(function() {
|
|
1073
|
+
PhysXJoint._defaultQuat = new engine.Quaternion();
|
|
1074
|
+
})();
|
|
1187
1075
|
|
|
1188
1076
|
/**
|
|
1189
|
-
* A
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
function PhysXStaticCollider(physXPhysics, position, rotation) {
|
|
1077
|
+
* A fixed joint permits no relative movement between two colliders. ie the bodies are glued together.
|
|
1078
|
+
*/ var PhysXFixedJoint = /*#__PURE__*/ function(PhysXJoint1) {
|
|
1079
|
+
_inherits(PhysXFixedJoint, PhysXJoint1);
|
|
1080
|
+
function PhysXFixedJoint(physXPhysics, collider) {
|
|
1194
1081
|
var _this;
|
|
1195
|
-
_this =
|
|
1196
|
-
_this.
|
|
1082
|
+
_this = PhysXJoint1.call(this, physXPhysics) || this;
|
|
1083
|
+
_this._collider = collider;
|
|
1084
|
+
_this._pxJoint = physXPhysics._pxPhysics.createFixedJoint(null, PhysXJoint._defaultVec, PhysXJoint._defaultQuat, collider._pxActor, PhysXJoint._defaultVec, PhysXJoint._defaultQuat);
|
|
1197
1085
|
return _this;
|
|
1198
1086
|
}
|
|
1199
|
-
return
|
|
1200
|
-
}(
|
|
1087
|
+
return PhysXFixedJoint;
|
|
1088
|
+
}(PhysXJoint);
|
|
1089
|
+
|
|
1090
|
+
/**
|
|
1091
|
+
* A joint which behaves in a similar way to a hinge or axle.
|
|
1092
|
+
*/ var PhysXHingeJoint = /*#__PURE__*/ function(PhysXJoint1) {
|
|
1093
|
+
_inherits(PhysXHingeJoint, PhysXJoint1);
|
|
1094
|
+
function PhysXHingeJoint(physXPhysics, collider) {
|
|
1095
|
+
var _this;
|
|
1096
|
+
_this = PhysXJoint1.call(this, physXPhysics) || this;
|
|
1097
|
+
_this._axisRotationQuaternion = new engine.Quaternion();
|
|
1098
|
+
_this._swingOffset = new engine.Vector3();
|
|
1099
|
+
_this._collider = collider;
|
|
1100
|
+
_this._pxJoint = physXPhysics._pxPhysics.createRevoluteJoint(null, PhysXJoint._defaultVec, PhysXJoint._defaultQuat, collider._pxActor, PhysXJoint._defaultVec, PhysXJoint._defaultQuat);
|
|
1101
|
+
return _this;
|
|
1102
|
+
}
|
|
1103
|
+
var _proto = PhysXHingeJoint.prototype;
|
|
1104
|
+
/**
|
|
1105
|
+
* {@inheritDoc IHingeJoint.setAxis }
|
|
1106
|
+
*/ _proto.setAxis = function setAxis(value) {
|
|
1107
|
+
var xAxis = PhysXJoint._xAxis;
|
|
1108
|
+
var axisRotationQuaternion = this._axisRotationQuaternion;
|
|
1109
|
+
xAxis.set(1, 0, 0);
|
|
1110
|
+
value.normalize();
|
|
1111
|
+
var angle = Math.acos(engine.Vector3.dot(xAxis, value));
|
|
1112
|
+
engine.Vector3.cross(xAxis, value, xAxis);
|
|
1113
|
+
engine.Quaternion.rotationAxisAngle(xAxis, angle, axisRotationQuaternion);
|
|
1114
|
+
this._setLocalPose(0, this._swingOffset, axisRotationQuaternion);
|
|
1115
|
+
};
|
|
1116
|
+
/**
|
|
1117
|
+
* {@inheritDoc IHingeJoint.setSwingOffset }
|
|
1118
|
+
*/ _proto.setSwingOffset = function setSwingOffset(value) {
|
|
1119
|
+
this._swingOffset.copyFrom(value);
|
|
1120
|
+
this._setLocalPose(1, this._swingOffset, this._axisRotationQuaternion);
|
|
1121
|
+
};
|
|
1122
|
+
/**
|
|
1123
|
+
* {@inheritDoc IHingeJoint.getAngle }
|
|
1124
|
+
*/ _proto.getAngle = function getAngle() {
|
|
1125
|
+
return this._pxJoint.getAngle();
|
|
1126
|
+
};
|
|
1127
|
+
/**
|
|
1128
|
+
* {@inheritDoc IHingeJoint.getVelocity }
|
|
1129
|
+
*/ _proto.getVelocity = function getVelocity() {
|
|
1130
|
+
return this._pxJoint.getVelocity();
|
|
1131
|
+
};
|
|
1132
|
+
/**
|
|
1133
|
+
* {@inheritDoc IHingeJoint.setHardLimitCone }
|
|
1134
|
+
*/ _proto.setHardLimit = function setHardLimit(lowerLimit, upperLimit, contactDist) {
|
|
1135
|
+
this._pxJoint.setHardLimit(lowerLimit, upperLimit, contactDist);
|
|
1136
|
+
};
|
|
1137
|
+
/**
|
|
1138
|
+
* {@inheritDoc IHingeJoint.setHardLimitCone }
|
|
1139
|
+
*/ _proto.setSoftLimit = function setSoftLimit(lowerLimit, upperLimit, stiffness, damping) {
|
|
1140
|
+
this._pxJoint.setSoftLimit(lowerLimit, upperLimit, stiffness, damping);
|
|
1141
|
+
};
|
|
1142
|
+
/**
|
|
1143
|
+
* {@inheritDoc IHingeJoint.setDriveVelocity }
|
|
1144
|
+
*/ _proto.setDriveVelocity = function setDriveVelocity(velocity, autowake) {
|
|
1145
|
+
if (autowake === void 0) autowake = true;
|
|
1146
|
+
this._pxJoint.setDriveVelocity(velocity, autowake);
|
|
1147
|
+
};
|
|
1148
|
+
/**
|
|
1149
|
+
* {@inheritDoc IHingeJoint.setDriveForceLimit }
|
|
1150
|
+
*/ _proto.setDriveForceLimit = function setDriveForceLimit(limit) {
|
|
1151
|
+
this._pxJoint.setDriveForceLimit(limit);
|
|
1152
|
+
};
|
|
1153
|
+
/**
|
|
1154
|
+
* {@inheritDoc IHingeJoint.setDriveGearRatio }
|
|
1155
|
+
*/ _proto.setDriveGearRatio = function setDriveGearRatio(ratio) {
|
|
1156
|
+
this._pxJoint.setDriveGearRatio(ratio);
|
|
1157
|
+
};
|
|
1158
|
+
/**
|
|
1159
|
+
* {@inheritDoc IHingeJoint.setHingeJointFlag }
|
|
1160
|
+
*/ _proto.setHingeJointFlag = function setHingeJointFlag(flag, value) {
|
|
1161
|
+
this._pxJoint.setRevoluteJointFlag(flag, value);
|
|
1162
|
+
};
|
|
1163
|
+
return PhysXHingeJoint;
|
|
1164
|
+
}(PhysXJoint);
|
|
1165
|
+
|
|
1166
|
+
/**
|
|
1167
|
+
* a joint that maintains an upper or lower bound (or both) on the distance between two points on different objects
|
|
1168
|
+
*/ var PhysXSpringJoint = /*#__PURE__*/ function(PhysXJoint1) {
|
|
1169
|
+
_inherits(PhysXSpringJoint, PhysXJoint1);
|
|
1170
|
+
function PhysXSpringJoint(physXPhysics, collider) {
|
|
1171
|
+
var _this;
|
|
1172
|
+
_this = PhysXJoint1.call(this, physXPhysics) || this;
|
|
1173
|
+
_this._swingOffset = new engine.Vector3();
|
|
1174
|
+
_this._collider = collider;
|
|
1175
|
+
_this._pxJoint = physXPhysics._pxPhysics.createDistanceJoint(null, PhysXJoint._defaultVec, PhysXJoint._defaultQuat, collider._pxActor, PhysXJoint._defaultVec, PhysXJoint._defaultQuat);
|
|
1176
|
+
_this._pxJoint.setDistanceJointFlag(2, true); // enable max distance;
|
|
1177
|
+
_this._pxJoint.setDistanceJointFlag(4, true); // enable min distance;
|
|
1178
|
+
_this._pxJoint.setDistanceJointFlag(8, true); // enable spring;
|
|
1179
|
+
return _this;
|
|
1180
|
+
}
|
|
1181
|
+
var _proto = PhysXSpringJoint.prototype;
|
|
1182
|
+
/**
|
|
1183
|
+
* {@inheritDoc ISpringJoint.setSwingOffset }
|
|
1184
|
+
*/ _proto.setSwingOffset = function setSwingOffset(value) {
|
|
1185
|
+
this._swingOffset.copyFrom(value);
|
|
1186
|
+
this._setLocalPose(1, value, PhysXJoint._defaultQuat);
|
|
1187
|
+
};
|
|
1188
|
+
/**
|
|
1189
|
+
* {@inheritDoc ISpringJoint.setMinDistance }
|
|
1190
|
+
*/ _proto.setMinDistance = function setMinDistance(distance) {
|
|
1191
|
+
this._pxJoint.setMinDistance(distance);
|
|
1192
|
+
};
|
|
1193
|
+
/**
|
|
1194
|
+
* {@inheritDoc ISpringJoint.setMaxDistance }
|
|
1195
|
+
*/ _proto.setMaxDistance = function setMaxDistance(distance) {
|
|
1196
|
+
this._pxJoint.setMaxDistance(distance);
|
|
1197
|
+
};
|
|
1198
|
+
/**
|
|
1199
|
+
* {@inheritDoc ISpringJoint.setTolerance }
|
|
1200
|
+
*/ _proto.setTolerance = function setTolerance(tolerance) {
|
|
1201
|
+
this._pxJoint.setTolerance(tolerance);
|
|
1202
|
+
};
|
|
1203
|
+
/**
|
|
1204
|
+
* {@inheritDoc ISpringJoint.setStiffness }
|
|
1205
|
+
*/ _proto.setStiffness = function setStiffness(stiffness) {
|
|
1206
|
+
this._pxJoint.setStiffness(stiffness);
|
|
1207
|
+
};
|
|
1208
|
+
/**
|
|
1209
|
+
* {@inheritDoc ISpringJoint.setDamping }
|
|
1210
|
+
*/ _proto.setDamping = function setDamping(damping) {
|
|
1211
|
+
this._pxJoint.setDamping(damping);
|
|
1212
|
+
};
|
|
1213
|
+
return PhysXSpringJoint;
|
|
1214
|
+
}(PhysXJoint);
|
|
1201
1215
|
|
|
1202
1216
|
/**
|
|
1203
1217
|
* Plane collider shape in PhysX.
|
|
@@ -1218,11 +1232,11 @@
|
|
|
1218
1232
|
|
|
1219
1233
|
/**
|
|
1220
1234
|
* Sphere collider shape in PhysX.
|
|
1221
|
-
*/ var PhysXSphereColliderShape = /*#__PURE__*/ function(
|
|
1222
|
-
_inherits(PhysXSphereColliderShape,
|
|
1235
|
+
*/ var PhysXSphereColliderShape = /*#__PURE__*/ function(PhysXColliderShape1) {
|
|
1236
|
+
_inherits(PhysXSphereColliderShape, PhysXColliderShape1);
|
|
1223
1237
|
function PhysXSphereColliderShape(physXPhysics, uniqueID, radius, material) {
|
|
1224
1238
|
var _this;
|
|
1225
|
-
_this =
|
|
1239
|
+
_this = PhysXColliderShape1.call(this, physXPhysics) || this;
|
|
1226
1240
|
_this._maxScale = 1;
|
|
1227
1241
|
_this._radius = radius;
|
|
1228
1242
|
_this._pxGeometry = new physXPhysics._physX.PxSphereGeometry(_this._radius * _this._maxScale);
|
|
@@ -1241,7 +1255,7 @@
|
|
|
1241
1255
|
/**
|
|
1242
1256
|
* {@inheritDoc IColliderShape.setWorldScale }
|
|
1243
1257
|
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
1244
|
-
|
|
1258
|
+
PhysXColliderShape1.prototype.setWorldScale.call(this, scale);
|
|
1245
1259
|
this._maxScale = Math.max(scale.x, scale.y, scale.z);
|
|
1246
1260
|
this._pxGeometry.radius = this._radius * this._maxScale;
|
|
1247
1261
|
this._pxShape.setGeometry(this._pxGeometry);
|
|
@@ -1324,8 +1338,13 @@
|
|
|
1324
1338
|
};
|
|
1325
1339
|
/**
|
|
1326
1340
|
* {@inheritDoc IPhysics.createPhysicsManager }
|
|
1327
|
-
*/ _proto.createPhysicsManager = function createPhysicsManager(
|
|
1328
|
-
|
|
1341
|
+
*/ _proto.createPhysicsManager = function createPhysicsManager() {
|
|
1342
|
+
return new PhysXPhysicsManager();
|
|
1343
|
+
};
|
|
1344
|
+
/**
|
|
1345
|
+
* {@inheritDoc IPhysics.createPhysicsScene }
|
|
1346
|
+
*/ _proto.createPhysicsScene = function createPhysicsScene(physicsManager, onContactBegin, onContactEnd, onContactStay, onTriggerBegin, onTriggerEnd, onTriggerStay) {
|
|
1347
|
+
var manager = new PhysXPhysicsScene(this, physicsManager, onContactBegin, onContactEnd, onContactStay, onTriggerBegin, onTriggerEnd, onTriggerStay);
|
|
1329
1348
|
return manager;
|
|
1330
1349
|
};
|
|
1331
1350
|
/**
|
|
@@ -1403,7 +1422,12 @@
|
|
|
1403
1422
|
InitializeState[InitializeState["Initialized"] = 2] = "Initialized";
|
|
1404
1423
|
})(InitializeState || (InitializeState = {}));
|
|
1405
1424
|
|
|
1425
|
+
//@ts-ignore
|
|
1426
|
+
var version = "0.0.0-experimental-double11.5";
|
|
1427
|
+
console.log("Galacean PhysX version: " + version);
|
|
1428
|
+
|
|
1406
1429
|
exports.PhysXPhysics = PhysXPhysics;
|
|
1430
|
+
exports.version = version;
|
|
1407
1431
|
|
|
1408
1432
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1409
1433
|
|