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