@galacean/engine-physics-lite 0.9.20 → 0.9.21
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 +1170 -1249
- package/dist/browser.min.js +1 -1
- package/dist/main.js +37 -112
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +31561 -32452
- package/dist/module.js +15 -97
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/LitePhysicsScene.d.ts +79 -0
package/dist/browser.js
CHANGED
|
@@ -1,1271 +1,1192 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@swc/helpers/src/_ts_decorate.mjs'), require('@swc/helpers/src/_inherits.mjs'), require('@swc/helpers/src/_create_class.mjs'), require('@swc/helpers/src/_instanceof.mjs'), require('@galacean/engine')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@swc/helpers/src/_ts_decorate.mjs', '@swc/helpers/src/_inherits.mjs', '@swc/helpers/src/_create_class.mjs', '@swc/helpers/src/_instanceof.mjs', '@galacean/engine'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.Galacean = global.Galacean || {}, global.Galacean.PhysicsLite = {}), global._ts_decorate, global._inherits, global._create_class, global._instanceof, global.Galacean));
|
|
5
|
+
}(this, (function (exports, _ts_decorate, _inherits, _create_class, _instanceof, engine) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
Copyright (c) Microsoft Corporation.
|
|
9
|
-
|
|
10
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
-
purpose with or without fee is hereby granted.
|
|
12
|
-
|
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
-
***************************************************************************** */
|
|
21
|
-
|
|
22
|
-
function __decorate(decorators, target, key, desc) {
|
|
23
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
24
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
25
|
-
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;
|
|
26
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
27
|
-
}
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
28
8
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
9
|
+
var _ts_decorate__default = /*#__PURE__*/_interopDefaultLegacy(_ts_decorate);
|
|
10
|
+
var _inherits__default = /*#__PURE__*/_interopDefaultLegacy(_inherits);
|
|
11
|
+
var _create_class__default = /*#__PURE__*/_interopDefaultLegacy(_create_class);
|
|
12
|
+
var _instanceof__default = /*#__PURE__*/_interopDefaultLegacy(_instanceof);
|
|
32
13
|
|
|
33
|
-
|
|
34
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Fastly remove an element from array.
|
|
16
|
+
* @param array - Array
|
|
17
|
+
* @param item - Element
|
|
18
|
+
*/ function removeFromArray(array, item) {
|
|
19
|
+
var index = array.indexOf(item);
|
|
20
|
+
if (index < 0) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
var last = array.length - 1;
|
|
24
|
+
if (index !== last) {
|
|
25
|
+
array[index] = array[last];
|
|
26
|
+
}
|
|
27
|
+
array.length--;
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Used to update tags.
|
|
32
|
+
*/ var LiteUpdateFlag = /*#__PURE__*/ function() {
|
|
33
|
+
function LiteUpdateFlag(_flags) {
|
|
34
|
+
if (_flags === void 0) _flags = [];
|
|
35
|
+
this._flags = _flags;
|
|
36
|
+
this./** Flag. */ flag = true;
|
|
37
|
+
this._flags.push(this);
|
|
38
|
+
}
|
|
39
|
+
var _proto = LiteUpdateFlag.prototype;
|
|
40
|
+
/**
|
|
41
|
+
* Destroy.
|
|
42
|
+
*/ _proto.destroy = function destroy() {
|
|
43
|
+
removeFromArray(this._flags, this);
|
|
44
|
+
this._flags = null;
|
|
45
|
+
};
|
|
46
|
+
return LiteUpdateFlag;
|
|
47
|
+
}();
|
|
35
48
|
|
|
36
|
-
|
|
37
|
-
|
|
49
|
+
/**
|
|
50
|
+
* @internal
|
|
51
|
+
*/ var LiteUpdateFlagManager = /*#__PURE__*/ function() {
|
|
52
|
+
function LiteUpdateFlagManager() {
|
|
53
|
+
this._updateFlags = [];
|
|
54
|
+
}
|
|
55
|
+
var _proto = LiteUpdateFlagManager.prototype;
|
|
56
|
+
_proto.register = function register() {
|
|
57
|
+
return new LiteUpdateFlag(this._updateFlags);
|
|
58
|
+
};
|
|
59
|
+
_proto.distribute = function distribute() {
|
|
60
|
+
var updateFlags = this._updateFlags;
|
|
61
|
+
for(var i = updateFlags.length - 1; i >= 0; i--){
|
|
62
|
+
updateFlags[i].flag = true;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
return LiteUpdateFlagManager;
|
|
66
|
+
}();
|
|
38
67
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Abstract class for collider shapes.
|
|
70
|
+
*/ var LiteColliderShape = /*#__PURE__*/ function() {
|
|
71
|
+
function LiteColliderShape() {
|
|
72
|
+
/** @internal */ this._transform = new LiteTransform();
|
|
73
|
+
/** @internal */ this._invModelMatrix = new engine.Matrix();
|
|
74
|
+
this._transform.owner = this;
|
|
75
|
+
this._inverseWorldMatFlag = this._transform.registerWorldChangeFlag();
|
|
76
|
+
}
|
|
77
|
+
var _proto = LiteColliderShape.prototype;
|
|
78
|
+
/**
|
|
79
|
+
* {@inheritDoc IColliderShape.setRotation }
|
|
80
|
+
*/ _proto.setRotation = function setRotation(rotation) {
|
|
81
|
+
console.log("Physics-lite don't support setRotation. Use Physics-PhysX instead!");
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* {@inheritDoc IColliderShape.setPosition }
|
|
85
|
+
*/ _proto.setPosition = function setPosition(position) {
|
|
86
|
+
this._transform.setPosition(position.x, position.y, position.z);
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* {@inheritDoc IColliderShape.setContactOffset }
|
|
90
|
+
*/ _proto.setContactOffset = function setContactOffset(offset) {
|
|
91
|
+
console.log("Physics-lite don't support setContactOffset. Use Physics-PhysX instead!");
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* {@inheritDoc IColliderShape.setMaterial }
|
|
95
|
+
*/ _proto.setMaterial = function setMaterial(material) {
|
|
96
|
+
console.log("Physics-lite don't support setMaterial. Use Physics-PhysX instead!");
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* {@inheritDoc IColliderShape.setUniqueID }
|
|
100
|
+
*/ _proto.setUniqueID = function setUniqueID(id) {
|
|
101
|
+
this._id = id;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* {@inheritDoc IColliderShape.setIsTrigger }
|
|
105
|
+
*/ _proto.setIsTrigger = function setIsTrigger(value) {
|
|
106
|
+
console.log("Physics-lite don't support setIsTrigger. Use Physics-PhysX instead!");
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* {@inheritDoc IColliderShape.destroy }
|
|
110
|
+
*/ _proto.destroy = function destroy() {};
|
|
111
|
+
_proto._updateHitResult = function _updateHitResult(ray, rayDistance, outHit, origin, isWorldRay) {
|
|
112
|
+
if (isWorldRay === void 0) isWorldRay = false;
|
|
113
|
+
var hitPoint = LiteColliderShape._tempPoint;
|
|
114
|
+
ray.getPoint(rayDistance, hitPoint);
|
|
115
|
+
if (!isWorldRay) {
|
|
116
|
+
engine.Vector3.transformCoordinate(hitPoint, this._transform.worldMatrix, hitPoint);
|
|
117
|
+
}
|
|
118
|
+
var distance = engine.Vector3.distance(origin, hitPoint);
|
|
119
|
+
if (distance < outHit.distance) {
|
|
120
|
+
outHit.point.copyFrom(hitPoint);
|
|
121
|
+
outHit.distance = distance;
|
|
122
|
+
outHit.shapeID = this._id;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
_proto._getLocalRay = function _getLocalRay(ray) {
|
|
126
|
+
var worldToLocal = this._getInvModelMatrix();
|
|
127
|
+
var outRay = LiteColliderShape._ray;
|
|
128
|
+
engine.Vector3.transformCoordinate(ray.origin, worldToLocal, outRay.origin);
|
|
129
|
+
engine.Vector3.transformNormal(ray.direction, worldToLocal, outRay.direction);
|
|
130
|
+
outRay.direction.normalize();
|
|
131
|
+
return outRay;
|
|
132
|
+
};
|
|
133
|
+
_proto._getInvModelMatrix = function _getInvModelMatrix() {
|
|
134
|
+
if (this._inverseWorldMatFlag.flag) {
|
|
135
|
+
engine.Matrix.invert(this._transform.worldMatrix, this._invModelMatrix);
|
|
136
|
+
this._inverseWorldMatFlag.flag = false;
|
|
137
|
+
}
|
|
138
|
+
return this._invModelMatrix;
|
|
139
|
+
};
|
|
140
|
+
return LiteColliderShape;
|
|
141
|
+
}();
|
|
142
|
+
LiteColliderShape._ray = new engine.Ray();
|
|
143
|
+
LiteColliderShape._tempPoint = new engine.Vector3();
|
|
43
144
|
|
|
44
|
-
|
|
145
|
+
/**
|
|
146
|
+
* Used to implement transformation related functions.
|
|
147
|
+
*/ var LiteTransform = /*#__PURE__*/ function() {
|
|
148
|
+
function LiteTransform() {
|
|
149
|
+
this._position = new engine.Vector3();
|
|
150
|
+
this._rotation = new engine.Vector3();
|
|
151
|
+
this._rotationQuaternion = new engine.Quaternion();
|
|
152
|
+
this._scale = new engine.Vector3(1, 1, 1);
|
|
153
|
+
this._worldRotationQuaternion = new engine.Quaternion();
|
|
154
|
+
this._localMatrix = new engine.Matrix();
|
|
155
|
+
this._worldMatrix = new engine.Matrix();
|
|
156
|
+
this._updateFlagManager = new LiteUpdateFlagManager();
|
|
157
|
+
this._isParentDirty = true;
|
|
158
|
+
this._parentTransformCache = null;
|
|
159
|
+
this._dirtyFlag = 0xbc;
|
|
160
|
+
}
|
|
161
|
+
var _proto = LiteTransform.prototype;
|
|
162
|
+
/**
|
|
163
|
+
* Set local position by X, Y, Z value.
|
|
164
|
+
* @param x - X coordinate
|
|
165
|
+
* @param y - Y coordinate
|
|
166
|
+
* @param z - Z coordinate
|
|
167
|
+
*/ _proto.setPosition = function setPosition(x, y, z) {
|
|
168
|
+
this._position.set(x, y, z);
|
|
169
|
+
this.position = this._position;
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Set local rotation by the X, Y, Z, and W components of the quaternion.
|
|
173
|
+
* @param x - X component of quaternion
|
|
174
|
+
* @param y - Y component of quaternion
|
|
175
|
+
* @param z - Z component of quaternion
|
|
176
|
+
* @param w - W component of quaternion
|
|
177
|
+
*/ _proto.setRotationQuaternion = function setRotationQuaternion(x, y, z, w) {
|
|
178
|
+
this._rotationQuaternion.set(x, y, z, w);
|
|
179
|
+
this.rotationQuaternion = this._rotationQuaternion;
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* Set local scaling by scaling values along X, Y, Z axis.
|
|
183
|
+
* @param x - Scaling along X axis
|
|
184
|
+
* @param y - Scaling along Y axis
|
|
185
|
+
* @param z - Scaling along Z axis
|
|
186
|
+
*/ _proto.setScale = function setScale(x, y, z) {
|
|
187
|
+
this._scale.set(x, y, z);
|
|
188
|
+
this.scale = this._scale;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Register world transform change flag.
|
|
192
|
+
* @returns Change flag
|
|
193
|
+
*/ _proto.registerWorldChangeFlag = function registerWorldChangeFlag() {
|
|
194
|
+
return this._updateFlagManager.register();
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* Get worldMatrix: Will trigger the worldMatrix update of itself and all parent entities.
|
|
198
|
+
* Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
|
|
199
|
+
* In summary, any update of related variables will cause the dirty mark of one of the full process (worldMatrix or worldRotationQuaternion) to be false.
|
|
200
|
+
*/ _proto._updateWorldPositionFlag = function _updateWorldPositionFlag() {
|
|
201
|
+
if (!this._isContainDirtyFlags(0x84)) {
|
|
202
|
+
this._worldAssociatedChange(0x84);
|
|
203
|
+
if (_instanceof__default['default'](this._owner, LiteCollider)) {
|
|
204
|
+
var shapes = this._owner._shapes;
|
|
205
|
+
for(var i = 0, n = shapes.length; i < n; i++){
|
|
206
|
+
shapes[i]._transform._updateWorldPositionFlag();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* Get worldMatrix: Will trigger the worldMatrix update of itself and all parent entities.
|
|
213
|
+
* Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
|
|
214
|
+
* Get worldRotationQuaternion: Will trigger the world rotation (in quaternion) update of itself and all parent entities.
|
|
215
|
+
* Get worldRotation: Will trigger the world rotation(in euler and quaternion) update of itself and world rotation(in quaternion) update of all parent entities.
|
|
216
|
+
* In summary, any update of related variables will cause the dirty mark of one of the full process (worldMatrix or worldRotationQuaternion) to be false.
|
|
217
|
+
*/ _proto._updateWorldRotationFlag = function _updateWorldRotationFlag() {
|
|
218
|
+
if (!this._isContainDirtyFlags(0x98)) {
|
|
219
|
+
this._worldAssociatedChange(0x98);
|
|
220
|
+
if (_instanceof__default['default'](this._owner, LiteCollider)) {
|
|
221
|
+
var shapes = this._owner._shapes;
|
|
222
|
+
for(var i = 0, n = shapes.length; i < n; i++){
|
|
223
|
+
shapes[i]._transform._updateWorldRotationFlag();
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* Get worldMatrix: Will trigger the worldMatrix update of itself and all parent entities.
|
|
230
|
+
* Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
|
|
231
|
+
* Get worldScale: Will trigger the scaling update of itself and all parent entities.
|
|
232
|
+
* In summary, any update of related variables will cause the dirty mark of one of the full process (worldMatrix) to be false.
|
|
233
|
+
*/ _proto._updateWorldScaleFlag = function _updateWorldScaleFlag() {
|
|
234
|
+
if (!this._isContainDirtyFlags(0xa0)) {
|
|
235
|
+
this._worldAssociatedChange(0xa0);
|
|
236
|
+
if (_instanceof__default['default'](this._owner, LiteCollider)) {
|
|
237
|
+
var shapes = this._owner._shapes;
|
|
238
|
+
for(var i = 0, n = shapes.length; i < n; i++){
|
|
239
|
+
shapes[i]._transform._updateWorldScaleFlag();
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* Update all world transform property dirty flag, the principle is the same as above.
|
|
246
|
+
*/ _proto._updateAllWorldFlag = function _updateAllWorldFlag() {
|
|
247
|
+
if (!this._isContainDirtyFlags(0xbc)) {
|
|
248
|
+
this._worldAssociatedChange(0xbc);
|
|
249
|
+
if (_instanceof__default['default'](this._owner, LiteCollider)) {
|
|
250
|
+
var shapes = this._owner._shapes;
|
|
251
|
+
for(var i = 0, n = shapes.length; i < n; i++){
|
|
252
|
+
shapes[i]._transform._updateAllWorldFlag();
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
_proto._getParentTransform = function _getParentTransform() {
|
|
258
|
+
if (!this._isParentDirty) {
|
|
259
|
+
return this._parentTransformCache;
|
|
260
|
+
}
|
|
261
|
+
var parentCache = null;
|
|
262
|
+
if (_instanceof__default['default'](this._owner, LiteColliderShape)) {
|
|
263
|
+
var parent = this._owner._collider;
|
|
264
|
+
parentCache = parent._transform;
|
|
265
|
+
}
|
|
266
|
+
this._parentTransformCache = parentCache;
|
|
267
|
+
this._isParentDirty = false;
|
|
268
|
+
return parentCache;
|
|
269
|
+
};
|
|
270
|
+
_proto._isContainDirtyFlags = function _isContainDirtyFlags(targetDirtyFlags) {
|
|
271
|
+
return (this._dirtyFlag & targetDirtyFlags) === targetDirtyFlags;
|
|
272
|
+
};
|
|
273
|
+
_proto._isContainDirtyFlag = function _isContainDirtyFlag(type) {
|
|
274
|
+
return (this._dirtyFlag & type) != 0;
|
|
275
|
+
};
|
|
276
|
+
_proto._setDirtyFlagTrue = function _setDirtyFlagTrue(type) {
|
|
277
|
+
this._dirtyFlag |= type;
|
|
278
|
+
};
|
|
279
|
+
_proto._setDirtyFlagFalse = function _setDirtyFlagFalse(type) {
|
|
280
|
+
this._dirtyFlag &= ~type;
|
|
281
|
+
};
|
|
282
|
+
_proto._worldAssociatedChange = function _worldAssociatedChange(type) {
|
|
283
|
+
this._dirtyFlag |= type;
|
|
284
|
+
this._updateFlagManager.distribute();
|
|
285
|
+
};
|
|
286
|
+
_create_class__default['default'](LiteTransform, [
|
|
287
|
+
{
|
|
288
|
+
key: "owner",
|
|
289
|
+
set: function set(value) {
|
|
290
|
+
this._owner = value;
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
key: "position",
|
|
295
|
+
get: /**
|
|
296
|
+
* Local position.
|
|
297
|
+
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
298
|
+
*/ function get() {
|
|
299
|
+
return this._position;
|
|
300
|
+
},
|
|
301
|
+
set: function set(value) {
|
|
302
|
+
if (this._position !== value) {
|
|
303
|
+
this._position.copyFrom(value);
|
|
304
|
+
}
|
|
305
|
+
this._setDirtyFlagTrue(0x40);
|
|
306
|
+
this._updateWorldPositionFlag();
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
key: "rotationQuaternion",
|
|
311
|
+
get: /**
|
|
312
|
+
* Local rotation, defining the rotation by using a unit quaternion.
|
|
313
|
+
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
314
|
+
*/ function get() {
|
|
315
|
+
if (this._isContainDirtyFlag(0x2)) {
|
|
316
|
+
engine.Quaternion.rotationEuler(engine.MathUtil.degreeToRadian(this._rotation.x), engine.MathUtil.degreeToRadian(this._rotation.y), engine.MathUtil.degreeToRadian(this._rotation.z), this._rotationQuaternion);
|
|
317
|
+
this._setDirtyFlagFalse(0x2);
|
|
318
|
+
}
|
|
319
|
+
return this._rotationQuaternion;
|
|
320
|
+
},
|
|
321
|
+
set: function set(value) {
|
|
322
|
+
if (this._rotationQuaternion !== value) {
|
|
323
|
+
this._rotationQuaternion.copyFrom(value);
|
|
324
|
+
}
|
|
325
|
+
this._setDirtyFlagTrue(0x40 | 0x1);
|
|
326
|
+
this._setDirtyFlagFalse(0x2);
|
|
327
|
+
this._updateWorldRotationFlag();
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
key: "worldRotationQuaternion",
|
|
332
|
+
get: /**
|
|
333
|
+
* World rotation, defining the rotation by using a unit quaternion.
|
|
334
|
+
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
335
|
+
*/ function get() {
|
|
336
|
+
if (this._isContainDirtyFlag(0x10)) {
|
|
337
|
+
var parent = this._getParentTransform();
|
|
338
|
+
if (parent != null) {
|
|
339
|
+
engine.Quaternion.multiply(parent.worldRotationQuaternion, this.rotationQuaternion, this._worldRotationQuaternion);
|
|
340
|
+
} else {
|
|
341
|
+
this._worldRotationQuaternion.copyFrom(this.rotationQuaternion);
|
|
342
|
+
}
|
|
343
|
+
this._setDirtyFlagFalse(0x10);
|
|
344
|
+
}
|
|
345
|
+
return this._worldRotationQuaternion;
|
|
346
|
+
},
|
|
347
|
+
set: function set(value) {
|
|
348
|
+
if (this._worldRotationQuaternion !== value) {
|
|
349
|
+
this._worldRotationQuaternion.copyFrom(value);
|
|
350
|
+
}
|
|
351
|
+
var parent = this._getParentTransform();
|
|
352
|
+
if (parent) {
|
|
353
|
+
engine.Quaternion.invert(parent.worldRotationQuaternion, LiteTransform._tempQuat0);
|
|
354
|
+
engine.Quaternion.multiply(value, LiteTransform._tempQuat0, this._rotationQuaternion);
|
|
355
|
+
} else {
|
|
356
|
+
this._rotationQuaternion.copyFrom(value);
|
|
357
|
+
}
|
|
358
|
+
this.rotationQuaternion = this._rotationQuaternion;
|
|
359
|
+
this._setDirtyFlagFalse(0x10);
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
key: "scale",
|
|
364
|
+
get: /**
|
|
365
|
+
* Local scaling.
|
|
366
|
+
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
367
|
+
*/ function get() {
|
|
368
|
+
return this._scale;
|
|
369
|
+
},
|
|
370
|
+
set: function set(value) {
|
|
371
|
+
if (this._scale !== value) {
|
|
372
|
+
this._scale.copyFrom(value);
|
|
373
|
+
}
|
|
374
|
+
this._setDirtyFlagTrue(0x40);
|
|
375
|
+
this._updateWorldScaleFlag();
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
key: "localMatrix",
|
|
380
|
+
get: /**
|
|
381
|
+
* Local matrix.
|
|
382
|
+
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
383
|
+
*/ function get() {
|
|
384
|
+
if (this._isContainDirtyFlag(0x40)) {
|
|
385
|
+
engine.Matrix.affineTransformation(this._scale, this.rotationQuaternion, this._position, this._localMatrix);
|
|
386
|
+
this._setDirtyFlagFalse(0x40);
|
|
387
|
+
}
|
|
388
|
+
return this._localMatrix;
|
|
389
|
+
},
|
|
390
|
+
set: function set(value) {
|
|
391
|
+
if (this._localMatrix !== value) {
|
|
392
|
+
this._localMatrix.copyFrom(value);
|
|
393
|
+
}
|
|
394
|
+
this._localMatrix.decompose(this._position, this._rotationQuaternion, this._scale);
|
|
395
|
+
this._setDirtyFlagTrue(0x1);
|
|
396
|
+
this._setDirtyFlagFalse(0x40);
|
|
397
|
+
this._updateAllWorldFlag();
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
key: "worldMatrix",
|
|
402
|
+
get: /**
|
|
403
|
+
* World matrix.
|
|
404
|
+
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
405
|
+
*/ function get() {
|
|
406
|
+
if (this._isContainDirtyFlag(0x80)) {
|
|
407
|
+
var parent = this._getParentTransform();
|
|
408
|
+
if (parent) {
|
|
409
|
+
engine.Matrix.multiply(parent.worldMatrix, this.localMatrix, this._worldMatrix);
|
|
410
|
+
} else {
|
|
411
|
+
this._worldMatrix.copyFrom(this.localMatrix);
|
|
412
|
+
}
|
|
413
|
+
this._setDirtyFlagFalse(0x80);
|
|
414
|
+
}
|
|
415
|
+
return this._worldMatrix;
|
|
416
|
+
},
|
|
417
|
+
set: function set(value) {
|
|
418
|
+
if (this._worldMatrix !== value) {
|
|
419
|
+
this._worldMatrix.copyFrom(value);
|
|
420
|
+
}
|
|
421
|
+
var parent = this._getParentTransform();
|
|
422
|
+
if (parent) {
|
|
423
|
+
engine.Matrix.invert(parent.worldMatrix, LiteTransform._tempMat42);
|
|
424
|
+
engine.Matrix.multiply(LiteTransform._tempMat42, value, this._localMatrix);
|
|
425
|
+
} else {
|
|
426
|
+
this._localMatrix.copyFrom(value);
|
|
427
|
+
}
|
|
428
|
+
this.localMatrix = this._localMatrix;
|
|
429
|
+
this._setDirtyFlagFalse(0x80);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
]);
|
|
433
|
+
return LiteTransform;
|
|
434
|
+
}();
|
|
435
|
+
LiteTransform._tempQuat0 = new engine.Quaternion();
|
|
436
|
+
LiteTransform._tempMat42 = new engine.Matrix();
|
|
437
|
+
var /**
|
|
438
|
+
* Dirty flag of transform.
|
|
439
|
+
*/ TransformFlag;
|
|
440
|
+
(function(TransformFlag) {
|
|
441
|
+
TransformFlag[TransformFlag["LocalEuler"] = 0x1] = "LocalEuler";
|
|
442
|
+
TransformFlag[TransformFlag["LocalQuat"] = 0x2] = "LocalQuat";
|
|
443
|
+
TransformFlag[TransformFlag["WorldPosition"] = 0x4] = "WorldPosition";
|
|
444
|
+
TransformFlag[TransformFlag["WorldEuler"] = 0x8] = "WorldEuler";
|
|
445
|
+
TransformFlag[TransformFlag["WorldQuat"] = 0x10] = "WorldQuat";
|
|
446
|
+
TransformFlag[TransformFlag["WorldScale"] = 0x20] = "WorldScale";
|
|
447
|
+
TransformFlag[TransformFlag["LocalMatrix"] = 0x40] = "LocalMatrix";
|
|
448
|
+
TransformFlag[TransformFlag["WorldMatrix"] = 0x80] = "WorldMatrix";
|
|
449
|
+
TransformFlag[TransformFlag[/** WorldMatrix | WorldPosition */ "WmWp"] = 0x84] = "WmWp";
|
|
450
|
+
TransformFlag[TransformFlag[/** WorldMatrix | WorldEuler | WorldQuat */ "WmWeWq"] = 0x98] = "WmWeWq";
|
|
451
|
+
TransformFlag[TransformFlag[/** WorldMatrix | WorldPosition | WorldEuler | WorldQuat */ "WmWpWeWq"] = 0x9c] = "WmWpWeWq";
|
|
452
|
+
TransformFlag[TransformFlag[/** WorldMatrix | WorldScale */ "WmWs"] = 0xa0] = "WmWs";
|
|
453
|
+
TransformFlag[TransformFlag[/** WorldMatrix | WorldPosition | WorldScale */ "WmWpWs"] = 0xa4] = "WmWpWs";
|
|
454
|
+
TransformFlag[TransformFlag[/** WorldMatrix | WorldPosition | WorldEuler | WorldQuat | WorldScale */ "WmWpWeWqWs"] = 0xbc] = "WmWpWeWqWs";
|
|
455
|
+
})(TransformFlag || (TransformFlag = {}));
|
|
45
456
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
*
|
|
91
|
-
*/
|
|
92
|
-
|
|
93
|
-
if (_flags === void 0) _flags = [];
|
|
94
|
-
this._flags = _flags;
|
|
95
|
-
this./** Flag. */ flag = true;
|
|
96
|
-
this._flags.push(this);
|
|
97
|
-
}
|
|
98
|
-
var _proto = LiteUpdateFlag.prototype;
|
|
99
|
-
/**
|
|
100
|
-
* Destroy.
|
|
101
|
-
*/ _proto.destroy = function destroy() {
|
|
102
|
-
removeFromArray(this._flags, this);
|
|
103
|
-
this._flags = null;
|
|
104
|
-
};
|
|
105
|
-
return LiteUpdateFlag;
|
|
106
|
-
}();
|
|
107
|
-
|
|
108
|
-
/**
|
|
457
|
+
/**
|
|
458
|
+
* Abstract class of physical collider.
|
|
459
|
+
*/ var LiteCollider = /*#__PURE__*/ function() {
|
|
460
|
+
function LiteCollider() {
|
|
461
|
+
/** @internal */ this._shapes = [];
|
|
462
|
+
/** @internal */ this._transform = new LiteTransform();
|
|
463
|
+
this._transform.owner = this;
|
|
464
|
+
}
|
|
465
|
+
var _proto = LiteCollider.prototype;
|
|
466
|
+
/**
|
|
467
|
+
* {@inheritDoc ICollider.addShape }
|
|
468
|
+
*/ _proto.addShape = function addShape(shape) {
|
|
469
|
+
var oldCollider = shape._collider;
|
|
470
|
+
if (oldCollider !== this) {
|
|
471
|
+
if (oldCollider) {
|
|
472
|
+
oldCollider.removeShape(shape);
|
|
473
|
+
}
|
|
474
|
+
this._shapes.push(shape);
|
|
475
|
+
shape._collider = this;
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
/**
|
|
479
|
+
* {@inheritDoc ICollider.removeShape }
|
|
480
|
+
*/ _proto.removeShape = function removeShape(shape) {
|
|
481
|
+
var index = this._shapes.indexOf(shape);
|
|
482
|
+
if (index !== -1) {
|
|
483
|
+
this._shapes.splice(index, 1);
|
|
484
|
+
shape._collider = null;
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
/**
|
|
488
|
+
* {@inheritDoc ICollider.setWorldTransform }
|
|
489
|
+
*/ _proto.setWorldTransform = function setWorldTransform(position, rotation) {
|
|
490
|
+
this._transform.setPosition(position.x, position.y, position.z);
|
|
491
|
+
this._transform.setRotationQuaternion(rotation.x, rotation.y, rotation.z, rotation.w);
|
|
492
|
+
};
|
|
493
|
+
/**
|
|
494
|
+
* {@inheritDoc ICollider.getWorldTransform }
|
|
495
|
+
*/ _proto.getWorldTransform = function getWorldTransform(outPosition, outRotation) {
|
|
496
|
+
var _this__transform = this._transform, position = _this__transform.position, rotationQuaternion = _this__transform.rotationQuaternion;
|
|
497
|
+
outPosition.set(position.x, position.y, position.z);
|
|
498
|
+
outRotation.set(rotationQuaternion.x, rotationQuaternion.y, rotationQuaternion.z, rotationQuaternion.w);
|
|
499
|
+
};
|
|
500
|
+
/**
|
|
501
|
+
* {@inheritDoc ICollider.destroy }
|
|
502
|
+
*/ _proto.destroy = function destroy() {};
|
|
503
|
+
/**
|
|
109
504
|
* @internal
|
|
110
|
-
*/
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
updateFlags[i].flag = true;
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
return LiteUpdateFlagManager;
|
|
125
|
-
}();
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Abstract class for collider shapes.
|
|
129
|
-
*/ var LiteColliderShape = /*#__PURE__*/ function() {
|
|
130
|
-
function LiteColliderShape() {
|
|
131
|
-
/** @internal */ this._transform = new LiteTransform();
|
|
132
|
-
/** @internal */ this._invModelMatrix = new engine.Matrix();
|
|
133
|
-
this._transform.owner = this;
|
|
134
|
-
this._inverseWorldMatFlag = this._transform.registerWorldChangeFlag();
|
|
135
|
-
}
|
|
136
|
-
var _proto = LiteColliderShape.prototype;
|
|
137
|
-
/**
|
|
138
|
-
* {@inheritDoc IColliderShape.setRotation }
|
|
139
|
-
*/ _proto.setRotation = function setRotation(rotation) {
|
|
140
|
-
console.log("Physics-lite don't support setRotation. Use Physics-PhysX instead!");
|
|
141
|
-
};
|
|
142
|
-
/**
|
|
143
|
-
* {@inheritDoc IColliderShape.setPosition }
|
|
144
|
-
*/ _proto.setPosition = function setPosition(position) {
|
|
145
|
-
this._transform.setPosition(position.x, position.y, position.z);
|
|
146
|
-
};
|
|
147
|
-
/**
|
|
148
|
-
* {@inheritDoc IColliderShape.setContactOffset }
|
|
149
|
-
*/ _proto.setContactOffset = function setContactOffset(offset) {
|
|
150
|
-
console.log("Physics-lite don't support setContactOffset. Use Physics-PhysX instead!");
|
|
151
|
-
};
|
|
152
|
-
/**
|
|
153
|
-
* {@inheritDoc IColliderShape.setMaterial }
|
|
154
|
-
*/ _proto.setMaterial = function setMaterial(material) {
|
|
155
|
-
console.log("Physics-lite don't support setMaterial. Use Physics-PhysX instead!");
|
|
156
|
-
};
|
|
157
|
-
/**
|
|
158
|
-
* {@inheritDoc IColliderShape.setUniqueID }
|
|
159
|
-
*/ _proto.setUniqueID = function setUniqueID(id) {
|
|
160
|
-
this._id = id;
|
|
161
|
-
};
|
|
162
|
-
/**
|
|
163
|
-
* {@inheritDoc IColliderShape.setIsTrigger }
|
|
164
|
-
*/ _proto.setIsTrigger = function setIsTrigger(value) {
|
|
165
|
-
console.log("Physics-lite don't support setIsTrigger. Use Physics-PhysX instead!");
|
|
166
|
-
};
|
|
167
|
-
/**
|
|
168
|
-
* {@inheritDoc IColliderShape.destroy }
|
|
169
|
-
*/ _proto.destroy = function destroy() {};
|
|
170
|
-
_proto._updateHitResult = function _updateHitResult(ray, rayDistance, outHit, origin, isWorldRay) {
|
|
171
|
-
if (isWorldRay === void 0) isWorldRay = false;
|
|
172
|
-
var hitPoint = LiteColliderShape._tempPoint;
|
|
173
|
-
ray.getPoint(rayDistance, hitPoint);
|
|
174
|
-
if (!isWorldRay) {
|
|
175
|
-
engine.Vector3.transformCoordinate(hitPoint, this._transform.worldMatrix, hitPoint);
|
|
176
|
-
}
|
|
177
|
-
var distance = engine.Vector3.distance(origin, hitPoint);
|
|
178
|
-
if (distance < outHit.distance) {
|
|
179
|
-
outHit.point.copyFrom(hitPoint);
|
|
180
|
-
outHit.distance = distance;
|
|
181
|
-
outHit.shapeID = this._id;
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
_proto._getLocalRay = function _getLocalRay(ray) {
|
|
185
|
-
var worldToLocal = this._getInvModelMatrix();
|
|
186
|
-
var outRay = LiteColliderShape._ray;
|
|
187
|
-
engine.Vector3.transformCoordinate(ray.origin, worldToLocal, outRay.origin);
|
|
188
|
-
engine.Vector3.transformNormal(ray.direction, worldToLocal, outRay.direction);
|
|
189
|
-
outRay.direction.normalize();
|
|
190
|
-
return outRay;
|
|
191
|
-
};
|
|
192
|
-
_proto._getInvModelMatrix = function _getInvModelMatrix() {
|
|
193
|
-
if (this._inverseWorldMatFlag.flag) {
|
|
194
|
-
engine.Matrix.invert(this._transform.worldMatrix, this._invModelMatrix);
|
|
195
|
-
this._inverseWorldMatFlag.flag = false;
|
|
196
|
-
}
|
|
197
|
-
return this._invModelMatrix;
|
|
198
|
-
};
|
|
199
|
-
return LiteColliderShape;
|
|
200
|
-
}();
|
|
201
|
-
(function() {
|
|
202
|
-
LiteColliderShape._ray = new engine.Ray();
|
|
203
|
-
})();
|
|
204
|
-
(function() {
|
|
205
|
-
LiteColliderShape._tempPoint = new engine.Vector3();
|
|
206
|
-
})();
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Used to implement transformation related functions.
|
|
210
|
-
*/ var LiteTransform = /*#__PURE__*/ function() {
|
|
211
|
-
function LiteTransform() {
|
|
212
|
-
this._position = new engine.Vector3();
|
|
213
|
-
this._rotation = new engine.Vector3();
|
|
214
|
-
this._rotationQuaternion = new engine.Quaternion();
|
|
215
|
-
this._scale = new engine.Vector3(1, 1, 1);
|
|
216
|
-
this._worldRotationQuaternion = new engine.Quaternion();
|
|
217
|
-
this._localMatrix = new engine.Matrix();
|
|
218
|
-
this._worldMatrix = new engine.Matrix();
|
|
219
|
-
this._updateFlagManager = new LiteUpdateFlagManager();
|
|
220
|
-
this._isParentDirty = true;
|
|
221
|
-
this._parentTransformCache = null;
|
|
222
|
-
this._dirtyFlag = 0xbc;
|
|
223
|
-
}
|
|
224
|
-
var _proto = LiteTransform.prototype;
|
|
225
|
-
/**
|
|
226
|
-
* Set local position by X, Y, Z value.
|
|
227
|
-
* @param x - X coordinate
|
|
228
|
-
* @param y - Y coordinate
|
|
229
|
-
* @param z - Z coordinate
|
|
230
|
-
*/ _proto.setPosition = function setPosition(x, y, z) {
|
|
231
|
-
this._position.set(x, y, z);
|
|
232
|
-
this.position = this._position;
|
|
233
|
-
};
|
|
234
|
-
/**
|
|
235
|
-
* Set local rotation by the X, Y, Z, and W components of the quaternion.
|
|
236
|
-
* @param x - X component of quaternion
|
|
237
|
-
* @param y - Y component of quaternion
|
|
238
|
-
* @param z - Z component of quaternion
|
|
239
|
-
* @param w - W component of quaternion
|
|
240
|
-
*/ _proto.setRotationQuaternion = function setRotationQuaternion(x, y, z, w) {
|
|
241
|
-
this._rotationQuaternion.set(x, y, z, w);
|
|
242
|
-
this.rotationQuaternion = this._rotationQuaternion;
|
|
243
|
-
};
|
|
244
|
-
/**
|
|
245
|
-
* Set local scaling by scaling values along X, Y, Z axis.
|
|
246
|
-
* @param x - Scaling along X axis
|
|
247
|
-
* @param y - Scaling along Y axis
|
|
248
|
-
* @param z - Scaling along Z axis
|
|
249
|
-
*/ _proto.setScale = function setScale(x, y, z) {
|
|
250
|
-
this._scale.set(x, y, z);
|
|
251
|
-
this.scale = this._scale;
|
|
252
|
-
};
|
|
253
|
-
/**
|
|
254
|
-
* Register world transform change flag.
|
|
255
|
-
* @returns Change flag
|
|
256
|
-
*/ _proto.registerWorldChangeFlag = function registerWorldChangeFlag() {
|
|
257
|
-
return this._updateFlagManager.register();
|
|
258
|
-
};
|
|
259
|
-
/**
|
|
260
|
-
* Get worldMatrix: Will trigger the worldMatrix update of itself and all parent entities.
|
|
261
|
-
* Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
|
|
262
|
-
* In summary, any update of related variables will cause the dirty mark of one of the full process (worldMatrix or worldRotationQuaternion) to be false.
|
|
263
|
-
*/ _proto._updateWorldPositionFlag = function _updateWorldPositionFlag() {
|
|
264
|
-
if (!this._isContainDirtyFlags(0x84)) {
|
|
265
|
-
this._worldAssociatedChange(0x84);
|
|
266
|
-
if (_instanceof(this._owner, LiteCollider)) {
|
|
267
|
-
var shapes = this._owner._shapes;
|
|
268
|
-
for(var i = 0, n = shapes.length; i < n; i++){
|
|
269
|
-
shapes[i]._transform._updateWorldPositionFlag();
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
};
|
|
274
|
-
/**
|
|
275
|
-
* Get worldMatrix: Will trigger the worldMatrix update of itself and all parent entities.
|
|
276
|
-
* Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
|
|
277
|
-
* Get worldRotationQuaternion: Will trigger the world rotation (in quaternion) update of itself and all parent entities.
|
|
278
|
-
* Get worldRotation: Will trigger the world rotation(in euler and quaternion) update of itself and world rotation(in quaternion) update of all parent entities.
|
|
279
|
-
* In summary, any update of related variables will cause the dirty mark of one of the full process (worldMatrix or worldRotationQuaternion) to be false.
|
|
280
|
-
*/ _proto._updateWorldRotationFlag = function _updateWorldRotationFlag() {
|
|
281
|
-
if (!this._isContainDirtyFlags(0x98)) {
|
|
282
|
-
this._worldAssociatedChange(0x98);
|
|
283
|
-
if (_instanceof(this._owner, LiteCollider)) {
|
|
284
|
-
var shapes = this._owner._shapes;
|
|
285
|
-
for(var i = 0, n = shapes.length; i < n; i++){
|
|
286
|
-
shapes[i]._transform._updateWorldRotationFlag();
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
/**
|
|
292
|
-
* Get worldMatrix: Will trigger the worldMatrix update of itself and all parent entities.
|
|
293
|
-
* Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
|
|
294
|
-
* Get worldScale: Will trigger the scaling update of itself and all parent entities.
|
|
295
|
-
* In summary, any update of related variables will cause the dirty mark of one of the full process (worldMatrix) to be false.
|
|
296
|
-
*/ _proto._updateWorldScaleFlag = function _updateWorldScaleFlag() {
|
|
297
|
-
if (!this._isContainDirtyFlags(0xa0)) {
|
|
298
|
-
this._worldAssociatedChange(0xa0);
|
|
299
|
-
if (_instanceof(this._owner, LiteCollider)) {
|
|
300
|
-
var shapes = this._owner._shapes;
|
|
301
|
-
for(var i = 0, n = shapes.length; i < n; i++){
|
|
302
|
-
shapes[i]._transform._updateWorldScaleFlag();
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
};
|
|
307
|
-
/**
|
|
308
|
-
* Update all world transform property dirty flag, the principle is the same as above.
|
|
309
|
-
*/ _proto._updateAllWorldFlag = function _updateAllWorldFlag() {
|
|
310
|
-
if (!this._isContainDirtyFlags(0xbc)) {
|
|
311
|
-
this._worldAssociatedChange(0xbc);
|
|
312
|
-
if (_instanceof(this._owner, LiteCollider)) {
|
|
313
|
-
var shapes = this._owner._shapes;
|
|
314
|
-
for(var i = 0, n = shapes.length; i < n; i++){
|
|
315
|
-
shapes[i]._transform._updateAllWorldFlag();
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
_proto._getParentTransform = function _getParentTransform() {
|
|
321
|
-
if (!this._isParentDirty) {
|
|
322
|
-
return this._parentTransformCache;
|
|
323
|
-
}
|
|
324
|
-
var parentCache = null;
|
|
325
|
-
if (_instanceof(this._owner, LiteColliderShape)) {
|
|
326
|
-
var parent = this._owner._collider;
|
|
327
|
-
parentCache = parent._transform;
|
|
328
|
-
}
|
|
329
|
-
this._parentTransformCache = parentCache;
|
|
330
|
-
this._isParentDirty = false;
|
|
331
|
-
return parentCache;
|
|
332
|
-
};
|
|
333
|
-
_proto._isContainDirtyFlags = function _isContainDirtyFlags(targetDirtyFlags) {
|
|
334
|
-
return (this._dirtyFlag & targetDirtyFlags) === targetDirtyFlags;
|
|
335
|
-
};
|
|
336
|
-
_proto._isContainDirtyFlag = function _isContainDirtyFlag(type) {
|
|
337
|
-
return (this._dirtyFlag & type) != 0;
|
|
338
|
-
};
|
|
339
|
-
_proto._setDirtyFlagTrue = function _setDirtyFlagTrue(type) {
|
|
340
|
-
this._dirtyFlag |= type;
|
|
341
|
-
};
|
|
342
|
-
_proto._setDirtyFlagFalse = function _setDirtyFlagFalse(type) {
|
|
343
|
-
this._dirtyFlag &= ~type;
|
|
344
|
-
};
|
|
345
|
-
_proto._worldAssociatedChange = function _worldAssociatedChange(type) {
|
|
346
|
-
this._dirtyFlag |= type;
|
|
347
|
-
this._updateFlagManager.distribute();
|
|
348
|
-
};
|
|
349
|
-
_create_class(LiteTransform, [
|
|
350
|
-
{
|
|
351
|
-
key: "owner",
|
|
352
|
-
set: function set(value) {
|
|
353
|
-
this._owner = value;
|
|
354
|
-
}
|
|
355
|
-
},
|
|
356
|
-
{
|
|
357
|
-
key: "position",
|
|
358
|
-
get: /**
|
|
359
|
-
* Local position.
|
|
360
|
-
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
361
|
-
*/ function get() {
|
|
362
|
-
return this._position;
|
|
363
|
-
},
|
|
364
|
-
set: function set(value) {
|
|
365
|
-
if (this._position !== value) {
|
|
366
|
-
this._position.copyFrom(value);
|
|
367
|
-
}
|
|
368
|
-
this._setDirtyFlagTrue(0x40);
|
|
369
|
-
this._updateWorldPositionFlag();
|
|
370
|
-
}
|
|
371
|
-
},
|
|
372
|
-
{
|
|
373
|
-
key: "rotationQuaternion",
|
|
374
|
-
get: /**
|
|
375
|
-
* Local rotation, defining the rotation by using a unit quaternion.
|
|
376
|
-
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
377
|
-
*/ function get() {
|
|
378
|
-
if (this._isContainDirtyFlag(0x2)) {
|
|
379
|
-
engine.Quaternion.rotationEuler(engine.MathUtil.degreeToRadian(this._rotation.x), engine.MathUtil.degreeToRadian(this._rotation.y), engine.MathUtil.degreeToRadian(this._rotation.z), this._rotationQuaternion);
|
|
380
|
-
this._setDirtyFlagFalse(0x2);
|
|
381
|
-
}
|
|
382
|
-
return this._rotationQuaternion;
|
|
383
|
-
},
|
|
384
|
-
set: function set(value) {
|
|
385
|
-
if (this._rotationQuaternion !== value) {
|
|
386
|
-
this._rotationQuaternion.copyFrom(value);
|
|
387
|
-
}
|
|
388
|
-
this._setDirtyFlagTrue(0x40 | 0x1);
|
|
389
|
-
this._setDirtyFlagFalse(0x2);
|
|
390
|
-
this._updateWorldRotationFlag();
|
|
391
|
-
}
|
|
392
|
-
},
|
|
393
|
-
{
|
|
394
|
-
key: "worldRotationQuaternion",
|
|
395
|
-
get: /**
|
|
396
|
-
* World rotation, defining the rotation by using a unit quaternion.
|
|
397
|
-
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
398
|
-
*/ function get() {
|
|
399
|
-
if (this._isContainDirtyFlag(0x10)) {
|
|
400
|
-
var parent = this._getParentTransform();
|
|
401
|
-
if (parent != null) {
|
|
402
|
-
engine.Quaternion.multiply(parent.worldRotationQuaternion, this.rotationQuaternion, this._worldRotationQuaternion);
|
|
403
|
-
} else {
|
|
404
|
-
this._worldRotationQuaternion.copyFrom(this.rotationQuaternion);
|
|
405
|
-
}
|
|
406
|
-
this._setDirtyFlagFalse(0x10);
|
|
407
|
-
}
|
|
408
|
-
return this._worldRotationQuaternion;
|
|
409
|
-
},
|
|
410
|
-
set: function set(value) {
|
|
411
|
-
if (this._worldRotationQuaternion !== value) {
|
|
412
|
-
this._worldRotationQuaternion.copyFrom(value);
|
|
413
|
-
}
|
|
414
|
-
var parent = this._getParentTransform();
|
|
415
|
-
if (parent) {
|
|
416
|
-
engine.Quaternion.invert(parent.worldRotationQuaternion, LiteTransform._tempQuat0);
|
|
417
|
-
engine.Quaternion.multiply(value, LiteTransform._tempQuat0, this._rotationQuaternion);
|
|
418
|
-
} else {
|
|
419
|
-
this._rotationQuaternion.copyFrom(value);
|
|
420
|
-
}
|
|
421
|
-
this.rotationQuaternion = this._rotationQuaternion;
|
|
422
|
-
this._setDirtyFlagFalse(0x10);
|
|
423
|
-
}
|
|
424
|
-
},
|
|
425
|
-
{
|
|
426
|
-
key: "scale",
|
|
427
|
-
get: /**
|
|
428
|
-
* Local scaling.
|
|
429
|
-
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
430
|
-
*/ function get() {
|
|
431
|
-
return this._scale;
|
|
432
|
-
},
|
|
433
|
-
set: function set(value) {
|
|
434
|
-
if (this._scale !== value) {
|
|
435
|
-
this._scale.copyFrom(value);
|
|
436
|
-
}
|
|
437
|
-
this._setDirtyFlagTrue(0x40);
|
|
438
|
-
this._updateWorldScaleFlag();
|
|
439
|
-
}
|
|
440
|
-
},
|
|
441
|
-
{
|
|
442
|
-
key: "localMatrix",
|
|
443
|
-
get: /**
|
|
444
|
-
* Local matrix.
|
|
445
|
-
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
446
|
-
*/ function get() {
|
|
447
|
-
if (this._isContainDirtyFlag(0x40)) {
|
|
448
|
-
engine.Matrix.affineTransformation(this._scale, this.rotationQuaternion, this._position, this._localMatrix);
|
|
449
|
-
this._setDirtyFlagFalse(0x40);
|
|
450
|
-
}
|
|
451
|
-
return this._localMatrix;
|
|
452
|
-
},
|
|
453
|
-
set: function set(value) {
|
|
454
|
-
if (this._localMatrix !== value) {
|
|
455
|
-
this._localMatrix.copyFrom(value);
|
|
456
|
-
}
|
|
457
|
-
this._localMatrix.decompose(this._position, this._rotationQuaternion, this._scale);
|
|
458
|
-
this._setDirtyFlagTrue(0x1);
|
|
459
|
-
this._setDirtyFlagFalse(0x40);
|
|
460
|
-
this._updateAllWorldFlag();
|
|
461
|
-
}
|
|
462
|
-
},
|
|
463
|
-
{
|
|
464
|
-
key: "worldMatrix",
|
|
465
|
-
get: /**
|
|
466
|
-
* World matrix.
|
|
467
|
-
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
468
|
-
*/ function get() {
|
|
469
|
-
if (this._isContainDirtyFlag(0x80)) {
|
|
470
|
-
var parent = this._getParentTransform();
|
|
471
|
-
if (parent) {
|
|
472
|
-
engine.Matrix.multiply(parent.worldMatrix, this.localMatrix, this._worldMatrix);
|
|
473
|
-
} else {
|
|
474
|
-
this._worldMatrix.copyFrom(this.localMatrix);
|
|
475
|
-
}
|
|
476
|
-
this._setDirtyFlagFalse(0x80);
|
|
477
|
-
}
|
|
478
|
-
return this._worldMatrix;
|
|
479
|
-
},
|
|
480
|
-
set: function set(value) {
|
|
481
|
-
if (this._worldMatrix !== value) {
|
|
482
|
-
this._worldMatrix.copyFrom(value);
|
|
483
|
-
}
|
|
484
|
-
var parent = this._getParentTransform();
|
|
485
|
-
if (parent) {
|
|
486
|
-
engine.Matrix.invert(parent.worldMatrix, LiteTransform._tempMat42);
|
|
487
|
-
engine.Matrix.multiply(LiteTransform._tempMat42, value, this._localMatrix);
|
|
488
|
-
} else {
|
|
489
|
-
this._localMatrix.copyFrom(value);
|
|
490
|
-
}
|
|
491
|
-
this.localMatrix = this._localMatrix;
|
|
492
|
-
this._setDirtyFlagFalse(0x80);
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
]);
|
|
496
|
-
return LiteTransform;
|
|
497
|
-
}();
|
|
498
|
-
(function() {
|
|
499
|
-
LiteTransform._tempQuat0 = new engine.Quaternion();
|
|
500
|
-
})();
|
|
501
|
-
(function() {
|
|
502
|
-
LiteTransform._tempMat42 = new engine.Matrix();
|
|
503
|
-
})();
|
|
504
|
-
var /**
|
|
505
|
-
* Dirty flag of transform.
|
|
506
|
-
*/ TransformFlag;
|
|
507
|
-
(function(TransformFlag) {
|
|
508
|
-
TransformFlag[TransformFlag["LocalEuler"] = 0x1] = "LocalEuler";
|
|
509
|
-
TransformFlag[TransformFlag["LocalQuat"] = 0x2] = "LocalQuat";
|
|
510
|
-
TransformFlag[TransformFlag["WorldPosition"] = 0x4] = "WorldPosition";
|
|
511
|
-
TransformFlag[TransformFlag["WorldEuler"] = 0x8] = "WorldEuler";
|
|
512
|
-
TransformFlag[TransformFlag["WorldQuat"] = 0x10] = "WorldQuat";
|
|
513
|
-
TransformFlag[TransformFlag["WorldScale"] = 0x20] = "WorldScale";
|
|
514
|
-
TransformFlag[TransformFlag["LocalMatrix"] = 0x40] = "LocalMatrix";
|
|
515
|
-
TransformFlag[TransformFlag["WorldMatrix"] = 0x80] = "WorldMatrix";
|
|
516
|
-
TransformFlag[TransformFlag[/** WorldMatrix | WorldPosition */ "WmWp"] = 0x84] = "WmWp";
|
|
517
|
-
TransformFlag[TransformFlag[/** WorldMatrix | WorldEuler | WorldQuat */ "WmWeWq"] = 0x98] = "WmWeWq";
|
|
518
|
-
TransformFlag[TransformFlag[/** WorldMatrix | WorldPosition | WorldEuler | WorldQuat */ "WmWpWeWq"] = 0x9c] = "WmWpWeWq";
|
|
519
|
-
TransformFlag[TransformFlag[/** WorldMatrix | WorldScale */ "WmWs"] = 0xa0] = "WmWs";
|
|
520
|
-
TransformFlag[TransformFlag[/** WorldMatrix | WorldPosition | WorldScale */ "WmWpWs"] = 0xa4] = "WmWpWs";
|
|
521
|
-
TransformFlag[TransformFlag[/** WorldMatrix | WorldPosition | WorldEuler | WorldQuat | WorldScale */ "WmWpWeWqWs"] = 0xbc] = "WmWpWeWqWs";
|
|
522
|
-
})(TransformFlag || (TransformFlag = {}));
|
|
505
|
+
*/ _proto._raycast = function _raycast(ray, onRaycast, hit) {
|
|
506
|
+
hit.distance = Number.MAX_VALUE;
|
|
507
|
+
var shapes = this._shapes;
|
|
508
|
+
for(var i = 0, n = shapes.length; i < n; i++){
|
|
509
|
+
var shape = shapes[i];
|
|
510
|
+
onRaycast(shape._id) && shape._raycast(ray, hit);
|
|
511
|
+
}
|
|
512
|
+
return hit.distance != Number.MAX_VALUE;
|
|
513
|
+
};
|
|
514
|
+
return LiteCollider;
|
|
515
|
+
}();
|
|
523
516
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
517
|
+
/**
|
|
518
|
+
* A dynamic collider can act with self-defined movement or physical force
|
|
519
|
+
*/ var LiteDynamicCollider = /*#__PURE__*/ function(LiteCollider) {
|
|
520
|
+
_inherits__default['default'](LiteDynamicCollider, LiteCollider);
|
|
521
|
+
function LiteDynamicCollider(position, rotation) {
|
|
522
|
+
var _this;
|
|
523
|
+
_this = LiteCollider.call(this) || this;
|
|
524
|
+
_this._transform.setPosition(position.x, position.y, position.z);
|
|
525
|
+
_this._transform.setRotationQuaternion(rotation.x, rotation.y, rotation.z, rotation.w);
|
|
526
|
+
return _this;
|
|
527
|
+
}
|
|
528
|
+
var _proto = LiteDynamicCollider.prototype;
|
|
529
|
+
/**
|
|
530
|
+
* {@inheritDoc IDynamicCollider.addForce }
|
|
531
|
+
*/ _proto.addForce = function addForce(force) {
|
|
532
|
+
throw "Physics-lite don't support addForce. Use Physics-PhysX instead!";
|
|
533
|
+
};
|
|
534
|
+
/**
|
|
535
|
+
* {@inheritDoc IDynamicCollider.addTorque }
|
|
536
|
+
*/ _proto.addTorque = function addTorque(torque) {
|
|
537
|
+
throw "Physics-lite don't support addTorque. Use Physics-PhysX instead!";
|
|
538
|
+
};
|
|
539
|
+
/**
|
|
540
|
+
* {@inheritDoc IDynamicCollider.move }
|
|
541
|
+
*/ _proto.move = function move(positionOrRotation, rotation) {
|
|
542
|
+
throw "Physics-lite don't support move. Use Physics-PhysX instead!";
|
|
543
|
+
};
|
|
544
|
+
/**
|
|
545
|
+
* {@inheritDoc IDynamicCollider.sleep }
|
|
546
|
+
*/ _proto.sleep = function sleep() {
|
|
547
|
+
throw "Physics-lite don't support putToSleep. Use Physics-PhysX instead!";
|
|
548
|
+
};
|
|
549
|
+
/**
|
|
550
|
+
* {@inheritDoc IDynamicCollider.setAngularDamping }
|
|
551
|
+
*/ _proto.setAngularDamping = function setAngularDamping(value) {
|
|
552
|
+
throw "Physics-lite don't support setAngularDamping. Use Physics-PhysX instead!";
|
|
553
|
+
};
|
|
554
|
+
/**
|
|
555
|
+
* {@inheritDoc IDynamicCollider.setAngularVelocity }
|
|
556
|
+
*/ _proto.setAngularVelocity = function setAngularVelocity(value) {
|
|
557
|
+
throw "Physics-lite don't support setAngularVelocity. Use Physics-PhysX instead!";
|
|
558
|
+
};
|
|
559
|
+
/**
|
|
560
|
+
* {@inheritDoc IDynamicCollider.setCenterOfMass }
|
|
561
|
+
*/ _proto.setCenterOfMass = function setCenterOfMass(value) {
|
|
562
|
+
throw "Physics-lite don't support setCenterOfMass. Use Physics-PhysX instead!";
|
|
563
|
+
};
|
|
564
|
+
/**
|
|
565
|
+
* {@inheritDoc IDynamicCollider.setCollisionDetectionMode }
|
|
566
|
+
*/ _proto.setCollisionDetectionMode = function setCollisionDetectionMode(value) {
|
|
567
|
+
throw "Physics-lite don't support setCollisionDetectionMode. Use Physics-PhysX instead!";
|
|
568
|
+
};
|
|
569
|
+
/**
|
|
570
|
+
* {@inheritDoc IDynamicCollider.setConstraints }
|
|
571
|
+
*/ _proto.setConstraints = function setConstraints(flags) {
|
|
572
|
+
throw "Physics-lite don't support setConstraints. Use Physics-PhysX instead!";
|
|
573
|
+
};
|
|
574
|
+
/**
|
|
575
|
+
* {@inheritDoc IDynamicCollider.setInertiaTensor }
|
|
576
|
+
*/ _proto.setInertiaTensor = function setInertiaTensor(value) {
|
|
577
|
+
throw "Physics-lite don't support setInertiaTensor. Use Physics-PhysX instead!";
|
|
578
|
+
};
|
|
579
|
+
/**
|
|
580
|
+
* {@inheritDoc IDynamicCollider.setIsKinematic }
|
|
581
|
+
*/ _proto.setIsKinematic = function setIsKinematic(value) {
|
|
582
|
+
throw "Physics-lite don't support setIsKinematic. Use Physics-PhysX instead!";
|
|
583
|
+
};
|
|
584
|
+
/**
|
|
585
|
+
* {@inheritDoc IDynamicCollider.setLinearDamping }
|
|
586
|
+
*/ _proto.setLinearDamping = function setLinearDamping(value) {
|
|
587
|
+
throw "Physics-lite don't support setLinearDamping. Use Physics-PhysX instead!";
|
|
588
|
+
};
|
|
589
|
+
/**
|
|
590
|
+
* {@inheritDoc IDynamicCollider.setLinearVelocity }
|
|
591
|
+
*/ _proto.setLinearVelocity = function setLinearVelocity(value) {
|
|
592
|
+
throw "Physics-lite don't support setLinearVelocity. Use Physics-PhysX instead!";
|
|
593
|
+
};
|
|
594
|
+
/**
|
|
595
|
+
* {@inheritDoc IDynamicCollider.setMass }
|
|
596
|
+
*/ _proto.setMass = function setMass(value) {
|
|
597
|
+
throw "Physics-lite don't support setMass. Use Physics-PhysX instead!";
|
|
598
|
+
};
|
|
599
|
+
/**
|
|
600
|
+
* {@inheritDoc IDynamicCollider.setMaxAngularVelocity }
|
|
601
|
+
*/ _proto.setMaxAngularVelocity = function setMaxAngularVelocity(value) {
|
|
602
|
+
throw "Physics-lite don't support setMaxAngularVelocity. Use Physics-PhysX instead!";
|
|
603
|
+
};
|
|
604
|
+
/**
|
|
605
|
+
* {@inheritDoc IDynamicCollider.setMaxDepenetrationVelocity }
|
|
606
|
+
*/ _proto.setMaxDepenetrationVelocity = function setMaxDepenetrationVelocity(value) {
|
|
607
|
+
throw "Physics-lite don't support setMaxDepenetrationVelocity. Use Physics-PhysX instead!";
|
|
608
|
+
};
|
|
609
|
+
/**
|
|
610
|
+
* {@inheritDoc IDynamicCollider.setSleepThreshold }
|
|
611
|
+
*/ _proto.setSleepThreshold = function setSleepThreshold(value) {
|
|
612
|
+
throw "Physics-lite don't support setSleepThreshold. Use Physics-PhysX instead!";
|
|
613
|
+
};
|
|
614
|
+
/**
|
|
615
|
+
* {@inheritDoc IDynamicCollider.setSolverIterations }
|
|
616
|
+
*/ _proto.setSolverIterations = function setSolverIterations(value) {
|
|
617
|
+
throw "Physics-lite don't support setSolverIterations. Use Physics-PhysX instead!";
|
|
618
|
+
};
|
|
619
|
+
/**
|
|
620
|
+
* {@inheritDoc IDynamicCollider.wakeUp }
|
|
621
|
+
*/ _proto.wakeUp = function wakeUp() {
|
|
622
|
+
throw "Physics-lite don't support wakeUp. Use Physics-PhysX instead!";
|
|
623
|
+
};
|
|
624
|
+
return LiteDynamicCollider;
|
|
625
|
+
}(LiteCollider);
|
|
583
626
|
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
throw "Physics-lite don't support setCenterOfMass. Use Physics-PhysX instead!";
|
|
630
|
-
};
|
|
631
|
-
/**
|
|
632
|
-
* {@inheritDoc IDynamicCollider.setCollisionDetectionMode }
|
|
633
|
-
*/ _proto.setCollisionDetectionMode = function setCollisionDetectionMode(value) {
|
|
634
|
-
throw "Physics-lite don't support setCollisionDetectionMode. Use Physics-PhysX instead!";
|
|
635
|
-
};
|
|
636
|
-
/**
|
|
637
|
-
* {@inheritDoc IDynamicCollider.setConstraints }
|
|
638
|
-
*/ _proto.setConstraints = function setConstraints(flags) {
|
|
639
|
-
throw "Physics-lite don't support setConstraints. Use Physics-PhysX instead!";
|
|
640
|
-
};
|
|
641
|
-
/**
|
|
642
|
-
* {@inheritDoc IDynamicCollider.setInertiaTensor }
|
|
643
|
-
*/ _proto.setInertiaTensor = function setInertiaTensor(value) {
|
|
644
|
-
throw "Physics-lite don't support setInertiaTensor. Use Physics-PhysX instead!";
|
|
645
|
-
};
|
|
646
|
-
/**
|
|
647
|
-
* {@inheritDoc IDynamicCollider.setIsKinematic }
|
|
648
|
-
*/ _proto.setIsKinematic = function setIsKinematic(value) {
|
|
649
|
-
throw "Physics-lite don't support setIsKinematic. Use Physics-PhysX instead!";
|
|
650
|
-
};
|
|
651
|
-
/**
|
|
652
|
-
* {@inheritDoc IDynamicCollider.setLinearDamping }
|
|
653
|
-
*/ _proto.setLinearDamping = function setLinearDamping(value) {
|
|
654
|
-
throw "Physics-lite don't support setLinearDamping. Use Physics-PhysX instead!";
|
|
655
|
-
};
|
|
656
|
-
/**
|
|
657
|
-
* {@inheritDoc IDynamicCollider.setLinearVelocity }
|
|
658
|
-
*/ _proto.setLinearVelocity = function setLinearVelocity(value) {
|
|
659
|
-
throw "Physics-lite don't support setLinearVelocity. Use Physics-PhysX instead!";
|
|
660
|
-
};
|
|
661
|
-
/**
|
|
662
|
-
* {@inheritDoc IDynamicCollider.setMass }
|
|
663
|
-
*/ _proto.setMass = function setMass(value) {
|
|
664
|
-
throw "Physics-lite don't support setMass. Use Physics-PhysX instead!";
|
|
665
|
-
};
|
|
666
|
-
/**
|
|
667
|
-
* {@inheritDoc IDynamicCollider.setMaxAngularVelocity }
|
|
668
|
-
*/ _proto.setMaxAngularVelocity = function setMaxAngularVelocity(value) {
|
|
669
|
-
throw "Physics-lite don't support setMaxAngularVelocity. Use Physics-PhysX instead!";
|
|
670
|
-
};
|
|
671
|
-
/**
|
|
672
|
-
* {@inheritDoc IDynamicCollider.setMaxDepenetrationVelocity }
|
|
673
|
-
*/ _proto.setMaxDepenetrationVelocity = function setMaxDepenetrationVelocity(value) {
|
|
674
|
-
throw "Physics-lite don't support setMaxDepenetrationVelocity. Use Physics-PhysX instead!";
|
|
675
|
-
};
|
|
676
|
-
/**
|
|
677
|
-
* {@inheritDoc IDynamicCollider.setSleepThreshold }
|
|
678
|
-
*/ _proto.setSleepThreshold = function setSleepThreshold(value) {
|
|
679
|
-
throw "Physics-lite don't support setSleepThreshold. Use Physics-PhysX instead!";
|
|
680
|
-
};
|
|
681
|
-
/**
|
|
682
|
-
* {@inheritDoc IDynamicCollider.setSolverIterations }
|
|
683
|
-
*/ _proto.setSolverIterations = function setSolverIterations(value) {
|
|
684
|
-
throw "Physics-lite don't support setSolverIterations. Use Physics-PhysX instead!";
|
|
685
|
-
};
|
|
686
|
-
/**
|
|
687
|
-
* {@inheritDoc IDynamicCollider.wakeUp }
|
|
688
|
-
*/ _proto.wakeUp = function wakeUp() {
|
|
689
|
-
throw "Physics-lite don't support wakeUp. Use Physics-PhysX instead!";
|
|
690
|
-
};
|
|
691
|
-
return LiteDynamicCollider;
|
|
692
|
-
}(LiteCollider);
|
|
627
|
+
/**
|
|
628
|
+
* High-performance unordered array, delete uses exchange method to improve performance, internal capacity only increases.
|
|
629
|
+
*/ var DisorderedArray = /*#__PURE__*/ function() {
|
|
630
|
+
function DisorderedArray(count) {
|
|
631
|
+
if (count === void 0) count = 0;
|
|
632
|
+
this.length = 0;
|
|
633
|
+
this._elements = new Array(count);
|
|
634
|
+
}
|
|
635
|
+
var _proto = DisorderedArray.prototype;
|
|
636
|
+
_proto.add = function add(element) {
|
|
637
|
+
if (this.length === this._elements.length) this._elements.push(element);
|
|
638
|
+
else this._elements[this.length] = element;
|
|
639
|
+
this.length++;
|
|
640
|
+
};
|
|
641
|
+
_proto.delete = function _delete(element) {
|
|
642
|
+
//TODO: It can be optimized for custom binary search and other algorithms, currently this._elements>=this.length wastes performance.
|
|
643
|
+
var index = this._elements.indexOf(element);
|
|
644
|
+
this.deleteByIndex(index);
|
|
645
|
+
};
|
|
646
|
+
_proto.get = function get(index) {
|
|
647
|
+
if (index >= this.length) {
|
|
648
|
+
throw "Index is out of range.";
|
|
649
|
+
}
|
|
650
|
+
return this._elements[index];
|
|
651
|
+
};
|
|
652
|
+
/**
|
|
653
|
+
*
|
|
654
|
+
* @param index
|
|
655
|
+
* @returns The replaced item is used to reset its index.
|
|
656
|
+
*/ _proto.deleteByIndex = function deleteByIndex(index) {
|
|
657
|
+
var elements = this._elements;
|
|
658
|
+
var end = null;
|
|
659
|
+
var lastIndex = this.length - 1;
|
|
660
|
+
if (index !== lastIndex) {
|
|
661
|
+
end = elements[lastIndex];
|
|
662
|
+
elements[index] = end;
|
|
663
|
+
}
|
|
664
|
+
this.length--;
|
|
665
|
+
return end;
|
|
666
|
+
};
|
|
667
|
+
_proto.garbageCollection = function garbageCollection() {
|
|
668
|
+
this._elements.length = this.length;
|
|
669
|
+
};
|
|
670
|
+
return DisorderedArray;
|
|
671
|
+
}();
|
|
693
672
|
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
_proto.add = function add(element) {
|
|
704
|
-
if (this.length === this._elements.length) this._elements.push(element);
|
|
705
|
-
else this._elements[this.length] = element;
|
|
706
|
-
this.length++;
|
|
707
|
-
};
|
|
708
|
-
_proto.delete = function _delete(element) {
|
|
709
|
-
//TODO: It can be optimized for custom binary search and other algorithms, currently this._elements>=this.length wastes performance.
|
|
710
|
-
var index = this._elements.indexOf(element);
|
|
711
|
-
this.deleteByIndex(index);
|
|
712
|
-
};
|
|
713
|
-
_proto.get = function get(index) {
|
|
714
|
-
if (index >= this.length) {
|
|
715
|
-
throw "Index is out of range.";
|
|
716
|
-
}
|
|
717
|
-
return this._elements[index];
|
|
718
|
-
};
|
|
719
|
-
/**
|
|
720
|
-
*
|
|
721
|
-
* @param index
|
|
722
|
-
* @returns The replaced item is used to reset its index.
|
|
723
|
-
*/ _proto.deleteByIndex = function deleteByIndex(index) {
|
|
724
|
-
var elements = this._elements;
|
|
725
|
-
var end = null;
|
|
726
|
-
var lastIndex = this.length - 1;
|
|
727
|
-
if (index !== lastIndex) {
|
|
728
|
-
end = elements[lastIndex];
|
|
729
|
-
elements[index] = end;
|
|
730
|
-
}
|
|
731
|
-
this.length--;
|
|
732
|
-
return end;
|
|
733
|
-
};
|
|
734
|
-
_proto.garbageCollection = function garbageCollection() {
|
|
735
|
-
this._elements.length = this.length;
|
|
736
|
-
};
|
|
737
|
-
return DisorderedArray;
|
|
738
|
-
}();
|
|
673
|
+
/**
|
|
674
|
+
* Structure used to get information back from a raycast or a sweep.
|
|
675
|
+
* @internal
|
|
676
|
+
*/ var LiteHitResult = function LiteHitResult() {
|
|
677
|
+
/** The collider that was hit. */ this.shapeID = -1;
|
|
678
|
+
/** The distance from the origin to the hit point. */ this.distance = 0;
|
|
679
|
+
/** The hit point of the collider that was hit in world space. */ this.point = new engine.Vector3();
|
|
680
|
+
/** The hit normal of the collider that was hit in world space. */ this.normal = new engine.Vector3();
|
|
681
|
+
};
|
|
739
682
|
|
|
740
|
-
|
|
741
|
-
|
|
683
|
+
/**
|
|
684
|
+
* Box collider shape in Lite.
|
|
685
|
+
*/ var LiteBoxColliderShape = /*#__PURE__*/ function(LiteColliderShape) {
|
|
686
|
+
_inherits__default['default'](LiteBoxColliderShape, LiteColliderShape);
|
|
687
|
+
function LiteBoxColliderShape(uniqueID, size, material) {
|
|
688
|
+
var _this;
|
|
689
|
+
_this = LiteColliderShape.call(this) || this;
|
|
690
|
+
_this._halfSize = new engine.Vector3();
|
|
691
|
+
_this._scale = new engine.Vector3(1, 1, 1);
|
|
692
|
+
/** @internal */ _this._boxMin = new engine.Vector3(-0.5, -0.5, -0.5);
|
|
693
|
+
/** @internal */ _this._boxMax = new engine.Vector3(0.5, 0.5, 0.5);
|
|
694
|
+
_this._id = uniqueID;
|
|
695
|
+
_this._halfSize.set(size.x * 0.5, size.y * 0.5, size.z * 0.5);
|
|
696
|
+
_this._setBondingBox();
|
|
697
|
+
return _this;
|
|
698
|
+
}
|
|
699
|
+
var _proto = LiteBoxColliderShape.prototype;
|
|
700
|
+
/**
|
|
701
|
+
* {@inheritDoc IColliderShape.setPosition }
|
|
702
|
+
*/ _proto.setPosition = function setPosition(position) {
|
|
703
|
+
LiteColliderShape.prototype.setPosition.call(this, position);
|
|
704
|
+
this._setBondingBox();
|
|
705
|
+
};
|
|
706
|
+
/**
|
|
707
|
+
* {@inheritDoc IColliderShape.setWorldScale }
|
|
708
|
+
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
709
|
+
this._transform.position = this._transform.position.multiply(scale);
|
|
710
|
+
this._scale.copyFrom(scale);
|
|
711
|
+
};
|
|
712
|
+
/**
|
|
713
|
+
* {@inheritDoc IBoxColliderShape.setSize }
|
|
714
|
+
*/ _proto.setSize = function setSize(value) {
|
|
715
|
+
this._halfSize.set(value.x * 0.5, value.y * 0.5, value.z * 0.5);
|
|
716
|
+
this._setBondingBox();
|
|
717
|
+
};
|
|
718
|
+
/**
|
|
742
719
|
* @internal
|
|
743
|
-
*/
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
720
|
+
*/ _proto._raycast = function _raycast(ray, hit) {
|
|
721
|
+
var localRay = this._getLocalRay(ray);
|
|
722
|
+
var boundingBox = LiteBoxColliderShape._tempBox;
|
|
723
|
+
boundingBox.min.set(-this._halfSize.x * this._scale.x, -this._halfSize.y * this._scale.y, -this._halfSize.z * this._scale.z);
|
|
724
|
+
boundingBox.max.set(this._halfSize.x * this._scale.x, this._halfSize.y * this._scale.y, this._halfSize.z * this._scale.z);
|
|
725
|
+
var rayDistance = localRay.intersectBox(boundingBox);
|
|
726
|
+
if (rayDistance !== -1) {
|
|
727
|
+
this._updateHitResult(localRay, rayDistance, hit, ray.origin);
|
|
728
|
+
return true;
|
|
729
|
+
} else {
|
|
730
|
+
return false;
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
_proto._setBondingBox = function _setBondingBox() {
|
|
734
|
+
var _this__transform = this._transform, center = _this__transform.position;
|
|
735
|
+
var halfSize = this._halfSize;
|
|
736
|
+
engine.Vector3.add(center, halfSize, this._boxMax);
|
|
737
|
+
engine.Vector3.subtract(center, halfSize, this._boxMin);
|
|
738
|
+
};
|
|
739
|
+
return LiteBoxColliderShape;
|
|
740
|
+
}(LiteColliderShape);
|
|
741
|
+
LiteBoxColliderShape._tempBox = new engine.BoundingBox();
|
|
749
742
|
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
};
|
|
800
|
-
_proto._setBondingBox = function _setBondingBox() {
|
|
801
|
-
var _this__transform = this._transform, center = _this__transform.position;
|
|
802
|
-
var halfSize = this._halfSize;
|
|
803
|
-
engine.Vector3.add(center, halfSize, this._boxMax);
|
|
804
|
-
engine.Vector3.subtract(center, halfSize, this._boxMin);
|
|
805
|
-
};
|
|
806
|
-
return LiteBoxColliderShape;
|
|
807
|
-
}(LiteColliderShape);
|
|
808
|
-
(function() {
|
|
809
|
-
LiteBoxColliderShape._tempBox = new engine.BoundingBox();
|
|
810
|
-
})();
|
|
811
|
-
|
|
812
|
-
/**
|
|
813
|
-
* Sphere collider shape in Lite.
|
|
814
|
-
*/ var LiteSphereColliderShape = /*#__PURE__*/ function(LiteColliderShape) {
|
|
815
|
-
_inherits(LiteSphereColliderShape, LiteColliderShape);
|
|
816
|
-
function LiteSphereColliderShape(uniqueID, radius, material) {
|
|
817
|
-
var _this;
|
|
818
|
-
_this = LiteColliderShape.call(this) || this;
|
|
819
|
-
_this._radius = 1;
|
|
820
|
-
_this._maxScale = 1;
|
|
821
|
-
_this._radius = radius;
|
|
822
|
-
_this._id = uniqueID;
|
|
823
|
-
return _this;
|
|
824
|
-
}
|
|
825
|
-
var _proto = LiteSphereColliderShape.prototype;
|
|
826
|
-
/**
|
|
827
|
-
* {@inheritDoc ISphereColliderShape.setRadius }
|
|
828
|
-
*/ _proto.setRadius = function setRadius(value) {
|
|
829
|
-
this._radius = value;
|
|
830
|
-
};
|
|
831
|
-
/**
|
|
832
|
-
* {@inheritDoc IColliderShape.setWorldScale }
|
|
833
|
-
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
834
|
-
this._maxScale = Math.max(scale.x, Math.max(scale.x, scale.y));
|
|
835
|
-
};
|
|
836
|
-
/**
|
|
837
|
-
* @internal
|
|
838
|
-
*/ _proto._raycast = function _raycast(ray, hit) {
|
|
839
|
-
var boundingSphere = LiteSphereColliderShape._tempSphere;
|
|
840
|
-
engine.Vector3.transformCoordinate(this._transform.position, this._collider._transform.worldMatrix, boundingSphere.center);
|
|
841
|
-
boundingSphere.radius = this.worldRadius;
|
|
842
|
-
var rayDistance = ray.intersectSphere(boundingSphere);
|
|
843
|
-
if (rayDistance !== -1) {
|
|
844
|
-
this._updateHitResult(ray, rayDistance, hit, ray.origin, true);
|
|
845
|
-
return true;
|
|
846
|
-
} else {
|
|
847
|
-
return false;
|
|
848
|
-
}
|
|
849
|
-
};
|
|
850
|
-
_create_class(LiteSphereColliderShape, [
|
|
851
|
-
{
|
|
852
|
-
key: "worldRadius",
|
|
853
|
-
get: function get() {
|
|
854
|
-
return this._radius * this._maxScale;
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
]);
|
|
858
|
-
return LiteSphereColliderShape;
|
|
859
|
-
}(LiteColliderShape);
|
|
860
|
-
(function() {
|
|
861
|
-
LiteSphereColliderShape._tempSphere = new engine.BoundingSphere();
|
|
862
|
-
})();
|
|
743
|
+
/**
|
|
744
|
+
* Sphere collider shape in Lite.
|
|
745
|
+
*/ var LiteSphereColliderShape = /*#__PURE__*/ function(LiteColliderShape) {
|
|
746
|
+
_inherits__default['default'](LiteSphereColliderShape, LiteColliderShape);
|
|
747
|
+
function LiteSphereColliderShape(uniqueID, radius, material) {
|
|
748
|
+
var _this;
|
|
749
|
+
_this = LiteColliderShape.call(this) || this;
|
|
750
|
+
_this._radius = 1;
|
|
751
|
+
_this._maxScale = 1;
|
|
752
|
+
_this._radius = radius;
|
|
753
|
+
_this._id = uniqueID;
|
|
754
|
+
return _this;
|
|
755
|
+
}
|
|
756
|
+
var _proto = LiteSphereColliderShape.prototype;
|
|
757
|
+
/**
|
|
758
|
+
* {@inheritDoc ISphereColliderShape.setRadius }
|
|
759
|
+
*/ _proto.setRadius = function setRadius(value) {
|
|
760
|
+
this._radius = value;
|
|
761
|
+
};
|
|
762
|
+
/**
|
|
763
|
+
* {@inheritDoc IColliderShape.setWorldScale }
|
|
764
|
+
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
765
|
+
this._maxScale = Math.max(scale.x, Math.max(scale.x, scale.y));
|
|
766
|
+
};
|
|
767
|
+
/**
|
|
768
|
+
* @internal
|
|
769
|
+
*/ _proto._raycast = function _raycast(ray, hit) {
|
|
770
|
+
var boundingSphere = LiteSphereColliderShape._tempSphere;
|
|
771
|
+
engine.Vector3.transformCoordinate(this._transform.position, this._collider._transform.worldMatrix, boundingSphere.center);
|
|
772
|
+
boundingSphere.radius = this.worldRadius;
|
|
773
|
+
var rayDistance = ray.intersectSphere(boundingSphere);
|
|
774
|
+
if (rayDistance !== -1) {
|
|
775
|
+
this._updateHitResult(ray, rayDistance, hit, ray.origin, true);
|
|
776
|
+
return true;
|
|
777
|
+
} else {
|
|
778
|
+
return false;
|
|
779
|
+
}
|
|
780
|
+
};
|
|
781
|
+
_create_class__default['default'](LiteSphereColliderShape, [
|
|
782
|
+
{
|
|
783
|
+
key: "worldRadius",
|
|
784
|
+
get: function get() {
|
|
785
|
+
return this._radius * this._maxScale;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
]);
|
|
789
|
+
return LiteSphereColliderShape;
|
|
790
|
+
}(LiteColliderShape);
|
|
791
|
+
LiteSphereColliderShape._tempSphere = new engine.BoundingSphere();
|
|
863
792
|
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
})(TriggerEventState || (TriggerEventState = {}));
|
|
1134
|
-
/**
|
|
1135
|
-
* Trigger event to store interactive object ids and state.
|
|
1136
|
-
*/ var TriggerEvent = function TriggerEvent(index1, index2) {
|
|
1137
|
-
this.alreadyInvoked = false;
|
|
1138
|
-
this.index1 = index1;
|
|
1139
|
-
this.index2 = index2;
|
|
1140
|
-
};
|
|
793
|
+
/**
|
|
794
|
+
* A manager is a collection of colliders and constraints which can interact.
|
|
795
|
+
*/ var LitePhysicsManager = /*#__PURE__*/ function() {
|
|
796
|
+
function LitePhysicsManager(onContactEnter, onContactExit, onContactStay, onTriggerEnter, onTriggerExit, onTriggerStay) {
|
|
797
|
+
this._colliders = [];
|
|
798
|
+
this._sphere = new engine.BoundingSphere();
|
|
799
|
+
this._box = new engine.BoundingBox();
|
|
800
|
+
this._currentEvents = new DisorderedArray();
|
|
801
|
+
this._eventMap = {};
|
|
802
|
+
this._eventPool = [];
|
|
803
|
+
this._onContactEnter = onContactEnter;
|
|
804
|
+
this._onContactExit = onContactExit;
|
|
805
|
+
this._onContactStay = onContactStay;
|
|
806
|
+
this._onTriggerEnter = onTriggerEnter;
|
|
807
|
+
this._onTriggerExit = onTriggerExit;
|
|
808
|
+
this._onTriggerStay = onTriggerStay;
|
|
809
|
+
}
|
|
810
|
+
var _proto = LitePhysicsManager.prototype;
|
|
811
|
+
/**
|
|
812
|
+
* {@inheritDoc IPhysicsManager.setGravity }
|
|
813
|
+
*/ _proto.setGravity = function setGravity(value) {
|
|
814
|
+
console.log("Physics-lite don't support gravity. Use Physics-PhysX instead!");
|
|
815
|
+
};
|
|
816
|
+
/**
|
|
817
|
+
* {@inheritDoc IPhysicsManager.addColliderShape }
|
|
818
|
+
*/ _proto.addColliderShape = function addColliderShape(colliderShape) {
|
|
819
|
+
this._eventMap[colliderShape._id] = {};
|
|
820
|
+
};
|
|
821
|
+
/**
|
|
822
|
+
* {@inheritDoc IPhysicsManager.removeColliderShape }
|
|
823
|
+
*/ _proto.removeColliderShape = function removeColliderShape(colliderShape) {
|
|
824
|
+
var _this = this, eventPool = _this._eventPool, currentEvents = _this._currentEvents;
|
|
825
|
+
var shapeID = colliderShape._id;
|
|
826
|
+
for(var i = currentEvents.length - 1; i >= 0; i--){
|
|
827
|
+
var event = currentEvents.get(i);
|
|
828
|
+
if (event.index1 == shapeID || event.index2 == shapeID) {
|
|
829
|
+
currentEvents.deleteByIndex(i);
|
|
830
|
+
eventPool.push(event);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
delete this._eventMap[shapeID];
|
|
834
|
+
};
|
|
835
|
+
/**
|
|
836
|
+
* {@inheritDoc IPhysicsManager.addCollider }
|
|
837
|
+
*/ _proto.addCollider = function addCollider(actor) {
|
|
838
|
+
this._colliders.push(actor);
|
|
839
|
+
};
|
|
840
|
+
/**
|
|
841
|
+
* {@inheritDoc IPhysicsManager.removeCollider }
|
|
842
|
+
*/ _proto.removeCollider = function removeCollider(collider) {
|
|
843
|
+
var index = this._colliders.indexOf(collider);
|
|
844
|
+
if (index !== -1) {
|
|
845
|
+
this._colliders.splice(index, 1);
|
|
846
|
+
}
|
|
847
|
+
};
|
|
848
|
+
/**
|
|
849
|
+
* {@inheritDoc IPhysicsManager.update }
|
|
850
|
+
*/ _proto.update = function update(deltaTime) {
|
|
851
|
+
var colliders = this._colliders;
|
|
852
|
+
for(var i = 0, len = colliders.length; i < len; i++){
|
|
853
|
+
this._collisionDetection(deltaTime, colliders[i]);
|
|
854
|
+
}
|
|
855
|
+
this._fireEvent();
|
|
856
|
+
};
|
|
857
|
+
/**
|
|
858
|
+
* {@inheritDoc IPhysicsManager.raycast }
|
|
859
|
+
*/ _proto.raycast = function raycast(ray, distance, onRaycast, hit) {
|
|
860
|
+
var colliders = this._colliders;
|
|
861
|
+
var hitResult;
|
|
862
|
+
if (hit) {
|
|
863
|
+
hitResult = LitePhysicsManager._hitResult;
|
|
864
|
+
}
|
|
865
|
+
var isHit = false;
|
|
866
|
+
var curHit = LitePhysicsManager._currentHit;
|
|
867
|
+
for(var i = 0, len = colliders.length; i < len; i++){
|
|
868
|
+
var collider = colliders[i];
|
|
869
|
+
if (collider._raycast(ray, onRaycast, curHit)) {
|
|
870
|
+
isHit = true;
|
|
871
|
+
if (curHit.distance < distance) {
|
|
872
|
+
if (hitResult) {
|
|
873
|
+
hitResult.normal.copyFrom(curHit.normal);
|
|
874
|
+
hitResult.point.copyFrom(curHit.point);
|
|
875
|
+
hitResult.distance = curHit.distance;
|
|
876
|
+
hitResult.shapeID = curHit.shapeID;
|
|
877
|
+
} else {
|
|
878
|
+
return true;
|
|
879
|
+
}
|
|
880
|
+
distance = curHit.distance;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
if (!isHit && hitResult) {
|
|
885
|
+
hitResult.shapeID = -1;
|
|
886
|
+
hitResult.distance = 0;
|
|
887
|
+
hitResult.point.set(0, 0, 0);
|
|
888
|
+
hitResult.normal.set(0, 0, 0);
|
|
889
|
+
} else if (isHit && hitResult) {
|
|
890
|
+
hit(hitResult.shapeID, hitResult.distance, hitResult.point, hitResult.normal);
|
|
891
|
+
}
|
|
892
|
+
return isHit;
|
|
893
|
+
};
|
|
894
|
+
/**
|
|
895
|
+
* {@inheritDoc IPhysicsManager.addCharacterController }
|
|
896
|
+
*/ _proto.addCharacterController = function addCharacterController(characterController) {
|
|
897
|
+
throw "Physics-lite don't support addCharacterController. Use Physics-PhysX instead!";
|
|
898
|
+
};
|
|
899
|
+
/**
|
|
900
|
+
* {@inheritDoc IPhysicsManager.removeCharacterController }
|
|
901
|
+
*/ _proto.removeCharacterController = function removeCharacterController(characterController) {
|
|
902
|
+
throw "Physics-lite don't support removeCharacterController. Use Physics-PhysX instead!";
|
|
903
|
+
};
|
|
904
|
+
_proto._getTrigger = function _getTrigger(index1, index2) {
|
|
905
|
+
var event;
|
|
906
|
+
if (this._eventPool.length) {
|
|
907
|
+
event = this._eventPool.pop();
|
|
908
|
+
event.index1 = index1;
|
|
909
|
+
event.index2 = index2;
|
|
910
|
+
} else {
|
|
911
|
+
event = new TriggerEvent(index1, index2);
|
|
912
|
+
}
|
|
913
|
+
this._eventMap[index1][index2] = event;
|
|
914
|
+
return event;
|
|
915
|
+
};
|
|
916
|
+
_proto._collisionDetection = function _collisionDetection(deltaTime, myCollider) {
|
|
917
|
+
var colliders = this._colliders;
|
|
918
|
+
var myColliderShapes = myCollider._shapes;
|
|
919
|
+
for(var i = 0, len = myColliderShapes.length; i < len; i++){
|
|
920
|
+
var myShape = myColliderShapes[i];
|
|
921
|
+
if (_instanceof__default['default'](myShape, LiteBoxColliderShape)) {
|
|
922
|
+
LitePhysicsManager._updateWorldBox(myShape, this._box);
|
|
923
|
+
for(var j = 0, len1 = colliders.length; j < len1; j++){
|
|
924
|
+
var colliderShape = colliders[j]._shapes;
|
|
925
|
+
for(var k = 0, len2 = colliderShape.length; k < len2; k++){
|
|
926
|
+
var shape = colliderShape[k];
|
|
927
|
+
var index1 = shape._id;
|
|
928
|
+
var index2 = myShape._id;
|
|
929
|
+
var event = index1 < index2 ? this._eventMap[index1][index2] : this._eventMap[index2][index1];
|
|
930
|
+
if (event !== undefined && !event.alreadyInvoked) {
|
|
931
|
+
continue;
|
|
932
|
+
}
|
|
933
|
+
if (shape != myShape && this._boxCollision(shape)) {
|
|
934
|
+
if (event === undefined) {
|
|
935
|
+
var event1 = index1 < index2 ? this._getTrigger(index1, index2) : this._getTrigger(index2, index1);
|
|
936
|
+
event1.state = 0;
|
|
937
|
+
event1.alreadyInvoked = false;
|
|
938
|
+
this._currentEvents.add(event1);
|
|
939
|
+
} else if (event.state === 0) {
|
|
940
|
+
event.state = 1;
|
|
941
|
+
event.alreadyInvoked = false;
|
|
942
|
+
} else if (event.state === 1) {
|
|
943
|
+
event.alreadyInvoked = false;
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
} else if (_instanceof__default['default'](myShape, LiteSphereColliderShape)) {
|
|
949
|
+
LitePhysicsManager._upWorldSphere(myShape, this._sphere);
|
|
950
|
+
for(var j1 = 0, len3 = colliders.length; j1 < len3; j1++){
|
|
951
|
+
var colliderShape1 = colliders[j1]._shapes;
|
|
952
|
+
for(var k1 = 0, len4 = colliderShape1.length; k1 < len4; k1++){
|
|
953
|
+
var shape1 = colliderShape1[k1];
|
|
954
|
+
var index11 = shape1._id;
|
|
955
|
+
var index21 = myShape._id;
|
|
956
|
+
var event2 = index11 < index21 ? this._eventMap[index11][index21] : this._eventMap[index21][index11];
|
|
957
|
+
if (event2 !== undefined && !event2.alreadyInvoked) {
|
|
958
|
+
continue;
|
|
959
|
+
}
|
|
960
|
+
if (shape1 != myShape && this._sphereCollision(shape1)) {
|
|
961
|
+
if (event2 === undefined) {
|
|
962
|
+
var event3 = index11 < index21 ? this._getTrigger(index11, index21) : this._getTrigger(index21, index11);
|
|
963
|
+
event3.state = 0;
|
|
964
|
+
event3.alreadyInvoked = false;
|
|
965
|
+
this._currentEvents.add(event3);
|
|
966
|
+
} else if (event2.state === 0) {
|
|
967
|
+
event2.state = 1;
|
|
968
|
+
event2.alreadyInvoked = false;
|
|
969
|
+
} else if (event2.state === 1) {
|
|
970
|
+
event2.alreadyInvoked = false;
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
};
|
|
978
|
+
_proto._fireEvent = function _fireEvent() {
|
|
979
|
+
var _this = this, eventPool = _this._eventPool, currentEvents = _this._currentEvents;
|
|
980
|
+
for(var i = currentEvents.length - 1; i >= 0; i--){
|
|
981
|
+
var event = currentEvents.get(i);
|
|
982
|
+
if (!event.alreadyInvoked) {
|
|
983
|
+
if (event.state == 0) {
|
|
984
|
+
this._onTriggerEnter(event.index1, event.index2);
|
|
985
|
+
event.alreadyInvoked = true;
|
|
986
|
+
} else if (event.state == 1) {
|
|
987
|
+
this._onTriggerStay(event.index1, event.index2);
|
|
988
|
+
event.alreadyInvoked = true;
|
|
989
|
+
}
|
|
990
|
+
} else {
|
|
991
|
+
event.state = 2;
|
|
992
|
+
this._eventMap[event.index1][event.index2] = undefined;
|
|
993
|
+
this._onTriggerExit(event.index1, event.index2);
|
|
994
|
+
currentEvents.deleteByIndex(i);
|
|
995
|
+
eventPool.push(event);
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
};
|
|
999
|
+
_proto._boxCollision = function _boxCollision(other) {
|
|
1000
|
+
if (_instanceof__default['default'](other, LiteBoxColliderShape)) {
|
|
1001
|
+
var box = LitePhysicsManager._tempBox;
|
|
1002
|
+
LitePhysicsManager._updateWorldBox(other, box);
|
|
1003
|
+
return engine.CollisionUtil.intersectsBoxAndBox(box, this._box);
|
|
1004
|
+
} else if (_instanceof__default['default'](other, LiteSphereColliderShape)) {
|
|
1005
|
+
var sphere = LitePhysicsManager._tempSphere;
|
|
1006
|
+
LitePhysicsManager._upWorldSphere(other, sphere);
|
|
1007
|
+
return engine.CollisionUtil.intersectsSphereAndBox(sphere, this._box);
|
|
1008
|
+
}
|
|
1009
|
+
return false;
|
|
1010
|
+
};
|
|
1011
|
+
_proto._sphereCollision = function _sphereCollision(other) {
|
|
1012
|
+
if (_instanceof__default['default'](other, LiteBoxColliderShape)) {
|
|
1013
|
+
var box = LitePhysicsManager._tempBox;
|
|
1014
|
+
LitePhysicsManager._updateWorldBox(other, box);
|
|
1015
|
+
return engine.CollisionUtil.intersectsSphereAndBox(this._sphere, box);
|
|
1016
|
+
} else if (_instanceof__default['default'](other, LiteSphereColliderShape)) {
|
|
1017
|
+
var sphere = LitePhysicsManager._tempSphere;
|
|
1018
|
+
LitePhysicsManager._upWorldSphere(other, sphere);
|
|
1019
|
+
return engine.CollisionUtil.intersectsSphereAndSphere(sphere, this._sphere);
|
|
1020
|
+
}
|
|
1021
|
+
return false;
|
|
1022
|
+
};
|
|
1023
|
+
/**
|
|
1024
|
+
* Calculate the bounding box in world space from boxCollider.
|
|
1025
|
+
* @param boxCollider - The boxCollider to calculate
|
|
1026
|
+
* @param out - The calculated boundingBox
|
|
1027
|
+
*/ LitePhysicsManager._updateWorldBox = function _updateWorldBox(boxCollider, out) {
|
|
1028
|
+
var mat = boxCollider._transform.worldMatrix;
|
|
1029
|
+
out.min.copyFrom(boxCollider._boxMin);
|
|
1030
|
+
out.max.copyFrom(boxCollider._boxMax);
|
|
1031
|
+
engine.BoundingBox.transform(out, mat, out);
|
|
1032
|
+
};
|
|
1033
|
+
/**
|
|
1034
|
+
* Get the sphere info of the given sphere collider in world space.
|
|
1035
|
+
* @param sphereCollider - The given sphere collider
|
|
1036
|
+
* @param out - The calculated boundingSphere
|
|
1037
|
+
*/ LitePhysicsManager._upWorldSphere = function _upWorldSphere(sphereCollider, out) {
|
|
1038
|
+
engine.Vector3.transformCoordinate(sphereCollider._transform.position, sphereCollider._transform.worldMatrix, out.center);
|
|
1039
|
+
out.radius = sphereCollider.worldRadius;
|
|
1040
|
+
};
|
|
1041
|
+
return LitePhysicsManager;
|
|
1042
|
+
}();
|
|
1043
|
+
LitePhysicsManager._tempSphere = new engine.BoundingSphere();
|
|
1044
|
+
LitePhysicsManager._tempBox = new engine.BoundingBox();
|
|
1045
|
+
LitePhysicsManager._currentHit = new LiteHitResult();
|
|
1046
|
+
LitePhysicsManager._hitResult = new LiteHitResult();
|
|
1047
|
+
var /**
|
|
1048
|
+
* Physics state
|
|
1049
|
+
*/ TriggerEventState;
|
|
1050
|
+
(function(TriggerEventState) {
|
|
1051
|
+
TriggerEventState[TriggerEventState["Enter"] = 0] = "Enter";
|
|
1052
|
+
TriggerEventState[TriggerEventState["Stay"] = 1] = "Stay";
|
|
1053
|
+
TriggerEventState[TriggerEventState["Exit"] = 2] = "Exit";
|
|
1054
|
+
})(TriggerEventState || (TriggerEventState = {}));
|
|
1055
|
+
/**
|
|
1056
|
+
* Trigger event to store interactive object ids and state.
|
|
1057
|
+
*/ var TriggerEvent = function TriggerEvent(index1, index2) {
|
|
1058
|
+
this.alreadyInvoked = false;
|
|
1059
|
+
this.index1 = index1;
|
|
1060
|
+
this.index2 = index2;
|
|
1061
|
+
};
|
|
1141
1062
|
|
|
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
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1063
|
+
/**
|
|
1064
|
+
* Physics material describes how to handle colliding objects (friction, bounciness).
|
|
1065
|
+
*/ var LitePhysicsMaterial = /*#__PURE__*/ function() {
|
|
1066
|
+
function LitePhysicsMaterial(staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine) {}
|
|
1067
|
+
var _proto = LitePhysicsMaterial.prototype;
|
|
1068
|
+
/**
|
|
1069
|
+
* {@inheritDoc IPhysicsMaterial.setBounciness }
|
|
1070
|
+
*/ _proto.setBounciness = function setBounciness(value) {
|
|
1071
|
+
throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
|
|
1072
|
+
};
|
|
1073
|
+
/**
|
|
1074
|
+
* {@inheritDoc IPhysicsMaterial.setDynamicFriction }
|
|
1075
|
+
*/ _proto.setDynamicFriction = function setDynamicFriction(value) {
|
|
1076
|
+
throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
|
|
1077
|
+
};
|
|
1078
|
+
/**
|
|
1079
|
+
* {@inheritDoc IPhysicsMaterial.setStaticFriction }
|
|
1080
|
+
*/ _proto.setStaticFriction = function setStaticFriction(value) {
|
|
1081
|
+
throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
|
|
1082
|
+
};
|
|
1083
|
+
/**
|
|
1084
|
+
* {@inheritDoc IPhysicsMaterial.setBounceCombine }
|
|
1085
|
+
*/ _proto.setBounceCombine = function setBounceCombine(value) {
|
|
1086
|
+
throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
|
|
1087
|
+
};
|
|
1088
|
+
/**
|
|
1089
|
+
* {@inheritDoc IPhysicsMaterial.setFrictionCombine }
|
|
1090
|
+
*/ _proto.setFrictionCombine = function setFrictionCombine(value) {
|
|
1091
|
+
throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
|
|
1092
|
+
};
|
|
1093
|
+
/**
|
|
1094
|
+
* {@inheritDoc IPhysicsMaterial.destroy }
|
|
1095
|
+
*/ _proto.destroy = function destroy() {};
|
|
1096
|
+
return LitePhysicsMaterial;
|
|
1097
|
+
}();
|
|
1177
1098
|
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1099
|
+
/**
|
|
1100
|
+
* A static collider component that will not move.
|
|
1101
|
+
* @remarks Mostly used for object which always stays at the same place and never moves around.
|
|
1102
|
+
*/ var LiteStaticCollider = /*#__PURE__*/ function(LiteCollider) {
|
|
1103
|
+
_inherits__default['default'](LiteStaticCollider, LiteCollider);
|
|
1104
|
+
function LiteStaticCollider(position, rotation) {
|
|
1105
|
+
var _this;
|
|
1106
|
+
_this = LiteCollider.call(this) || this;
|
|
1107
|
+
_this._transform.setPosition(position.x, position.y, position.z);
|
|
1108
|
+
_this._transform.setRotationQuaternion(rotation.x, rotation.y, rotation.z, rotation.w);
|
|
1109
|
+
return _this;
|
|
1110
|
+
}
|
|
1111
|
+
return LiteStaticCollider;
|
|
1112
|
+
}(LiteCollider);
|
|
1192
1113
|
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1114
|
+
/**
|
|
1115
|
+
* Static interface implement decorator.
|
|
1116
|
+
* https://stackoverflow.com/questions/13955157/how-to-define-static-property-in-typescript-interface
|
|
1117
|
+
*/ function StaticInterfaceImplement() {
|
|
1118
|
+
return function(constructor) {
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1200
1121
|
|
|
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
|
-
|
|
1122
|
+
exports.LitePhysics = /*#__PURE__*/ function() {
|
|
1123
|
+
function LitePhysics() {}
|
|
1124
|
+
/**
|
|
1125
|
+
* {@inheritDoc IPhysics.createPhysicsManager }
|
|
1126
|
+
*/ LitePhysics.createPhysicsManager = function createPhysicsManager(onContactBegin, onContactEnd, onContactPersist, onTriggerBegin, onTriggerEnd, onTriggerPersist) {
|
|
1127
|
+
return new LitePhysicsManager(onContactBegin, onContactEnd, onContactPersist, onTriggerBegin, onTriggerEnd, onTriggerPersist);
|
|
1128
|
+
};
|
|
1129
|
+
/**
|
|
1130
|
+
* {@inheritDoc IPhysics.createStaticCollider }
|
|
1131
|
+
*/ LitePhysics.createStaticCollider = function createStaticCollider(position, rotation) {
|
|
1132
|
+
return new LiteStaticCollider(position, rotation);
|
|
1133
|
+
};
|
|
1134
|
+
/**
|
|
1135
|
+
* {@inheritDoc IPhysics.createDynamicCollider }
|
|
1136
|
+
*/ LitePhysics.createDynamicCollider = function createDynamicCollider(position, rotation) {
|
|
1137
|
+
return new LiteDynamicCollider(position, rotation);
|
|
1138
|
+
};
|
|
1139
|
+
/**
|
|
1140
|
+
* {@inheritDoc IPhysics.createCharacterController }
|
|
1141
|
+
*/ LitePhysics.createCharacterController = function createCharacterController() {
|
|
1142
|
+
throw "Physics-lite don't support createCharacterController. Use Physics-PhysX instead!";
|
|
1143
|
+
};
|
|
1144
|
+
/**
|
|
1145
|
+
* {@inheritDoc IPhysics.createPhysicsMaterial }
|
|
1146
|
+
*/ LitePhysics.createPhysicsMaterial = function createPhysicsMaterial(staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine) {
|
|
1147
|
+
return new LitePhysicsMaterial(staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine);
|
|
1148
|
+
};
|
|
1149
|
+
/**
|
|
1150
|
+
* {@inheritDoc IPhysics.createBoxColliderShape }
|
|
1151
|
+
*/ LitePhysics.createBoxColliderShape = function createBoxColliderShape(uniqueID, size, material) {
|
|
1152
|
+
return new LiteBoxColliderShape(uniqueID, size, material);
|
|
1153
|
+
};
|
|
1154
|
+
/**
|
|
1155
|
+
* {@inheritDoc IPhysics.createSphereColliderShape }
|
|
1156
|
+
*/ LitePhysics.createSphereColliderShape = function createSphereColliderShape(uniqueID, radius, material) {
|
|
1157
|
+
return new LiteSphereColliderShape(uniqueID, radius, material);
|
|
1158
|
+
};
|
|
1159
|
+
/**
|
|
1160
|
+
* {@inheritDoc IPhysics.createPlaneColliderShape }
|
|
1161
|
+
*/ LitePhysics.createPlaneColliderShape = function createPlaneColliderShape(uniqueID, material) {
|
|
1162
|
+
throw "Physics-lite don't support PlaneColliderShape. Use Physics-PhysX instead!";
|
|
1163
|
+
};
|
|
1164
|
+
/**
|
|
1165
|
+
* {@inheritDoc IPhysics.createCapsuleColliderShape }
|
|
1166
|
+
*/ LitePhysics.createCapsuleColliderShape = function createCapsuleColliderShape(uniqueID, radius, height, material) {
|
|
1167
|
+
throw "Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!";
|
|
1168
|
+
};
|
|
1169
|
+
/**
|
|
1170
|
+
* {@inheritDoc IPhysics.createFixedJoint }
|
|
1171
|
+
*/ LitePhysics.createFixedJoint = function createFixedJoint(collider) {
|
|
1172
|
+
throw "Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!";
|
|
1173
|
+
};
|
|
1174
|
+
/**
|
|
1175
|
+
* {@inheritDoc IPhysics.createHingeJoint }
|
|
1176
|
+
*/ LitePhysics.createHingeJoint = function createHingeJoint(collider) {
|
|
1177
|
+
throw "Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!";
|
|
1178
|
+
};
|
|
1179
|
+
/**
|
|
1180
|
+
* {@inheritDoc IPhysics.createSpringJoint }
|
|
1181
|
+
*/ LitePhysics.createSpringJoint = function createSpringJoint(collider) {
|
|
1182
|
+
throw "Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!";
|
|
1183
|
+
};
|
|
1184
|
+
return LitePhysics;
|
|
1185
|
+
}();
|
|
1186
|
+
exports.LitePhysics = _ts_decorate__default['default']([
|
|
1187
|
+
StaticInterfaceImplement()
|
|
1188
|
+
], exports.LitePhysics);
|
|
1268
1189
|
|
|
1269
|
-
|
|
1190
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1270
1191
|
|
|
1271
|
-
}));
|
|
1192
|
+
})));
|