@galacean/engine-physics-physx 0.9.21 → 0.9.22
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 +1359 -1292
- package/dist/browser.min.js +1 -1
- package/dist/main.js +102 -38
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +32444 -31558
- package/dist/module.js +88 -21
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
package/dist/browser.js
CHANGED
|
@@ -1,1316 +1,1383 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}(this, (function (exports,
|
|
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
|
+
})(this, (function (exports, engine) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
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;
|
|
11
|
+
}
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
/******************************************************************************
|
|
14
|
+
Copyright (c) Microsoft Corporation.
|
|
15
|
+
|
|
16
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
17
|
+
purpose with or without fee is hereby granted.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
20
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
21
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
22
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
23
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
24
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
25
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
26
|
+
***************************************************************************** */
|
|
27
|
+
|
|
28
|
+
function __decorate(decorators, target, key, desc) {
|
|
29
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
30
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
31
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
32
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
33
|
+
}
|
|
12
34
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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 = {}));
|
|
18
43
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
function PhysXJoint() {
|
|
23
|
-
this._connectedAnchor = new engine.Vector3();
|
|
24
|
-
this._breakForce = Number.MAX_VALUE;
|
|
25
|
-
this._breakTorque = Number.MAX_VALUE;
|
|
26
|
-
}
|
|
27
|
-
var _proto = PhysXJoint.prototype;
|
|
28
|
-
/**
|
|
29
|
-
* {@inheritDoc IJoint.setConnectedCollider }
|
|
30
|
-
*/ _proto.setConnectedCollider = function setConnectedCollider(value) {
|
|
31
|
-
var _this__collider;
|
|
32
|
-
this._pxJoint.setActors((value == null ? void 0 : value._pxActor) || null, ((_this__collider = this._collider) == null ? void 0 : _this__collider._pxActor) || null);
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* {@inheritDoc IJoint.setConnectedAnchor }
|
|
36
|
-
*/ _proto.setConnectedAnchor = function setConnectedAnchor(value) {
|
|
37
|
-
this._connectedAnchor.copyFrom(value);
|
|
38
|
-
this._setLocalPose(0, value, PhysXJoint._defaultQuat);
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* {@inheritDoc IJoint.setConnectedMassScale }
|
|
42
|
-
*/ _proto.setConnectedMassScale = function setConnectedMassScale(value) {
|
|
43
|
-
this._pxJoint.setInvMassScale0(1 / value);
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* {@inheritDoc IJoint.setConnectedInertiaScale }
|
|
47
|
-
*/ _proto.setConnectedInertiaScale = function setConnectedInertiaScale(value) {
|
|
48
|
-
this._pxJoint.setInvInertiaScale0(1 / value);
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* {@inheritDoc IJoint.setMassScale }
|
|
52
|
-
*/ _proto.setMassScale = function setMassScale(value) {
|
|
53
|
-
this._pxJoint.setInvMassScale1(1 / value);
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* {@inheritDoc IJoint.setInertiaScale }
|
|
57
|
-
*/ _proto.setInertiaScale = function setInertiaScale(value) {
|
|
58
|
-
this._pxJoint.setInvInertiaScale1(1 / value);
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* {@inheritDoc IJoint.setBreakForce }
|
|
62
|
-
*/ _proto.setBreakForce = function setBreakForce(value) {
|
|
63
|
-
this._breakForce = value;
|
|
64
|
-
this._pxJoint.setBreakForce(this._breakForce, this._breakTorque);
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* {@inheritDoc IJoint.setBreakTorque }
|
|
68
|
-
*/ _proto.setBreakTorque = function setBreakTorque(value) {
|
|
69
|
-
this._breakTorque = value;
|
|
70
|
-
this._pxJoint.setBreakForce(this._breakForce, this._breakTorque);
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* Set the joint local pose for an actor.
|
|
74
|
-
* @param actor 0 for the first actor, 1 for the second actor.
|
|
75
|
-
* @param position the local position for the actor this joint
|
|
76
|
-
* @param rotation the local rotation for the actor this joint
|
|
77
|
-
*/ _proto._setLocalPose = function _setLocalPose(actor, position, rotation) {
|
|
78
|
-
this._pxJoint.setLocalPose(actor, position, rotation);
|
|
79
|
-
};
|
|
80
|
-
return PhysXJoint;
|
|
81
|
-
}();
|
|
82
|
-
PhysXJoint._xAxis = new engine.Vector3(1, 0, 0);
|
|
83
|
-
PhysXJoint._defaultVec = new engine.Vector3();
|
|
84
|
-
PhysXJoint._defaultQuat = new engine.Quaternion();
|
|
44
|
+
function _set_prototype_of(o, p) {
|
|
45
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
46
|
+
o.__proto__ = p;
|
|
85
47
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
*/ var PhysXFixedJoint = /*#__PURE__*/ function(PhysXJoint1) {
|
|
89
|
-
_inherits__default['default'](PhysXFixedJoint, PhysXJoint1);
|
|
90
|
-
function PhysXFixedJoint(collider) {
|
|
91
|
-
var _this;
|
|
92
|
-
_this = PhysXJoint1.call(this) || this;
|
|
93
|
-
_this._collider = collider;
|
|
94
|
-
_this._pxJoint = exports.PhysXPhysics._pxPhysics.createFixedJoint(null, PhysXJoint._defaultVec, PhysXJoint._defaultQuat, collider._pxActor, PhysXJoint._defaultVec, PhysXJoint._defaultQuat);
|
|
95
|
-
return _this;
|
|
96
|
-
}
|
|
97
|
-
return PhysXFixedJoint;
|
|
98
|
-
}(PhysXJoint);
|
|
48
|
+
return o;
|
|
49
|
+
};
|
|
99
50
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
*/ var PhysXHingeJoint = /*#__PURE__*/ function(PhysXJoint1) {
|
|
103
|
-
_inherits__default['default'](PhysXHingeJoint, PhysXJoint1);
|
|
104
|
-
function PhysXHingeJoint(collider) {
|
|
105
|
-
var _this;
|
|
106
|
-
_this = PhysXJoint1.call(this) || this;
|
|
107
|
-
_this._axisRotationQuaternion = new engine.Quaternion();
|
|
108
|
-
_this._swingOffset = new engine.Vector3();
|
|
109
|
-
_this._velocity = new engine.Vector3();
|
|
110
|
-
_this._collider = collider;
|
|
111
|
-
_this._pxJoint = exports.PhysXPhysics._pxPhysics.createRevoluteJoint(null, PhysXJoint._defaultVec, PhysXJoint._defaultQuat, collider._pxActor, PhysXJoint._defaultVec, PhysXJoint._defaultQuat);
|
|
112
|
-
return _this;
|
|
113
|
-
}
|
|
114
|
-
var _proto = PhysXHingeJoint.prototype;
|
|
115
|
-
/**
|
|
116
|
-
* {@inheritDoc IHingeJoint.setAxis }
|
|
117
|
-
*/ _proto.setAxis = function setAxis(value) {
|
|
118
|
-
var xAxis = PhysXJoint._xAxis;
|
|
119
|
-
var axisRotationQuaternion = this._axisRotationQuaternion;
|
|
120
|
-
xAxis.set(1, 0, 0);
|
|
121
|
-
value.normalize();
|
|
122
|
-
var angle = Math.acos(engine.Vector3.dot(xAxis, value));
|
|
123
|
-
engine.Vector3.cross(xAxis, value, xAxis);
|
|
124
|
-
engine.Quaternion.rotationAxisAngle(xAxis, angle, axisRotationQuaternion);
|
|
125
|
-
this._setLocalPose(0, this._swingOffset, axisRotationQuaternion);
|
|
126
|
-
};
|
|
127
|
-
/**
|
|
128
|
-
* {@inheritDoc IHingeJoint.setSwingOffset }
|
|
129
|
-
*/ _proto.setSwingOffset = function setSwingOffset(value) {
|
|
130
|
-
this._swingOffset.copyFrom(value);
|
|
131
|
-
this._setLocalPose(1, this._swingOffset, this._axisRotationQuaternion);
|
|
132
|
-
};
|
|
133
|
-
/**
|
|
134
|
-
* {@inheritDoc IHingeJoint.getAngle }
|
|
135
|
-
*/ _proto.getAngle = function getAngle() {
|
|
136
|
-
return this._pxJoint.getAngle();
|
|
137
|
-
};
|
|
138
|
-
/**
|
|
139
|
-
* {@inheritDoc IHingeJoint.getVelocity }
|
|
140
|
-
*/ _proto.getVelocity = function getVelocity() {
|
|
141
|
-
var velocity = this._velocity;
|
|
142
|
-
velocity.copyFrom(this._pxJoint.getVelocity());
|
|
143
|
-
return velocity;
|
|
144
|
-
};
|
|
145
|
-
/**
|
|
146
|
-
* {@inheritDoc IHingeJoint.setHardLimitCone }
|
|
147
|
-
*/ _proto.setHardLimit = function setHardLimit(lowerLimit, upperLimit, contactDist) {
|
|
148
|
-
this._pxJoint.setHardLimit(lowerLimit, upperLimit, contactDist);
|
|
149
|
-
};
|
|
150
|
-
/**
|
|
151
|
-
* {@inheritDoc IHingeJoint.setHardLimitCone }
|
|
152
|
-
*/ _proto.setSoftLimit = function setSoftLimit(lowerLimit, upperLimit, stiffness, damping) {
|
|
153
|
-
this._pxJoint.setSoftLimit(lowerLimit, upperLimit, stiffness, damping);
|
|
154
|
-
};
|
|
155
|
-
/**
|
|
156
|
-
* {@inheritDoc IHingeJoint.setDriveVelocity }
|
|
157
|
-
*/ _proto.setDriveVelocity = function setDriveVelocity(velocity) {
|
|
158
|
-
this._pxJoint.setDriveVelocity(velocity);
|
|
159
|
-
};
|
|
160
|
-
/**
|
|
161
|
-
* {@inheritDoc IHingeJoint.setDriveForceLimit }
|
|
162
|
-
*/ _proto.setDriveForceLimit = function setDriveForceLimit(limit) {
|
|
163
|
-
this._pxJoint.setDriveForceLimit(limit);
|
|
164
|
-
};
|
|
165
|
-
/**
|
|
166
|
-
* {@inheritDoc IHingeJoint.setDriveGearRatio }
|
|
167
|
-
*/ _proto.setDriveGearRatio = function setDriveGearRatio(ratio) {
|
|
168
|
-
this._pxJoint.setDriveGearRatio(ratio);
|
|
169
|
-
};
|
|
170
|
-
/**
|
|
171
|
-
* {@inheritDoc IHingeJoint.setHingeJointFlag }
|
|
172
|
-
*/ _proto.setHingeJointFlag = function setHingeJointFlag(flag, value) {
|
|
173
|
-
this._pxJoint.setRevoluteJointFlag(flag, value);
|
|
174
|
-
};
|
|
175
|
-
return PhysXHingeJoint;
|
|
176
|
-
}(PhysXJoint);
|
|
51
|
+
return _set_prototype_of(o, p);
|
|
52
|
+
}
|
|
177
53
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
function PhysXSpringJoint(collider) {
|
|
183
|
-
var _this;
|
|
184
|
-
_this = PhysXJoint1.call(this) || this;
|
|
185
|
-
_this._swingOffset = new engine.Vector3();
|
|
186
|
-
_this._collider = collider;
|
|
187
|
-
_this._pxJoint = exports.PhysXPhysics._pxPhysics.createDistanceJoint(null, PhysXJoint._defaultVec, PhysXJoint._defaultQuat, collider._pxActor, PhysXJoint._defaultVec, PhysXJoint._defaultQuat);
|
|
188
|
-
_this._pxJoint.setDistanceJointFlag(2, true); // enable max distance;
|
|
189
|
-
_this._pxJoint.setDistanceJointFlag(4, true); // enable min distance;
|
|
190
|
-
_this._pxJoint.setDistanceJointFlag(8, true); // enable spring;
|
|
191
|
-
return _this;
|
|
192
|
-
}
|
|
193
|
-
var _proto = PhysXSpringJoint.prototype;
|
|
194
|
-
/**
|
|
195
|
-
* {@inheritDoc ISpringJoint.setSwingOffset }
|
|
196
|
-
*/ _proto.setSwingOffset = function setSwingOffset(value) {
|
|
197
|
-
this._swingOffset.copyFrom(value);
|
|
198
|
-
this._setLocalPose(1, value, PhysXJoint._defaultQuat);
|
|
199
|
-
};
|
|
200
|
-
/**
|
|
201
|
-
* {@inheritDoc ISpringJoint.setMinDistance }
|
|
202
|
-
*/ _proto.setMinDistance = function setMinDistance(distance) {
|
|
203
|
-
this._pxJoint.setMinDistance(distance);
|
|
204
|
-
};
|
|
205
|
-
/**
|
|
206
|
-
* {@inheritDoc ISpringJoint.setMaxDistance }
|
|
207
|
-
*/ _proto.setMaxDistance = function setMaxDistance(distance) {
|
|
208
|
-
this._pxJoint.setMaxDistance(distance);
|
|
209
|
-
};
|
|
210
|
-
/**
|
|
211
|
-
* {@inheritDoc ISpringJoint.setTolerance }
|
|
212
|
-
*/ _proto.setTolerance = function setTolerance(tolerance) {
|
|
213
|
-
this._pxJoint.setTolerance(tolerance);
|
|
214
|
-
};
|
|
215
|
-
/**
|
|
216
|
-
* {@inheritDoc ISpringJoint.setStiffness }
|
|
217
|
-
*/ _proto.setStiffness = function setStiffness(stiffness) {
|
|
218
|
-
this._pxJoint.setStiffness(stiffness);
|
|
219
|
-
};
|
|
220
|
-
/**
|
|
221
|
-
* {@inheritDoc ISpringJoint.setDamping }
|
|
222
|
-
*/ _proto.setDamping = function setDamping(damping) {
|
|
223
|
-
this._pxJoint.setDamping(damping);
|
|
224
|
-
};
|
|
225
|
-
return PhysXSpringJoint;
|
|
226
|
-
}(PhysXJoint);
|
|
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
|
+
}
|
|
227
58
|
|
|
228
|
-
|
|
229
|
-
* High-performance unordered array, delete uses exchange method to improve performance, internal capacity only increases.
|
|
230
|
-
*/ var DisorderedArray = /*#__PURE__*/ function() {
|
|
231
|
-
function DisorderedArray(count) {
|
|
232
|
-
if (count === void 0) count = 0;
|
|
233
|
-
this.length = 0;
|
|
234
|
-
this._elements = new Array(count);
|
|
235
|
-
}
|
|
236
|
-
var _proto = DisorderedArray.prototype;
|
|
237
|
-
_proto.add = function add(element) {
|
|
238
|
-
if (this.length === this._elements.length) this._elements.push(element);
|
|
239
|
-
else this._elements[this.length] = element;
|
|
240
|
-
this.length++;
|
|
241
|
-
};
|
|
242
|
-
_proto.delete = function _delete(element) {
|
|
243
|
-
//TODO: It can be optimized for custom binary search and other algorithms, currently this._elements>=this.length wastes performance.
|
|
244
|
-
var index = this._elements.indexOf(element);
|
|
245
|
-
this.deleteByIndex(index);
|
|
246
|
-
};
|
|
247
|
-
_proto.get = function get(index) {
|
|
248
|
-
if (index >= this.length) {
|
|
249
|
-
throw "Index is out of range.";
|
|
250
|
-
}
|
|
251
|
-
return this._elements[index];
|
|
252
|
-
};
|
|
253
|
-
/**
|
|
254
|
-
*
|
|
255
|
-
* @param index
|
|
256
|
-
* @returns The replaced item is used to reset its index.
|
|
257
|
-
*/ _proto.deleteByIndex = function deleteByIndex(index) {
|
|
258
|
-
var elements = this._elements;
|
|
259
|
-
var end = null;
|
|
260
|
-
var lastIndex = this.length - 1;
|
|
261
|
-
if (index !== lastIndex) {
|
|
262
|
-
end = elements[lastIndex];
|
|
263
|
-
elements[index] = end;
|
|
264
|
-
}
|
|
265
|
-
this.length--;
|
|
266
|
-
return end;
|
|
267
|
-
};
|
|
268
|
-
_proto.garbageCollection = function garbageCollection() {
|
|
269
|
-
this._elements.length = this.length;
|
|
270
|
-
};
|
|
271
|
-
return DisorderedArray;
|
|
272
|
-
}();
|
|
59
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });
|
|
273
60
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
ShapeFlag[ShapeFlag[/** The shape will partake in collision in the physical simulation. */ "SIMULATION_SHAPE"] = 1] = "SIMULATION_SHAPE";
|
|
277
|
-
ShapeFlag[ShapeFlag[/** The shape will partake in scene queries (ray casts, overlap tests, sweeps, ...). */ "SCENE_QUERY_SHAPE"] = 2] = "SCENE_QUERY_SHAPE";
|
|
278
|
-
ShapeFlag[ShapeFlag[/** The shape is a trigger which can send reports whenever other shapes enter/leave its volume. */ "TRIGGER_SHAPE"] = 4] = "TRIGGER_SHAPE";
|
|
279
|
-
})(ShapeFlag || (ShapeFlag = {}));
|
|
280
|
-
/**
|
|
281
|
-
* Abstract class for collider shapes.
|
|
282
|
-
*/ var PhysXColliderShape = /*#__PURE__*/ function() {
|
|
283
|
-
function PhysXColliderShape() {
|
|
284
|
-
/** @internal */ this._controllers = new DisorderedArray();
|
|
285
|
-
this._scale = new engine.Vector3(1, 1, 1);
|
|
286
|
-
this._position = new engine.Vector3();
|
|
287
|
-
this._rotation = null;
|
|
288
|
-
this._axis = null;
|
|
289
|
-
this._physxRotation = new engine.Quaternion();
|
|
290
|
-
this._shapeFlags = 2 | 1;
|
|
291
|
-
/** @internal */ this._pxMaterials = new Array(1);
|
|
292
|
-
}
|
|
293
|
-
var _proto = PhysXColliderShape.prototype;
|
|
294
|
-
/**
|
|
295
|
-
* {@inheritDoc IColliderShape.setRotation }
|
|
296
|
-
*/ _proto.setRotation = function setRotation(value) {
|
|
297
|
-
this._rotation = value;
|
|
298
|
-
engine.Quaternion.rotationYawPitchRoll(value.x, value.y, value.z, this._physxRotation);
|
|
299
|
-
this._axis && engine.Quaternion.multiply(this._physxRotation, this._axis, this._physxRotation);
|
|
300
|
-
this._physxRotation.normalize();
|
|
301
|
-
this._setLocalPose();
|
|
302
|
-
};
|
|
303
|
-
/**
|
|
304
|
-
* {@inheritDoc IColliderShape.setPosition }
|
|
305
|
-
*/ _proto.setPosition = function setPosition(value) {
|
|
306
|
-
if (value !== this._position) {
|
|
307
|
-
this._position.copyFrom(value);
|
|
308
|
-
}
|
|
309
|
-
this._setLocalPose();
|
|
310
|
-
};
|
|
311
|
-
/**
|
|
312
|
-
* {@inheritDoc IColliderShape.setContactOffset }
|
|
313
|
-
* @default 0.02f * PxTolerancesScale::length
|
|
314
|
-
*/ _proto.setContactOffset = function setContactOffset(offset) {
|
|
315
|
-
this._pxShape.setContactOffset(offset);
|
|
316
|
-
var controllers = this._controllers;
|
|
317
|
-
for(var i = 0, n = controllers.length; i < n; i++){
|
|
318
|
-
controllers.get(i)._pxController.setContactOffset(offset);
|
|
319
|
-
}
|
|
320
|
-
};
|
|
321
|
-
/**
|
|
322
|
-
* {@inheritDoc IColliderShape.setMaterial }
|
|
323
|
-
*/ _proto.setMaterial = function setMaterial(value) {
|
|
324
|
-
this._pxMaterials[0] = value._pxMaterial;
|
|
325
|
-
this._pxShape.setMaterials(this._pxMaterials);
|
|
326
|
-
};
|
|
327
|
-
/**
|
|
328
|
-
* {@inheritDoc IColliderShape.setIsTrigger }
|
|
329
|
-
*/ _proto.setIsTrigger = function setIsTrigger(value) {
|
|
330
|
-
this._modifyFlag(1, !value);
|
|
331
|
-
this._modifyFlag(4, value);
|
|
332
|
-
this._setShapeFlags(this._shapeFlags);
|
|
333
|
-
};
|
|
334
|
-
/**
|
|
335
|
-
* {@inheritDoc IColliderShape.destroy }
|
|
336
|
-
*/ _proto.destroy = function destroy() {
|
|
337
|
-
this._pxShape.release();
|
|
338
|
-
};
|
|
339
|
-
/**
|
|
340
|
-
* @internal
|
|
341
|
-
*/ _proto._setShapeFlags = function _setShapeFlags(flags) {
|
|
342
|
-
this._shapeFlags = flags;
|
|
343
|
-
this._pxShape.setFlags(new exports.PhysXPhysics._physX.PxShapeFlags(this._shapeFlags));
|
|
344
|
-
};
|
|
345
|
-
_proto._setLocalPose = function _setLocalPose() {
|
|
346
|
-
var transform = PhysXColliderShape.transform;
|
|
347
|
-
engine.Vector3.multiply(this._position, this._scale, transform.translation);
|
|
348
|
-
transform.rotation = this._physxRotation;
|
|
349
|
-
this._pxShape.setLocalPose(transform);
|
|
350
|
-
};
|
|
351
|
-
_proto._initialize = function _initialize(material, id) {
|
|
352
|
-
this._id = id;
|
|
353
|
-
this._pxMaterials[0] = material._pxMaterial;
|
|
354
|
-
this._pxShape = exports.PhysXPhysics._pxPhysics.createShape(this._pxGeometry, material._pxMaterial, true, new exports.PhysXPhysics._physX.PxShapeFlags(this._shapeFlags));
|
|
355
|
-
this._pxShape.setQueryFilterData(new exports.PhysXPhysics._physX.PxFilterData(id, 0, 0, 0));
|
|
356
|
-
};
|
|
357
|
-
_proto._modifyFlag = function _modifyFlag(flag, value) {
|
|
358
|
-
this._shapeFlags = value ? this._shapeFlags | flag : this._shapeFlags & ~flag;
|
|
359
|
-
};
|
|
360
|
-
return PhysXColliderShape;
|
|
361
|
-
}();
|
|
362
|
-
PhysXColliderShape.halfSqrt = 0.70710678118655;
|
|
363
|
-
PhysXColliderShape.transform = {
|
|
364
|
-
translation: new engine.Vector3(),
|
|
365
|
-
rotation: null
|
|
366
|
-
};
|
|
61
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
62
|
+
}
|
|
367
63
|
|
|
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
|
-
|
|
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
|
+
})();
|
|
410
136
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
_this._initialize(material, uniqueID);
|
|
425
|
-
_this._setLocalPose();
|
|
426
|
-
return _this;
|
|
427
|
-
}
|
|
428
|
-
var _proto = PhysXCapsuleColliderShape.prototype;
|
|
429
|
-
/**
|
|
430
|
-
* {@inheritDoc ICapsuleColliderShape.setRadius }
|
|
431
|
-
*/ _proto.setRadius = function setRadius(value) {
|
|
432
|
-
this._radius = value;
|
|
433
|
-
switch(this._upAxis){
|
|
434
|
-
case /** Up axis is X. */ 0:
|
|
435
|
-
this._pxGeometry.radius = this._radius * Math.max(this._scale.y, this._scale.z);
|
|
436
|
-
break;
|
|
437
|
-
case 1:
|
|
438
|
-
this._pxGeometry.radius = this._radius * Math.max(this._scale.x, this._scale.z);
|
|
439
|
-
break;
|
|
440
|
-
case /** Up axis is Z. */ 2:
|
|
441
|
-
this._pxGeometry.radius = this._radius * Math.max(this._scale.x, this._scale.y);
|
|
442
|
-
break;
|
|
443
|
-
}
|
|
444
|
-
this._pxShape.setGeometry(this._pxGeometry);
|
|
445
|
-
var controllers = this._controllers;
|
|
446
|
-
for(var i = 0, n = controllers.length; i < n; i++){
|
|
447
|
-
controllers.get(i)._pxController.setRadius(value);
|
|
448
|
-
}
|
|
449
|
-
};
|
|
450
|
-
/**
|
|
451
|
-
* {@inheritDoc ICapsuleColliderShape.setHeight }
|
|
452
|
-
*/ _proto.setHeight = function setHeight(value) {
|
|
453
|
-
this._halfHeight = value * 0.5;
|
|
454
|
-
switch(this._upAxis){
|
|
455
|
-
case 0:
|
|
456
|
-
this._pxGeometry.halfHeight = this._halfHeight * this._scale.x;
|
|
457
|
-
break;
|
|
458
|
-
case 1:
|
|
459
|
-
this._pxGeometry.halfHeight = this._halfHeight * this._scale.y;
|
|
460
|
-
break;
|
|
461
|
-
case 2:
|
|
462
|
-
this._pxGeometry.halfHeight = this._halfHeight * this._scale.z;
|
|
463
|
-
break;
|
|
464
|
-
}
|
|
465
|
-
this._pxShape.setGeometry(this._pxGeometry);
|
|
466
|
-
var controllers = this._controllers;
|
|
467
|
-
for(var i = 0, n = controllers.length; i < n; i++){
|
|
468
|
-
controllers.get(i)._pxController.setHeight(value);
|
|
469
|
-
}
|
|
470
|
-
};
|
|
471
|
-
/**
|
|
472
|
-
* {@inheritDoc ICapsuleColliderShape.setUpAxis }
|
|
473
|
-
*/ _proto.setUpAxis = function setUpAxis(upAxis) {
|
|
474
|
-
var _this = this, rotation = _this._rotation, axis = _this._axis, physxRotation = _this._physxRotation;
|
|
475
|
-
this._upAxis = upAxis;
|
|
476
|
-
switch(this._upAxis){
|
|
477
|
-
case 0:
|
|
478
|
-
axis.set(0, 0, 0, 1);
|
|
479
|
-
break;
|
|
480
|
-
case 1:
|
|
481
|
-
axis.set(0, 0, PhysXColliderShape.halfSqrt, PhysXColliderShape.halfSqrt);
|
|
482
|
-
break;
|
|
483
|
-
case 2:
|
|
484
|
-
axis.set(0, PhysXColliderShape.halfSqrt, 0, PhysXColliderShape.halfSqrt);
|
|
485
|
-
break;
|
|
486
|
-
}
|
|
487
|
-
if (rotation) {
|
|
488
|
-
engine.Quaternion.rotationYawPitchRoll(rotation.x, rotation.y, rotation.z, physxRotation);
|
|
489
|
-
engine.Quaternion.multiply(physxRotation, axis, physxRotation);
|
|
490
|
-
} else {
|
|
491
|
-
physxRotation.copyFrom(axis);
|
|
492
|
-
}
|
|
493
|
-
this._setLocalPose();
|
|
494
|
-
};
|
|
495
|
-
/**
|
|
496
|
-
* {@inheritDoc IColliderShape.setWorldScale }
|
|
497
|
-
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
498
|
-
this._scale.copyFrom(scale);
|
|
499
|
-
this._setLocalPose();
|
|
500
|
-
switch(this._upAxis){
|
|
501
|
-
case 0:
|
|
502
|
-
this._pxGeometry.radius = this._radius * Math.max(scale.y, scale.z);
|
|
503
|
-
this._pxGeometry.halfHeight = this._halfHeight * scale.x;
|
|
504
|
-
break;
|
|
505
|
-
case 1:
|
|
506
|
-
this._pxGeometry.radius = this._radius * Math.max(scale.x, scale.z);
|
|
507
|
-
this._pxGeometry.halfHeight = this._halfHeight * scale.y;
|
|
508
|
-
break;
|
|
509
|
-
case 2:
|
|
510
|
-
this._pxGeometry.radius = this._radius * Math.max(scale.x, scale.y);
|
|
511
|
-
this._pxGeometry.halfHeight = this._halfHeight * scale.z;
|
|
512
|
-
break;
|
|
513
|
-
}
|
|
514
|
-
this._pxShape.setGeometry(this._pxGeometry);
|
|
515
|
-
};
|
|
516
|
-
return PhysXCapsuleColliderShape;
|
|
517
|
-
}(PhysXColliderShape);
|
|
518
|
-
var /**
|
|
519
|
-
* The up axis of the collider shape.
|
|
520
|
-
*/ ColliderShapeUpAxis;
|
|
521
|
-
(function(ColliderShapeUpAxis) {
|
|
522
|
-
ColliderShapeUpAxis[ColliderShapeUpAxis["X"] = 0] = "X";
|
|
523
|
-
ColliderShapeUpAxis[ColliderShapeUpAxis["Y"] = 1] = "Y";
|
|
524
|
-
ColliderShapeUpAxis[ColliderShapeUpAxis["Z"] = 2] = "Z";
|
|
525
|
-
})(ColliderShapeUpAxis || (ColliderShapeUpAxis = {}));
|
|
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);
|
|
526
150
|
|
|
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
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
this._pxController = pxManager._getControllerManager().createController(desc);
|
|
605
|
-
this._pxController.setQueryFilterData(new exports.PhysXPhysics._physX.PxFilterData(shape._id, 0, 0, 0));
|
|
606
|
-
};
|
|
607
|
-
/**
|
|
608
|
-
* @internal
|
|
609
|
-
*/ _proto._destroyPXController = function _destroyPXController() {
|
|
610
|
-
if (this._pxController) {
|
|
611
|
-
this._pxController.release();
|
|
612
|
-
this._pxController = null;
|
|
613
|
-
}
|
|
614
|
-
};
|
|
615
|
-
return PhysXCharacterController;
|
|
616
|
-
}();
|
|
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);
|
|
617
228
|
|
|
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
|
-
|
|
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);
|
|
664
278
|
|
|
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
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
* {@inheritDoc IDynamicCollider.setCenterOfMass }
|
|
711
|
-
*/ _proto.setCenterOfMass = function setCenterOfMass(position) {
|
|
712
|
-
this._pxActor.setCMassLocalPose(position);
|
|
713
|
-
};
|
|
714
|
-
/**
|
|
715
|
-
* {@inheritDoc IDynamicCollider.setInertiaTensor }
|
|
716
|
-
*/ _proto.setInertiaTensor = function setInertiaTensor(value) {
|
|
717
|
-
this._pxActor.setMassSpaceInertiaTensor(value);
|
|
718
|
-
};
|
|
719
|
-
/**
|
|
720
|
-
* {@inheritDoc IDynamicCollider.setMaxAngularVelocity }
|
|
721
|
-
*/ _proto.setMaxAngularVelocity = function setMaxAngularVelocity(value) {
|
|
722
|
-
this._pxActor.setMaxAngularVelocity(value);
|
|
723
|
-
};
|
|
724
|
-
/**
|
|
725
|
-
* {@inheritDoc IDynamicCollider.setMaxDepenetrationVelocity }
|
|
726
|
-
*/ _proto.setMaxDepenetrationVelocity = function setMaxDepenetrationVelocity(value) {
|
|
727
|
-
this._pxActor.setMaxDepenetrationVelocity(value);
|
|
728
|
-
};
|
|
729
|
-
/**
|
|
730
|
-
* {@inheritDoc IDynamicCollider.setSleepThreshold }
|
|
731
|
-
* @default 1e-5f * PxTolerancesScale::speed * PxTolerancesScale::speed
|
|
732
|
-
*/ _proto.setSleepThreshold = function setSleepThreshold(value) {
|
|
733
|
-
this._pxActor.setSleepThreshold(value);
|
|
734
|
-
};
|
|
735
|
-
/**
|
|
736
|
-
* {@inheritDoc IDynamicCollider.setSolverIterations }
|
|
737
|
-
*/ _proto.setSolverIterations = function setSolverIterations(value) {
|
|
738
|
-
this._pxActor.setSolverIterationCounts(value, 1);
|
|
739
|
-
};
|
|
740
|
-
/**
|
|
741
|
-
* {@inheritDoc IDynamicCollider.setCollisionDetectionMode }
|
|
742
|
-
*/ _proto.setCollisionDetectionMode = function setCollisionDetectionMode(value) {
|
|
743
|
-
switch(value){
|
|
744
|
-
case 1:
|
|
745
|
-
this._pxActor.setRigidBodyFlag(exports.PhysXPhysics._physX.PxRigidBodyFlag.eENABLE_CCD, true);
|
|
746
|
-
break;
|
|
747
|
-
case 2:
|
|
748
|
-
this._pxActor.setRigidBodyFlag(exports.PhysXPhysics._physX.PxRigidBodyFlag.eENABLE_CCD_FRICTION, true);
|
|
749
|
-
break;
|
|
750
|
-
case 3:
|
|
751
|
-
this._pxActor.setRigidBodyFlag(exports.PhysXPhysics._physX.PxRigidBodyFlag.eENABLE_SPECULATIVE_CCD, true);
|
|
752
|
-
break;
|
|
753
|
-
case 0:
|
|
754
|
-
this._pxActor.setRigidBodyFlag(exports.PhysXPhysics._physX.PxRigidBodyFlag.eENABLE_CCD, false);
|
|
755
|
-
this._pxActor.setRigidBodyFlag(exports.PhysXPhysics._physX.PxRigidBodyFlag.eENABLE_CCD_FRICTION, false);
|
|
756
|
-
this._pxActor.setRigidBodyFlag(exports.PhysXPhysics._physX.PxRigidBodyFlag.eENABLE_SPECULATIVE_CCD, false);
|
|
757
|
-
break;
|
|
758
|
-
}
|
|
759
|
-
};
|
|
760
|
-
/**
|
|
761
|
-
* {@inheritDoc IDynamicCollider.setIsKinematic }
|
|
762
|
-
*/ _proto.setIsKinematic = function setIsKinematic(value) {
|
|
763
|
-
if (value) {
|
|
764
|
-
this._pxActor.setRigidBodyFlag(exports.PhysXPhysics._physX.PxRigidBodyFlag.eKINEMATIC, true);
|
|
765
|
-
} else {
|
|
766
|
-
this._pxActor.setRigidBodyFlag(exports.PhysXPhysics._physX.PxRigidBodyFlag.eKINEMATIC, false);
|
|
767
|
-
}
|
|
768
|
-
};
|
|
769
|
-
/**
|
|
770
|
-
* {@inheritDoc IDynamicCollider.setConstraints }
|
|
771
|
-
*/ _proto.setConstraints = function setConstraints(flags) {
|
|
772
|
-
this._pxActor.setRigidDynamicLockFlags(flags);
|
|
773
|
-
};
|
|
774
|
-
/**
|
|
775
|
-
* {@inheritDoc IDynamicCollider.addForce }
|
|
776
|
-
*/ _proto.addForce = function addForce(force) {
|
|
777
|
-
this._pxActor.addForce({
|
|
778
|
-
x: force.x,
|
|
779
|
-
y: force.y,
|
|
780
|
-
z: force.z
|
|
781
|
-
});
|
|
782
|
-
};
|
|
783
|
-
/**
|
|
784
|
-
* {@inheritDoc IDynamicCollider.addTorque }
|
|
785
|
-
*/ _proto.addTorque = function addTorque(torque) {
|
|
786
|
-
this._pxActor.addTorque({
|
|
787
|
-
x: torque.x,
|
|
788
|
-
y: torque.y,
|
|
789
|
-
z: torque.z
|
|
790
|
-
});
|
|
791
|
-
};
|
|
792
|
-
/**
|
|
793
|
-
* {@inheritDoc IDynamicCollider.move }
|
|
794
|
-
*/ _proto.move = function move(positionOrRotation, rotation) {
|
|
795
|
-
if (rotation) {
|
|
796
|
-
this._pxActor.setKinematicTarget(positionOrRotation, rotation);
|
|
797
|
-
return;
|
|
798
|
-
}
|
|
799
|
-
var tempTranslation = PhysXDynamicCollider._tempTranslation;
|
|
800
|
-
var tempRotation = PhysXDynamicCollider._tempRotation;
|
|
801
|
-
this.getWorldTransform(tempTranslation, tempRotation);
|
|
802
|
-
if (_instanceof__default['default'](positionOrRotation, engine.Vector3)) {
|
|
803
|
-
this._pxActor.setKinematicTarget(positionOrRotation, tempRotation);
|
|
804
|
-
} else {
|
|
805
|
-
this._pxActor.setKinematicTarget(tempTranslation, positionOrRotation);
|
|
806
|
-
}
|
|
807
|
-
};
|
|
808
|
-
/**
|
|
809
|
-
* {@inheritDoc IDynamicCollider.sleep }
|
|
810
|
-
*/ _proto.sleep = function sleep() {
|
|
811
|
-
return this._pxActor.putToSleep();
|
|
812
|
-
};
|
|
813
|
-
/**
|
|
814
|
-
* {@inheritDoc IDynamicCollider.wakeUp }
|
|
815
|
-
*/ _proto.wakeUp = function wakeUp() {
|
|
816
|
-
return this._pxActor.wakeUp();
|
|
817
|
-
};
|
|
818
|
-
return PhysXDynamicCollider;
|
|
819
|
-
}(PhysXCollider);
|
|
820
|
-
PhysXDynamicCollider._tempTranslation = new engine.Vector3();
|
|
821
|
-
PhysXDynamicCollider._tempRotation = new engine.Quaternion();
|
|
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
|
+
}();
|
|
822
324
|
|
|
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
|
-
|
|
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
|
-
if (!characterController._pxController) {
|
|
921
|
-
var shape = characterController._shape;
|
|
922
|
-
if (shape) {
|
|
923
|
-
var lastPXManager = characterController._pxManager;
|
|
924
|
-
if (lastPXManager !== this) {
|
|
925
|
-
lastPXManager && characterController._destroyPXController();
|
|
926
|
-
characterController._createPXController(this, shape);
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
characterController._pxManager = this;
|
|
931
|
-
};
|
|
932
|
-
/**
|
|
933
|
-
* {@inheritDoc IPhysicsManager.removeCharacterController }
|
|
934
|
-
*/ _proto.removeCharacterController = function removeCharacterController(characterController) {
|
|
935
|
-
characterController._pxManager = null;
|
|
936
|
-
};
|
|
937
|
-
/**
|
|
938
|
-
* {@inheritDoc IPhysicsManager.update }
|
|
939
|
-
*/ _proto.update = function update(elapsedTime) {
|
|
940
|
-
this._simulate(elapsedTime);
|
|
941
|
-
this._fetchResults();
|
|
942
|
-
this._fireEvent();
|
|
943
|
-
};
|
|
944
|
-
/**
|
|
945
|
-
* {@inheritDoc IPhysicsManager.raycast }
|
|
946
|
-
*/ _proto.raycast = function raycast(ray, distance, onRaycast, hit) {
|
|
947
|
-
var pxHitResult = PhysXPhysicsManager._pxRaycastHit;
|
|
948
|
-
distance = Math.min(distance, 3.4e38); // float32 max value limit in physx raycast.
|
|
949
|
-
var raycastCallback = {
|
|
950
|
-
preFilter: function(filterData, shape, actor) {
|
|
951
|
-
var index = shape.getQueryFilterData().word0;
|
|
952
|
-
if (onRaycast(index)) {
|
|
953
|
-
return 2; // eBLOCK
|
|
954
|
-
} else {
|
|
955
|
-
return 0; // eNONE
|
|
956
|
-
}
|
|
957
|
-
},
|
|
958
|
-
postFilter: function(filterData, hit) {}
|
|
959
|
-
};
|
|
960
|
-
var result = this._pxScene.raycastSingle(ray.origin, ray.direction, distance, pxHitResult, PhysXPhysicsManager._pxFilterData, exports.PhysXPhysics._physX.PxQueryFilterCallback.implement(raycastCallback));
|
|
961
|
-
if (result && hit != undefined) {
|
|
962
|
-
var position = PhysXPhysicsManager._tempPosition, normal = PhysXPhysicsManager._tempNormal;
|
|
963
|
-
var pxPosition = pxHitResult.position, pxNormal = pxHitResult.normal;
|
|
964
|
-
position.set(pxPosition.x, pxPosition.y, pxPosition.z);
|
|
965
|
-
normal.set(pxNormal.x, pxNormal.y, pxNormal.z);
|
|
966
|
-
hit(pxHitResult.getShape().getQueryFilterData().word0, pxHitResult.distance, position, normal);
|
|
967
|
-
}
|
|
968
|
-
return result;
|
|
969
|
-
};
|
|
970
|
-
/**
|
|
971
|
-
* @internal
|
|
972
|
-
*/ _proto._getControllerManager = function _getControllerManager() {
|
|
973
|
-
var pxControllerManager = this._pxControllerManager;
|
|
974
|
-
if (pxControllerManager === null) {
|
|
975
|
-
this._pxControllerManager = pxControllerManager = this._pxScene.createControllerManager();
|
|
976
|
-
}
|
|
977
|
-
return pxControllerManager;
|
|
978
|
-
};
|
|
979
|
-
_proto._simulate = function _simulate(elapsedTime) {
|
|
980
|
-
this._pxScene.simulate(elapsedTime, true);
|
|
981
|
-
};
|
|
982
|
-
_proto._fetchResults = function _fetchResults(block) {
|
|
983
|
-
if (block === void 0) block = true;
|
|
984
|
-
this._pxScene.fetchResults(block);
|
|
985
|
-
};
|
|
986
|
-
_proto._getTrigger = function _getTrigger(index1, index2) {
|
|
987
|
-
var event;
|
|
988
|
-
if (this._eventPool.length) {
|
|
989
|
-
event = this._eventPool.pop();
|
|
990
|
-
event.index1 = index1;
|
|
991
|
-
event.index2 = index2;
|
|
992
|
-
} else {
|
|
993
|
-
event = new TriggerEvent(index1, index2);
|
|
994
|
-
}
|
|
995
|
-
this._eventMap[index1][index2] = event;
|
|
996
|
-
return event;
|
|
997
|
-
};
|
|
998
|
-
_proto._fireEvent = function _fireEvent() {
|
|
999
|
-
var _this = this, eventPool = _this._eventPool, currentEvents = _this._currentEvents;
|
|
1000
|
-
for(var i = currentEvents.length - 1; i >= 0; i--){
|
|
1001
|
-
var event = currentEvents.get(i);
|
|
1002
|
-
if (event.state == 0) {
|
|
1003
|
-
this._onTriggerEnter(event.index1, event.index2);
|
|
1004
|
-
event.state = 1;
|
|
1005
|
-
} else if (event.state == 1) {
|
|
1006
|
-
this._onTriggerStay(event.index1, event.index2);
|
|
1007
|
-
} else if (event.state == 2) {
|
|
1008
|
-
this._onTriggerExit(event.index1, event.index2);
|
|
1009
|
-
currentEvents.deleteByIndex(i);
|
|
1010
|
-
eventPool.push(event);
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
};
|
|
1014
|
-
PhysXPhysicsManager._init = function _init() {
|
|
1015
|
-
PhysXPhysicsManager._pxRaycastHit = new exports.PhysXPhysics._physX.PxRaycastHit();
|
|
1016
|
-
PhysXPhysicsManager._pxFilterData = new exports.PhysXPhysics._physX.PxQueryFilterData();
|
|
1017
|
-
PhysXPhysicsManager._pxFilterData.flags = new exports.PhysXPhysics._physX.PxQueryFlags(1 | 2 | 4);
|
|
1018
|
-
};
|
|
1019
|
-
return PhysXPhysicsManager;
|
|
1020
|
-
}();
|
|
1021
|
-
PhysXPhysicsManager._tempPosition = new engine.Vector3();
|
|
1022
|
-
PhysXPhysicsManager._tempNormal = new engine.Vector3();
|
|
1023
|
-
var /**
|
|
1024
|
-
* Filtering flags for scene queries.
|
|
1025
|
-
*/ QueryFlag;
|
|
1026
|
-
(function(QueryFlag) {
|
|
1027
|
-
QueryFlag[QueryFlag["STATIC"] = 1] = "STATIC";
|
|
1028
|
-
QueryFlag[QueryFlag["DYNAMIC"] = 2] = "DYNAMIC";
|
|
1029
|
-
QueryFlag[QueryFlag["PRE_FILTER"] = 4] = "PRE_FILTER";
|
|
1030
|
-
QueryFlag[QueryFlag["POST_FILTER"] = 8] = "POST_FILTER";
|
|
1031
|
-
QueryFlag[QueryFlag["ANY_HIT"] = 16] = "ANY_HIT";
|
|
1032
|
-
QueryFlag[QueryFlag["NO_BLOCK"] = 32] = "NO_BLOCK";
|
|
1033
|
-
})(QueryFlag || (QueryFlag = {}));
|
|
1034
|
-
var /**
|
|
1035
|
-
* Physics state
|
|
1036
|
-
*/ TriggerEventState;
|
|
1037
|
-
(function(TriggerEventState) {
|
|
1038
|
-
TriggerEventState[TriggerEventState["Enter"] = 0] = "Enter";
|
|
1039
|
-
TriggerEventState[TriggerEventState["Stay"] = 1] = "Stay";
|
|
1040
|
-
TriggerEventState[TriggerEventState["Exit"] = 2] = "Exit";
|
|
1041
|
-
})(TriggerEventState || (TriggerEventState = {}));
|
|
1042
|
-
/**
|
|
1043
|
-
* Trigger event to store interactive object ids and state.
|
|
1044
|
-
*/ var TriggerEvent = function TriggerEvent(index1, index2) {
|
|
1045
|
-
this.index1 = index1;
|
|
1046
|
-
this.index2 = index2;
|
|
1047
|
-
};
|
|
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
|
+
})();
|
|
1048
422
|
|
|
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
|
-
*/ CombineMode;
|
|
1094
|
-
(function(CombineMode) {
|
|
1095
|
-
CombineMode[CombineMode[/** Averages the friction/bounce of the two colliding materials. */ "Average"] = 0] = "Average";
|
|
1096
|
-
CombineMode[CombineMode[/** Uses the smaller friction/bounce of the two colliding materials. */ "Minimum"] = 1] = "Minimum";
|
|
1097
|
-
CombineMode[CombineMode[/** Multiplies the friction/bounce of the two colliding materials. */ "Multiply"] = 2] = "Multiply";
|
|
1098
|
-
CombineMode[CombineMode[/** Uses the larger friction/bounce of the two colliding materials. */ "Maximum"] = 3] = "Maximum";
|
|
1099
|
-
})(CombineMode || (CombineMode = {}));
|
|
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
|
+
})();
|
|
1100
467
|
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
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 = {}));
|
|
1114
583
|
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
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
|
+
}();
|
|
1138
674
|
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
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
|
+
})();
|
|
1172
723
|
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
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
|
+
})();
|
|
1180
885
|
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
+
// Physx have no API to remove/readd cct into scene.
|
|
983
|
+
if (!characterController._pxController) {
|
|
984
|
+
var shape = characterController._shape;
|
|
985
|
+
if (shape) {
|
|
986
|
+
var lastPXManager = characterController._pxManager;
|
|
987
|
+
if (lastPXManager !== this) {
|
|
988
|
+
lastPXManager && characterController._destroyPXController();
|
|
989
|
+
characterController._createPXController(this, shape);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
characterController._pxManager = this;
|
|
994
|
+
};
|
|
995
|
+
/**
|
|
996
|
+
* {@inheritDoc IPhysicsManager.removeCharacterController }
|
|
997
|
+
*/ _proto.removeCharacterController = function removeCharacterController(characterController) {
|
|
998
|
+
characterController._pxManager = null;
|
|
999
|
+
};
|
|
1000
|
+
/**
|
|
1001
|
+
* {@inheritDoc IPhysicsManager.update }
|
|
1002
|
+
*/ _proto.update = function update(elapsedTime) {
|
|
1003
|
+
this._simulate(elapsedTime);
|
|
1004
|
+
this._fetchResults();
|
|
1005
|
+
this._fireEvent();
|
|
1006
|
+
};
|
|
1007
|
+
/**
|
|
1008
|
+
* {@inheritDoc IPhysicsManager.raycast }
|
|
1009
|
+
*/ _proto.raycast = function raycast(ray, distance, onRaycast, hit) {
|
|
1010
|
+
var pxHitResult = PhysXPhysicsManager._pxRaycastHit;
|
|
1011
|
+
distance = Math.min(distance, 3.4e38); // float32 max value limit in physx raycast.
|
|
1012
|
+
var raycastCallback = {
|
|
1013
|
+
preFilter: function(filterData, shape, actor) {
|
|
1014
|
+
var index = shape.getQueryFilterData().word0;
|
|
1015
|
+
if (onRaycast(index)) {
|
|
1016
|
+
return 2; // eBLOCK
|
|
1017
|
+
} else {
|
|
1018
|
+
return 0; // eNONE
|
|
1019
|
+
}
|
|
1020
|
+
},
|
|
1021
|
+
postFilter: function(filterData, hit) {}
|
|
1022
|
+
};
|
|
1023
|
+
var result = this._pxScene.raycastSingle(ray.origin, ray.direction, distance, pxHitResult, PhysXPhysicsManager._pxFilterData, exports.PhysXPhysics._physX.PxQueryFilterCallback.implement(raycastCallback));
|
|
1024
|
+
if (result && hit != undefined) {
|
|
1025
|
+
var position = PhysXPhysicsManager._tempPosition, normal = PhysXPhysicsManager._tempNormal;
|
|
1026
|
+
var pxPosition = pxHitResult.position, pxNormal = pxHitResult.normal;
|
|
1027
|
+
position.set(pxPosition.x, pxPosition.y, pxPosition.z);
|
|
1028
|
+
normal.set(pxNormal.x, pxNormal.y, pxNormal.z);
|
|
1029
|
+
hit(pxHitResult.getShape().getQueryFilterData().word0, pxHitResult.distance, position, normal);
|
|
1030
|
+
}
|
|
1031
|
+
return result;
|
|
1032
|
+
};
|
|
1033
|
+
/**
|
|
1034
|
+
* @internal
|
|
1035
|
+
*/ _proto._getControllerManager = function _getControllerManager() {
|
|
1036
|
+
var pxControllerManager = this._pxControllerManager;
|
|
1037
|
+
if (pxControllerManager === null) {
|
|
1038
|
+
this._pxControllerManager = pxControllerManager = this._pxScene.createControllerManager();
|
|
1039
|
+
}
|
|
1040
|
+
return pxControllerManager;
|
|
1041
|
+
};
|
|
1042
|
+
_proto._simulate = function _simulate(elapsedTime) {
|
|
1043
|
+
this._pxScene.simulate(elapsedTime, true);
|
|
1044
|
+
};
|
|
1045
|
+
_proto._fetchResults = function _fetchResults(block) {
|
|
1046
|
+
if (block === void 0) block = true;
|
|
1047
|
+
this._pxScene.fetchResults(block);
|
|
1048
|
+
};
|
|
1049
|
+
_proto._getTrigger = function _getTrigger(index1, index2) {
|
|
1050
|
+
var event;
|
|
1051
|
+
if (this._eventPool.length) {
|
|
1052
|
+
event = this._eventPool.pop();
|
|
1053
|
+
event.index1 = index1;
|
|
1054
|
+
event.index2 = index2;
|
|
1055
|
+
} else {
|
|
1056
|
+
event = new TriggerEvent(index1, index2);
|
|
1057
|
+
}
|
|
1058
|
+
this._eventMap[index1][index2] = event;
|
|
1059
|
+
return event;
|
|
1060
|
+
};
|
|
1061
|
+
_proto._fireEvent = function _fireEvent() {
|
|
1062
|
+
var _this = this, eventPool = _this._eventPool, currentEvents = _this._currentEvents;
|
|
1063
|
+
for(var i = currentEvents.length - 1; i >= 0; i--){
|
|
1064
|
+
var event = currentEvents.get(i);
|
|
1065
|
+
if (event.state == 0) {
|
|
1066
|
+
this._onTriggerEnter(event.index1, event.index2);
|
|
1067
|
+
event.state = 1;
|
|
1068
|
+
} else if (event.state == 1) {
|
|
1069
|
+
this._onTriggerStay(event.index1, event.index2);
|
|
1070
|
+
} else if (event.state == 2) {
|
|
1071
|
+
this._onTriggerExit(event.index1, event.index2);
|
|
1072
|
+
currentEvents.deleteByIndex(i);
|
|
1073
|
+
eventPool.push(event);
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
};
|
|
1077
|
+
PhysXPhysicsManager._init = function _init() {
|
|
1078
|
+
PhysXPhysicsManager._pxRaycastHit = new exports.PhysXPhysics._physX.PxRaycastHit();
|
|
1079
|
+
PhysXPhysicsManager._pxFilterData = new exports.PhysXPhysics._physX.PxQueryFilterData();
|
|
1080
|
+
PhysXPhysicsManager._pxFilterData.flags = new exports.PhysXPhysics._physX.PxQueryFlags(1 | 2 | 4);
|
|
1081
|
+
};
|
|
1082
|
+
return PhysXPhysicsManager;
|
|
1083
|
+
}();
|
|
1084
|
+
(function() {
|
|
1085
|
+
PhysXPhysicsManager._tempPosition = new engine.Vector3();
|
|
1086
|
+
})();
|
|
1087
|
+
(function() {
|
|
1088
|
+
PhysXPhysicsManager._tempNormal = new engine.Vector3();
|
|
1089
|
+
})();
|
|
1090
|
+
var /**
|
|
1091
|
+
* Filtering flags for scene queries.
|
|
1092
|
+
*/ QueryFlag;
|
|
1093
|
+
(function(QueryFlag) {
|
|
1094
|
+
QueryFlag[QueryFlag["STATIC"] = 1] = "STATIC";
|
|
1095
|
+
QueryFlag[QueryFlag["DYNAMIC"] = 2] = "DYNAMIC";
|
|
1096
|
+
QueryFlag[QueryFlag["PRE_FILTER"] = 4] = "PRE_FILTER";
|
|
1097
|
+
QueryFlag[QueryFlag["POST_FILTER"] = 8] = "POST_FILTER";
|
|
1098
|
+
QueryFlag[QueryFlag["ANY_HIT"] = 16] = "ANY_HIT";
|
|
1099
|
+
QueryFlag[QueryFlag["NO_BLOCK"] = 32] = "NO_BLOCK";
|
|
1100
|
+
})(QueryFlag || (QueryFlag = {}));
|
|
1101
|
+
var /**
|
|
1102
|
+
* Physics state
|
|
1103
|
+
*/ TriggerEventState;
|
|
1104
|
+
(function(TriggerEventState) {
|
|
1105
|
+
TriggerEventState[TriggerEventState["Enter"] = 0] = "Enter";
|
|
1106
|
+
TriggerEventState[TriggerEventState["Stay"] = 1] = "Stay";
|
|
1107
|
+
TriggerEventState[TriggerEventState["Exit"] = 2] = "Exit";
|
|
1108
|
+
})(TriggerEventState || (TriggerEventState = {}));
|
|
1109
|
+
/**
|
|
1110
|
+
* Trigger event to store interactive object ids and state.
|
|
1111
|
+
*/ var TriggerEvent = function TriggerEvent(index1, index2) {
|
|
1112
|
+
this.index1 = index1;
|
|
1113
|
+
this.index2 = index2;
|
|
1114
|
+
};
|
|
1313
1115
|
|
|
1314
|
-
|
|
1116
|
+
/**
|
|
1117
|
+
* Physics material describes how to handle colliding objects (friction, bounciness).
|
|
1118
|
+
*/ var PhysXPhysicsMaterial = /*#__PURE__*/ function() {
|
|
1119
|
+
function PhysXPhysicsMaterial(staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine) {
|
|
1120
|
+
var pxMaterial = exports.PhysXPhysics._pxPhysics.createMaterial(staticFriction, dynamicFriction, bounciness);
|
|
1121
|
+
pxMaterial.setFrictionCombineMode(frictionCombine);
|
|
1122
|
+
pxMaterial.setRestitutionCombineMode(bounceCombine);
|
|
1123
|
+
this._pxMaterial = pxMaterial;
|
|
1124
|
+
}
|
|
1125
|
+
var _proto = PhysXPhysicsMaterial.prototype;
|
|
1126
|
+
/**
|
|
1127
|
+
* {@inheritDoc IPhysicsMaterial.setBounciness }
|
|
1128
|
+
*/ _proto.setBounciness = function setBounciness(value) {
|
|
1129
|
+
this._pxMaterial.setRestitution(value);
|
|
1130
|
+
};
|
|
1131
|
+
/**
|
|
1132
|
+
* {@inheritDoc IPhysicsMaterial.setDynamicFriction }
|
|
1133
|
+
*/ _proto.setDynamicFriction = function setDynamicFriction(value) {
|
|
1134
|
+
this._pxMaterial.setDynamicFriction(value);
|
|
1135
|
+
};
|
|
1136
|
+
/**
|
|
1137
|
+
* {@inheritDoc IPhysicsMaterial.setStaticFriction }
|
|
1138
|
+
*/ _proto.setStaticFriction = function setStaticFriction(value) {
|
|
1139
|
+
this._pxMaterial.setStaticFriction(value);
|
|
1140
|
+
};
|
|
1141
|
+
/**
|
|
1142
|
+
* {@inheritDoc IPhysicsMaterial.setBounceCombine }
|
|
1143
|
+
*/ _proto.setBounceCombine = function setBounceCombine(value) {
|
|
1144
|
+
this._pxMaterial.setRestitutionCombineMode(value);
|
|
1145
|
+
};
|
|
1146
|
+
/**
|
|
1147
|
+
* {@inheritDoc IPhysicsMaterial.setFrictionCombine }
|
|
1148
|
+
*/ _proto.setFrictionCombine = function setFrictionCombine(value) {
|
|
1149
|
+
this._pxMaterial.setFrictionCombineMode(value);
|
|
1150
|
+
};
|
|
1151
|
+
/**
|
|
1152
|
+
* {@inheritDoc IPhysicsMaterial.destroy }
|
|
1153
|
+
*/ _proto.destroy = function destroy() {
|
|
1154
|
+
this._pxMaterial.release();
|
|
1155
|
+
};
|
|
1156
|
+
return PhysXPhysicsMaterial;
|
|
1157
|
+
}();
|
|
1158
|
+
var /**
|
|
1159
|
+
* Describes how physics materials of the colliding objects are combined.
|
|
1160
|
+
*/ CombineMode;
|
|
1161
|
+
(function(CombineMode) {
|
|
1162
|
+
CombineMode[CombineMode[/** Averages the friction/bounce of the two colliding materials. */ "Average"] = 0] = "Average";
|
|
1163
|
+
CombineMode[CombineMode[/** Uses the smaller friction/bounce of the two colliding materials. */ "Minimum"] = 1] = "Minimum";
|
|
1164
|
+
CombineMode[CombineMode[/** Multiplies the friction/bounce of the two colliding materials. */ "Multiply"] = 2] = "Multiply";
|
|
1165
|
+
CombineMode[CombineMode[/** Uses the larger friction/bounce of the two colliding materials. */ "Maximum"] = 3] = "Maximum";
|
|
1166
|
+
})(CombineMode || (CombineMode = {}));
|
|
1315
1167
|
|
|
1316
|
-
|
|
1168
|
+
/**
|
|
1169
|
+
* A static collider component that will not move.
|
|
1170
|
+
* @remarks Mostly used for object which always stays at the same place and never moves around.
|
|
1171
|
+
*/ var PhysXStaticCollider = /*#__PURE__*/ function(PhysXCollider) {
|
|
1172
|
+
_inherits(PhysXStaticCollider, PhysXCollider);
|
|
1173
|
+
function PhysXStaticCollider(position, rotation) {
|
|
1174
|
+
var _this;
|
|
1175
|
+
_this = PhysXCollider.call(this) || this;
|
|
1176
|
+
_this._pxActor = exports.PhysXPhysics._pxPhysics.createRigidStatic(_this._transform(position, rotation));
|
|
1177
|
+
return _this;
|
|
1178
|
+
}
|
|
1179
|
+
return PhysXStaticCollider;
|
|
1180
|
+
}(PhysXCollider);
|
|
1181
|
+
|
|
1182
|
+
/**
|
|
1183
|
+
* Plane collider shape in PhysX.
|
|
1184
|
+
*/ var PhysXPlaneColliderShape = /*#__PURE__*/ function(PhysXColliderShape1) {
|
|
1185
|
+
_inherits(PhysXPlaneColliderShape, PhysXColliderShape1);
|
|
1186
|
+
function PhysXPlaneColliderShape(uniqueID, material) {
|
|
1187
|
+
var _this;
|
|
1188
|
+
_this = PhysXColliderShape1.call(this) || this;
|
|
1189
|
+
_this._axis = new engine.Quaternion(0, 0, PhysXColliderShape.halfSqrt, PhysXColliderShape.halfSqrt);
|
|
1190
|
+
_this._physxRotation.copyFrom(_this._axis);
|
|
1191
|
+
_this._pxGeometry = new exports.PhysXPhysics._physX.PxPlaneGeometry();
|
|
1192
|
+
_this._initialize(material, uniqueID);
|
|
1193
|
+
_this._setLocalPose();
|
|
1194
|
+
return _this;
|
|
1195
|
+
}
|
|
1196
|
+
var _proto = PhysXPlaneColliderShape.prototype;
|
|
1197
|
+
/**
|
|
1198
|
+
* {@inheritDoc IColliderShape.setWorldScale }
|
|
1199
|
+
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
1200
|
+
this._scale.copyFrom(scale);
|
|
1201
|
+
this._setLocalPose();
|
|
1202
|
+
};
|
|
1203
|
+
return PhysXPlaneColliderShape;
|
|
1204
|
+
}(PhysXColliderShape);
|
|
1205
|
+
|
|
1206
|
+
/**
|
|
1207
|
+
* Sphere collider shape in PhysX.
|
|
1208
|
+
*/ var PhysXSphereColliderShape = /*#__PURE__*/ function(PhysXColliderShape) {
|
|
1209
|
+
_inherits(PhysXSphereColliderShape, PhysXColliderShape);
|
|
1210
|
+
function PhysXSphereColliderShape(uniqueID, radius, material) {
|
|
1211
|
+
var _this;
|
|
1212
|
+
_this = PhysXColliderShape.call(this) || this;
|
|
1213
|
+
_this._maxScale = 1;
|
|
1214
|
+
_this._radius = radius;
|
|
1215
|
+
_this._pxGeometry = new exports.PhysXPhysics._physX.PxSphereGeometry(_this._radius * _this._maxScale);
|
|
1216
|
+
_this._initialize(material, uniqueID);
|
|
1217
|
+
_this._setLocalPose();
|
|
1218
|
+
return _this;
|
|
1219
|
+
}
|
|
1220
|
+
var _proto = PhysXSphereColliderShape.prototype;
|
|
1221
|
+
/**
|
|
1222
|
+
* {@inheritDoc ISphereColliderShape.setRadius }
|
|
1223
|
+
*/ _proto.setRadius = function setRadius(value) {
|
|
1224
|
+
this._radius = value;
|
|
1225
|
+
this._pxGeometry.radius = value * this._maxScale;
|
|
1226
|
+
this._pxShape.setGeometry(this._pxGeometry);
|
|
1227
|
+
};
|
|
1228
|
+
/**
|
|
1229
|
+
* {@inheritDoc IColliderShape.setWorldScale }
|
|
1230
|
+
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
1231
|
+
this._scale.copyFrom(scale);
|
|
1232
|
+
this._setLocalPose();
|
|
1233
|
+
this._maxScale = Math.max(scale.x, Math.max(scale.x, scale.y));
|
|
1234
|
+
this._pxGeometry.radius = this._radius * this._maxScale;
|
|
1235
|
+
this._pxShape.setGeometry(this._pxGeometry);
|
|
1236
|
+
};
|
|
1237
|
+
return PhysXSphereColliderShape;
|
|
1238
|
+
}(PhysXColliderShape);
|
|
1239
|
+
|
|
1240
|
+
/**
|
|
1241
|
+
* Static interface implement decorator.
|
|
1242
|
+
* https://stackoverflow.com/questions/13955157/how-to-define-static-property-in-typescript-interface
|
|
1243
|
+
*/ function StaticInterfaceImplement() {
|
|
1244
|
+
return function(constructor) {
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
exports.PhysXPhysics = /*#__PURE__*/ function() {
|
|
1249
|
+
function PhysXPhysics1() {}
|
|
1250
|
+
/**
|
|
1251
|
+
* Initialize PhysXPhysics.
|
|
1252
|
+
* @param runtimeMode - Runtime mode
|
|
1253
|
+
* @returns Promise object
|
|
1254
|
+
*/ PhysXPhysics1.initialize = function initialize(runtimeMode) {
|
|
1255
|
+
if (runtimeMode === void 0) runtimeMode = exports.PhysXRuntimeMode.Auto;
|
|
1256
|
+
var scriptPromise = new Promise(function(resolve, reject) {
|
|
1257
|
+
var script = document.createElement("script");
|
|
1258
|
+
document.body.appendChild(script);
|
|
1259
|
+
script.async = true;
|
|
1260
|
+
script.onload = resolve;
|
|
1261
|
+
script.onerror = reject;
|
|
1262
|
+
if (runtimeMode == exports.PhysXRuntimeMode.Auto) {
|
|
1263
|
+
var supported = function() {
|
|
1264
|
+
try {
|
|
1265
|
+
if (typeof WebAssembly === "object" && typeof WebAssembly.instantiate === "function") {
|
|
1266
|
+
var module = new WebAssembly.Module(Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00));
|
|
1267
|
+
if (_instanceof(module, WebAssembly.Module)) return _instanceof(new WebAssembly.Instance(module), WebAssembly.Instance);
|
|
1268
|
+
}
|
|
1269
|
+
} catch (e) {}
|
|
1270
|
+
return false;
|
|
1271
|
+
}();
|
|
1272
|
+
if (supported) {
|
|
1273
|
+
runtimeMode = exports.PhysXRuntimeMode.WebAssembly;
|
|
1274
|
+
} else {
|
|
1275
|
+
runtimeMode = exports.PhysXRuntimeMode.JavaScript;
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
if (runtimeMode == exports.PhysXRuntimeMode.JavaScript) {
|
|
1279
|
+
script.src = "https://gw.alipayobjects.com/os/lib/oasis-engine/physics-physx/0.9.0-beta.56/libs/physx.release.js.js";
|
|
1280
|
+
} else if (runtimeMode == exports.PhysXRuntimeMode.WebAssembly) {
|
|
1281
|
+
script.src = "https://gw.alipayobjects.com/os/lib/oasis-engine/physics-physx/0.9.0-beta.56/libs/physx.release.js";
|
|
1282
|
+
}
|
|
1283
|
+
});
|
|
1284
|
+
return new Promise(function(resolve, reject) {
|
|
1285
|
+
scriptPromise.then(function() {
|
|
1286
|
+
return window.PHYSX().then(function(PHYSX) {
|
|
1287
|
+
exports.PhysXPhysics._init(PHYSX);
|
|
1288
|
+
console.log("PhysX loaded.");
|
|
1289
|
+
resolve();
|
|
1290
|
+
}, reject);
|
|
1291
|
+
}, reject).catch(reject);
|
|
1292
|
+
});
|
|
1293
|
+
};
|
|
1294
|
+
/**
|
|
1295
|
+
* Destroy PhysXPhysics.
|
|
1296
|
+
*/ PhysXPhysics1.destroy = function destroy() {
|
|
1297
|
+
this._pxFoundation.release();
|
|
1298
|
+
this._pxPhysics.release();
|
|
1299
|
+
this._physX = null;
|
|
1300
|
+
this._pxFoundation = null;
|
|
1301
|
+
this._pxPhysics = null;
|
|
1302
|
+
};
|
|
1303
|
+
/**
|
|
1304
|
+
* {@inheritDoc IPhysics.createPhysicsManager }
|
|
1305
|
+
*/ PhysXPhysics1.createPhysicsManager = function createPhysicsManager(onContactBegin, onContactEnd, onContactStay, onTriggerBegin, onTriggerEnd, onTriggerStay) {
|
|
1306
|
+
return new PhysXPhysicsManager(onContactBegin, onContactEnd, onContactStay, onTriggerBegin, onTriggerEnd, onTriggerStay);
|
|
1307
|
+
};
|
|
1308
|
+
/**
|
|
1309
|
+
* {@inheritDoc IPhysics.createStaticCollider }
|
|
1310
|
+
*/ PhysXPhysics1.createStaticCollider = function createStaticCollider(position, rotation) {
|
|
1311
|
+
return new PhysXStaticCollider(position, rotation);
|
|
1312
|
+
};
|
|
1313
|
+
/**
|
|
1314
|
+
* {@inheritDoc IPhysics.createDynamicCollider }
|
|
1315
|
+
*/ PhysXPhysics1.createDynamicCollider = function createDynamicCollider(position, rotation) {
|
|
1316
|
+
return new PhysXDynamicCollider(position, rotation);
|
|
1317
|
+
};
|
|
1318
|
+
/**
|
|
1319
|
+
* {@inheritDoc IPhysics.createCharacterController }
|
|
1320
|
+
*/ PhysXPhysics1.createCharacterController = function createCharacterController() {
|
|
1321
|
+
return new PhysXCharacterController();
|
|
1322
|
+
};
|
|
1323
|
+
/**
|
|
1324
|
+
* {@inheritDoc IPhysics.createPhysicsMaterial }
|
|
1325
|
+
*/ PhysXPhysics1.createPhysicsMaterial = function createPhysicsMaterial(staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine) {
|
|
1326
|
+
return new PhysXPhysicsMaterial(staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine);
|
|
1327
|
+
};
|
|
1328
|
+
/**
|
|
1329
|
+
* {@inheritDoc IPhysics.createBoxColliderShape }
|
|
1330
|
+
*/ PhysXPhysics1.createBoxColliderShape = function createBoxColliderShape(uniqueID, size, material) {
|
|
1331
|
+
return new PhysXBoxColliderShape(uniqueID, size, material);
|
|
1332
|
+
};
|
|
1333
|
+
/**
|
|
1334
|
+
* {@inheritDoc IPhysics.createSphereColliderShape }
|
|
1335
|
+
*/ PhysXPhysics1.createSphereColliderShape = function createSphereColliderShape(uniqueID, radius, material) {
|
|
1336
|
+
return new PhysXSphereColliderShape(uniqueID, radius, material);
|
|
1337
|
+
};
|
|
1338
|
+
/**
|
|
1339
|
+
* {@inheritDoc IPhysics.createPlaneColliderShape }
|
|
1340
|
+
*/ PhysXPhysics1.createPlaneColliderShape = function createPlaneColliderShape(uniqueID, material) {
|
|
1341
|
+
return new PhysXPlaneColliderShape(uniqueID, material);
|
|
1342
|
+
};
|
|
1343
|
+
/**
|
|
1344
|
+
* {@inheritDoc IPhysics.createCapsuleColliderShape }
|
|
1345
|
+
*/ PhysXPhysics1.createCapsuleColliderShape = function createCapsuleColliderShape(uniqueID, radius, height, material) {
|
|
1346
|
+
return new PhysXCapsuleColliderShape(uniqueID, radius, height, material);
|
|
1347
|
+
};
|
|
1348
|
+
/**
|
|
1349
|
+
* {@inheritDoc IPhysics.createFixedJoint }
|
|
1350
|
+
*/ PhysXPhysics1.createFixedJoint = function createFixedJoint(collider) {
|
|
1351
|
+
return new PhysXFixedJoint(collider);
|
|
1352
|
+
};
|
|
1353
|
+
/**
|
|
1354
|
+
* {@inheritDoc IPhysics.createHingeJoint }
|
|
1355
|
+
*/ PhysXPhysics1.createHingeJoint = function createHingeJoint(collider) {
|
|
1356
|
+
return new PhysXHingeJoint(collider);
|
|
1357
|
+
};
|
|
1358
|
+
/**
|
|
1359
|
+
* {@inheritDoc IPhysics.createSpringJoint }
|
|
1360
|
+
*/ PhysXPhysics1.createSpringJoint = function createSpringJoint(collider) {
|
|
1361
|
+
return new PhysXSpringJoint(collider);
|
|
1362
|
+
};
|
|
1363
|
+
PhysXPhysics1._init = function _init(physX) {
|
|
1364
|
+
var version = physX.PX_PHYSICS_VERSION;
|
|
1365
|
+
var defaultErrorCallback = new physX.PxDefaultErrorCallback();
|
|
1366
|
+
var allocator = new physX.PxDefaultAllocator();
|
|
1367
|
+
var pxFoundation = physX.PxCreateFoundation(version, allocator, defaultErrorCallback);
|
|
1368
|
+
var pxPhysics = physX.PxCreatePhysics(version, pxFoundation, new physX.PxTolerancesScale(), false, null);
|
|
1369
|
+
physX.PxInitExtensions(pxPhysics, null);
|
|
1370
|
+
exports.PhysXPhysics._physX = physX;
|
|
1371
|
+
exports.PhysXPhysics._pxFoundation = pxFoundation;
|
|
1372
|
+
exports.PhysXPhysics._pxPhysics = pxPhysics;
|
|
1373
|
+
PhysXPhysicsManager._init();
|
|
1374
|
+
};
|
|
1375
|
+
return PhysXPhysics1;
|
|
1376
|
+
}();
|
|
1377
|
+
exports.PhysXPhysics = __decorate([
|
|
1378
|
+
StaticInterfaceImplement()
|
|
1379
|
+
], exports.PhysXPhysics);
|
|
1380
|
+
|
|
1381
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1382
|
+
|
|
1383
|
+
}));
|