@galacean/engine-physics-physx 1.0.0-alpha.6 → 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/browser.js +1378 -1329
- package/dist/browser.min.js +1 -1
- package/dist/main.js +125 -76
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +32396 -2631
- package/dist/module.js +125 -76
- package/dist/module.js.map +1 -1
- package/package.json +10 -4
- package/types/PhysXCharacterController.d.ts +3 -0
- package/types/shape/PhysXBoxColliderShape.d.ts +1 -0
- package/types/shape/PhysXColliderShape.d.ts +1 -1
- package/types/shape/PhysXPlaneColliderShape.d.ts +0 -5
- package/types/StaticInterfaceImplement.d.ts +0 -5
package/dist/browser.js
CHANGED
|
@@ -1,1360 +1,1409 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@galacean/engine')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@galacean/engine'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.Galacean = global.Galacean || {}, global.Galacean.PhysicsPhysX = {}), global.Galacean));
|
|
5
5
|
})(this, (function (exports, engine) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return left instanceof right;
|
|
7
|
+
function _instanceof(left, right) {
|
|
8
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
9
|
+
return !!right[Symbol.hasInstance](left);
|
|
10
|
+
} else return left instanceof right;
|
|
12
11
|
}
|
|
13
|
-
}
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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 = {}));
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return o;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
return setPrototypeOf(o, p);
|
|
31
|
-
}
|
|
22
|
+
function _set_prototype_of(o, p) {
|
|
23
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
24
|
+
o.__proto__ = p;
|
|
32
25
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
26
|
+
return o;
|
|
27
|
+
};
|
|
36
28
|
|
|
37
|
-
|
|
38
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
39
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
29
|
+
return _set_prototype_of(o, p);
|
|
40
30
|
}
|
|
41
31
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
49
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
50
|
-
}
|
|
32
|
+
function _inherits(subClass, superClass) {
|
|
33
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
34
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });
|
|
51
38
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
39
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
40
|
+
}
|
|
41
|
+
|
|
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
|
+
})();
|
|
119
115
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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);
|
|
133
129
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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);
|
|
211
207
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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);
|
|
261
257
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
258
|
+
/**
|
|
259
|
+
* High-performance unordered array, delete uses exchange method to improve performance, internal capacity only increases.
|
|
260
|
+
*/ var DisorderedArray = /*#__PURE__*/ function() {
|
|
261
|
+
function DisorderedArray(count) {
|
|
262
|
+
if (count === void 0) count = 0;
|
|
263
|
+
this.length = 0;
|
|
264
|
+
this._elements = new Array(count);
|
|
265
|
+
}
|
|
266
|
+
var _proto = DisorderedArray.prototype;
|
|
267
|
+
_proto.add = function add(element) {
|
|
268
|
+
if (this.length === this._elements.length) this._elements.push(element);
|
|
269
|
+
else this._elements[this.length] = element;
|
|
270
|
+
this.length++;
|
|
271
|
+
};
|
|
272
|
+
_proto.delete = function _delete(element) {
|
|
273
|
+
//TODO: It can be optimized for custom binary search and other algorithms, currently this._elements>=this.length wastes performance.
|
|
274
|
+
var index = this._elements.indexOf(element);
|
|
275
|
+
this.deleteByIndex(index);
|
|
276
|
+
};
|
|
277
|
+
_proto.get = function get(index) {
|
|
278
|
+
if (index >= this.length) {
|
|
279
|
+
throw "Index is out of range.";
|
|
280
|
+
}
|
|
281
|
+
return this._elements[index];
|
|
282
|
+
};
|
|
283
|
+
/**
|
|
284
|
+
*
|
|
285
|
+
* @param index
|
|
286
|
+
* @returns The replaced item is used to reset its index.
|
|
287
|
+
*/ _proto.deleteByIndex = function deleteByIndex(index) {
|
|
288
|
+
var elements = this._elements;
|
|
289
|
+
var end = null;
|
|
290
|
+
var lastIndex = this.length - 1;
|
|
291
|
+
if (index !== lastIndex) {
|
|
292
|
+
end = elements[lastIndex];
|
|
293
|
+
elements[index] = end;
|
|
294
|
+
}
|
|
295
|
+
this.length--;
|
|
296
|
+
return end;
|
|
297
|
+
};
|
|
298
|
+
_proto.garbageCollection = function garbageCollection() {
|
|
299
|
+
this._elements.length = this.length;
|
|
300
|
+
};
|
|
301
|
+
return DisorderedArray;
|
|
302
|
+
}();
|
|
307
303
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
304
|
+
var ShapeFlag;
|
|
305
|
+
(function(ShapeFlag) {
|
|
306
|
+
ShapeFlag[ShapeFlag[/** The shape will partake in collision in the physical simulation. */ "SIMULATION_SHAPE"] = 1] = "SIMULATION_SHAPE";
|
|
307
|
+
ShapeFlag[ShapeFlag[/** The shape will partake in scene queries (ray casts, overlap tests, sweeps, ...). */ "SCENE_QUERY_SHAPE"] = 2] = "SCENE_QUERY_SHAPE";
|
|
308
|
+
ShapeFlag[ShapeFlag[/** The shape is a trigger which can send reports whenever other shapes enter/leave its volume. */ "TRIGGER_SHAPE"] = 4] = "TRIGGER_SHAPE";
|
|
309
|
+
})(ShapeFlag || (ShapeFlag = {}));
|
|
310
|
+
/**
|
|
311
|
+
* Abstract class for collider shapes.
|
|
312
|
+
*/ var PhysXColliderShape = /*#__PURE__*/ function() {
|
|
313
|
+
function PhysXColliderShape(physXPhysics) {
|
|
314
|
+
/** @internal */ this._controllers = new DisorderedArray();
|
|
315
|
+
this._scale = new engine.Vector3(1, 1, 1);
|
|
316
|
+
this._position = new engine.Vector3();
|
|
317
|
+
this._rotation = null;
|
|
318
|
+
this._axis = null;
|
|
319
|
+
this._physXRotation = new engine.Quaternion();
|
|
320
|
+
this._shapeFlags = 2 | 1;
|
|
321
|
+
/** @internal */ this._pxMaterials = new Array(1);
|
|
322
|
+
this._physXPhysics = physXPhysics;
|
|
323
|
+
}
|
|
324
|
+
var _proto = PhysXColliderShape.prototype;
|
|
325
|
+
/**
|
|
326
|
+
* {@inheritDoc IColliderShape.setRotation }
|
|
327
|
+
*/ _proto.setRotation = function setRotation(value) {
|
|
328
|
+
this._rotation = value;
|
|
329
|
+
engine.Quaternion.rotationYawPitchRoll(value.x, value.y, value.z, this._physXRotation);
|
|
330
|
+
this._axis && engine.Quaternion.multiply(this._physXRotation, this._axis, this._physXRotation);
|
|
331
|
+
this._physXRotation.normalize();
|
|
332
|
+
this._setLocalPose();
|
|
333
|
+
};
|
|
334
|
+
/**
|
|
335
|
+
* {@inheritDoc IColliderShape.setPosition }
|
|
336
|
+
*/ _proto.setPosition = function setPosition(value) {
|
|
337
|
+
if (value !== this._position) {
|
|
338
|
+
this._position.copyFrom(value);
|
|
339
|
+
}
|
|
340
|
+
var controllers = this._controllers;
|
|
341
|
+
for(var i = 0, n = controllers.length; i < n; i++){
|
|
342
|
+
controllers.get(i)._pxController.setLocalPosition(this._position, this._scale);
|
|
343
|
+
}
|
|
344
|
+
this._setLocalPose();
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* {@inheritDoc IColliderShape.setWorldScale }
|
|
348
|
+
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
349
|
+
this._scale.copyFrom(scale);
|
|
350
|
+
this._setLocalPose();
|
|
351
|
+
var controllers = this._controllers;
|
|
352
|
+
for(var i = 0, n = controllers.length; i < n; i++){
|
|
353
|
+
controllers.get(i)._setLocalPosition(this._position, this._scale);
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
/**
|
|
357
|
+
* {@inheritDoc IColliderShape.setContactOffset }
|
|
358
|
+
* @default 0.02f * PxTolerancesScale::length
|
|
359
|
+
*/ _proto.setContactOffset = function setContactOffset(offset) {
|
|
360
|
+
this._pxShape.setContactOffset(offset);
|
|
361
|
+
var controllers = this._controllers;
|
|
362
|
+
for(var i = 0, n = controllers.length; i < n; i++){
|
|
363
|
+
controllers.get(i)._pxController.setContactOffset(offset);
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
/**
|
|
367
|
+
* {@inheritDoc IColliderShape.setMaterial }
|
|
368
|
+
*/ _proto.setMaterial = function setMaterial(value) {
|
|
369
|
+
this._pxMaterials[0] = value._pxMaterial;
|
|
370
|
+
this._pxShape.setMaterials(this._pxMaterials);
|
|
371
|
+
};
|
|
372
|
+
/**
|
|
373
|
+
* {@inheritDoc IColliderShape.setIsTrigger }
|
|
374
|
+
*/ _proto.setIsTrigger = function setIsTrigger(value) {
|
|
375
|
+
this._modifyFlag(1, !value);
|
|
376
|
+
this._modifyFlag(4, value);
|
|
377
|
+
this._setShapeFlags(this._shapeFlags);
|
|
378
|
+
};
|
|
379
|
+
/**
|
|
380
|
+
* {@inheritDoc IColliderShape.destroy }
|
|
381
|
+
*/ _proto.destroy = function destroy() {
|
|
382
|
+
this._pxShape.release();
|
|
383
|
+
};
|
|
384
|
+
/**
|
|
385
|
+
* @internal
|
|
386
|
+
*/ _proto._setShapeFlags = function _setShapeFlags(flags) {
|
|
387
|
+
this._shapeFlags = flags;
|
|
388
|
+
this._pxShape.setFlags(new this._physXPhysics._physX.PxShapeFlags(this._shapeFlags));
|
|
389
|
+
};
|
|
390
|
+
_proto._setLocalPose = function _setLocalPose() {
|
|
391
|
+
var transform = PhysXColliderShape.transform;
|
|
392
|
+
engine.Vector3.multiply(this._position, this._scale, transform.translation);
|
|
393
|
+
transform.rotation = this._physXRotation;
|
|
394
|
+
this._pxShape.setLocalPose(transform);
|
|
395
|
+
};
|
|
396
|
+
_proto._initialize = function _initialize(material, id) {
|
|
397
|
+
this._id = id;
|
|
398
|
+
this._pxMaterials[0] = material._pxMaterial;
|
|
399
|
+
this._pxShape = this._physXPhysics._pxPhysics.createShape(this._pxGeometry, material._pxMaterial, true, new this._physXPhysics._physX.PxShapeFlags(this._shapeFlags));
|
|
400
|
+
this._pxShape.setUUID(id);
|
|
401
|
+
};
|
|
402
|
+
_proto._modifyFlag = function _modifyFlag(flag, value) {
|
|
403
|
+
this._shapeFlags = value ? this._shapeFlags | flag : this._shapeFlags & ~flag;
|
|
404
|
+
};
|
|
405
|
+
return PhysXColliderShape;
|
|
406
|
+
}();
|
|
407
|
+
(function() {
|
|
408
|
+
PhysXColliderShape.halfSqrt = 0.70710678118655;
|
|
409
|
+
})();
|
|
410
|
+
(function() {
|
|
411
|
+
PhysXColliderShape.transform = {
|
|
412
|
+
translation: new engine.Vector3(),
|
|
413
|
+
rotation: null
|
|
414
|
+
};
|
|
415
|
+
})();
|
|
402
416
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
417
|
+
/**
|
|
418
|
+
* Box collider shape in PhysX.
|
|
419
|
+
*/ var PhysXBoxColliderShape = /*#__PURE__*/ function(PhysXColliderShape) {
|
|
420
|
+
_inherits(PhysXBoxColliderShape, PhysXColliderShape);
|
|
421
|
+
function PhysXBoxColliderShape(physXPhysics, uniqueID, size, material) {
|
|
422
|
+
var _this;
|
|
423
|
+
_this = PhysXColliderShape.call(this, physXPhysics) || this;
|
|
424
|
+
/** @internal */ _this._halfSize = new engine.Vector3();
|
|
425
|
+
_this._halfSize.set(size.x * 0.5, size.y * 0.5, size.z * 0.5);
|
|
426
|
+
_this._pxGeometry = new physXPhysics._physX.PxBoxGeometry(_this._halfSize.x * _this._scale.x, _this._halfSize.y * _this._scale.y, _this._halfSize.z * _this._scale.z);
|
|
427
|
+
_this._initialize(material, uniqueID);
|
|
428
|
+
_this._setLocalPose();
|
|
429
|
+
return _this;
|
|
430
|
+
}
|
|
431
|
+
var _proto = PhysXBoxColliderShape.prototype;
|
|
432
|
+
/**
|
|
433
|
+
* {@inheritDoc IBoxColliderShape.setSize }
|
|
434
|
+
*/ _proto.setSize = function setSize(value) {
|
|
435
|
+
var tempExtents = PhysXBoxColliderShape._tempHalfExtents;
|
|
436
|
+
this._halfSize.set(value.x * 0.5, value.y * 0.5, value.z * 0.5);
|
|
437
|
+
engine.Vector3.multiply(this._halfSize, this._scale, tempExtents);
|
|
438
|
+
this._pxGeometry.halfExtents = tempExtents;
|
|
439
|
+
this._pxShape.setGeometry(this._pxGeometry);
|
|
440
|
+
this._updateController(tempExtents);
|
|
441
|
+
};
|
|
442
|
+
/**
|
|
443
|
+
* {@inheritDoc IColliderShape.setWorldScale }
|
|
444
|
+
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
445
|
+
PhysXColliderShape.prototype.setWorldScale.call(this, scale);
|
|
446
|
+
var tempExtents = PhysXBoxColliderShape._tempHalfExtents;
|
|
447
|
+
engine.Vector3.multiply(this._halfSize, this._scale, tempExtents);
|
|
448
|
+
this._pxGeometry.halfExtents = tempExtents;
|
|
449
|
+
this._pxShape.setGeometry(this._pxGeometry);
|
|
450
|
+
this._updateController(tempExtents);
|
|
451
|
+
};
|
|
452
|
+
_proto._updateController = function _updateController(extents) {
|
|
453
|
+
var controllers = this._controllers;
|
|
454
|
+
for(var i = 0, n = controllers.length; i < n; i++){
|
|
455
|
+
var pxController = controllers.get(i)._pxController;
|
|
456
|
+
pxController.setHalfHeight(extents.x);
|
|
457
|
+
pxController.setHalfSideExtent(extents.y);
|
|
458
|
+
pxController.setHalfForwardExtent(extents.z);
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
return PhysXBoxColliderShape;
|
|
462
|
+
}(PhysXColliderShape);
|
|
463
|
+
(function() {
|
|
464
|
+
PhysXBoxColliderShape._tempHalfExtents = new engine.Vector3();
|
|
465
|
+
})();
|
|
445
466
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
467
|
+
/**
|
|
468
|
+
* Capsule collider shape in PhysX.
|
|
469
|
+
*/ var PhysXCapsuleColliderShape = /*#__PURE__*/ function(PhysXColliderShape1) {
|
|
470
|
+
_inherits(PhysXCapsuleColliderShape, PhysXColliderShape1);
|
|
471
|
+
function PhysXCapsuleColliderShape(physXPhysics, uniqueID, radius, height, material) {
|
|
472
|
+
var _this;
|
|
473
|
+
_this = PhysXColliderShape1.call(this, physXPhysics) || this;
|
|
474
|
+
_this._upAxis = /** Up axis is Y. */ 1;
|
|
475
|
+
_this._radius = radius;
|
|
476
|
+
_this._halfHeight = height * 0.5;
|
|
477
|
+
_this._axis = new engine.Quaternion(0, 0, PhysXColliderShape.halfSqrt, PhysXColliderShape.halfSqrt);
|
|
478
|
+
_this._physXRotation.copyFrom(_this._axis);
|
|
479
|
+
_this._pxGeometry = new physXPhysics._physX.PxCapsuleGeometry(_this._radius, _this._halfHeight);
|
|
480
|
+
_this._initialize(material, uniqueID);
|
|
481
|
+
_this._setLocalPose();
|
|
482
|
+
return _this;
|
|
483
|
+
}
|
|
484
|
+
var _proto = PhysXCapsuleColliderShape.prototype;
|
|
485
|
+
/**
|
|
486
|
+
* {@inheritDoc ICapsuleColliderShape.setRadius }
|
|
487
|
+
*/ _proto.setRadius = function setRadius(value) {
|
|
488
|
+
this._radius = value;
|
|
489
|
+
switch(this._upAxis){
|
|
490
|
+
case /** Up axis is X. */ 0:
|
|
491
|
+
this._pxGeometry.radius = this._radius * Math.max(this._scale.y, this._scale.z);
|
|
492
|
+
break;
|
|
493
|
+
case 1:
|
|
494
|
+
this._pxGeometry.radius = this._radius * Math.max(this._scale.x, this._scale.z);
|
|
495
|
+
break;
|
|
496
|
+
case /** Up axis is Z. */ 2:
|
|
497
|
+
this._pxGeometry.radius = this._radius * Math.max(this._scale.x, this._scale.y);
|
|
498
|
+
break;
|
|
499
|
+
}
|
|
500
|
+
this._pxShape.setGeometry(this._pxGeometry);
|
|
501
|
+
var radius = this._pxGeometry.radius;
|
|
502
|
+
var controllers = this._controllers;
|
|
503
|
+
for(var i = 0, n = controllers.length; i < n; i++){
|
|
504
|
+
controllers.get(i)._pxController.setRadius(radius);
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
/**
|
|
508
|
+
* {@inheritDoc ICapsuleColliderShape.setHeight }
|
|
509
|
+
*/ _proto.setHeight = function setHeight(value) {
|
|
510
|
+
this._halfHeight = value * 0.5;
|
|
511
|
+
switch(this._upAxis){
|
|
512
|
+
case 0:
|
|
513
|
+
this._pxGeometry.halfHeight = this._halfHeight * this._scale.x;
|
|
514
|
+
break;
|
|
515
|
+
case 1:
|
|
516
|
+
this._pxGeometry.halfHeight = this._halfHeight * this._scale.y;
|
|
517
|
+
break;
|
|
518
|
+
case 2:
|
|
519
|
+
this._pxGeometry.halfHeight = this._halfHeight * this._scale.z;
|
|
520
|
+
break;
|
|
521
|
+
}
|
|
522
|
+
this._pxShape.setGeometry(this._pxGeometry);
|
|
523
|
+
var height = this._pxGeometry.halfHeight * 2;
|
|
524
|
+
var controllers = this._controllers;
|
|
525
|
+
for(var i = 0, n = controllers.length; i < n; i++){
|
|
526
|
+
controllers.get(i)._pxController.setHeight(height);
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
/**
|
|
530
|
+
* {@inheritDoc ICapsuleColliderShape.setUpAxis }
|
|
531
|
+
*/ _proto.setUpAxis = function setUpAxis(upAxis) {
|
|
532
|
+
var _this = this, rotation = _this._rotation, axis = _this._axis, physXRotation = _this._physXRotation;
|
|
533
|
+
this._upAxis = upAxis;
|
|
534
|
+
switch(this._upAxis){
|
|
535
|
+
case 0:
|
|
536
|
+
axis.set(0, 0, 0, 1);
|
|
537
|
+
break;
|
|
538
|
+
case 1:
|
|
539
|
+
axis.set(0, 0, PhysXColliderShape.halfSqrt, PhysXColliderShape.halfSqrt);
|
|
540
|
+
break;
|
|
541
|
+
case 2:
|
|
542
|
+
axis.set(0, PhysXColliderShape.halfSqrt, 0, PhysXColliderShape.halfSqrt);
|
|
543
|
+
break;
|
|
544
|
+
}
|
|
545
|
+
if (rotation) {
|
|
546
|
+
engine.Quaternion.rotationYawPitchRoll(rotation.x, rotation.y, rotation.z, physXRotation);
|
|
547
|
+
engine.Quaternion.multiply(physXRotation, axis, physXRotation);
|
|
548
|
+
} else {
|
|
549
|
+
physXRotation.copyFrom(axis);
|
|
550
|
+
}
|
|
551
|
+
this._setLocalPose();
|
|
552
|
+
};
|
|
553
|
+
/**
|
|
554
|
+
* {@inheritDoc IColliderShape.setWorldScale }
|
|
555
|
+
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
556
|
+
PhysXColliderShape1.prototype.setWorldScale.call(this, scale);
|
|
557
|
+
var geometry = this._pxGeometry;
|
|
558
|
+
switch(this._upAxis){
|
|
559
|
+
case 0:
|
|
560
|
+
geometry.radius = this._radius * Math.max(scale.y, scale.z);
|
|
561
|
+
geometry.halfHeight = this._halfHeight * scale.x;
|
|
562
|
+
break;
|
|
563
|
+
case 1:
|
|
564
|
+
geometry.radius = this._radius * Math.max(scale.x, scale.z);
|
|
565
|
+
geometry.halfHeight = this._halfHeight * scale.y;
|
|
566
|
+
break;
|
|
567
|
+
case 2:
|
|
568
|
+
geometry.radius = this._radius * Math.max(scale.x, scale.y);
|
|
569
|
+
geometry.halfHeight = this._halfHeight * scale.z;
|
|
570
|
+
break;
|
|
571
|
+
}
|
|
572
|
+
this._pxShape.setGeometry(geometry);
|
|
573
|
+
var radius = geometry.radius;
|
|
574
|
+
var height = geometry.halfHeight * 2;
|
|
575
|
+
var controllers = this._controllers;
|
|
576
|
+
for(var i = 0, n = controllers.length; i < n; i++){
|
|
577
|
+
var pxController = controllers.get(i)._pxController;
|
|
578
|
+
pxController.setRadius(radius);
|
|
579
|
+
pxController.setHeight(height);
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
return PhysXCapsuleColliderShape;
|
|
583
|
+
}(PhysXColliderShape);
|
|
584
|
+
var /**
|
|
585
|
+
* The up axis of the collider shape.
|
|
586
|
+
*/ ColliderShapeUpAxis;
|
|
587
|
+
(function(ColliderShapeUpAxis) {
|
|
588
|
+
ColliderShapeUpAxis[ColliderShapeUpAxis["X"] = 0] = "X";
|
|
589
|
+
ColliderShapeUpAxis[ColliderShapeUpAxis["Y"] = 1] = "Y";
|
|
590
|
+
ColliderShapeUpAxis[ColliderShapeUpAxis["Z"] = 2] = "Z";
|
|
591
|
+
})(ColliderShapeUpAxis || (ColliderShapeUpAxis = {}));
|
|
561
592
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
593
|
+
/**
|
|
594
|
+
* Base class for character controllers.
|
|
595
|
+
*/ var PhysXCharacterController = /*#__PURE__*/ function() {
|
|
596
|
+
function PhysXCharacterController(physXPhysics) {
|
|
597
|
+
this._scaledOffset = new engine.Vector3();
|
|
598
|
+
this._position = null;
|
|
599
|
+
this._physXPhysics = physXPhysics;
|
|
600
|
+
}
|
|
601
|
+
var _proto = PhysXCharacterController.prototype;
|
|
602
|
+
/**
|
|
603
|
+
* {@inheritDoc ICharacterController.move }
|
|
604
|
+
*/ _proto.move = function move(disp, minDist, elapsedTime) {
|
|
605
|
+
return this._pxController.move(disp, minDist, elapsedTime);
|
|
606
|
+
};
|
|
607
|
+
/**
|
|
608
|
+
* {@inheritDoc ICharacterController.setWorldPosition }
|
|
609
|
+
*/ _proto.setWorldPosition = function setWorldPosition(position) {
|
|
610
|
+
this._position = position;
|
|
611
|
+
if (this._pxController) {
|
|
612
|
+
engine.Vector3.add(position, this._scaledOffset, PhysXCharacterController._tempVec);
|
|
613
|
+
this._pxController.setPosition(PhysXCharacterController._tempVec);
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
/**
|
|
617
|
+
* {@inheritDoc ICharacterController.getWorldPosition }
|
|
618
|
+
*/ _proto.getWorldPosition = function getWorldPosition(position) {
|
|
619
|
+
position.copyFrom(this._pxController.getPosition());
|
|
620
|
+
position.subtract(this._scaledOffset);
|
|
621
|
+
};
|
|
622
|
+
/**
|
|
623
|
+
* {@inheritDoc ICharacterController.setStepOffset }
|
|
624
|
+
*/ _proto.setStepOffset = function setStepOffset(offset) {
|
|
625
|
+
this._pxController.setStepOffset(offset);
|
|
626
|
+
};
|
|
627
|
+
/**
|
|
628
|
+
* {@inheritDoc ICharacterController.setNonWalkableMode }
|
|
629
|
+
*/ _proto.setNonWalkableMode = function setNonWalkableMode(flag) {
|
|
630
|
+
this._pxController.setNonWalkableMode(flag);
|
|
631
|
+
};
|
|
632
|
+
/**
|
|
633
|
+
* {@inheritDoc ICharacterController.setUpDirection }
|
|
634
|
+
*/ _proto.setUpDirection = function setUpDirection(up) {
|
|
635
|
+
this._pxController.setUpDirection(up);
|
|
636
|
+
};
|
|
637
|
+
/**
|
|
638
|
+
* {@inheritDoc ICharacterController.setSlopeLimit }
|
|
639
|
+
*/ _proto.setSlopeLimit = function setSlopeLimit(slopeLimit) {
|
|
640
|
+
this._pxController.setSlopeLimit(slopeLimit);
|
|
641
|
+
};
|
|
642
|
+
/**
|
|
643
|
+
* {@inheritDoc ICharacterController.addShape }
|
|
644
|
+
*/ _proto.addShape = function addShape(shape) {
|
|
645
|
+
this._pxManager && this._createPXController(this._pxManager, shape);
|
|
646
|
+
this._shape = shape;
|
|
647
|
+
shape._controllers.add(this);
|
|
648
|
+
};
|
|
649
|
+
/**
|
|
650
|
+
* {@inheritDoc ICharacterController.removeShape }
|
|
651
|
+
*/ _proto.removeShape = function removeShape(shape) {
|
|
652
|
+
this._destroyPXController();
|
|
653
|
+
this._shape = null;
|
|
654
|
+
shape._controllers.delete(this);
|
|
655
|
+
};
|
|
656
|
+
/**
|
|
657
|
+
* {@inheritDoc ICharacterController.destroy }
|
|
658
|
+
*/ _proto.destroy = function destroy() {
|
|
659
|
+
this._destroyPXController();
|
|
660
|
+
};
|
|
661
|
+
/**
|
|
662
|
+
* @internal
|
|
663
|
+
*/ _proto._createPXController = function _createPXController(pxManager, shape) {
|
|
664
|
+
var desc;
|
|
665
|
+
if (_instanceof(shape, PhysXBoxColliderShape)) {
|
|
666
|
+
desc = new this._physXPhysics._physX.PxBoxControllerDesc();
|
|
667
|
+
desc.halfHeight = shape._halfSize.x;
|
|
668
|
+
desc.halfSideExtent = shape._halfSize.y;
|
|
669
|
+
desc.halfForwardExtent = shape._halfSize.z;
|
|
670
|
+
} else if (_instanceof(shape, PhysXCapsuleColliderShape)) {
|
|
671
|
+
desc = new this._physXPhysics._physX.PxCapsuleControllerDesc();
|
|
672
|
+
desc.radius = shape._radius;
|
|
673
|
+
desc.height = shape._halfHeight * 2;
|
|
674
|
+
desc.climbingMode = 1; // constraint mode
|
|
675
|
+
} else {
|
|
676
|
+
throw "unsupported shape type";
|
|
677
|
+
}
|
|
678
|
+
desc.setMaterial(shape._pxMaterials[0]);
|
|
679
|
+
this._pxController = pxManager._getControllerManager().createController(desc);
|
|
680
|
+
this._pxController.setUUID(shape._id);
|
|
681
|
+
};
|
|
682
|
+
/**
|
|
683
|
+
* @internal
|
|
684
|
+
*/ _proto._destroyPXController = function _destroyPXController() {
|
|
685
|
+
if (this._pxController) {
|
|
686
|
+
this._pxController.release();
|
|
687
|
+
this._pxController = null;
|
|
688
|
+
}
|
|
689
|
+
};
|
|
690
|
+
/**
|
|
691
|
+
* @internal
|
|
692
|
+
*/ _proto._setLocalPosition = function _setLocalPosition(position, scale) {
|
|
693
|
+
engine.Vector3.multiply(position, scale, this._scaledOffset);
|
|
694
|
+
this.setWorldPosition(this._position);
|
|
695
|
+
};
|
|
696
|
+
return PhysXCharacterController;
|
|
697
|
+
}();
|
|
698
|
+
(function() {
|
|
699
|
+
PhysXCharacterController._tempVec = new engine.Vector3();
|
|
700
|
+
})();
|
|
654
701
|
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
702
|
+
/**
|
|
703
|
+
* Abstract class of physical collider.
|
|
704
|
+
*/ var PhysXCollider = /*#__PURE__*/ function() {
|
|
705
|
+
function PhysXCollider(physXPhysics) {
|
|
706
|
+
this._physXPhysics = physXPhysics;
|
|
707
|
+
}
|
|
708
|
+
var _proto = PhysXCollider.prototype;
|
|
709
|
+
/**
|
|
710
|
+
* {@inheritDoc ICollider.addShape }
|
|
711
|
+
*/ _proto.addShape = function addShape(shape) {
|
|
712
|
+
this._pxActor.attachShape(shape._pxShape);
|
|
713
|
+
};
|
|
714
|
+
/**
|
|
715
|
+
* {@inheritDoc ICollider.removeShape }
|
|
716
|
+
*/ _proto.removeShape = function removeShape(shape) {
|
|
717
|
+
this._pxActor.detachShape(shape._pxShape, true);
|
|
718
|
+
};
|
|
719
|
+
/**
|
|
720
|
+
* {@inheritDoc ICollider.setWorldTransform }
|
|
721
|
+
*/ _proto.setWorldTransform = function setWorldTransform(position, rotation) {
|
|
722
|
+
this._pxActor.setGlobalPose(this._transform(position, rotation), true);
|
|
723
|
+
};
|
|
724
|
+
/**
|
|
725
|
+
* {@inheritDoc ICollider.getWorldTransform }
|
|
726
|
+
*/ _proto.getWorldTransform = function getWorldTransform(outPosition, outRotation) {
|
|
727
|
+
var transform = this._pxActor.getGlobalPose();
|
|
728
|
+
outPosition.set(transform.translation.x, transform.translation.y, transform.translation.z);
|
|
729
|
+
outRotation.set(transform.rotation.x, transform.rotation.y, transform.rotation.z, transform.rotation.w);
|
|
730
|
+
};
|
|
731
|
+
/**
|
|
732
|
+
* {@inheritDoc ICollider.destroy }
|
|
733
|
+
*/ _proto.destroy = function destroy() {
|
|
734
|
+
this._pxActor.release();
|
|
735
|
+
};
|
|
736
|
+
/**
|
|
737
|
+
* @internal
|
|
738
|
+
*/ _proto._transform = function _transform(pos, rot) {
|
|
739
|
+
var transform = PhysXCollider._tempTransform;
|
|
740
|
+
transform.translation = pos;
|
|
741
|
+
transform.rotation = rot.normalize();
|
|
742
|
+
return transform;
|
|
743
|
+
};
|
|
744
|
+
return PhysXCollider;
|
|
745
|
+
}();
|
|
746
|
+
(function() {
|
|
747
|
+
PhysXCollider._tempTransform = {
|
|
748
|
+
translation: null,
|
|
749
|
+
rotation: null
|
|
750
|
+
};
|
|
751
|
+
})();
|
|
703
752
|
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
753
|
+
var CollisionDetectionMode;
|
|
754
|
+
(function(CollisionDetectionMode) {
|
|
755
|
+
CollisionDetectionMode[CollisionDetectionMode[/** Continuous collision detection is off for this dynamic collider. */ "Discrete"] = 0] = "Discrete";
|
|
756
|
+
CollisionDetectionMode[CollisionDetectionMode[/** Continuous collision detection is on for colliding with static mesh geometry. */ "Continuous"] = 1] = "Continuous";
|
|
757
|
+
CollisionDetectionMode[CollisionDetectionMode[/** Continuous collision detection is on for colliding with static and dynamic geometry. */ "ContinuousDynamic"] = 2] = "ContinuousDynamic";
|
|
758
|
+
CollisionDetectionMode[CollisionDetectionMode[/** Speculative continuous collision detection is on for static and dynamic geometries */ "ContinuousSpeculative"] = 3] = "ContinuousSpeculative";
|
|
759
|
+
})(CollisionDetectionMode || (CollisionDetectionMode = {}));
|
|
760
|
+
/**
|
|
761
|
+
* A dynamic collider can act with self-defined movement or physical force
|
|
762
|
+
*/ var PhysXDynamicCollider = /*#__PURE__*/ function(PhysXCollider) {
|
|
763
|
+
_inherits(PhysXDynamicCollider, PhysXCollider);
|
|
764
|
+
function PhysXDynamicCollider(physXPhysics, position, rotation) {
|
|
765
|
+
var _this;
|
|
766
|
+
_this = PhysXCollider.call(this, physXPhysics) || this;
|
|
767
|
+
var transform = _this._transform(position, rotation);
|
|
768
|
+
_this._pxActor = physXPhysics._pxPhysics.createRigidDynamic(transform);
|
|
769
|
+
return _this;
|
|
770
|
+
}
|
|
771
|
+
var _proto = PhysXDynamicCollider.prototype;
|
|
772
|
+
/**
|
|
773
|
+
* {@inheritDoc IDynamicCollider.setLinearDamping }
|
|
774
|
+
*/ _proto.setLinearDamping = function setLinearDamping(value) {
|
|
775
|
+
this._pxActor.setLinearDamping(value);
|
|
776
|
+
};
|
|
777
|
+
/**
|
|
778
|
+
* {@inheritDoc IDynamicCollider.setAngularDamping }
|
|
779
|
+
*/ _proto.setAngularDamping = function setAngularDamping(value) {
|
|
780
|
+
this._pxActor.setAngularDamping(value);
|
|
781
|
+
};
|
|
782
|
+
/**
|
|
783
|
+
* {@inheritDoc IDynamicCollider.setLinearVelocity }
|
|
784
|
+
*/ _proto.setLinearVelocity = function setLinearVelocity(value) {
|
|
785
|
+
this._pxActor.setLinearVelocity(value, true);
|
|
786
|
+
};
|
|
787
|
+
/**
|
|
788
|
+
* {@inheritDoc IDynamicCollider.setAngularVelocity }
|
|
789
|
+
*/ _proto.setAngularVelocity = function setAngularVelocity(value) {
|
|
790
|
+
this._pxActor.setAngularVelocity(value, true);
|
|
791
|
+
};
|
|
792
|
+
/**
|
|
793
|
+
* {@inheritDoc IDynamicCollider.setMass }
|
|
794
|
+
*/ _proto.setMass = function setMass(value) {
|
|
795
|
+
this._pxActor.setMass(value);
|
|
796
|
+
};
|
|
797
|
+
/**
|
|
798
|
+
* {@inheritDoc IDynamicCollider.setCenterOfMass }
|
|
799
|
+
*/ _proto.setCenterOfMass = function setCenterOfMass(position) {
|
|
800
|
+
this._pxActor.setCMassLocalPose(position);
|
|
801
|
+
};
|
|
802
|
+
/**
|
|
803
|
+
* {@inheritDoc IDynamicCollider.setInertiaTensor }
|
|
804
|
+
*/ _proto.setInertiaTensor = function setInertiaTensor(value) {
|
|
805
|
+
this._pxActor.setMassSpaceInertiaTensor(value);
|
|
806
|
+
};
|
|
807
|
+
/**
|
|
808
|
+
* {@inheritDoc IDynamicCollider.setMaxAngularVelocity }
|
|
809
|
+
*/ _proto.setMaxAngularVelocity = function setMaxAngularVelocity(value) {
|
|
810
|
+
this._pxActor.setMaxAngularVelocity(value);
|
|
811
|
+
};
|
|
812
|
+
/**
|
|
813
|
+
* {@inheritDoc IDynamicCollider.setMaxDepenetrationVelocity }
|
|
814
|
+
*/ _proto.setMaxDepenetrationVelocity = function setMaxDepenetrationVelocity(value) {
|
|
815
|
+
this._pxActor.setMaxDepenetrationVelocity(value);
|
|
816
|
+
};
|
|
817
|
+
/**
|
|
818
|
+
* {@inheritDoc IDynamicCollider.setSleepThreshold }
|
|
819
|
+
* @default 1e-5f * PxTolerancesScale::speed * PxTolerancesScale::speed
|
|
820
|
+
*/ _proto.setSleepThreshold = function setSleepThreshold(value) {
|
|
821
|
+
this._pxActor.setSleepThreshold(value);
|
|
822
|
+
};
|
|
823
|
+
/**
|
|
824
|
+
* {@inheritDoc IDynamicCollider.setSolverIterations }
|
|
825
|
+
*/ _proto.setSolverIterations = function setSolverIterations(value) {
|
|
826
|
+
this._pxActor.setSolverIterationCounts(value, 1);
|
|
827
|
+
};
|
|
828
|
+
/**
|
|
829
|
+
* {@inheritDoc IDynamicCollider.setCollisionDetectionMode }
|
|
830
|
+
*/ _proto.setCollisionDetectionMode = function setCollisionDetectionMode(value) {
|
|
831
|
+
switch(value){
|
|
832
|
+
case 1:
|
|
833
|
+
this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eENABLE_CCD, true);
|
|
834
|
+
break;
|
|
835
|
+
case 2:
|
|
836
|
+
this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eENABLE_CCD_FRICTION, true);
|
|
837
|
+
break;
|
|
838
|
+
case 3:
|
|
839
|
+
this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eENABLE_SPECULATIVE_CCD, true);
|
|
840
|
+
break;
|
|
841
|
+
case 0:
|
|
842
|
+
var physX = this._physXPhysics._physX;
|
|
843
|
+
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_CCD, false);
|
|
844
|
+
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_CCD_FRICTION, false);
|
|
845
|
+
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_SPECULATIVE_CCD, false);
|
|
846
|
+
break;
|
|
847
|
+
}
|
|
848
|
+
};
|
|
849
|
+
/**
|
|
850
|
+
* {@inheritDoc IDynamicCollider.setIsKinematic }
|
|
851
|
+
*/ _proto.setIsKinematic = function setIsKinematic(value) {
|
|
852
|
+
if (value) {
|
|
853
|
+
this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eKINEMATIC, true);
|
|
854
|
+
} else {
|
|
855
|
+
this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eKINEMATIC, false);
|
|
856
|
+
}
|
|
857
|
+
};
|
|
858
|
+
/**
|
|
859
|
+
* {@inheritDoc IDynamicCollider.setConstraints }
|
|
860
|
+
*/ _proto.setConstraints = function setConstraints(flags) {
|
|
861
|
+
this._pxActor.setRigidDynamicLockFlags(flags);
|
|
862
|
+
};
|
|
863
|
+
/**
|
|
864
|
+
* {@inheritDoc IDynamicCollider.addForce }
|
|
865
|
+
*/ _proto.addForce = function addForce(force) {
|
|
866
|
+
this._pxActor.addForce({
|
|
867
|
+
x: force.x,
|
|
868
|
+
y: force.y,
|
|
869
|
+
z: force.z
|
|
870
|
+
});
|
|
871
|
+
};
|
|
872
|
+
/**
|
|
873
|
+
* {@inheritDoc IDynamicCollider.addTorque }
|
|
874
|
+
*/ _proto.addTorque = function addTorque(torque) {
|
|
875
|
+
this._pxActor.addTorque({
|
|
876
|
+
x: torque.x,
|
|
877
|
+
y: torque.y,
|
|
878
|
+
z: torque.z
|
|
879
|
+
});
|
|
880
|
+
};
|
|
881
|
+
/**
|
|
882
|
+
* {@inheritDoc IDynamicCollider.move }
|
|
883
|
+
*/ _proto.move = function move(positionOrRotation, rotation) {
|
|
884
|
+
if (rotation) {
|
|
885
|
+
this._pxActor.setKinematicTarget(positionOrRotation, rotation);
|
|
886
|
+
return;
|
|
887
|
+
}
|
|
888
|
+
var tempTranslation = PhysXDynamicCollider._tempTranslation;
|
|
889
|
+
var tempRotation = PhysXDynamicCollider._tempRotation;
|
|
890
|
+
this.getWorldTransform(tempTranslation, tempRotation);
|
|
891
|
+
if (_instanceof(positionOrRotation, engine.Vector3)) {
|
|
892
|
+
this._pxActor.setKinematicTarget(positionOrRotation, tempRotation);
|
|
893
|
+
} else {
|
|
894
|
+
this._pxActor.setKinematicTarget(tempTranslation, positionOrRotation);
|
|
895
|
+
}
|
|
896
|
+
};
|
|
897
|
+
/**
|
|
898
|
+
* {@inheritDoc IDynamicCollider.sleep }
|
|
899
|
+
*/ _proto.sleep = function sleep() {
|
|
900
|
+
return this._pxActor.putToSleep();
|
|
901
|
+
};
|
|
902
|
+
/**
|
|
903
|
+
* {@inheritDoc IDynamicCollider.wakeUp }
|
|
904
|
+
*/ _proto.wakeUp = function wakeUp() {
|
|
905
|
+
return this._pxActor.wakeUp();
|
|
906
|
+
};
|
|
907
|
+
return PhysXDynamicCollider;
|
|
908
|
+
}(PhysXCollider);
|
|
909
|
+
(function() {
|
|
910
|
+
PhysXDynamicCollider._tempTranslation = new engine.Vector3();
|
|
911
|
+
})();
|
|
912
|
+
(function() {
|
|
913
|
+
PhysXDynamicCollider._tempRotation = new engine.Quaternion();
|
|
914
|
+
})();
|
|
862
915
|
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
916
|
+
/**
|
|
917
|
+
* A manager is a collection of colliders and constraints which can interact.
|
|
918
|
+
*/ var PhysXPhysicsManager = /*#__PURE__*/ function() {
|
|
919
|
+
function PhysXPhysicsManager(physXPhysics, onContactEnter, onContactExit, onContactStay, onTriggerEnter, onTriggerExit, onTriggerStay) {
|
|
920
|
+
var _this = this;
|
|
921
|
+
/** @internal */ this._pxControllerManager = null;
|
|
922
|
+
this._currentEvents = new DisorderedArray();
|
|
923
|
+
this._eventMap = {};
|
|
924
|
+
this._eventPool = [];
|
|
925
|
+
this._physXPhysics = physXPhysics;
|
|
926
|
+
var physX = physXPhysics._physX;
|
|
927
|
+
this._pxRaycastHit = new physX.PxRaycastHit();
|
|
928
|
+
this._pxFilterData = new physX.PxQueryFilterData();
|
|
929
|
+
this._pxFilterData.flags = new physX.PxQueryFlags(1 | 2 | 4);
|
|
930
|
+
this._onContactEnter = onContactEnter;
|
|
931
|
+
this._onContactExit = onContactExit;
|
|
932
|
+
this._onContactStay = onContactStay;
|
|
933
|
+
this._onTriggerEnter = onTriggerEnter;
|
|
934
|
+
this._onTriggerExit = onTriggerExit;
|
|
935
|
+
this._onTriggerStay = onTriggerStay;
|
|
936
|
+
var triggerCallback = {
|
|
937
|
+
onContactBegin: function(index1, index2) {
|
|
938
|
+
_this._onContactEnter(index1, index2);
|
|
939
|
+
},
|
|
940
|
+
onContactEnd: function(index1, index2) {
|
|
941
|
+
_this._onContactExit(index1, index2);
|
|
942
|
+
},
|
|
943
|
+
onContactPersist: function(index1, index2) {
|
|
944
|
+
_this._onContactStay(index1, index2);
|
|
945
|
+
},
|
|
946
|
+
onTriggerBegin: function(index1, index2) {
|
|
947
|
+
var event = index1 < index2 ? _this._getTrigger(index1, index2) : _this._getTrigger(index2, index1);
|
|
948
|
+
event.state = 0;
|
|
949
|
+
_this._currentEvents.add(event);
|
|
950
|
+
},
|
|
951
|
+
onTriggerEnd: function(index1, index2) {
|
|
952
|
+
var event;
|
|
953
|
+
if (index1 < index2) {
|
|
954
|
+
var subMap = _this._eventMap[index1];
|
|
955
|
+
event = subMap[index2];
|
|
956
|
+
subMap[index2] = undefined;
|
|
957
|
+
} else {
|
|
958
|
+
var subMap1 = _this._eventMap[index2];
|
|
959
|
+
event = subMap1[index1];
|
|
960
|
+
subMap1[index1] = undefined;
|
|
961
|
+
}
|
|
962
|
+
event.state = 2;
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
var pxPhysics = physXPhysics._pxPhysics;
|
|
966
|
+
var physXSimulationCallbackInstance = physX.PxSimulationEventCallback.implement(triggerCallback);
|
|
967
|
+
var sceneDesc = physX.getDefaultSceneDesc(pxPhysics.getTolerancesScale(), 0, physXSimulationCallbackInstance);
|
|
968
|
+
this._pxScene = pxPhysics.createScene(sceneDesc);
|
|
969
|
+
}
|
|
970
|
+
var _proto = PhysXPhysicsManager.prototype;
|
|
971
|
+
/**
|
|
972
|
+
* {@inheritDoc IPhysicsManager.setGravity }
|
|
973
|
+
*/ _proto.setGravity = function setGravity(value) {
|
|
974
|
+
this._pxScene.setGravity(value);
|
|
975
|
+
};
|
|
976
|
+
/**
|
|
977
|
+
* {@inheritDoc IPhysicsManager.addColliderShape }
|
|
978
|
+
*/ _proto.addColliderShape = function addColliderShape(colliderShape) {
|
|
979
|
+
this._eventMap[colliderShape._id] = {};
|
|
980
|
+
};
|
|
981
|
+
/**
|
|
982
|
+
* {@inheritDoc IPhysicsManager.removeColliderShape }
|
|
983
|
+
*/ _proto.removeColliderShape = function removeColliderShape(colliderShape) {
|
|
984
|
+
var _this = this, eventPool = _this._eventPool, currentEvents = _this._currentEvents;
|
|
985
|
+
var shapeID = colliderShape._id;
|
|
986
|
+
for(var i = currentEvents.length - 1; i >= 0; i--){
|
|
987
|
+
var event = currentEvents.get(i);
|
|
988
|
+
if (event.index1 == shapeID || event.index2 == shapeID) {
|
|
989
|
+
currentEvents.deleteByIndex(i);
|
|
990
|
+
eventPool.push(event);
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
delete this._eventMap[shapeID];
|
|
994
|
+
};
|
|
995
|
+
/**
|
|
996
|
+
* {@inheritDoc IPhysicsManager.addCollider }
|
|
997
|
+
*/ _proto.addCollider = function addCollider(collider) {
|
|
998
|
+
this._pxScene.addActor(collider._pxActor, null);
|
|
999
|
+
};
|
|
1000
|
+
/**
|
|
1001
|
+
* {@inheritDoc IPhysicsManager.removeCollider }
|
|
1002
|
+
*/ _proto.removeCollider = function removeCollider(collider) {
|
|
1003
|
+
this._pxScene.removeActor(collider._pxActor, true);
|
|
1004
|
+
};
|
|
1005
|
+
/**
|
|
1006
|
+
* {@inheritDoc IPhysicsManager.addCharacterController }
|
|
1007
|
+
*/ _proto.addCharacterController = function addCharacterController(characterController) {
|
|
1008
|
+
var lastPXManager = characterController._pxManager;
|
|
1009
|
+
var shape = characterController._shape;
|
|
1010
|
+
if (shape) {
|
|
1011
|
+
if (lastPXManager !== this) {
|
|
1012
|
+
lastPXManager && characterController._destroyPXController();
|
|
1013
|
+
characterController._createPXController(this, shape);
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
characterController._pxManager = this;
|
|
1017
|
+
};
|
|
1018
|
+
/**
|
|
1019
|
+
* {@inheritDoc IPhysicsManager.removeCharacterController }
|
|
1020
|
+
*/ _proto.removeCharacterController = function removeCharacterController(characterController) {
|
|
1021
|
+
characterController._pxController = null;
|
|
1022
|
+
characterController._pxManager = null;
|
|
1023
|
+
};
|
|
1024
|
+
/**
|
|
1025
|
+
* {@inheritDoc IPhysicsManager.update }
|
|
1026
|
+
*/ _proto.update = function update(elapsedTime) {
|
|
1027
|
+
this._simulate(elapsedTime);
|
|
1028
|
+
this._fetchResults();
|
|
1029
|
+
this._fireEvent();
|
|
1030
|
+
};
|
|
1031
|
+
/**
|
|
1032
|
+
* {@inheritDoc IPhysicsManager.raycast }
|
|
1033
|
+
*/ _proto.raycast = function raycast(ray, distance, onRaycast, hit) {
|
|
1034
|
+
var _this = this, pxHitResult = _this._pxRaycastHit;
|
|
1035
|
+
distance = Math.min(distance, 3.4e38); // float32 max value limit in physx raycast.
|
|
1036
|
+
var raycastCallback = {
|
|
1037
|
+
preFilter: function(filterData, index, actor) {
|
|
1038
|
+
if (onRaycast(index)) {
|
|
1039
|
+
return 2; // eBLOCK
|
|
1040
|
+
} else {
|
|
1041
|
+
return 0; // eNONE
|
|
1042
|
+
}
|
|
1043
|
+
},
|
|
1044
|
+
postFilter: function(filterData, hit) {}
|
|
1045
|
+
};
|
|
1046
|
+
var result = this._pxScene.raycastSingle(ray.origin, ray.direction, distance, pxHitResult, this._pxFilterData, this._physXPhysics._physX.PxQueryFilterCallback.implement(raycastCallback));
|
|
1047
|
+
if (result && hit != undefined) {
|
|
1048
|
+
var position = PhysXPhysicsManager._tempPosition, normal = PhysXPhysicsManager._tempNormal;
|
|
1049
|
+
var pxPosition = pxHitResult.position, pxNormal = pxHitResult.normal;
|
|
1050
|
+
position.set(pxPosition.x, pxPosition.y, pxPosition.z);
|
|
1051
|
+
normal.set(pxNormal.x, pxNormal.y, pxNormal.z);
|
|
1052
|
+
hit(pxHitResult.getShape().getUUID(), pxHitResult.distance, position, normal);
|
|
1053
|
+
}
|
|
1054
|
+
return result;
|
|
1055
|
+
};
|
|
1056
|
+
/**
|
|
1057
|
+
* @internal
|
|
1058
|
+
*/ _proto._getControllerManager = function _getControllerManager() {
|
|
1059
|
+
var pxControllerManager = this._pxControllerManager;
|
|
1060
|
+
if (pxControllerManager === null) {
|
|
1061
|
+
this._pxControllerManager = pxControllerManager = this._pxScene.createControllerManager();
|
|
1062
|
+
}
|
|
1063
|
+
return pxControllerManager;
|
|
1064
|
+
};
|
|
1065
|
+
_proto._simulate = function _simulate(elapsedTime) {
|
|
1066
|
+
this._pxScene.simulate(elapsedTime, true);
|
|
1067
|
+
};
|
|
1068
|
+
_proto._fetchResults = function _fetchResults(block) {
|
|
1069
|
+
if (block === void 0) block = true;
|
|
1070
|
+
this._pxScene.fetchResults(block);
|
|
1071
|
+
};
|
|
1072
|
+
_proto._getTrigger = function _getTrigger(index1, index2) {
|
|
1073
|
+
var event;
|
|
1074
|
+
if (this._eventPool.length) {
|
|
1075
|
+
event = this._eventPool.pop();
|
|
1076
|
+
event.index1 = index1;
|
|
1077
|
+
event.index2 = index2;
|
|
1078
|
+
} else {
|
|
1079
|
+
event = new TriggerEvent(index1, index2);
|
|
1080
|
+
}
|
|
1081
|
+
this._eventMap[index1][index2] = event;
|
|
1082
|
+
return event;
|
|
1083
|
+
};
|
|
1084
|
+
_proto._fireEvent = function _fireEvent() {
|
|
1085
|
+
var _this = this, eventPool = _this._eventPool, currentEvents = _this._currentEvents;
|
|
1086
|
+
for(var i = currentEvents.length - 1; i >= 0; i--){
|
|
1087
|
+
var event = currentEvents.get(i);
|
|
1088
|
+
if (event.state == 0) {
|
|
1089
|
+
this._onTriggerEnter(event.index1, event.index2);
|
|
1090
|
+
event.state = 1;
|
|
1091
|
+
} else if (event.state == 1) {
|
|
1092
|
+
this._onTriggerStay(event.index1, event.index2);
|
|
1093
|
+
} else if (event.state == 2) {
|
|
1094
|
+
this._onTriggerExit(event.index1, event.index2);
|
|
1095
|
+
currentEvents.deleteByIndex(i);
|
|
1096
|
+
eventPool.push(event);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
};
|
|
1100
|
+
return PhysXPhysicsManager;
|
|
1101
|
+
}();
|
|
1102
|
+
(function() {
|
|
1103
|
+
PhysXPhysicsManager._tempPosition = new engine.Vector3();
|
|
1104
|
+
})();
|
|
1105
|
+
(function() {
|
|
1106
|
+
PhysXPhysicsManager._tempNormal = new engine.Vector3();
|
|
1107
|
+
})();
|
|
1108
|
+
var /**
|
|
1109
|
+
* Filtering flags for scene queries.
|
|
1110
|
+
*/ QueryFlag;
|
|
1111
|
+
(function(QueryFlag) {
|
|
1112
|
+
QueryFlag[QueryFlag["STATIC"] = 1] = "STATIC";
|
|
1113
|
+
QueryFlag[QueryFlag["DYNAMIC"] = 2] = "DYNAMIC";
|
|
1114
|
+
QueryFlag[QueryFlag["PRE_FILTER"] = 4] = "PRE_FILTER";
|
|
1115
|
+
QueryFlag[QueryFlag["POST_FILTER"] = 8] = "POST_FILTER";
|
|
1116
|
+
QueryFlag[QueryFlag["ANY_HIT"] = 16] = "ANY_HIT";
|
|
1117
|
+
QueryFlag[QueryFlag["NO_BLOCK"] = 32] = "NO_BLOCK";
|
|
1118
|
+
})(QueryFlag || (QueryFlag = {}));
|
|
1119
|
+
var /**
|
|
1120
|
+
* Physics state
|
|
1121
|
+
*/ TriggerEventState;
|
|
1122
|
+
(function(TriggerEventState) {
|
|
1123
|
+
TriggerEventState[TriggerEventState["Enter"] = 0] = "Enter";
|
|
1124
|
+
TriggerEventState[TriggerEventState["Stay"] = 1] = "Stay";
|
|
1125
|
+
TriggerEventState[TriggerEventState["Exit"] = 2] = "Exit";
|
|
1126
|
+
})(TriggerEventState || (TriggerEventState = {}));
|
|
1127
|
+
/**
|
|
1128
|
+
* Trigger event to store interactive object ids and state.
|
|
1129
|
+
*/ var TriggerEvent = function TriggerEvent(index1, index2) {
|
|
1130
|
+
this.index1 = index1;
|
|
1131
|
+
this.index2 = index2;
|
|
1132
|
+
};
|
|
1076
1133
|
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1134
|
+
/**
|
|
1135
|
+
* Physics material describes how to handle colliding objects (friction, bounciness).
|
|
1136
|
+
*/ var PhysXPhysicsMaterial = /*#__PURE__*/ function() {
|
|
1137
|
+
function PhysXPhysicsMaterial(physXPhysics, staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine) {
|
|
1138
|
+
this._physXPhysics = physXPhysics;
|
|
1139
|
+
var pxMaterial = physXPhysics._pxPhysics.createMaterial(staticFriction, dynamicFriction, bounciness);
|
|
1140
|
+
pxMaterial.setFrictionCombineMode(frictionCombine);
|
|
1141
|
+
pxMaterial.setRestitutionCombineMode(bounceCombine);
|
|
1142
|
+
this._pxMaterial = pxMaterial;
|
|
1143
|
+
}
|
|
1144
|
+
var _proto = PhysXPhysicsMaterial.prototype;
|
|
1145
|
+
/**
|
|
1146
|
+
* {@inheritDoc IPhysicsMaterial.setBounciness }
|
|
1147
|
+
*/ _proto.setBounciness = function setBounciness(value) {
|
|
1148
|
+
this._pxMaterial.setRestitution(value);
|
|
1149
|
+
};
|
|
1150
|
+
/**
|
|
1151
|
+
* {@inheritDoc IPhysicsMaterial.setDynamicFriction }
|
|
1152
|
+
*/ _proto.setDynamicFriction = function setDynamicFriction(value) {
|
|
1153
|
+
this._pxMaterial.setDynamicFriction(value);
|
|
1154
|
+
};
|
|
1155
|
+
/**
|
|
1156
|
+
* {@inheritDoc IPhysicsMaterial.setStaticFriction }
|
|
1157
|
+
*/ _proto.setStaticFriction = function setStaticFriction(value) {
|
|
1158
|
+
this._pxMaterial.setStaticFriction(value);
|
|
1159
|
+
};
|
|
1160
|
+
/**
|
|
1161
|
+
* {@inheritDoc IPhysicsMaterial.setBounceCombine }
|
|
1162
|
+
*/ _proto.setBounceCombine = function setBounceCombine(value) {
|
|
1163
|
+
this._pxMaterial.setRestitutionCombineMode(value);
|
|
1164
|
+
};
|
|
1165
|
+
/**
|
|
1166
|
+
* {@inheritDoc IPhysicsMaterial.setFrictionCombine }
|
|
1167
|
+
*/ _proto.setFrictionCombine = function setFrictionCombine(value) {
|
|
1168
|
+
this._pxMaterial.setFrictionCombineMode(value);
|
|
1169
|
+
};
|
|
1170
|
+
/**
|
|
1171
|
+
* {@inheritDoc IPhysicsMaterial.destroy }
|
|
1172
|
+
*/ _proto.destroy = function destroy() {
|
|
1173
|
+
this._pxMaterial.release();
|
|
1174
|
+
};
|
|
1175
|
+
return PhysXPhysicsMaterial;
|
|
1176
|
+
}();
|
|
1177
|
+
var /**
|
|
1178
|
+
* Describes how physics materials of the colliding objects are combined.
|
|
1179
|
+
*/ CombineMode;
|
|
1180
|
+
(function(CombineMode) {
|
|
1181
|
+
CombineMode[CombineMode[/** Averages the friction/bounce of the two colliding materials. */ "Average"] = 0] = "Average";
|
|
1182
|
+
CombineMode[CombineMode[/** Uses the smaller friction/bounce of the two colliding materials. */ "Minimum"] = 1] = "Minimum";
|
|
1183
|
+
CombineMode[CombineMode[/** Multiplies the friction/bounce of the two colliding materials. */ "Multiply"] = 2] = "Multiply";
|
|
1184
|
+
CombineMode[CombineMode[/** Uses the larger friction/bounce of the two colliding materials. */ "Maximum"] = 3] = "Maximum";
|
|
1185
|
+
})(CombineMode || (CombineMode = {}));
|
|
1129
1186
|
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1187
|
+
/**
|
|
1188
|
+
* A static collider component that will not move.
|
|
1189
|
+
* @remarks Mostly used for object which always stays at the same place and never moves around.
|
|
1190
|
+
*/ var PhysXStaticCollider = /*#__PURE__*/ function(PhysXCollider) {
|
|
1191
|
+
_inherits(PhysXStaticCollider, PhysXCollider);
|
|
1192
|
+
function PhysXStaticCollider(physXPhysics, position, rotation) {
|
|
1193
|
+
var _this;
|
|
1194
|
+
_this = PhysXCollider.call(this, physXPhysics) || this;
|
|
1195
|
+
_this._pxActor = physXPhysics._pxPhysics.createRigidStatic(_this._transform(position, rotation));
|
|
1196
|
+
return _this;
|
|
1197
|
+
}
|
|
1198
|
+
return PhysXStaticCollider;
|
|
1199
|
+
}(PhysXCollider);
|
|
1143
1200
|
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
* {@inheritDoc IColliderShape.setWorldScale }
|
|
1161
|
-
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
1162
|
-
this._scale.copyFrom(scale);
|
|
1163
|
-
this._setLocalPose();
|
|
1164
|
-
};
|
|
1165
|
-
return PhysXPlaneColliderShape;
|
|
1166
|
-
}(PhysXColliderShape);
|
|
1201
|
+
/**
|
|
1202
|
+
* Plane collider shape in PhysX.
|
|
1203
|
+
*/ var PhysXPlaneColliderShape = /*#__PURE__*/ function(PhysXColliderShape1) {
|
|
1204
|
+
_inherits(PhysXPlaneColliderShape, PhysXColliderShape1);
|
|
1205
|
+
function PhysXPlaneColliderShape(physXPhysics, uniqueID, material) {
|
|
1206
|
+
var _this;
|
|
1207
|
+
_this = PhysXColliderShape1.call(this, physXPhysics) || this;
|
|
1208
|
+
_this._axis = new engine.Quaternion(0, 0, PhysXColliderShape.halfSqrt, PhysXColliderShape.halfSqrt);
|
|
1209
|
+
_this._physXRotation.copyFrom(_this._axis);
|
|
1210
|
+
_this._pxGeometry = new physXPhysics._physX.PxPlaneGeometry();
|
|
1211
|
+
_this._initialize(material, uniqueID);
|
|
1212
|
+
_this._setLocalPose();
|
|
1213
|
+
return _this;
|
|
1214
|
+
}
|
|
1215
|
+
return PhysXPlaneColliderShape;
|
|
1216
|
+
}(PhysXColliderShape);
|
|
1167
1217
|
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
}(PhysXColliderShape);
|
|
1218
|
+
/**
|
|
1219
|
+
* Sphere collider shape in PhysX.
|
|
1220
|
+
*/ var PhysXSphereColliderShape = /*#__PURE__*/ function(PhysXColliderShape) {
|
|
1221
|
+
_inherits(PhysXSphereColliderShape, PhysXColliderShape);
|
|
1222
|
+
function PhysXSphereColliderShape(physXPhysics, uniqueID, radius, material) {
|
|
1223
|
+
var _this;
|
|
1224
|
+
_this = PhysXColliderShape.call(this, physXPhysics) || this;
|
|
1225
|
+
_this._maxScale = 1;
|
|
1226
|
+
_this._radius = radius;
|
|
1227
|
+
_this._pxGeometry = new physXPhysics._physX.PxSphereGeometry(_this._radius * _this._maxScale);
|
|
1228
|
+
_this._initialize(material, uniqueID);
|
|
1229
|
+
_this._setLocalPose();
|
|
1230
|
+
return _this;
|
|
1231
|
+
}
|
|
1232
|
+
var _proto = PhysXSphereColliderShape.prototype;
|
|
1233
|
+
/**
|
|
1234
|
+
* {@inheritDoc ISphereColliderShape.setRadius }
|
|
1235
|
+
*/ _proto.setRadius = function setRadius(value) {
|
|
1236
|
+
this._radius = value;
|
|
1237
|
+
this._pxGeometry.radius = value * this._maxScale;
|
|
1238
|
+
this._pxShape.setGeometry(this._pxGeometry);
|
|
1239
|
+
};
|
|
1240
|
+
/**
|
|
1241
|
+
* {@inheritDoc IColliderShape.setWorldScale }
|
|
1242
|
+
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
1243
|
+
PhysXColliderShape.prototype.setWorldScale.call(this, scale);
|
|
1244
|
+
this._maxScale = Math.max(scale.x, Math.max(scale.x, scale.y));
|
|
1245
|
+
this._pxGeometry.radius = this._radius * this._maxScale;
|
|
1246
|
+
this._pxShape.setGeometry(this._pxGeometry);
|
|
1247
|
+
};
|
|
1248
|
+
return PhysXSphereColliderShape;
|
|
1249
|
+
}(PhysXColliderShape);
|
|
1201
1250
|
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1251
|
+
/**
|
|
1252
|
+
* PhysX object creation.
|
|
1253
|
+
*/ var PhysXPhysics = /*#__PURE__*/ function() {
|
|
1254
|
+
function PhysXPhysics(runtimeMode) {
|
|
1255
|
+
if (runtimeMode === void 0) runtimeMode = exports.PhysXRuntimeMode.Auto;
|
|
1256
|
+
this._initializeState = 0;
|
|
1257
|
+
this._runTimeMode = runtimeMode;
|
|
1258
|
+
}
|
|
1259
|
+
var _proto = PhysXPhysics.prototype;
|
|
1260
|
+
/**
|
|
1261
|
+
* Initialize PhysXPhysics.
|
|
1262
|
+
* @param runtimeMode - Runtime mode
|
|
1263
|
+
* @returns Promise object
|
|
1264
|
+
*/ _proto.initialize = function initialize() {
|
|
1265
|
+
var _this = this;
|
|
1266
|
+
if (this._initializeState === 2) {
|
|
1267
|
+
return Promise.resolve();
|
|
1268
|
+
} else if (this._initializeState === 1) {
|
|
1269
|
+
return this._initializePromise;
|
|
1270
|
+
}
|
|
1271
|
+
var runtimeMode = this._runTimeMode;
|
|
1272
|
+
var scriptPromise = new Promise(function(resolve, reject) {
|
|
1273
|
+
var script = document.createElement("script");
|
|
1274
|
+
document.body.appendChild(script);
|
|
1275
|
+
script.async = true;
|
|
1276
|
+
script.onload = resolve;
|
|
1277
|
+
script.onerror = reject;
|
|
1278
|
+
if (runtimeMode == exports.PhysXRuntimeMode.Auto) {
|
|
1279
|
+
var supported = function() {
|
|
1280
|
+
try {
|
|
1281
|
+
if (typeof WebAssembly === "object" && typeof WebAssembly.instantiate === "function") {
|
|
1282
|
+
var module = new WebAssembly.Module(Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00));
|
|
1283
|
+
if (_instanceof(module, WebAssembly.Module)) return _instanceof(new WebAssembly.Instance(module), WebAssembly.Instance);
|
|
1284
|
+
}
|
|
1285
|
+
} catch (e) {}
|
|
1286
|
+
return false;
|
|
1287
|
+
}();
|
|
1288
|
+
if (supported) {
|
|
1289
|
+
runtimeMode = exports.PhysXRuntimeMode.WebAssembly;
|
|
1290
|
+
} else {
|
|
1291
|
+
runtimeMode = exports.PhysXRuntimeMode.JavaScript;
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
if (runtimeMode == exports.PhysXRuntimeMode.JavaScript) {
|
|
1295
|
+
script.src = "https://gw.alipayobjects.com/os/lib/oasis-engine/physics-physx/1.0.0-alpha.4/libs/physx.release.js.js";
|
|
1296
|
+
} else if (runtimeMode == exports.PhysXRuntimeMode.WebAssembly) {
|
|
1297
|
+
script.src = "https://gw.alipayobjects.com/os/lib/oasis-engine/physics-physx/1.0.0-alpha.4/libs/physx.release.js";
|
|
1298
|
+
}
|
|
1299
|
+
});
|
|
1300
|
+
var initializePromise = new Promise(function(resolve, reject) {
|
|
1301
|
+
scriptPromise.then(function() {
|
|
1302
|
+
return window.PHYSX().then(function(PHYSX) {
|
|
1303
|
+
_this._init(PHYSX);
|
|
1304
|
+
_this._initializeState = 2;
|
|
1305
|
+
_this._initializePromise = null;
|
|
1306
|
+
console.log("PhysX loaded.");
|
|
1307
|
+
resolve();
|
|
1308
|
+
}, reject);
|
|
1309
|
+
}, reject).catch(reject);
|
|
1310
|
+
});
|
|
1311
|
+
this._initializePromise = initializePromise;
|
|
1312
|
+
return initializePromise;
|
|
1313
|
+
};
|
|
1314
|
+
/**
|
|
1315
|
+
* Destroy PhysXPhysics.
|
|
1316
|
+
*/ _proto.destroy = function destroy() {
|
|
1317
|
+
this._physX.PxCloseExtensions();
|
|
1318
|
+
this._pxPhysics.release();
|
|
1319
|
+
this._pxFoundation.release();
|
|
1320
|
+
this._physX = null;
|
|
1321
|
+
this._pxFoundation = null;
|
|
1322
|
+
this._pxPhysics = null;
|
|
1323
|
+
};
|
|
1324
|
+
/**
|
|
1325
|
+
* {@inheritDoc IPhysics.createPhysicsManager }
|
|
1326
|
+
*/ _proto.createPhysicsManager = function createPhysicsManager(onContactBegin, onContactEnd, onContactStay, onTriggerBegin, onTriggerEnd, onTriggerStay) {
|
|
1327
|
+
var manager = new PhysXPhysicsManager(this, onContactBegin, onContactEnd, onContactStay, onTriggerBegin, onTriggerEnd, onTriggerStay);
|
|
1328
|
+
return manager;
|
|
1329
|
+
};
|
|
1330
|
+
/**
|
|
1331
|
+
* {@inheritDoc IPhysics.createStaticCollider }
|
|
1332
|
+
*/ _proto.createStaticCollider = function createStaticCollider(position, rotation) {
|
|
1333
|
+
return new PhysXStaticCollider(this, position, rotation);
|
|
1334
|
+
};
|
|
1335
|
+
/**
|
|
1336
|
+
* {@inheritDoc IPhysics.createDynamicCollider }
|
|
1337
|
+
*/ _proto.createDynamicCollider = function createDynamicCollider(position, rotation) {
|
|
1338
|
+
return new PhysXDynamicCollider(this, position, rotation);
|
|
1339
|
+
};
|
|
1340
|
+
/**
|
|
1341
|
+
* {@inheritDoc IPhysics.createCharacterController }
|
|
1342
|
+
*/ _proto.createCharacterController = function createCharacterController() {
|
|
1343
|
+
return new PhysXCharacterController(this);
|
|
1344
|
+
};
|
|
1345
|
+
/**
|
|
1346
|
+
* {@inheritDoc IPhysics.createPhysicsMaterial }
|
|
1347
|
+
*/ _proto.createPhysicsMaterial = function createPhysicsMaterial(staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine) {
|
|
1348
|
+
return new PhysXPhysicsMaterial(this, staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine);
|
|
1349
|
+
};
|
|
1350
|
+
/**
|
|
1351
|
+
* {@inheritDoc IPhysics.createBoxColliderShape }
|
|
1352
|
+
*/ _proto.createBoxColliderShape = function createBoxColliderShape(uniqueID, size, material) {
|
|
1353
|
+
return new PhysXBoxColliderShape(this, uniqueID, size, material);
|
|
1354
|
+
};
|
|
1355
|
+
/**
|
|
1356
|
+
* {@inheritDoc IPhysics.createSphereColliderShape }
|
|
1357
|
+
*/ _proto.createSphereColliderShape = function createSphereColliderShape(uniqueID, radius, material) {
|
|
1358
|
+
return new PhysXSphereColliderShape(this, uniqueID, radius, material);
|
|
1359
|
+
};
|
|
1360
|
+
/**
|
|
1361
|
+
* {@inheritDoc IPhysics.createPlaneColliderShape }
|
|
1362
|
+
*/ _proto.createPlaneColliderShape = function createPlaneColliderShape(uniqueID, material) {
|
|
1363
|
+
return new PhysXPlaneColliderShape(this, uniqueID, material);
|
|
1364
|
+
};
|
|
1365
|
+
/**
|
|
1366
|
+
* {@inheritDoc IPhysics.createCapsuleColliderShape }
|
|
1367
|
+
*/ _proto.createCapsuleColliderShape = function createCapsuleColliderShape(uniqueID, radius, height, material) {
|
|
1368
|
+
return new PhysXCapsuleColliderShape(this, uniqueID, radius, height, material);
|
|
1369
|
+
};
|
|
1370
|
+
/**
|
|
1371
|
+
* {@inheritDoc IPhysics.createFixedJoint }
|
|
1372
|
+
*/ _proto.createFixedJoint = function createFixedJoint(collider) {
|
|
1373
|
+
return new PhysXFixedJoint(this, collider);
|
|
1374
|
+
};
|
|
1375
|
+
/**
|
|
1376
|
+
* {@inheritDoc IPhysics.createHingeJoint }
|
|
1377
|
+
*/ _proto.createHingeJoint = function createHingeJoint(collider) {
|
|
1378
|
+
return new PhysXHingeJoint(this, collider);
|
|
1379
|
+
};
|
|
1380
|
+
/**
|
|
1381
|
+
* {@inheritDoc IPhysics.createSpringJoint }
|
|
1382
|
+
*/ _proto.createSpringJoint = function createSpringJoint(collider) {
|
|
1383
|
+
return new PhysXSpringJoint(this, collider);
|
|
1384
|
+
};
|
|
1385
|
+
_proto._init = function _init(physX) {
|
|
1386
|
+
var version = physX.PX_PHYSICS_VERSION;
|
|
1387
|
+
var defaultErrorCallback = new physX.PxDefaultErrorCallback();
|
|
1388
|
+
var allocator = new physX.PxDefaultAllocator();
|
|
1389
|
+
var pxFoundation = physX.PxCreateFoundation(version, allocator, defaultErrorCallback);
|
|
1390
|
+
var pxPhysics = physX.PxCreatePhysics(version, pxFoundation, new physX.PxTolerancesScale(), false, null);
|
|
1391
|
+
physX.PxInitExtensions(pxPhysics, null);
|
|
1392
|
+
this._physX = physX;
|
|
1393
|
+
this._pxFoundation = pxFoundation;
|
|
1394
|
+
this._pxPhysics = pxPhysics;
|
|
1395
|
+
};
|
|
1396
|
+
return PhysXPhysics;
|
|
1397
|
+
}();
|
|
1398
|
+
var InitializeState;
|
|
1399
|
+
(function(InitializeState) {
|
|
1400
|
+
InitializeState[InitializeState["Uninitialized"] = 0] = "Uninitialized";
|
|
1401
|
+
InitializeState[InitializeState["Initializing"] = 1] = "Initializing";
|
|
1402
|
+
InitializeState[InitializeState["Initialized"] = 2] = "Initialized";
|
|
1403
|
+
})(InitializeState || (InitializeState = {}));
|
|
1355
1404
|
|
|
1356
|
-
|
|
1405
|
+
exports.PhysXPhysics = PhysXPhysics;
|
|
1357
1406
|
|
|
1358
|
-
|
|
1407
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1359
1408
|
|
|
1360
1409
|
}));
|