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