@galacean/engine-physics-lite 0.0.0-experimental-1.3-xr.9 → 0.0.0-experimental-1.4-small-language.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +239 -221
- 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 +239 -221
- package/dist/main.js.map +1 -1
- package/dist/module.js +239 -221
- package/dist/module.js.map +1 -1
- package/package.json +7 -4
- package/types/LiteDynamicCollider.d.ts +28 -0
- package/types/LitePhysics.d.ts +6 -2
- package/types/LitePhysicsScene.d.ts +13 -18
- package/types/shape/LiteBoxColliderShape.d.ts +7 -1
- package/types/shape/LiteColliderShape.d.ts +11 -2
- package/types/shape/LiteSphereColliderShape.d.ts +5 -1
- package/dist/miniprogram.js +0 -1278
- package/types/DisorderedArray.d.ts +0 -18
package/dist/module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Utils,
|
|
1
|
+
import { Utils, Vector3, Quaternion, Vector4, Ray, MathUtil, Matrix, Logger, BoundingBox, BoundingSphere, DisorderedArray, CollisionUtil } from '@galacean/engine';
|
|
2
2
|
|
|
3
3
|
function _set_prototype_of(o, p) {
|
|
4
4
|
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
@@ -90,6 +90,7 @@ function _instanceof(left, right) {
|
|
|
90
90
|
/** @internal */ this._worldScale = new Vector3(1, 1, 1);
|
|
91
91
|
/** @internal */ this._transform = new LiteTransform();
|
|
92
92
|
/** @internal */ this._invModelMatrix = new Matrix();
|
|
93
|
+
this._rotation = new Vector3();
|
|
93
94
|
this._transform.owner = this;
|
|
94
95
|
this._inverseWorldMatFlag = this._transform.registerWorldChangeFlag();
|
|
95
96
|
}
|
|
@@ -97,7 +98,8 @@ function _instanceof(left, right) {
|
|
|
97
98
|
/**
|
|
98
99
|
* {@inheritDoc IColliderShape.setRotation }
|
|
99
100
|
*/ _proto.setRotation = function setRotation(rotation) {
|
|
100
|
-
|
|
101
|
+
var rotationInRadians = this._rotation.set(MathUtil.degreeToRadian(rotation.x), MathUtil.degreeToRadian(rotation.y), MathUtil.degreeToRadian(rotation.z));
|
|
102
|
+
Quaternion.rotationEuler(rotationInRadians.x, rotationInRadians.y, rotationInRadians.z, this._transform.rotationQuaternion);
|
|
101
103
|
};
|
|
102
104
|
/**
|
|
103
105
|
* {@inheritDoc IColliderShape.setPosition }
|
|
@@ -172,12 +174,12 @@ function _instanceof(left, right) {
|
|
|
172
174
|
};
|
|
173
175
|
return LiteColliderShape;
|
|
174
176
|
}();
|
|
175
|
-
(
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
(
|
|
179
|
-
|
|
180
|
-
|
|
177
|
+
LiteColliderShape._tempPos = new Vector3();
|
|
178
|
+
LiteColliderShape._tempRot = new Quaternion();
|
|
179
|
+
LiteColliderShape._tempScale = new Vector3();
|
|
180
|
+
LiteColliderShape._tempPoint = new Vector3();
|
|
181
|
+
LiteColliderShape._tempVector4 = new Vector4();
|
|
182
|
+
LiteColliderShape._ray = new Ray();
|
|
181
183
|
|
|
182
184
|
/**
|
|
183
185
|
* Used to implement transformation related functions.
|
|
@@ -193,7 +195,7 @@ function _instanceof(left, right) {
|
|
|
193
195
|
this._updateFlagManager = new LiteUpdateFlagManager();
|
|
194
196
|
this._isParentDirty = true;
|
|
195
197
|
this._parentTransformCache = null;
|
|
196
|
-
this._dirtyFlag =
|
|
198
|
+
this._dirtyFlag = 188;
|
|
197
199
|
}
|
|
198
200
|
var _proto = LiteTransform.prototype;
|
|
199
201
|
/**
|
|
@@ -235,8 +237,8 @@ function _instanceof(left, right) {
|
|
|
235
237
|
* Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
|
|
236
238
|
* In summary, any update of related variables will cause the dirty mark of one of the full process (worldMatrix or worldRotationQuaternion) to be false.
|
|
237
239
|
*/ _proto._updateWorldPositionFlag = function _updateWorldPositionFlag() {
|
|
238
|
-
if (!this._isContainDirtyFlags(
|
|
239
|
-
this._worldAssociatedChange(
|
|
240
|
+
if (!this._isContainDirtyFlags(132)) {
|
|
241
|
+
this._worldAssociatedChange(132);
|
|
240
242
|
if (_instanceof(this._owner, LiteCollider)) {
|
|
241
243
|
var shapes = this._owner._shapes;
|
|
242
244
|
for(var i = 0, n = shapes.length; i < n; i++){
|
|
@@ -252,8 +254,8 @@ function _instanceof(left, right) {
|
|
|
252
254
|
* Get worldRotation: Will trigger the world rotation(in euler and quaternion) update of itself and world rotation(in quaternion) update of all parent entities.
|
|
253
255
|
* In summary, any update of related variables will cause the dirty mark of one of the full process (worldMatrix or worldRotationQuaternion) to be false.
|
|
254
256
|
*/ _proto._updateWorldRotationFlag = function _updateWorldRotationFlag() {
|
|
255
|
-
if (!this._isContainDirtyFlags(
|
|
256
|
-
this._worldAssociatedChange(
|
|
257
|
+
if (!this._isContainDirtyFlags(152)) {
|
|
258
|
+
this._worldAssociatedChange(152);
|
|
257
259
|
if (_instanceof(this._owner, LiteCollider)) {
|
|
258
260
|
var shapes = this._owner._shapes;
|
|
259
261
|
for(var i = 0, n = shapes.length; i < n; i++){
|
|
@@ -268,8 +270,8 @@ function _instanceof(left, right) {
|
|
|
268
270
|
* Get worldScale: Will trigger the scaling update of itself and all parent entities.
|
|
269
271
|
* In summary, any update of related variables will cause the dirty mark of one of the full process (worldMatrix) to be false.
|
|
270
272
|
*/ _proto._updateWorldScaleFlag = function _updateWorldScaleFlag() {
|
|
271
|
-
if (!this._isContainDirtyFlags(
|
|
272
|
-
this._worldAssociatedChange(
|
|
273
|
+
if (!this._isContainDirtyFlags(160)) {
|
|
274
|
+
this._worldAssociatedChange(160);
|
|
273
275
|
if (_instanceof(this._owner, LiteCollider)) {
|
|
274
276
|
var shapes = this._owner._shapes;
|
|
275
277
|
for(var i = 0, n = shapes.length; i < n; i++){
|
|
@@ -281,8 +283,8 @@ function _instanceof(left, right) {
|
|
|
281
283
|
/**
|
|
282
284
|
* Update all world transform property dirty flag, the principle is the same as above.
|
|
283
285
|
*/ _proto._updateAllWorldFlag = function _updateAllWorldFlag() {
|
|
284
|
-
if (!this._isContainDirtyFlags(
|
|
285
|
-
this._worldAssociatedChange(
|
|
286
|
+
if (!this._isContainDirtyFlags(188)) {
|
|
287
|
+
this._worldAssociatedChange(188);
|
|
286
288
|
if (_instanceof(this._owner, LiteCollider)) {
|
|
287
289
|
var shapes = this._owner._shapes;
|
|
288
290
|
for(var i = 0, n = shapes.length; i < n; i++){
|
|
@@ -339,7 +341,7 @@ function _instanceof(left, right) {
|
|
|
339
341
|
if (this._position !== value) {
|
|
340
342
|
this._position.copyFrom(value);
|
|
341
343
|
}
|
|
342
|
-
this._setDirtyFlagTrue(
|
|
344
|
+
this._setDirtyFlagTrue(64);
|
|
343
345
|
this._updateWorldPositionFlag();
|
|
344
346
|
}
|
|
345
347
|
},
|
|
@@ -349,9 +351,9 @@ function _instanceof(left, right) {
|
|
|
349
351
|
* Local rotation, defining the rotation by using a unit quaternion.
|
|
350
352
|
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
351
353
|
*/ function get() {
|
|
352
|
-
if (this._isContainDirtyFlag(
|
|
354
|
+
if (this._isContainDirtyFlag(2)) {
|
|
353
355
|
Quaternion.rotationEuler(MathUtil.degreeToRadian(this._rotation.x), MathUtil.degreeToRadian(this._rotation.y), MathUtil.degreeToRadian(this._rotation.z), this._rotationQuaternion);
|
|
354
|
-
this._setDirtyFlagFalse(
|
|
356
|
+
this._setDirtyFlagFalse(2);
|
|
355
357
|
}
|
|
356
358
|
return this._rotationQuaternion;
|
|
357
359
|
},
|
|
@@ -359,8 +361,8 @@ function _instanceof(left, right) {
|
|
|
359
361
|
if (this._rotationQuaternion !== value) {
|
|
360
362
|
this._rotationQuaternion.copyFrom(value);
|
|
361
363
|
}
|
|
362
|
-
this._setDirtyFlagTrue(
|
|
363
|
-
this._setDirtyFlagFalse(
|
|
364
|
+
this._setDirtyFlagTrue(64 | 1);
|
|
365
|
+
this._setDirtyFlagFalse(2);
|
|
364
366
|
this._updateWorldRotationFlag();
|
|
365
367
|
}
|
|
366
368
|
},
|
|
@@ -370,14 +372,14 @@ function _instanceof(left, right) {
|
|
|
370
372
|
* World rotation, defining the rotation by using a unit quaternion.
|
|
371
373
|
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
372
374
|
*/ function get() {
|
|
373
|
-
if (this._isContainDirtyFlag(
|
|
375
|
+
if (this._isContainDirtyFlag(16)) {
|
|
374
376
|
var parent = this._getParentTransform();
|
|
375
377
|
if (parent != null) {
|
|
376
378
|
Quaternion.multiply(parent.worldRotationQuaternion, this.rotationQuaternion, this._worldRotationQuaternion);
|
|
377
379
|
} else {
|
|
378
380
|
this._worldRotationQuaternion.copyFrom(this.rotationQuaternion);
|
|
379
381
|
}
|
|
380
|
-
this._setDirtyFlagFalse(
|
|
382
|
+
this._setDirtyFlagFalse(16);
|
|
381
383
|
}
|
|
382
384
|
return this._worldRotationQuaternion;
|
|
383
385
|
},
|
|
@@ -393,7 +395,7 @@ function _instanceof(left, right) {
|
|
|
393
395
|
this._rotationQuaternion.copyFrom(value);
|
|
394
396
|
}
|
|
395
397
|
this.rotationQuaternion = this._rotationQuaternion;
|
|
396
|
-
this._setDirtyFlagFalse(
|
|
398
|
+
this._setDirtyFlagFalse(16);
|
|
397
399
|
}
|
|
398
400
|
},
|
|
399
401
|
{
|
|
@@ -408,7 +410,7 @@ function _instanceof(left, right) {
|
|
|
408
410
|
if (this._scale !== value) {
|
|
409
411
|
this._scale.copyFrom(value);
|
|
410
412
|
}
|
|
411
|
-
this._setDirtyFlagTrue(
|
|
413
|
+
this._setDirtyFlagTrue(64);
|
|
412
414
|
this._updateWorldScaleFlag();
|
|
413
415
|
}
|
|
414
416
|
},
|
|
@@ -418,9 +420,9 @@ function _instanceof(left, right) {
|
|
|
418
420
|
* Local matrix.
|
|
419
421
|
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
420
422
|
*/ function get() {
|
|
421
|
-
if (this._isContainDirtyFlag(
|
|
423
|
+
if (this._isContainDirtyFlag(64)) {
|
|
422
424
|
Matrix.affineTransformation(this._scale, this.rotationQuaternion, this._position, this._localMatrix);
|
|
423
|
-
this._setDirtyFlagFalse(
|
|
425
|
+
this._setDirtyFlagFalse(64);
|
|
424
426
|
}
|
|
425
427
|
return this._localMatrix;
|
|
426
428
|
},
|
|
@@ -429,8 +431,8 @@ function _instanceof(left, right) {
|
|
|
429
431
|
this._localMatrix.copyFrom(value);
|
|
430
432
|
}
|
|
431
433
|
this._localMatrix.decompose(this._position, this._rotationQuaternion, this._scale);
|
|
432
|
-
this._setDirtyFlagTrue(
|
|
433
|
-
this._setDirtyFlagFalse(
|
|
434
|
+
this._setDirtyFlagTrue(1);
|
|
435
|
+
this._setDirtyFlagFalse(64);
|
|
434
436
|
this._updateAllWorldFlag();
|
|
435
437
|
}
|
|
436
438
|
},
|
|
@@ -440,14 +442,14 @@ function _instanceof(left, right) {
|
|
|
440
442
|
* World matrix.
|
|
441
443
|
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
442
444
|
*/ function get() {
|
|
443
|
-
if (this._isContainDirtyFlag(
|
|
445
|
+
if (this._isContainDirtyFlag(128)) {
|
|
444
446
|
var parent = this._getParentTransform();
|
|
445
447
|
if (parent) {
|
|
446
448
|
Matrix.multiply(parent.worldMatrix, this.localMatrix, this._worldMatrix);
|
|
447
449
|
} else {
|
|
448
450
|
this._worldMatrix.copyFrom(this.localMatrix);
|
|
449
451
|
}
|
|
450
|
-
this._setDirtyFlagFalse(
|
|
452
|
+
this._setDirtyFlagFalse(128);
|
|
451
453
|
}
|
|
452
454
|
return this._worldMatrix;
|
|
453
455
|
},
|
|
@@ -463,37 +465,14 @@ function _instanceof(left, right) {
|
|
|
463
465
|
this._localMatrix.copyFrom(value);
|
|
464
466
|
}
|
|
465
467
|
this.localMatrix = this._localMatrix;
|
|
466
|
-
this._setDirtyFlagFalse(
|
|
468
|
+
this._setDirtyFlagFalse(128);
|
|
467
469
|
}
|
|
468
470
|
}
|
|
469
471
|
]);
|
|
470
472
|
return LiteTransform;
|
|
471
473
|
}();
|
|
472
|
-
(
|
|
473
|
-
|
|
474
|
-
})();
|
|
475
|
-
(function() {
|
|
476
|
-
LiteTransform._tempMat42 = new Matrix();
|
|
477
|
-
})();
|
|
478
|
-
var /**
|
|
479
|
-
* Dirty flag of transform.
|
|
480
|
-
*/ TransformFlag;
|
|
481
|
-
(function(TransformFlag) {
|
|
482
|
-
TransformFlag[TransformFlag["LocalEuler"] = 0x1] = "LocalEuler";
|
|
483
|
-
TransformFlag[TransformFlag["LocalQuat"] = 0x2] = "LocalQuat";
|
|
484
|
-
TransformFlag[TransformFlag["WorldPosition"] = 0x4] = "WorldPosition";
|
|
485
|
-
TransformFlag[TransformFlag["WorldEuler"] = 0x8] = "WorldEuler";
|
|
486
|
-
TransformFlag[TransformFlag["WorldQuat"] = 0x10] = "WorldQuat";
|
|
487
|
-
TransformFlag[TransformFlag["WorldScale"] = 0x20] = "WorldScale";
|
|
488
|
-
TransformFlag[TransformFlag["LocalMatrix"] = 0x40] = "LocalMatrix";
|
|
489
|
-
TransformFlag[TransformFlag["WorldMatrix"] = 0x80] = "WorldMatrix";
|
|
490
|
-
TransformFlag[TransformFlag[/** WorldMatrix | WorldPosition */ "WmWp"] = 0x84] = "WmWp";
|
|
491
|
-
TransformFlag[TransformFlag[/** WorldMatrix | WorldEuler | WorldQuat */ "WmWeWq"] = 0x98] = "WmWeWq";
|
|
492
|
-
TransformFlag[TransformFlag[/** WorldMatrix | WorldPosition | WorldEuler | WorldQuat */ "WmWpWeWq"] = 0x9c] = "WmWpWeWq";
|
|
493
|
-
TransformFlag[TransformFlag[/** WorldMatrix | WorldScale */ "WmWs"] = 0xa0] = "WmWs";
|
|
494
|
-
TransformFlag[TransformFlag[/** WorldMatrix | WorldPosition | WorldScale */ "WmWpWs"] = 0xa4] = "WmWpWs";
|
|
495
|
-
TransformFlag[TransformFlag[/** WorldMatrix | WorldPosition | WorldEuler | WorldQuat | WorldScale */ "WmWpWeWqWs"] = 0xbc] = "WmWpWeWqWs";
|
|
496
|
-
})(TransformFlag || (TransformFlag = {}));
|
|
474
|
+
LiteTransform._tempQuat0 = new Quaternion();
|
|
475
|
+
LiteTransform._tempMat42 = new Matrix();
|
|
497
476
|
|
|
498
477
|
/**
|
|
499
478
|
* Abstract class of physical collider.
|
|
@@ -509,11 +488,13 @@ var /**
|
|
|
509
488
|
*/ _proto.addShape = function addShape(shape) {
|
|
510
489
|
var oldCollider = shape._collider;
|
|
511
490
|
if (oldCollider !== this) {
|
|
491
|
+
var _this__scene;
|
|
512
492
|
if (oldCollider) {
|
|
513
493
|
oldCollider.removeShape(shape);
|
|
514
494
|
}
|
|
515
495
|
this._shapes.push(shape);
|
|
516
496
|
shape._collider = this;
|
|
497
|
+
(_this__scene = this._scene) == null ? void 0 : _this__scene._addColliderShape(shape);
|
|
517
498
|
}
|
|
518
499
|
};
|
|
519
500
|
/**
|
|
@@ -521,8 +502,10 @@ var /**
|
|
|
521
502
|
*/ _proto.removeShape = function removeShape(shape) {
|
|
522
503
|
var index = this._shapes.indexOf(shape);
|
|
523
504
|
if (index !== -1) {
|
|
505
|
+
var _this__scene;
|
|
524
506
|
this._shapes.splice(index, 1);
|
|
525
507
|
shape._collider = null;
|
|
508
|
+
(_this__scene = this._scene) == null ? void 0 : _this__scene._removeColliderShape(shape);
|
|
526
509
|
}
|
|
527
510
|
};
|
|
528
511
|
/**
|
|
@@ -557,18 +540,34 @@ var /**
|
|
|
557
540
|
|
|
558
541
|
/**
|
|
559
542
|
* A dynamic collider can act with self-defined movement or physical force
|
|
560
|
-
*/ var LiteDynamicCollider = /*#__PURE__*/ function(
|
|
561
|
-
_inherits(LiteDynamicCollider,
|
|
543
|
+
*/ var LiteDynamicCollider = /*#__PURE__*/ function(LiteCollider) {
|
|
544
|
+
_inherits(LiteDynamicCollider, LiteCollider);
|
|
562
545
|
function LiteDynamicCollider(position, rotation) {
|
|
563
546
|
var _this;
|
|
564
|
-
_this =
|
|
565
|
-
/** @internal */ _this._isStaticCollider = false;
|
|
547
|
+
_this = LiteCollider.call(this) || this, /** @internal */ _this._isStaticCollider = false;
|
|
566
548
|
_this._transform.setPosition(position.x, position.y, position.z);
|
|
567
549
|
_this._transform.setRotationQuaternion(rotation.x, rotation.y, rotation.z, rotation.w);
|
|
568
550
|
return _this;
|
|
569
551
|
}
|
|
570
552
|
var _proto = LiteDynamicCollider.prototype;
|
|
571
553
|
/**
|
|
554
|
+
* {@inheritDoc IDynamicCollider.getInertiaTensor }
|
|
555
|
+
*/ _proto.getInertiaTensor = function getInertiaTensor(out) {
|
|
556
|
+
Logger.error("Physics-lite don't support getInertiaTensor. Use Physics-PhysX instead!");
|
|
557
|
+
return out;
|
|
558
|
+
};
|
|
559
|
+
/**
|
|
560
|
+
* {@inheritDoc IDynamicCollider.getCenterOfMass }
|
|
561
|
+
*/ _proto.getCenterOfMass = function getCenterOfMass(out) {
|
|
562
|
+
Logger.error("Physics-lite don't support getCenterOfMass. Use Physics-PhysX instead!");
|
|
563
|
+
return out;
|
|
564
|
+
};
|
|
565
|
+
/**
|
|
566
|
+
* {@inheritDoc IDynamicCollider.setMassAndUpdateInertia }
|
|
567
|
+
*/ _proto.setMassAndUpdateInertia = function setMassAndUpdateInertia(mass) {
|
|
568
|
+
Logger.error("Physics-lite don't support setMassAndUpdateInertia. Use Physics-PhysX instead!");
|
|
569
|
+
};
|
|
570
|
+
/**
|
|
572
571
|
* {@inheritDoc IDynamicCollider.addForce }
|
|
573
572
|
*/ _proto.addForce = function addForce(force) {
|
|
574
573
|
throw "Physics-lite don't support addForce. Use Physics-PhysX instead!";
|
|
@@ -589,74 +588,96 @@ var /**
|
|
|
589
588
|
throw "Physics-lite don't support putToSleep. Use Physics-PhysX instead!";
|
|
590
589
|
};
|
|
591
590
|
/**
|
|
591
|
+
* {@inheritDoc IDynamicCollider.isSleeping }
|
|
592
|
+
*/ _proto.isSleeping = function isSleeping() {
|
|
593
|
+
throw "Physics-lite don't support isSleeping. Use Physics-PhysX instead!";
|
|
594
|
+
};
|
|
595
|
+
/**
|
|
592
596
|
* {@inheritDoc IDynamicCollider.setAngularDamping }
|
|
593
597
|
*/ _proto.setAngularDamping = function setAngularDamping(value) {
|
|
594
|
-
|
|
598
|
+
Logger.error("Physics-lite don't support setAngularDamping. Use Physics-PhysX instead!");
|
|
599
|
+
};
|
|
600
|
+
/**
|
|
601
|
+
* {@inheritDoc IDynamicCollider.getAngularVelocity }
|
|
602
|
+
*/ _proto.getAngularVelocity = function getAngularVelocity(out) {
|
|
603
|
+
Logger.error("Physics-lite don't support getAngularVelocity. Use Physics-PhysX instead!");
|
|
604
|
+
return out;
|
|
595
605
|
};
|
|
596
606
|
/**
|
|
597
607
|
* {@inheritDoc IDynamicCollider.setAngularVelocity }
|
|
598
608
|
*/ _proto.setAngularVelocity = function setAngularVelocity(value) {
|
|
599
|
-
|
|
609
|
+
Logger.error("Physics-lite don't support setAngularVelocity. Use Physics-PhysX instead!");
|
|
600
610
|
};
|
|
601
611
|
/**
|
|
602
612
|
* {@inheritDoc IDynamicCollider.setCenterOfMass }
|
|
603
613
|
*/ _proto.setCenterOfMass = function setCenterOfMass(value) {
|
|
604
|
-
|
|
614
|
+
Logger.error("Physics-lite don't support setCenterOfMass. Use Physics-PhysX instead!");
|
|
605
615
|
};
|
|
606
616
|
/**
|
|
607
617
|
* {@inheritDoc IDynamicCollider.setCollisionDetectionMode }
|
|
608
618
|
*/ _proto.setCollisionDetectionMode = function setCollisionDetectionMode(value) {
|
|
609
|
-
|
|
619
|
+
Logger.error("Physics-lite don't support setCollisionDetectionMode. Use Physics-PhysX instead!");
|
|
610
620
|
};
|
|
611
621
|
/**
|
|
612
622
|
* {@inheritDoc IDynamicCollider.setConstraints }
|
|
613
623
|
*/ _proto.setConstraints = function setConstraints(flags) {
|
|
614
|
-
|
|
624
|
+
Logger.error("Physics-lite don't support setConstraints. Use Physics-PhysX instead!");
|
|
615
625
|
};
|
|
616
626
|
/**
|
|
617
627
|
* {@inheritDoc IDynamicCollider.setInertiaTensor }
|
|
618
628
|
*/ _proto.setInertiaTensor = function setInertiaTensor(value) {
|
|
619
|
-
|
|
629
|
+
Logger.error("Physics-lite don't support setInertiaTensor. Use Physics-PhysX instead!");
|
|
630
|
+
};
|
|
631
|
+
/**
|
|
632
|
+
* {@inheritDoc IDynamicCollider.setUseGravity }
|
|
633
|
+
*/ _proto.setUseGravity = function setUseGravity(value) {
|
|
634
|
+
Logger.error("Physics-lite don't support setUseGravity. Use Physics-PhysX instead!");
|
|
620
635
|
};
|
|
621
636
|
/**
|
|
622
637
|
* {@inheritDoc IDynamicCollider.setIsKinematic }
|
|
623
638
|
*/ _proto.setIsKinematic = function setIsKinematic(value) {
|
|
624
|
-
|
|
639
|
+
Logger.error("Physics-lite don't support setIsKinematic. Use Physics-PhysX instead!");
|
|
625
640
|
};
|
|
626
641
|
/**
|
|
627
642
|
* {@inheritDoc IDynamicCollider.setLinearDamping }
|
|
628
643
|
*/ _proto.setLinearDamping = function setLinearDamping(value) {
|
|
629
|
-
|
|
644
|
+
Logger.error("Physics-lite don't support setLinearDamping. Use Physics-PhysX instead!");
|
|
645
|
+
};
|
|
646
|
+
/**
|
|
647
|
+
* {@inheritDoc IDynamicCollider.getLinearVelocity }
|
|
648
|
+
*/ _proto.getLinearVelocity = function getLinearVelocity(out) {
|
|
649
|
+
Logger.error("Physics-lite don't support getLinearVelocity. Use Physics-PhysX instead!");
|
|
650
|
+
return out;
|
|
630
651
|
};
|
|
631
652
|
/**
|
|
632
653
|
* {@inheritDoc IDynamicCollider.setLinearVelocity }
|
|
633
654
|
*/ _proto.setLinearVelocity = function setLinearVelocity(value) {
|
|
634
|
-
|
|
655
|
+
Logger.error("Physics-lite don't support setLinearVelocity. Use Physics-PhysX instead!");
|
|
635
656
|
};
|
|
636
657
|
/**
|
|
637
658
|
* {@inheritDoc IDynamicCollider.setMass }
|
|
638
659
|
*/ _proto.setMass = function setMass(value) {
|
|
639
|
-
|
|
660
|
+
Logger.error("Physics-lite don't support setMass. Use Physics-PhysX instead!");
|
|
640
661
|
};
|
|
641
662
|
/**
|
|
642
663
|
* {@inheritDoc IDynamicCollider.setMaxAngularVelocity }
|
|
643
664
|
*/ _proto.setMaxAngularVelocity = function setMaxAngularVelocity(value) {
|
|
644
|
-
|
|
665
|
+
Logger.error("Physics-lite don't support setMaxAngularVelocity. Use Physics-PhysX instead!");
|
|
645
666
|
};
|
|
646
667
|
/**
|
|
647
668
|
* {@inheritDoc IDynamicCollider.setMaxDepenetrationVelocity }
|
|
648
669
|
*/ _proto.setMaxDepenetrationVelocity = function setMaxDepenetrationVelocity(value) {
|
|
649
|
-
|
|
670
|
+
Logger.error("Physics-lite don't support setMaxDepenetrationVelocity. Use Physics-PhysX instead!");
|
|
650
671
|
};
|
|
651
672
|
/**
|
|
652
673
|
* {@inheritDoc IDynamicCollider.setSleepThreshold }
|
|
653
674
|
*/ _proto.setSleepThreshold = function setSleepThreshold(value) {
|
|
654
|
-
|
|
675
|
+
Logger.error("Physics-lite don't support setSleepThreshold. Use Physics-PhysX instead!");
|
|
655
676
|
};
|
|
656
677
|
/**
|
|
657
678
|
* {@inheritDoc IDynamicCollider.setSolverIterations }
|
|
658
679
|
*/ _proto.setSolverIterations = function setSolverIterations(value) {
|
|
659
|
-
|
|
680
|
+
Logger.error("Physics-lite don't support setSolverIterations. Use Physics-PhysX instead!");
|
|
660
681
|
};
|
|
661
682
|
/**
|
|
662
683
|
* {@inheritDoc IDynamicCollider.wakeUp }
|
|
@@ -702,52 +723,6 @@ var /**
|
|
|
702
723
|
return LitePhysicsMaterial;
|
|
703
724
|
}();
|
|
704
725
|
|
|
705
|
-
/**
|
|
706
|
-
* High-performance unordered array, delete uses exchange method to improve performance, internal capacity only increases.
|
|
707
|
-
*/ var DisorderedArray = /*#__PURE__*/ function() {
|
|
708
|
-
function DisorderedArray(count) {
|
|
709
|
-
if (count === void 0) count = 0;
|
|
710
|
-
this.length = 0;
|
|
711
|
-
this._elements = new Array(count);
|
|
712
|
-
}
|
|
713
|
-
var _proto = DisorderedArray.prototype;
|
|
714
|
-
_proto.add = function add(element) {
|
|
715
|
-
if (this.length === this._elements.length) this._elements.push(element);
|
|
716
|
-
else this._elements[this.length] = element;
|
|
717
|
-
this.length++;
|
|
718
|
-
};
|
|
719
|
-
_proto.delete = function _delete(element) {
|
|
720
|
-
//TODO: It can be optimized for custom binary search and other algorithms, currently this._elements>=this.length wastes performance.
|
|
721
|
-
var index = this._elements.indexOf(element);
|
|
722
|
-
this.deleteByIndex(index);
|
|
723
|
-
};
|
|
724
|
-
_proto.get = function get(index) {
|
|
725
|
-
if (index >= this.length) {
|
|
726
|
-
throw "Index is out of range.";
|
|
727
|
-
}
|
|
728
|
-
return this._elements[index];
|
|
729
|
-
};
|
|
730
|
-
/**
|
|
731
|
-
*
|
|
732
|
-
* @param index
|
|
733
|
-
* @returns The replaced item is used to reset its index.
|
|
734
|
-
*/ _proto.deleteByIndex = function deleteByIndex(index) {
|
|
735
|
-
var elements = this._elements;
|
|
736
|
-
var end = null;
|
|
737
|
-
var lastIndex = this.length - 1;
|
|
738
|
-
if (index !== lastIndex) {
|
|
739
|
-
end = elements[lastIndex];
|
|
740
|
-
elements[index] = end;
|
|
741
|
-
}
|
|
742
|
-
this.length--;
|
|
743
|
-
return end;
|
|
744
|
-
};
|
|
745
|
-
_proto.garbageCollection = function garbageCollection() {
|
|
746
|
-
this._elements.length = this.length;
|
|
747
|
-
};
|
|
748
|
-
return DisorderedArray;
|
|
749
|
-
}();
|
|
750
|
-
|
|
751
726
|
/**
|
|
752
727
|
* Structure used to get information back from a raycast or a sweep.
|
|
753
728
|
* @internal
|
|
@@ -764,11 +739,7 @@ var /**
|
|
|
764
739
|
_inherits(LiteBoxColliderShape, LiteColliderShape1);
|
|
765
740
|
function LiteBoxColliderShape(uniqueID, size, material) {
|
|
766
741
|
var _this;
|
|
767
|
-
_this = LiteColliderShape1.call(this) || this;
|
|
768
|
-
_this._halfSize = new Vector3();
|
|
769
|
-
_this._sizeScale = new Vector3(1, 1, 1);
|
|
770
|
-
/** @internal */ _this._boxMin = new Vector3(-0.5, -0.5, -0.5);
|
|
771
|
-
/** @internal */ _this._boxMax = new Vector3(0.5, 0.5, 0.5);
|
|
742
|
+
_this = LiteColliderShape1.call(this) || this, _this._halfSize = new Vector3(), _this._sizeScale = new Vector3(1, 1, 1), /** @internal */ _this._boxMin = new Vector3(-0.5, -0.5, -0.5), /** @internal */ _this._boxMax = new Vector3(0.5, 0.5, 0.5);
|
|
772
743
|
_this._id = uniqueID;
|
|
773
744
|
_this._halfSize.set(size.x * 0.5, size.y * 0.5, size.z * 0.5);
|
|
774
745
|
_this._setBondingBox();
|
|
@@ -795,6 +766,44 @@ var /**
|
|
|
795
766
|
this._setBondingBox();
|
|
796
767
|
};
|
|
797
768
|
/**
|
|
769
|
+
* {@inheritDoc IColliderShape.pointDistance }
|
|
770
|
+
*/ _proto.pointDistance = function pointDistance(point) {
|
|
771
|
+
var position = LiteColliderShape._tempPos;
|
|
772
|
+
var rotation = LiteColliderShape._tempRot;
|
|
773
|
+
this._transform.worldMatrix.decompose(position, rotation, LiteColliderShape._tempScale);
|
|
774
|
+
var _this__transform = this._transform, shapePosition = _this__transform.position;
|
|
775
|
+
var m = LiteBoxColliderShape._tempMatrix;
|
|
776
|
+
var invM = LiteBoxColliderShape._tempInvMatrix;
|
|
777
|
+
var p = LiteColliderShape._tempPoint;
|
|
778
|
+
var scale = this._sizeScale;
|
|
779
|
+
var boundingBox = LiteBoxColliderShape._tempBox;
|
|
780
|
+
var _this = this, _boxMin = _this._boxMin, _boxMax = _this._boxMax;
|
|
781
|
+
p.copyFrom(_boxMin);
|
|
782
|
+
p.subtract(shapePosition);
|
|
783
|
+
p.divide(scale);
|
|
784
|
+
boundingBox.min.copyFrom(p);
|
|
785
|
+
p.copyFrom(_boxMax);
|
|
786
|
+
p.subtract(shapePosition);
|
|
787
|
+
p.divide(scale);
|
|
788
|
+
boundingBox.max.copyFrom(p);
|
|
789
|
+
Matrix.affineTransformation(scale, rotation, position, m);
|
|
790
|
+
Matrix.invert(m, invM);
|
|
791
|
+
Vector3.transformCoordinate(point, invM, p);
|
|
792
|
+
var min = boundingBox.min;
|
|
793
|
+
var max = boundingBox.max;
|
|
794
|
+
p.x = Math.max(min.x, Math.min(p.x, max.x));
|
|
795
|
+
p.y = Math.max(min.y, Math.min(p.y, max.y));
|
|
796
|
+
p.z = Math.max(min.z, Math.min(p.z, max.z));
|
|
797
|
+
Vector3.transformCoordinate(p, m, p);
|
|
798
|
+
var res = LiteColliderShape._tempVector4;
|
|
799
|
+
if (Vector3.equals(p, point)) {
|
|
800
|
+
res.set(point.x, point.y, point.z, 0);
|
|
801
|
+
} else {
|
|
802
|
+
res.set(p.x, p.y, p.z, Vector3.distanceSquared(p, point));
|
|
803
|
+
}
|
|
804
|
+
return res;
|
|
805
|
+
};
|
|
806
|
+
/**
|
|
798
807
|
* @internal
|
|
799
808
|
*/ _proto._raycast = function _raycast(ray, hit) {
|
|
800
809
|
var localRay = this._getLocalRay(ray);
|
|
@@ -820,9 +829,9 @@ var /**
|
|
|
820
829
|
};
|
|
821
830
|
return LiteBoxColliderShape;
|
|
822
831
|
}(LiteColliderShape);
|
|
823
|
-
(
|
|
824
|
-
|
|
825
|
-
|
|
832
|
+
LiteBoxColliderShape._tempBox = new BoundingBox();
|
|
833
|
+
LiteBoxColliderShape._tempMatrix = new Matrix();
|
|
834
|
+
LiteBoxColliderShape._tempInvMatrix = new Matrix();
|
|
826
835
|
|
|
827
836
|
/**
|
|
828
837
|
* Sphere collider shape in Lite.
|
|
@@ -830,9 +839,7 @@ var /**
|
|
|
830
839
|
_inherits(LiteSphereColliderShape, LiteColliderShape1);
|
|
831
840
|
function LiteSphereColliderShape(uniqueID, radius, material) {
|
|
832
841
|
var _this;
|
|
833
|
-
_this = LiteColliderShape1.call(this) || this;
|
|
834
|
-
_this._radius = 1;
|
|
835
|
-
_this._maxScale = 1;
|
|
842
|
+
_this = LiteColliderShape1.call(this) || this, _this._radius = 1, _this._maxScale = 1;
|
|
836
843
|
_this._radius = radius;
|
|
837
844
|
_this._id = uniqueID;
|
|
838
845
|
return _this;
|
|
@@ -850,6 +857,27 @@ var /**
|
|
|
850
857
|
this._maxScale = Math.max(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z));
|
|
851
858
|
};
|
|
852
859
|
/**
|
|
860
|
+
* {@inheritDoc IColliderShape.pointDistance }
|
|
861
|
+
*/ _proto.pointDistance = function pointDistance(point) {
|
|
862
|
+
var position = LiteColliderShape._tempPos;
|
|
863
|
+
var worldRadius = this.worldRadius;
|
|
864
|
+
this._transform.worldMatrix.decompose(position, LiteColliderShape._tempRot, LiteColliderShape._tempScale);
|
|
865
|
+
var p = LiteColliderShape._tempPoint;
|
|
866
|
+
Vector3.subtract(point, position, p);
|
|
867
|
+
var distanceFromCenter = p.lengthSquared();
|
|
868
|
+
var direction = p.normalize();
|
|
869
|
+
Vector3.scale(direction, worldRadius, p);
|
|
870
|
+
p.add(position);
|
|
871
|
+
var res = LiteColliderShape._tempVector4;
|
|
872
|
+
var distanceSquared = Vector3.distanceSquared(p, point);
|
|
873
|
+
if (distanceFromCenter <= worldRadius * worldRadius) {
|
|
874
|
+
res.set(point.x, point.y, point.z, 0);
|
|
875
|
+
} else {
|
|
876
|
+
res.set(p.x, p.y, p.z, distanceSquared);
|
|
877
|
+
}
|
|
878
|
+
return res;
|
|
879
|
+
};
|
|
880
|
+
/**
|
|
853
881
|
* @internal
|
|
854
882
|
*/ _proto._raycast = function _raycast(ray, hit) {
|
|
855
883
|
var boundingSphere = LiteSphereColliderShape._tempSphere;
|
|
@@ -873,9 +901,7 @@ var /**
|
|
|
873
901
|
]);
|
|
874
902
|
return LiteSphereColliderShape;
|
|
875
903
|
}(LiteColliderShape);
|
|
876
|
-
(
|
|
877
|
-
LiteSphereColliderShape._tempSphere = new BoundingSphere();
|
|
878
|
-
})();
|
|
904
|
+
LiteSphereColliderShape._tempSphere = new BoundingSphere();
|
|
879
905
|
|
|
880
906
|
/**
|
|
881
907
|
* A manager is a collection of colliders and constraints which can interact.
|
|
@@ -897,51 +923,35 @@ var /**
|
|
|
897
923
|
}
|
|
898
924
|
var _proto = LitePhysicsScene.prototype;
|
|
899
925
|
/**
|
|
900
|
-
* {@inheritDoc
|
|
926
|
+
* {@inheritDoc IPhysicsScene.setGravity }
|
|
901
927
|
*/ _proto.setGravity = function setGravity(value) {
|
|
902
928
|
console.log("Physics-lite don't support gravity. Use Physics-PhysX instead!");
|
|
903
929
|
};
|
|
904
930
|
/**
|
|
905
|
-
* {@inheritDoc
|
|
906
|
-
*/ _proto.addColliderShape = function addColliderShape(colliderShape) {
|
|
907
|
-
this._eventMap[colliderShape._id] = {};
|
|
908
|
-
};
|
|
909
|
-
/**
|
|
910
|
-
* {@inheritDoc IPhysicsManager.removeColliderShape }
|
|
911
|
-
*/ _proto.removeColliderShape = function removeColliderShape(colliderShape) {
|
|
912
|
-
var _this = this, eventPool = _this._eventPool, currentEvents = _this._currentEvents, eventMap = _this._eventMap;
|
|
913
|
-
var id = colliderShape._id;
|
|
914
|
-
for(var i = currentEvents.length - 1; i >= 0; i--){
|
|
915
|
-
var event = currentEvents.get(i);
|
|
916
|
-
if (event.index1 == id) {
|
|
917
|
-
currentEvents.deleteByIndex(i);
|
|
918
|
-
eventPool.push(event);
|
|
919
|
-
} else if (event.index2 == id) {
|
|
920
|
-
currentEvents.deleteByIndex(i);
|
|
921
|
-
eventPool.push(event);
|
|
922
|
-
// If the shape is big index, should clear from the small index shape subMap
|
|
923
|
-
eventMap[event.index1][id] = undefined;
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
delete eventMap[id];
|
|
927
|
-
};
|
|
928
|
-
/**
|
|
929
|
-
* {@inheritDoc IPhysicsManager.addCollider }
|
|
931
|
+
* {@inheritDoc IPhysicsScene.addCollider }
|
|
930
932
|
*/ _proto.addCollider = function addCollider(actor) {
|
|
933
|
+
actor._scene = this;
|
|
931
934
|
var colliders = actor._isStaticCollider ? this._staticColliders : this._dynamicColliders;
|
|
932
935
|
colliders.push(actor);
|
|
936
|
+
var shapes = actor._shapes;
|
|
937
|
+
for(var i = 0, n = shapes.length; i < n; i++){
|
|
938
|
+
this._addColliderShape(shapes[i]);
|
|
939
|
+
}
|
|
933
940
|
};
|
|
934
941
|
/**
|
|
935
|
-
* {@inheritDoc
|
|
942
|
+
* {@inheritDoc IPhysicsScene.removeCollider }
|
|
936
943
|
*/ _proto.removeCollider = function removeCollider(collider) {
|
|
944
|
+
collider._scene = null;
|
|
937
945
|
var colliders = collider._isStaticCollider ? this._staticColliders : this._dynamicColliders;
|
|
938
946
|
var index = colliders.indexOf(collider);
|
|
939
|
-
|
|
940
|
-
|
|
947
|
+
index > -1 && colliders.splice(index, 1);
|
|
948
|
+
var shapes = collider._shapes;
|
|
949
|
+
for(var i = 0, n = shapes.length; i < n; i++){
|
|
950
|
+
this._removeColliderShape(shapes[i]);
|
|
941
951
|
}
|
|
942
952
|
};
|
|
943
953
|
/**
|
|
944
|
-
* {@inheritDoc
|
|
954
|
+
* {@inheritDoc IPhysicsScene.update }
|
|
945
955
|
*/ _proto.update = function update(deltaTime) {
|
|
946
956
|
var dynamicColliders = this._dynamicColliders;
|
|
947
957
|
for(var i = 0, len = dynamicColliders.length; i < len; i++){
|
|
@@ -952,13 +962,16 @@ var /**
|
|
|
952
962
|
this._fireEvent();
|
|
953
963
|
};
|
|
954
964
|
/**
|
|
955
|
-
* {@inheritDoc
|
|
965
|
+
* {@inheritDoc IPhysicsScene.raycast }
|
|
956
966
|
*/ _proto.raycast = function raycast(ray, distance, onRaycast, hit) {
|
|
957
967
|
if (!hit) {
|
|
958
968
|
return this._raycast(ray, distance, onRaycast, this._staticColliders, hit) || this._raycast(ray, distance, onRaycast, this._dynamicColliders, hit);
|
|
959
969
|
} else {
|
|
960
970
|
var raycastStaticRes = this._raycast(ray, distance, onRaycast, this._staticColliders, hit);
|
|
961
|
-
|
|
971
|
+
if (raycastStaticRes) {
|
|
972
|
+
distance = LitePhysicsScene._currentHit.distance;
|
|
973
|
+
}
|
|
974
|
+
var raycastDynamicRes = this._raycast(ray, distance, onRaycast, this._dynamicColliders, hit);
|
|
962
975
|
var isHit = raycastStaticRes || raycastDynamicRes;
|
|
963
976
|
var hitResult = LitePhysicsScene._hitResult;
|
|
964
977
|
if (!isHit) {
|
|
@@ -973,15 +986,41 @@ var /**
|
|
|
973
986
|
}
|
|
974
987
|
};
|
|
975
988
|
/**
|
|
976
|
-
* {@inheritDoc
|
|
989
|
+
* {@inheritDoc IPhysicsScene.addCharacterController }
|
|
977
990
|
*/ _proto.addCharacterController = function addCharacterController(characterController) {
|
|
978
991
|
throw "Physics-lite don't support addCharacterController. Use Physics-PhysX instead!";
|
|
979
992
|
};
|
|
980
993
|
/**
|
|
981
|
-
* {@inheritDoc
|
|
994
|
+
* {@inheritDoc IPhysicsScene.removeCharacterController }
|
|
982
995
|
*/ _proto.removeCharacterController = function removeCharacterController(characterController) {
|
|
983
996
|
throw "Physics-lite don't support removeCharacterController. Use Physics-PhysX instead!";
|
|
984
997
|
};
|
|
998
|
+
/**
|
|
999
|
+
* {@inheritDoc IPhysicsScene.destroy }
|
|
1000
|
+
*/ _proto.destroy = function destroy() {};
|
|
1001
|
+
/**
|
|
1002
|
+
* @internal
|
|
1003
|
+
*/ _proto._addColliderShape = function _addColliderShape(colliderShape) {
|
|
1004
|
+
this._eventMap[colliderShape._id] = {};
|
|
1005
|
+
};
|
|
1006
|
+
/**
|
|
1007
|
+
* @internal
|
|
1008
|
+
*/ _proto._removeColliderShape = function _removeColliderShape(colliderShape) {
|
|
1009
|
+
var _this = this, eventPool = _this._eventPool, currentEvents = _this._currentEvents, eventMap = _this._eventMap;
|
|
1010
|
+
var id = colliderShape._id;
|
|
1011
|
+
currentEvents.forEach(function(event, i) {
|
|
1012
|
+
if (event.index1 == id) {
|
|
1013
|
+
currentEvents.deleteByIndex(i);
|
|
1014
|
+
eventPool.push(event);
|
|
1015
|
+
} else if (event.index2 == id) {
|
|
1016
|
+
currentEvents.deleteByIndex(i);
|
|
1017
|
+
eventPool.push(event);
|
|
1018
|
+
// If the shape is big index, should clear from the small index shape subMap
|
|
1019
|
+
eventMap[event.index1][id] = undefined;
|
|
1020
|
+
}
|
|
1021
|
+
});
|
|
1022
|
+
delete eventMap[id];
|
|
1023
|
+
};
|
|
985
1024
|
_proto._getTrigger = function _getTrigger(index1, index2) {
|
|
986
1025
|
var event;
|
|
987
1026
|
if (this._eventPool.length) {
|
|
@@ -1056,25 +1095,25 @@ var /**
|
|
|
1056
1095
|
}
|
|
1057
1096
|
};
|
|
1058
1097
|
_proto._fireEvent = function _fireEvent() {
|
|
1059
|
-
var _this = this
|
|
1060
|
-
|
|
1061
|
-
|
|
1098
|
+
var _this = this;
|
|
1099
|
+
var _this1 = this, eventPool = _this1._eventPool, currentEvents = _this1._currentEvents;
|
|
1100
|
+
currentEvents.forEach(function(event, i) {
|
|
1062
1101
|
if (!event.alreadyInvoked) {
|
|
1063
1102
|
if (event.state == 0) {
|
|
1064
|
-
|
|
1103
|
+
_this._onTriggerEnter(event.index1, event.index2);
|
|
1065
1104
|
event.alreadyInvoked = true;
|
|
1066
1105
|
} else if (event.state == 1) {
|
|
1067
|
-
|
|
1106
|
+
_this._onTriggerStay(event.index1, event.index2);
|
|
1068
1107
|
event.alreadyInvoked = true;
|
|
1069
1108
|
}
|
|
1070
1109
|
} else {
|
|
1071
1110
|
event.state = 2;
|
|
1072
|
-
|
|
1073
|
-
this._onTriggerExit(event.index1, event.index2);
|
|
1111
|
+
_this._eventMap[event.index1][event.index2] = undefined;
|
|
1074
1112
|
currentEvents.deleteByIndex(i);
|
|
1113
|
+
_this._onTriggerExit(event.index1, event.index2);
|
|
1075
1114
|
eventPool.push(event);
|
|
1076
1115
|
}
|
|
1077
|
-
}
|
|
1116
|
+
});
|
|
1078
1117
|
};
|
|
1079
1118
|
_proto._boxCollision = function _boxCollision(other) {
|
|
1080
1119
|
if (_instanceof(other, LiteBoxColliderShape)) {
|
|
@@ -1101,26 +1140,19 @@ var /**
|
|
|
1101
1140
|
return false;
|
|
1102
1141
|
};
|
|
1103
1142
|
_proto._raycast = function _raycast(ray, distance, onRaycast, colliders, hit) {
|
|
1104
|
-
var hitResult;
|
|
1105
|
-
if (hit) {
|
|
1106
|
-
hitResult = LitePhysicsScene._hitResult;
|
|
1107
|
-
}
|
|
1108
1143
|
var isHit = false;
|
|
1109
1144
|
var curHit = LitePhysicsScene._currentHit;
|
|
1110
1145
|
for(var i = 0, len = colliders.length; i < len; i++){
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
return true;
|
|
1122
|
-
}
|
|
1123
|
-
distance = curHit.distance;
|
|
1146
|
+
if (colliders[i]._raycast(ray, onRaycast, curHit) && curHit.distance < distance) {
|
|
1147
|
+
if (hit) {
|
|
1148
|
+
isHit = true;
|
|
1149
|
+
var hitResult = LitePhysicsScene._hitResult;
|
|
1150
|
+
hitResult.normal.copyFrom(curHit.normal);
|
|
1151
|
+
hitResult.point.copyFrom(curHit.point);
|
|
1152
|
+
hitResult.distance = distance = curHit.distance;
|
|
1153
|
+
hitResult.shapeID = curHit.shapeID;
|
|
1154
|
+
} else {
|
|
1155
|
+
return true;
|
|
1124
1156
|
}
|
|
1125
1157
|
}
|
|
1126
1158
|
}
|
|
@@ -1146,26 +1178,10 @@ var /**
|
|
|
1146
1178
|
};
|
|
1147
1179
|
return LitePhysicsScene;
|
|
1148
1180
|
}();
|
|
1149
|
-
(
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
(
|
|
1153
|
-
LitePhysicsScene._tempBox = new BoundingBox();
|
|
1154
|
-
})();
|
|
1155
|
-
(function() {
|
|
1156
|
-
LitePhysicsScene._currentHit = new LiteHitResult();
|
|
1157
|
-
})();
|
|
1158
|
-
(function() {
|
|
1159
|
-
LitePhysicsScene._hitResult = new LiteHitResult();
|
|
1160
|
-
})();
|
|
1161
|
-
var /**
|
|
1162
|
-
* Physics state
|
|
1163
|
-
*/ TriggerEventState;
|
|
1164
|
-
(function(TriggerEventState) {
|
|
1165
|
-
TriggerEventState[TriggerEventState["Enter"] = 0] = "Enter";
|
|
1166
|
-
TriggerEventState[TriggerEventState["Stay"] = 1] = "Stay";
|
|
1167
|
-
TriggerEventState[TriggerEventState["Exit"] = 2] = "Exit";
|
|
1168
|
-
})(TriggerEventState || (TriggerEventState = {}));
|
|
1181
|
+
LitePhysicsScene._tempSphere = new BoundingSphere();
|
|
1182
|
+
LitePhysicsScene._tempBox = new BoundingBox();
|
|
1183
|
+
LitePhysicsScene._currentHit = new LiteHitResult();
|
|
1184
|
+
LitePhysicsScene._hitResult = new LiteHitResult();
|
|
1169
1185
|
/**
|
|
1170
1186
|
* Trigger event to store interactive object ids and state.
|
|
1171
1187
|
*/ var TriggerEvent = function TriggerEvent(index1, index2) {
|
|
@@ -1177,12 +1193,11 @@ var /**
|
|
|
1177
1193
|
/**
|
|
1178
1194
|
* A static collider component that will not move.
|
|
1179
1195
|
* @remarks Mostly used for object which always stays at the same place and never moves around.
|
|
1180
|
-
*/ var LiteStaticCollider = /*#__PURE__*/ function(
|
|
1181
|
-
_inherits(LiteStaticCollider,
|
|
1196
|
+
*/ var LiteStaticCollider = /*#__PURE__*/ function(LiteCollider) {
|
|
1197
|
+
_inherits(LiteStaticCollider, LiteCollider);
|
|
1182
1198
|
function LiteStaticCollider(position, rotation) {
|
|
1183
1199
|
var _this;
|
|
1184
|
-
_this =
|
|
1185
|
-
/** @internal */ _this._isStaticCollider = true;
|
|
1200
|
+
_this = LiteCollider.call(this) || this, /** @internal */ _this._isStaticCollider = true;
|
|
1186
1201
|
_this._transform.setPosition(position.x, position.y, position.z);
|
|
1187
1202
|
_this._transform.setRotationQuaternion(rotation.x, rotation.y, rotation.z, rotation.w);
|
|
1188
1203
|
return _this;
|
|
@@ -1263,12 +1278,15 @@ var LitePhysics = /*#__PURE__*/ function() {
|
|
|
1263
1278
|
*/ _proto.createSpringJoint = function createSpringJoint(collider) {
|
|
1264
1279
|
throw "Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!";
|
|
1265
1280
|
};
|
|
1281
|
+
/**
|
|
1282
|
+
* {@inheritDoc IPhysics.destroy }
|
|
1283
|
+
*/ _proto.destroy = function destroy() {};
|
|
1266
1284
|
return LitePhysics;
|
|
1267
1285
|
}();
|
|
1268
1286
|
|
|
1269
1287
|
//@ts-ignore
|
|
1270
|
-
var version = "0.0.0-experimental-1.
|
|
1271
|
-
console.log("Galacean
|
|
1288
|
+
var version = "0.0.0-experimental-1.4-small-language.0";
|
|
1289
|
+
console.log("Galacean Engine Physics Lite Version: " + version);
|
|
1272
1290
|
|
|
1273
1291
|
export { LitePhysics, version };
|
|
1274
1292
|
//# sourceMappingURL=module.js.map
|