@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/module.js
CHANGED
|
@@ -172,12 +172,8 @@ function _instanceof(left, right) {
|
|
|
172
172
|
};
|
|
173
173
|
return LiteColliderShape;
|
|
174
174
|
}();
|
|
175
|
-
(
|
|
176
|
-
|
|
177
|
-
})();
|
|
178
|
-
(function() {
|
|
179
|
-
LiteColliderShape._tempPoint = new Vector3();
|
|
180
|
-
})();
|
|
175
|
+
LiteColliderShape._ray = new Ray();
|
|
176
|
+
LiteColliderShape._tempPoint = new Vector3();
|
|
181
177
|
|
|
182
178
|
/**
|
|
183
179
|
* Used to implement transformation related functions.
|
|
@@ -193,7 +189,7 @@ function _instanceof(left, right) {
|
|
|
193
189
|
this._updateFlagManager = new LiteUpdateFlagManager();
|
|
194
190
|
this._isParentDirty = true;
|
|
195
191
|
this._parentTransformCache = null;
|
|
196
|
-
this._dirtyFlag =
|
|
192
|
+
this._dirtyFlag = 188;
|
|
197
193
|
}
|
|
198
194
|
var _proto = LiteTransform.prototype;
|
|
199
195
|
/**
|
|
@@ -235,8 +231,8 @@ function _instanceof(left, right) {
|
|
|
235
231
|
* Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
|
|
236
232
|
* 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
233
|
*/ _proto._updateWorldPositionFlag = function _updateWorldPositionFlag() {
|
|
238
|
-
if (!this._isContainDirtyFlags(
|
|
239
|
-
this._worldAssociatedChange(
|
|
234
|
+
if (!this._isContainDirtyFlags(132)) {
|
|
235
|
+
this._worldAssociatedChange(132);
|
|
240
236
|
if (_instanceof(this._owner, LiteCollider)) {
|
|
241
237
|
var shapes = this._owner._shapes;
|
|
242
238
|
for(var i = 0, n = shapes.length; i < n; i++){
|
|
@@ -252,8 +248,8 @@ function _instanceof(left, right) {
|
|
|
252
248
|
* 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
249
|
* 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
250
|
*/ _proto._updateWorldRotationFlag = function _updateWorldRotationFlag() {
|
|
255
|
-
if (!this._isContainDirtyFlags(
|
|
256
|
-
this._worldAssociatedChange(
|
|
251
|
+
if (!this._isContainDirtyFlags(152)) {
|
|
252
|
+
this._worldAssociatedChange(152);
|
|
257
253
|
if (_instanceof(this._owner, LiteCollider)) {
|
|
258
254
|
var shapes = this._owner._shapes;
|
|
259
255
|
for(var i = 0, n = shapes.length; i < n; i++){
|
|
@@ -268,8 +264,8 @@ function _instanceof(left, right) {
|
|
|
268
264
|
* Get worldScale: Will trigger the scaling update of itself and all parent entities.
|
|
269
265
|
* In summary, any update of related variables will cause the dirty mark of one of the full process (worldMatrix) to be false.
|
|
270
266
|
*/ _proto._updateWorldScaleFlag = function _updateWorldScaleFlag() {
|
|
271
|
-
if (!this._isContainDirtyFlags(
|
|
272
|
-
this._worldAssociatedChange(
|
|
267
|
+
if (!this._isContainDirtyFlags(160)) {
|
|
268
|
+
this._worldAssociatedChange(160);
|
|
273
269
|
if (_instanceof(this._owner, LiteCollider)) {
|
|
274
270
|
var shapes = this._owner._shapes;
|
|
275
271
|
for(var i = 0, n = shapes.length; i < n; i++){
|
|
@@ -281,8 +277,8 @@ function _instanceof(left, right) {
|
|
|
281
277
|
/**
|
|
282
278
|
* Update all world transform property dirty flag, the principle is the same as above.
|
|
283
279
|
*/ _proto._updateAllWorldFlag = function _updateAllWorldFlag() {
|
|
284
|
-
if (!this._isContainDirtyFlags(
|
|
285
|
-
this._worldAssociatedChange(
|
|
280
|
+
if (!this._isContainDirtyFlags(188)) {
|
|
281
|
+
this._worldAssociatedChange(188);
|
|
286
282
|
if (_instanceof(this._owner, LiteCollider)) {
|
|
287
283
|
var shapes = this._owner._shapes;
|
|
288
284
|
for(var i = 0, n = shapes.length; i < n; i++){
|
|
@@ -339,7 +335,7 @@ function _instanceof(left, right) {
|
|
|
339
335
|
if (this._position !== value) {
|
|
340
336
|
this._position.copyFrom(value);
|
|
341
337
|
}
|
|
342
|
-
this._setDirtyFlagTrue(
|
|
338
|
+
this._setDirtyFlagTrue(64);
|
|
343
339
|
this._updateWorldPositionFlag();
|
|
344
340
|
}
|
|
345
341
|
},
|
|
@@ -349,9 +345,9 @@ function _instanceof(left, right) {
|
|
|
349
345
|
* Local rotation, defining the rotation by using a unit quaternion.
|
|
350
346
|
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
351
347
|
*/ function get() {
|
|
352
|
-
if (this._isContainDirtyFlag(
|
|
348
|
+
if (this._isContainDirtyFlag(2)) {
|
|
353
349
|
Quaternion.rotationEuler(MathUtil.degreeToRadian(this._rotation.x), MathUtil.degreeToRadian(this._rotation.y), MathUtil.degreeToRadian(this._rotation.z), this._rotationQuaternion);
|
|
354
|
-
this._setDirtyFlagFalse(
|
|
350
|
+
this._setDirtyFlagFalse(2);
|
|
355
351
|
}
|
|
356
352
|
return this._rotationQuaternion;
|
|
357
353
|
},
|
|
@@ -359,8 +355,8 @@ function _instanceof(left, right) {
|
|
|
359
355
|
if (this._rotationQuaternion !== value) {
|
|
360
356
|
this._rotationQuaternion.copyFrom(value);
|
|
361
357
|
}
|
|
362
|
-
this._setDirtyFlagTrue(
|
|
363
|
-
this._setDirtyFlagFalse(
|
|
358
|
+
this._setDirtyFlagTrue(64 | 1);
|
|
359
|
+
this._setDirtyFlagFalse(2);
|
|
364
360
|
this._updateWorldRotationFlag();
|
|
365
361
|
}
|
|
366
362
|
},
|
|
@@ -370,14 +366,14 @@ function _instanceof(left, right) {
|
|
|
370
366
|
* World rotation, defining the rotation by using a unit quaternion.
|
|
371
367
|
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
372
368
|
*/ function get() {
|
|
373
|
-
if (this._isContainDirtyFlag(
|
|
369
|
+
if (this._isContainDirtyFlag(16)) {
|
|
374
370
|
var parent = this._getParentTransform();
|
|
375
371
|
if (parent != null) {
|
|
376
372
|
Quaternion.multiply(parent.worldRotationQuaternion, this.rotationQuaternion, this._worldRotationQuaternion);
|
|
377
373
|
} else {
|
|
378
374
|
this._worldRotationQuaternion.copyFrom(this.rotationQuaternion);
|
|
379
375
|
}
|
|
380
|
-
this._setDirtyFlagFalse(
|
|
376
|
+
this._setDirtyFlagFalse(16);
|
|
381
377
|
}
|
|
382
378
|
return this._worldRotationQuaternion;
|
|
383
379
|
},
|
|
@@ -393,7 +389,7 @@ function _instanceof(left, right) {
|
|
|
393
389
|
this._rotationQuaternion.copyFrom(value);
|
|
394
390
|
}
|
|
395
391
|
this.rotationQuaternion = this._rotationQuaternion;
|
|
396
|
-
this._setDirtyFlagFalse(
|
|
392
|
+
this._setDirtyFlagFalse(16);
|
|
397
393
|
}
|
|
398
394
|
},
|
|
399
395
|
{
|
|
@@ -408,7 +404,7 @@ function _instanceof(left, right) {
|
|
|
408
404
|
if (this._scale !== value) {
|
|
409
405
|
this._scale.copyFrom(value);
|
|
410
406
|
}
|
|
411
|
-
this._setDirtyFlagTrue(
|
|
407
|
+
this._setDirtyFlagTrue(64);
|
|
412
408
|
this._updateWorldScaleFlag();
|
|
413
409
|
}
|
|
414
410
|
},
|
|
@@ -418,9 +414,9 @@ function _instanceof(left, right) {
|
|
|
418
414
|
* Local matrix.
|
|
419
415
|
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
420
416
|
*/ function get() {
|
|
421
|
-
if (this._isContainDirtyFlag(
|
|
417
|
+
if (this._isContainDirtyFlag(64)) {
|
|
422
418
|
Matrix.affineTransformation(this._scale, this.rotationQuaternion, this._position, this._localMatrix);
|
|
423
|
-
this._setDirtyFlagFalse(
|
|
419
|
+
this._setDirtyFlagFalse(64);
|
|
424
420
|
}
|
|
425
421
|
return this._localMatrix;
|
|
426
422
|
},
|
|
@@ -429,8 +425,8 @@ function _instanceof(left, right) {
|
|
|
429
425
|
this._localMatrix.copyFrom(value);
|
|
430
426
|
}
|
|
431
427
|
this._localMatrix.decompose(this._position, this._rotationQuaternion, this._scale);
|
|
432
|
-
this._setDirtyFlagTrue(
|
|
433
|
-
this._setDirtyFlagFalse(
|
|
428
|
+
this._setDirtyFlagTrue(1);
|
|
429
|
+
this._setDirtyFlagFalse(64);
|
|
434
430
|
this._updateAllWorldFlag();
|
|
435
431
|
}
|
|
436
432
|
},
|
|
@@ -440,14 +436,14 @@ function _instanceof(left, right) {
|
|
|
440
436
|
* World matrix.
|
|
441
437
|
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
442
438
|
*/ function get() {
|
|
443
|
-
if (this._isContainDirtyFlag(
|
|
439
|
+
if (this._isContainDirtyFlag(128)) {
|
|
444
440
|
var parent = this._getParentTransform();
|
|
445
441
|
if (parent) {
|
|
446
442
|
Matrix.multiply(parent.worldMatrix, this.localMatrix, this._worldMatrix);
|
|
447
443
|
} else {
|
|
448
444
|
this._worldMatrix.copyFrom(this.localMatrix);
|
|
449
445
|
}
|
|
450
|
-
this._setDirtyFlagFalse(
|
|
446
|
+
this._setDirtyFlagFalse(128);
|
|
451
447
|
}
|
|
452
448
|
return this._worldMatrix;
|
|
453
449
|
},
|
|
@@ -463,37 +459,14 @@ function _instanceof(left, right) {
|
|
|
463
459
|
this._localMatrix.copyFrom(value);
|
|
464
460
|
}
|
|
465
461
|
this.localMatrix = this._localMatrix;
|
|
466
|
-
this._setDirtyFlagFalse(
|
|
462
|
+
this._setDirtyFlagFalse(128);
|
|
467
463
|
}
|
|
468
464
|
}
|
|
469
465
|
]);
|
|
470
466
|
return LiteTransform;
|
|
471
467
|
}();
|
|
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 = {}));
|
|
468
|
+
LiteTransform._tempQuat0 = new Quaternion();
|
|
469
|
+
LiteTransform._tempMat42 = new Matrix();
|
|
497
470
|
|
|
498
471
|
/**
|
|
499
472
|
* Abstract class of physical collider.
|
|
@@ -509,11 +482,13 @@ var /**
|
|
|
509
482
|
*/ _proto.addShape = function addShape(shape) {
|
|
510
483
|
var oldCollider = shape._collider;
|
|
511
484
|
if (oldCollider !== this) {
|
|
485
|
+
var _this__scene;
|
|
512
486
|
if (oldCollider) {
|
|
513
487
|
oldCollider.removeShape(shape);
|
|
514
488
|
}
|
|
515
489
|
this._shapes.push(shape);
|
|
516
490
|
shape._collider = this;
|
|
491
|
+
(_this__scene = this._scene) == null ? void 0 : _this__scene._addColliderShape(shape);
|
|
517
492
|
}
|
|
518
493
|
};
|
|
519
494
|
/**
|
|
@@ -521,8 +496,10 @@ var /**
|
|
|
521
496
|
*/ _proto.removeShape = function removeShape(shape) {
|
|
522
497
|
var index = this._shapes.indexOf(shape);
|
|
523
498
|
if (index !== -1) {
|
|
499
|
+
var _this__scene;
|
|
524
500
|
this._shapes.splice(index, 1);
|
|
525
501
|
shape._collider = null;
|
|
502
|
+
(_this__scene = this._scene) == null ? void 0 : _this__scene._removeColliderShape(shape);
|
|
526
503
|
}
|
|
527
504
|
};
|
|
528
505
|
/**
|
|
@@ -557,18 +534,34 @@ var /**
|
|
|
557
534
|
|
|
558
535
|
/**
|
|
559
536
|
* A dynamic collider can act with self-defined movement or physical force
|
|
560
|
-
*/ var LiteDynamicCollider = /*#__PURE__*/ function(
|
|
561
|
-
_inherits(LiteDynamicCollider,
|
|
537
|
+
*/ var LiteDynamicCollider = /*#__PURE__*/ function(LiteCollider) {
|
|
538
|
+
_inherits(LiteDynamicCollider, LiteCollider);
|
|
562
539
|
function LiteDynamicCollider(position, rotation) {
|
|
563
540
|
var _this;
|
|
564
|
-
_this =
|
|
565
|
-
/** @internal */ _this._isStaticCollider = false;
|
|
541
|
+
_this = LiteCollider.call(this) || this, /** @internal */ _this._isStaticCollider = false;
|
|
566
542
|
_this._transform.setPosition(position.x, position.y, position.z);
|
|
567
543
|
_this._transform.setRotationQuaternion(rotation.x, rotation.y, rotation.z, rotation.w);
|
|
568
544
|
return _this;
|
|
569
545
|
}
|
|
570
546
|
var _proto = LiteDynamicCollider.prototype;
|
|
571
547
|
/**
|
|
548
|
+
* {@inheritDoc IDynamicCollider.getInertiaTensor }
|
|
549
|
+
*/ _proto.getInertiaTensor = function getInertiaTensor(out) {
|
|
550
|
+
console.error("Physics-lite don't support getInertiaTensor. Use Physics-PhysX instead!");
|
|
551
|
+
return out;
|
|
552
|
+
};
|
|
553
|
+
/**
|
|
554
|
+
* {@inheritDoc IDynamicCollider.getCenterOfMass }
|
|
555
|
+
*/ _proto.getCenterOfMass = function getCenterOfMass(out) {
|
|
556
|
+
console.error("Physics-lite don't support getCenterOfMass. Use Physics-PhysX instead!");
|
|
557
|
+
return out;
|
|
558
|
+
};
|
|
559
|
+
/**
|
|
560
|
+
* {@inheritDoc IDynamicCollider.setMassAndUpdateInertia }
|
|
561
|
+
*/ _proto.setMassAndUpdateInertia = function setMassAndUpdateInertia(mass) {
|
|
562
|
+
console.error("Physics-lite don't support setMassAndUpdateInertia. Use Physics-PhysX instead!");
|
|
563
|
+
};
|
|
564
|
+
/**
|
|
572
565
|
* {@inheritDoc IDynamicCollider.addForce }
|
|
573
566
|
*/ _proto.addForce = function addForce(force) {
|
|
574
567
|
throw "Physics-lite don't support addForce. Use Physics-PhysX instead!";
|
|
@@ -589,74 +582,106 @@ var /**
|
|
|
589
582
|
throw "Physics-lite don't support putToSleep. Use Physics-PhysX instead!";
|
|
590
583
|
};
|
|
591
584
|
/**
|
|
585
|
+
* {@inheritDoc IDynamicCollider.isSleeping }
|
|
586
|
+
*/ _proto.isSleeping = function isSleeping() {
|
|
587
|
+
throw "Physics-lite don't support isSleeping. Use Physics-PhysX instead!";
|
|
588
|
+
};
|
|
589
|
+
/**
|
|
590
|
+
* {@inheritDoc IDynamicCollider.getAngularDamping }
|
|
591
|
+
*/ _proto.getAngularDamping = function getAngularDamping() {
|
|
592
|
+
throw "Physics-lite don't support getAngularDamping. Use Physics-PhysX instead!";
|
|
593
|
+
};
|
|
594
|
+
/**
|
|
592
595
|
* {@inheritDoc IDynamicCollider.setAngularDamping }
|
|
593
596
|
*/ _proto.setAngularDamping = function setAngularDamping(value) {
|
|
594
|
-
|
|
597
|
+
console.error("Physics-lite don't support setAngularDamping. Use Physics-PhysX instead!");
|
|
598
|
+
};
|
|
599
|
+
/**
|
|
600
|
+
* {@inheritDoc IDynamicCollider.getAngularVelocity }
|
|
601
|
+
*/ _proto.getAngularVelocity = function getAngularVelocity(out) {
|
|
602
|
+
console.error("Physics-lite don't support getAngularVelocity. Use Physics-PhysX instead!");
|
|
603
|
+
return out;
|
|
595
604
|
};
|
|
596
605
|
/**
|
|
597
606
|
* {@inheritDoc IDynamicCollider.setAngularVelocity }
|
|
598
607
|
*/ _proto.setAngularVelocity = function setAngularVelocity(value) {
|
|
599
|
-
|
|
608
|
+
console.error("Physics-lite don't support setAngularVelocity. Use Physics-PhysX instead!");
|
|
600
609
|
};
|
|
601
610
|
/**
|
|
602
611
|
* {@inheritDoc IDynamicCollider.setCenterOfMass }
|
|
603
612
|
*/ _proto.setCenterOfMass = function setCenterOfMass(value) {
|
|
604
|
-
|
|
613
|
+
console.error("Physics-lite don't support setCenterOfMass. Use Physics-PhysX instead!");
|
|
605
614
|
};
|
|
606
615
|
/**
|
|
607
616
|
* {@inheritDoc IDynamicCollider.setCollisionDetectionMode }
|
|
608
617
|
*/ _proto.setCollisionDetectionMode = function setCollisionDetectionMode(value) {
|
|
609
|
-
|
|
618
|
+
console.error("Physics-lite don't support setCollisionDetectionMode. Use Physics-PhysX instead!");
|
|
610
619
|
};
|
|
611
620
|
/**
|
|
612
621
|
* {@inheritDoc IDynamicCollider.setConstraints }
|
|
613
622
|
*/ _proto.setConstraints = function setConstraints(flags) {
|
|
614
|
-
|
|
623
|
+
console.error("Physics-lite don't support setConstraints. Use Physics-PhysX instead!");
|
|
615
624
|
};
|
|
616
625
|
/**
|
|
617
626
|
* {@inheritDoc IDynamicCollider.setInertiaTensor }
|
|
618
627
|
*/ _proto.setInertiaTensor = function setInertiaTensor(value) {
|
|
619
|
-
|
|
628
|
+
console.error("Physics-lite don't support setInertiaTensor. Use Physics-PhysX instead!");
|
|
620
629
|
};
|
|
621
630
|
/**
|
|
622
631
|
* {@inheritDoc IDynamicCollider.setIsKinematic }
|
|
623
632
|
*/ _proto.setIsKinematic = function setIsKinematic(value) {
|
|
624
|
-
|
|
633
|
+
console.error("Physics-lite don't support setIsKinematic. Use Physics-PhysX instead!");
|
|
634
|
+
};
|
|
635
|
+
/**
|
|
636
|
+
* {@inheritDoc IDynamicCollider.setLinearDamping }
|
|
637
|
+
*/ _proto.getLinearDamping = function getLinearDamping() {
|
|
638
|
+
throw "Physics-lite don't support getLinearDamping. Use Physics-PhysX instead!";
|
|
625
639
|
};
|
|
626
640
|
/**
|
|
627
641
|
* {@inheritDoc IDynamicCollider.setLinearDamping }
|
|
628
642
|
*/ _proto.setLinearDamping = function setLinearDamping(value) {
|
|
629
|
-
|
|
643
|
+
console.error("Physics-lite don't support setLinearDamping. Use Physics-PhysX instead!");
|
|
644
|
+
};
|
|
645
|
+
/**
|
|
646
|
+
* {@inheritDoc IDynamicCollider.getLinearVelocity }
|
|
647
|
+
*/ _proto.getLinearVelocity = function getLinearVelocity(out) {
|
|
648
|
+
console.error("Physics-lite don't support getLinearVelocity. Use Physics-PhysX instead!");
|
|
649
|
+
return out;
|
|
630
650
|
};
|
|
631
651
|
/**
|
|
632
652
|
* {@inheritDoc IDynamicCollider.setLinearVelocity }
|
|
633
653
|
*/ _proto.setLinearVelocity = function setLinearVelocity(value) {
|
|
634
|
-
|
|
654
|
+
console.error("Physics-lite don't support setLinearVelocity. Use Physics-PhysX instead!");
|
|
635
655
|
};
|
|
636
656
|
/**
|
|
637
657
|
* {@inheritDoc IDynamicCollider.setMass }
|
|
638
658
|
*/ _proto.setMass = function setMass(value) {
|
|
639
|
-
|
|
659
|
+
console.error("Physics-lite don't support setMass. Use Physics-PhysX instead!");
|
|
640
660
|
};
|
|
641
661
|
/**
|
|
642
662
|
* {@inheritDoc IDynamicCollider.setMaxAngularVelocity }
|
|
643
663
|
*/ _proto.setMaxAngularVelocity = function setMaxAngularVelocity(value) {
|
|
644
|
-
|
|
664
|
+
console.error("Physics-lite don't support setMaxAngularVelocity. Use Physics-PhysX instead!");
|
|
665
|
+
};
|
|
666
|
+
/**
|
|
667
|
+
* {@inheritDoc IDynamicCollider.setMaxDepenetrationVelocity }
|
|
668
|
+
*/ _proto.getMaxDepenetrationVelocity = function getMaxDepenetrationVelocity() {
|
|
669
|
+
throw "Physics-lite don't support getMaxDepenetrationVelocity. Use Physics-PhysX instead!";
|
|
645
670
|
};
|
|
646
671
|
/**
|
|
647
672
|
* {@inheritDoc IDynamicCollider.setMaxDepenetrationVelocity }
|
|
648
673
|
*/ _proto.setMaxDepenetrationVelocity = function setMaxDepenetrationVelocity(value) {
|
|
649
|
-
|
|
674
|
+
console.error("Physics-lite don't support setMaxDepenetrationVelocity. Use Physics-PhysX instead!");
|
|
650
675
|
};
|
|
651
676
|
/**
|
|
652
677
|
* {@inheritDoc IDynamicCollider.setSleepThreshold }
|
|
653
678
|
*/ _proto.setSleepThreshold = function setSleepThreshold(value) {
|
|
654
|
-
|
|
679
|
+
console.error("Physics-lite don't support setSleepThreshold. Use Physics-PhysX instead!");
|
|
655
680
|
};
|
|
656
681
|
/**
|
|
657
682
|
* {@inheritDoc IDynamicCollider.setSolverIterations }
|
|
658
683
|
*/ _proto.setSolverIterations = function setSolverIterations(value) {
|
|
659
|
-
|
|
684
|
+
console.error("Physics-lite don't support setSolverIterations. Use Physics-PhysX instead!");
|
|
660
685
|
};
|
|
661
686
|
/**
|
|
662
687
|
* {@inheritDoc IDynamicCollider.wakeUp }
|
|
@@ -714,15 +739,11 @@ var /**
|
|
|
714
739
|
|
|
715
740
|
/**
|
|
716
741
|
* Box collider shape in Lite.
|
|
717
|
-
*/ var LiteBoxColliderShape = /*#__PURE__*/ function(
|
|
718
|
-
_inherits(LiteBoxColliderShape,
|
|
742
|
+
*/ var LiteBoxColliderShape = /*#__PURE__*/ function(LiteColliderShape) {
|
|
743
|
+
_inherits(LiteBoxColliderShape, LiteColliderShape);
|
|
719
744
|
function LiteBoxColliderShape(uniqueID, size, material) {
|
|
720
745
|
var _this;
|
|
721
|
-
_this =
|
|
722
|
-
_this._halfSize = new Vector3();
|
|
723
|
-
_this._sizeScale = new Vector3(1, 1, 1);
|
|
724
|
-
/** @internal */ _this._boxMin = new Vector3(-0.5, -0.5, -0.5);
|
|
725
|
-
/** @internal */ _this._boxMax = new Vector3(0.5, 0.5, 0.5);
|
|
746
|
+
_this = LiteColliderShape.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);
|
|
726
747
|
_this._id = uniqueID;
|
|
727
748
|
_this._halfSize.set(size.x * 0.5, size.y * 0.5, size.z * 0.5);
|
|
728
749
|
_this._setBondingBox();
|
|
@@ -732,13 +753,13 @@ var /**
|
|
|
732
753
|
/**
|
|
733
754
|
* {@inheritDoc IColliderShape.setPosition }
|
|
734
755
|
*/ _proto.setPosition = function setPosition(position) {
|
|
735
|
-
|
|
756
|
+
LiteColliderShape.prototype.setPosition.call(this, position);
|
|
736
757
|
this._setBondingBox();
|
|
737
758
|
};
|
|
738
759
|
/**
|
|
739
760
|
* {@inheritDoc IColliderShape.setWorldScale }
|
|
740
761
|
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
741
|
-
|
|
762
|
+
LiteColliderShape.prototype.setWorldScale.call(this, scale);
|
|
742
763
|
this._sizeScale.set(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z));
|
|
743
764
|
this._setBondingBox();
|
|
744
765
|
};
|
|
@@ -774,19 +795,15 @@ var /**
|
|
|
774
795
|
};
|
|
775
796
|
return LiteBoxColliderShape;
|
|
776
797
|
}(LiteColliderShape);
|
|
777
|
-
(
|
|
778
|
-
LiteBoxColliderShape._tempBox = new BoundingBox();
|
|
779
|
-
})();
|
|
798
|
+
LiteBoxColliderShape._tempBox = new BoundingBox();
|
|
780
799
|
|
|
781
800
|
/**
|
|
782
801
|
* Sphere collider shape in Lite.
|
|
783
|
-
*/ var LiteSphereColliderShape = /*#__PURE__*/ function(
|
|
784
|
-
_inherits(LiteSphereColliderShape,
|
|
802
|
+
*/ var LiteSphereColliderShape = /*#__PURE__*/ function(LiteColliderShape) {
|
|
803
|
+
_inherits(LiteSphereColliderShape, LiteColliderShape);
|
|
785
804
|
function LiteSphereColliderShape(uniqueID, radius, material) {
|
|
786
805
|
var _this;
|
|
787
|
-
_this =
|
|
788
|
-
_this._radius = 1;
|
|
789
|
-
_this._maxScale = 1;
|
|
806
|
+
_this = LiteColliderShape.call(this) || this, _this._radius = 1, _this._maxScale = 1;
|
|
790
807
|
_this._radius = radius;
|
|
791
808
|
_this._id = uniqueID;
|
|
792
809
|
return _this;
|
|
@@ -800,7 +817,7 @@ var /**
|
|
|
800
817
|
/**
|
|
801
818
|
* {@inheritDoc IColliderShape.setWorldScale }
|
|
802
819
|
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
803
|
-
|
|
820
|
+
LiteColliderShape.prototype.setWorldScale.call(this, scale);
|
|
804
821
|
this._maxScale = Math.max(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z));
|
|
805
822
|
};
|
|
806
823
|
/**
|
|
@@ -827,9 +844,7 @@ var /**
|
|
|
827
844
|
]);
|
|
828
845
|
return LiteSphereColliderShape;
|
|
829
846
|
}(LiteColliderShape);
|
|
830
|
-
(
|
|
831
|
-
LiteSphereColliderShape._tempSphere = new BoundingSphere();
|
|
832
|
-
})();
|
|
847
|
+
LiteSphereColliderShape._tempSphere = new BoundingSphere();
|
|
833
848
|
|
|
834
849
|
/**
|
|
835
850
|
* A manager is a collection of colliders and constraints which can interact.
|
|
@@ -856,41 +871,26 @@ var /**
|
|
|
856
871
|
console.log("Physics-lite don't support gravity. Use Physics-PhysX instead!");
|
|
857
872
|
};
|
|
858
873
|
/**
|
|
859
|
-
* {@inheritDoc IPhysicsManager.addColliderShape }
|
|
860
|
-
*/ _proto.addColliderShape = function addColliderShape(colliderShape) {
|
|
861
|
-
this._eventMap[colliderShape._id] = {};
|
|
862
|
-
};
|
|
863
|
-
/**
|
|
864
|
-
* {@inheritDoc IPhysicsManager.removeColliderShape }
|
|
865
|
-
*/ _proto.removeColliderShape = function removeColliderShape(colliderShape) {
|
|
866
|
-
var _this = this, eventPool = _this._eventPool, currentEvents = _this._currentEvents, eventMap = _this._eventMap;
|
|
867
|
-
var id = colliderShape._id;
|
|
868
|
-
currentEvents.forEach(function(event, i) {
|
|
869
|
-
if (event.index1 == id) {
|
|
870
|
-
currentEvents.deleteByIndex(i);
|
|
871
|
-
eventPool.push(event);
|
|
872
|
-
} else if (event.index2 == id) {
|
|
873
|
-
currentEvents.deleteByIndex(i);
|
|
874
|
-
eventPool.push(event);
|
|
875
|
-
// If the shape is big index, should clear from the small index shape subMap
|
|
876
|
-
eventMap[event.index1][id] = undefined;
|
|
877
|
-
}
|
|
878
|
-
});
|
|
879
|
-
delete eventMap[id];
|
|
880
|
-
};
|
|
881
|
-
/**
|
|
882
874
|
* {@inheritDoc IPhysicsManager.addCollider }
|
|
883
875
|
*/ _proto.addCollider = function addCollider(actor) {
|
|
876
|
+
actor._scene = this;
|
|
884
877
|
var colliders = actor._isStaticCollider ? this._staticColliders : this._dynamicColliders;
|
|
885
878
|
colliders.push(actor);
|
|
879
|
+
var shapes = actor._shapes;
|
|
880
|
+
for(var i = 0, n = shapes.length; i < n; i++){
|
|
881
|
+
this._addColliderShape(shapes[i]);
|
|
882
|
+
}
|
|
886
883
|
};
|
|
887
884
|
/**
|
|
888
885
|
* {@inheritDoc IPhysicsManager.removeCollider }
|
|
889
886
|
*/ _proto.removeCollider = function removeCollider(collider) {
|
|
887
|
+
collider._scene = null;
|
|
890
888
|
var colliders = collider._isStaticCollider ? this._staticColliders : this._dynamicColliders;
|
|
891
889
|
var index = colliders.indexOf(collider);
|
|
892
|
-
|
|
893
|
-
|
|
890
|
+
index > -1 && colliders.splice(index, 1);
|
|
891
|
+
var shapes = collider._shapes;
|
|
892
|
+
for(var i = 0, n = shapes.length; i < n; i++){
|
|
893
|
+
this._removeColliderShape(shapes[i]);
|
|
894
894
|
}
|
|
895
895
|
};
|
|
896
896
|
/**
|
|
@@ -938,6 +938,29 @@ var /**
|
|
|
938
938
|
*/ _proto.removeCharacterController = function removeCharacterController(characterController) {
|
|
939
939
|
throw "Physics-lite don't support removeCharacterController. Use Physics-PhysX instead!";
|
|
940
940
|
};
|
|
941
|
+
/**
|
|
942
|
+
* @internal
|
|
943
|
+
*/ _proto._addColliderShape = function _addColliderShape(colliderShape) {
|
|
944
|
+
this._eventMap[colliderShape._id] = {};
|
|
945
|
+
};
|
|
946
|
+
/**
|
|
947
|
+
* @internal
|
|
948
|
+
*/ _proto._removeColliderShape = function _removeColliderShape(colliderShape) {
|
|
949
|
+
var _this = this, eventPool = _this._eventPool, currentEvents = _this._currentEvents, eventMap = _this._eventMap;
|
|
950
|
+
var id = colliderShape._id;
|
|
951
|
+
currentEvents.forEach(function(event, i) {
|
|
952
|
+
if (event.index1 == id) {
|
|
953
|
+
currentEvents.deleteByIndex(i);
|
|
954
|
+
eventPool.push(event);
|
|
955
|
+
} else if (event.index2 == id) {
|
|
956
|
+
currentEvents.deleteByIndex(i);
|
|
957
|
+
eventPool.push(event);
|
|
958
|
+
// If the shape is big index, should clear from the small index shape subMap
|
|
959
|
+
eventMap[event.index1][id] = undefined;
|
|
960
|
+
}
|
|
961
|
+
});
|
|
962
|
+
delete eventMap[id];
|
|
963
|
+
};
|
|
941
964
|
_proto._getTrigger = function _getTrigger(index1, index2) {
|
|
942
965
|
var event;
|
|
943
966
|
if (this._eventPool.length) {
|
|
@@ -1095,26 +1118,10 @@ var /**
|
|
|
1095
1118
|
};
|
|
1096
1119
|
return LitePhysicsScene;
|
|
1097
1120
|
}();
|
|
1098
|
-
(
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
(
|
|
1102
|
-
LitePhysicsScene._tempBox = new BoundingBox();
|
|
1103
|
-
})();
|
|
1104
|
-
(function() {
|
|
1105
|
-
LitePhysicsScene._currentHit = new LiteHitResult();
|
|
1106
|
-
})();
|
|
1107
|
-
(function() {
|
|
1108
|
-
LitePhysicsScene._hitResult = new LiteHitResult();
|
|
1109
|
-
})();
|
|
1110
|
-
var /**
|
|
1111
|
-
* Physics state
|
|
1112
|
-
*/ TriggerEventState;
|
|
1113
|
-
(function(TriggerEventState) {
|
|
1114
|
-
TriggerEventState[TriggerEventState["Enter"] = 0] = "Enter";
|
|
1115
|
-
TriggerEventState[TriggerEventState["Stay"] = 1] = "Stay";
|
|
1116
|
-
TriggerEventState[TriggerEventState["Exit"] = 2] = "Exit";
|
|
1117
|
-
})(TriggerEventState || (TriggerEventState = {}));
|
|
1121
|
+
LitePhysicsScene._tempSphere = new BoundingSphere();
|
|
1122
|
+
LitePhysicsScene._tempBox = new BoundingBox();
|
|
1123
|
+
LitePhysicsScene._currentHit = new LiteHitResult();
|
|
1124
|
+
LitePhysicsScene._hitResult = new LiteHitResult();
|
|
1118
1125
|
/**
|
|
1119
1126
|
* Trigger event to store interactive object ids and state.
|
|
1120
1127
|
*/ var TriggerEvent = function TriggerEvent(index1, index2) {
|
|
@@ -1126,12 +1133,11 @@ var /**
|
|
|
1126
1133
|
/**
|
|
1127
1134
|
* A static collider component that will not move.
|
|
1128
1135
|
* @remarks Mostly used for object which always stays at the same place and never moves around.
|
|
1129
|
-
*/ var LiteStaticCollider = /*#__PURE__*/ function(
|
|
1130
|
-
_inherits(LiteStaticCollider,
|
|
1136
|
+
*/ var LiteStaticCollider = /*#__PURE__*/ function(LiteCollider) {
|
|
1137
|
+
_inherits(LiteStaticCollider, LiteCollider);
|
|
1131
1138
|
function LiteStaticCollider(position, rotation) {
|
|
1132
1139
|
var _this;
|
|
1133
|
-
_this =
|
|
1134
|
-
/** @internal */ _this._isStaticCollider = true;
|
|
1140
|
+
_this = LiteCollider.call(this) || this, /** @internal */ _this._isStaticCollider = true;
|
|
1135
1141
|
_this._transform.setPosition(position.x, position.y, position.z);
|
|
1136
1142
|
_this._transform.setRotationQuaternion(rotation.x, rotation.y, rotation.z, rotation.w);
|
|
1137
1143
|
return _this;
|
|
@@ -1216,7 +1222,7 @@ var LitePhysics = /*#__PURE__*/ function() {
|
|
|
1216
1222
|
}();
|
|
1217
1223
|
|
|
1218
1224
|
//@ts-ignore
|
|
1219
|
-
var version = "1.
|
|
1225
|
+
var version = "1.4.0-alpha.1";
|
|
1220
1226
|
console.log("Galacean PhysicsLite version: " + version);
|
|
1221
1227
|
|
|
1222
1228
|
export { LitePhysics, version };
|