@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 CHANGED
@@ -176,12 +176,8 @@
176
176
  };
177
177
  return LiteColliderShape;
178
178
  }();
179
- (function() {
180
- LiteColliderShape._ray = new engine.Ray();
181
- })();
182
- (function() {
183
- LiteColliderShape._tempPoint = new engine.Vector3();
184
- })();
179
+ LiteColliderShape._ray = new engine.Ray();
180
+ LiteColliderShape._tempPoint = new engine.Vector3();
185
181
 
186
182
  /**
187
183
  * Used to implement transformation related functions.
@@ -197,7 +193,7 @@
197
193
  this._updateFlagManager = new LiteUpdateFlagManager();
198
194
  this._isParentDirty = true;
199
195
  this._parentTransformCache = null;
200
- this._dirtyFlag = 0xbc;
196
+ this._dirtyFlag = 188;
201
197
  }
202
198
  var _proto = LiteTransform.prototype;
203
199
  /**
@@ -239,8 +235,8 @@
239
235
  * Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
240
236
  * 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
237
  */ _proto._updateWorldPositionFlag = function _updateWorldPositionFlag() {
242
- if (!this._isContainDirtyFlags(0x84)) {
243
- this._worldAssociatedChange(0x84);
238
+ if (!this._isContainDirtyFlags(132)) {
239
+ this._worldAssociatedChange(132);
244
240
  if (_instanceof(this._owner, LiteCollider)) {
245
241
  var shapes = this._owner._shapes;
246
242
  for(var i = 0, n = shapes.length; i < n; i++){
@@ -256,8 +252,8 @@
256
252
  * 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
253
  * 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
254
  */ _proto._updateWorldRotationFlag = function _updateWorldRotationFlag() {
259
- if (!this._isContainDirtyFlags(0x98)) {
260
- this._worldAssociatedChange(0x98);
255
+ if (!this._isContainDirtyFlags(152)) {
256
+ this._worldAssociatedChange(152);
261
257
  if (_instanceof(this._owner, LiteCollider)) {
262
258
  var shapes = this._owner._shapes;
263
259
  for(var i = 0, n = shapes.length; i < n; i++){
@@ -272,8 +268,8 @@
272
268
  * Get worldScale: Will trigger the scaling update of itself and all parent entities.
273
269
  * In summary, any update of related variables will cause the dirty mark of one of the full process (worldMatrix) to be false.
274
270
  */ _proto._updateWorldScaleFlag = function _updateWorldScaleFlag() {
275
- if (!this._isContainDirtyFlags(0xa0)) {
276
- this._worldAssociatedChange(0xa0);
271
+ if (!this._isContainDirtyFlags(160)) {
272
+ this._worldAssociatedChange(160);
277
273
  if (_instanceof(this._owner, LiteCollider)) {
278
274
  var shapes = this._owner._shapes;
279
275
  for(var i = 0, n = shapes.length; i < n; i++){
@@ -285,8 +281,8 @@
285
281
  /**
286
282
  * Update all world transform property dirty flag, the principle is the same as above.
287
283
  */ _proto._updateAllWorldFlag = function _updateAllWorldFlag() {
288
- if (!this._isContainDirtyFlags(0xbc)) {
289
- this._worldAssociatedChange(0xbc);
284
+ if (!this._isContainDirtyFlags(188)) {
285
+ this._worldAssociatedChange(188);
290
286
  if (_instanceof(this._owner, LiteCollider)) {
291
287
  var shapes = this._owner._shapes;
292
288
  for(var i = 0, n = shapes.length; i < n; i++){
@@ -343,7 +339,7 @@
343
339
  if (this._position !== value) {
344
340
  this._position.copyFrom(value);
345
341
  }
346
- this._setDirtyFlagTrue(0x40);
342
+ this._setDirtyFlagTrue(64);
347
343
  this._updateWorldPositionFlag();
348
344
  }
349
345
  },
@@ -353,9 +349,9 @@
353
349
  * Local rotation, defining the rotation by using a unit quaternion.
354
350
  * @remarks Need to re-assign after modification to ensure that the modification takes effect.
355
351
  */ function get() {
356
- if (this._isContainDirtyFlag(0x2)) {
352
+ if (this._isContainDirtyFlag(2)) {
357
353
  engine.Quaternion.rotationEuler(engine.MathUtil.degreeToRadian(this._rotation.x), engine.MathUtil.degreeToRadian(this._rotation.y), engine.MathUtil.degreeToRadian(this._rotation.z), this._rotationQuaternion);
358
- this._setDirtyFlagFalse(0x2);
354
+ this._setDirtyFlagFalse(2);
359
355
  }
360
356
  return this._rotationQuaternion;
361
357
  },
@@ -363,8 +359,8 @@
363
359
  if (this._rotationQuaternion !== value) {
364
360
  this._rotationQuaternion.copyFrom(value);
365
361
  }
366
- this._setDirtyFlagTrue(0x40 | 0x1);
367
- this._setDirtyFlagFalse(0x2);
362
+ this._setDirtyFlagTrue(64 | 1);
363
+ this._setDirtyFlagFalse(2);
368
364
  this._updateWorldRotationFlag();
369
365
  }
370
366
  },
@@ -374,14 +370,14 @@
374
370
  * World rotation, defining the rotation by using a unit quaternion.
375
371
  * @remarks Need to re-assign after modification to ensure that the modification takes effect.
376
372
  */ function get() {
377
- if (this._isContainDirtyFlag(0x10)) {
373
+ if (this._isContainDirtyFlag(16)) {
378
374
  var parent = this._getParentTransform();
379
375
  if (parent != null) {
380
376
  engine.Quaternion.multiply(parent.worldRotationQuaternion, this.rotationQuaternion, this._worldRotationQuaternion);
381
377
  } else {
382
378
  this._worldRotationQuaternion.copyFrom(this.rotationQuaternion);
383
379
  }
384
- this._setDirtyFlagFalse(0x10);
380
+ this._setDirtyFlagFalse(16);
385
381
  }
386
382
  return this._worldRotationQuaternion;
387
383
  },
@@ -397,7 +393,7 @@
397
393
  this._rotationQuaternion.copyFrom(value);
398
394
  }
399
395
  this.rotationQuaternion = this._rotationQuaternion;
400
- this._setDirtyFlagFalse(0x10);
396
+ this._setDirtyFlagFalse(16);
401
397
  }
402
398
  },
403
399
  {
@@ -412,7 +408,7 @@
412
408
  if (this._scale !== value) {
413
409
  this._scale.copyFrom(value);
414
410
  }
415
- this._setDirtyFlagTrue(0x40);
411
+ this._setDirtyFlagTrue(64);
416
412
  this._updateWorldScaleFlag();
417
413
  }
418
414
  },
@@ -422,9 +418,9 @@
422
418
  * Local matrix.
423
419
  * @remarks Need to re-assign after modification to ensure that the modification takes effect.
424
420
  */ function get() {
425
- if (this._isContainDirtyFlag(0x40)) {
421
+ if (this._isContainDirtyFlag(64)) {
426
422
  engine.Matrix.affineTransformation(this._scale, this.rotationQuaternion, this._position, this._localMatrix);
427
- this._setDirtyFlagFalse(0x40);
423
+ this._setDirtyFlagFalse(64);
428
424
  }
429
425
  return this._localMatrix;
430
426
  },
@@ -433,8 +429,8 @@
433
429
  this._localMatrix.copyFrom(value);
434
430
  }
435
431
  this._localMatrix.decompose(this._position, this._rotationQuaternion, this._scale);
436
- this._setDirtyFlagTrue(0x1);
437
- this._setDirtyFlagFalse(0x40);
432
+ this._setDirtyFlagTrue(1);
433
+ this._setDirtyFlagFalse(64);
438
434
  this._updateAllWorldFlag();
439
435
  }
440
436
  },
@@ -444,14 +440,14 @@
444
440
  * World matrix.
445
441
  * @remarks Need to re-assign after modification to ensure that the modification takes effect.
446
442
  */ function get() {
447
- if (this._isContainDirtyFlag(0x80)) {
443
+ if (this._isContainDirtyFlag(128)) {
448
444
  var parent = this._getParentTransform();
449
445
  if (parent) {
450
446
  engine.Matrix.multiply(parent.worldMatrix, this.localMatrix, this._worldMatrix);
451
447
  } else {
452
448
  this._worldMatrix.copyFrom(this.localMatrix);
453
449
  }
454
- this._setDirtyFlagFalse(0x80);
450
+ this._setDirtyFlagFalse(128);
455
451
  }
456
452
  return this._worldMatrix;
457
453
  },
@@ -467,37 +463,14 @@
467
463
  this._localMatrix.copyFrom(value);
468
464
  }
469
465
  this.localMatrix = this._localMatrix;
470
- this._setDirtyFlagFalse(0x80);
466
+ this._setDirtyFlagFalse(128);
471
467
  }
472
468
  }
473
469
  ]);
474
470
  return LiteTransform;
475
471
  }();
476
- (function() {
477
- LiteTransform._tempQuat0 = new engine.Quaternion();
478
- })();
479
- (function() {
480
- LiteTransform._tempMat42 = new engine.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 = {}));
472
+ LiteTransform._tempQuat0 = new engine.Quaternion();
473
+ LiteTransform._tempMat42 = new engine.Matrix();
501
474
 
502
475
  /**
503
476
  * Abstract class of physical collider.
@@ -513,11 +486,13 @@
513
486
  */ _proto.addShape = function addShape(shape) {
514
487
  var oldCollider = shape._collider;
515
488
  if (oldCollider !== this) {
489
+ var _this__scene;
516
490
  if (oldCollider) {
517
491
  oldCollider.removeShape(shape);
518
492
  }
519
493
  this._shapes.push(shape);
520
494
  shape._collider = this;
495
+ (_this__scene = this._scene) == null ? void 0 : _this__scene._addColliderShape(shape);
521
496
  }
522
497
  };
523
498
  /**
@@ -525,8 +500,10 @@
525
500
  */ _proto.removeShape = function removeShape(shape) {
526
501
  var index = this._shapes.indexOf(shape);
527
502
  if (index !== -1) {
503
+ var _this__scene;
528
504
  this._shapes.splice(index, 1);
529
505
  shape._collider = null;
506
+ (_this__scene = this._scene) == null ? void 0 : _this__scene._removeColliderShape(shape);
530
507
  }
531
508
  };
532
509
  /**
@@ -561,18 +538,34 @@
561
538
 
562
539
  /**
563
540
  * A dynamic collider can act with self-defined movement or physical force
564
- */ var LiteDynamicCollider = /*#__PURE__*/ function(LiteCollider1) {
565
- _inherits(LiteDynamicCollider, LiteCollider1);
541
+ */ var LiteDynamicCollider = /*#__PURE__*/ function(LiteCollider) {
542
+ _inherits(LiteDynamicCollider, LiteCollider);
566
543
  function LiteDynamicCollider(position, rotation) {
567
544
  var _this;
568
- _this = LiteCollider1.call(this) || this;
569
- /** @internal */ _this._isStaticCollider = false;
545
+ _this = LiteCollider.call(this) || this, /** @internal */ _this._isStaticCollider = false;
570
546
  _this._transform.setPosition(position.x, position.y, position.z);
571
547
  _this._transform.setRotationQuaternion(rotation.x, rotation.y, rotation.z, rotation.w);
572
548
  return _this;
573
549
  }
574
550
  var _proto = LiteDynamicCollider.prototype;
575
551
  /**
552
+ * {@inheritDoc IDynamicCollider.getInertiaTensor }
553
+ */ _proto.getInertiaTensor = function getInertiaTensor(out) {
554
+ console.error("Physics-lite don't support getInertiaTensor. Use Physics-PhysX instead!");
555
+ return out;
556
+ };
557
+ /**
558
+ * {@inheritDoc IDynamicCollider.getCenterOfMass }
559
+ */ _proto.getCenterOfMass = function getCenterOfMass(out) {
560
+ console.error("Physics-lite don't support getCenterOfMass. Use Physics-PhysX instead!");
561
+ return out;
562
+ };
563
+ /**
564
+ * {@inheritDoc IDynamicCollider.setMassAndUpdateInertia }
565
+ */ _proto.setMassAndUpdateInertia = function setMassAndUpdateInertia(mass) {
566
+ console.error("Physics-lite don't support setMassAndUpdateInertia. Use Physics-PhysX instead!");
567
+ };
568
+ /**
576
569
  * {@inheritDoc IDynamicCollider.addForce }
577
570
  */ _proto.addForce = function addForce(force) {
578
571
  throw "Physics-lite don't support addForce. Use Physics-PhysX instead!";
@@ -593,74 +586,106 @@
593
586
  throw "Physics-lite don't support putToSleep. Use Physics-PhysX instead!";
594
587
  };
595
588
  /**
589
+ * {@inheritDoc IDynamicCollider.isSleeping }
590
+ */ _proto.isSleeping = function isSleeping() {
591
+ throw "Physics-lite don't support isSleeping. Use Physics-PhysX instead!";
592
+ };
593
+ /**
594
+ * {@inheritDoc IDynamicCollider.getAngularDamping }
595
+ */ _proto.getAngularDamping = function getAngularDamping() {
596
+ throw "Physics-lite don't support getAngularDamping. Use Physics-PhysX instead!";
597
+ };
598
+ /**
596
599
  * {@inheritDoc IDynamicCollider.setAngularDamping }
597
600
  */ _proto.setAngularDamping = function setAngularDamping(value) {
598
- throw "Physics-lite don't support setAngularDamping. Use Physics-PhysX instead!";
601
+ console.error("Physics-lite don't support setAngularDamping. Use Physics-PhysX instead!");
602
+ };
603
+ /**
604
+ * {@inheritDoc IDynamicCollider.getAngularVelocity }
605
+ */ _proto.getAngularVelocity = function getAngularVelocity(out) {
606
+ console.error("Physics-lite don't support getAngularVelocity. Use Physics-PhysX instead!");
607
+ return out;
599
608
  };
600
609
  /**
601
610
  * {@inheritDoc IDynamicCollider.setAngularVelocity }
602
611
  */ _proto.setAngularVelocity = function setAngularVelocity(value) {
603
- throw "Physics-lite don't support setAngularVelocity. Use Physics-PhysX instead!";
612
+ console.error("Physics-lite don't support setAngularVelocity. Use Physics-PhysX instead!");
604
613
  };
605
614
  /**
606
615
  * {@inheritDoc IDynamicCollider.setCenterOfMass }
607
616
  */ _proto.setCenterOfMass = function setCenterOfMass(value) {
608
- throw "Physics-lite don't support setCenterOfMass. Use Physics-PhysX instead!";
617
+ console.error("Physics-lite don't support setCenterOfMass. Use Physics-PhysX instead!");
609
618
  };
610
619
  /**
611
620
  * {@inheritDoc IDynamicCollider.setCollisionDetectionMode }
612
621
  */ _proto.setCollisionDetectionMode = function setCollisionDetectionMode(value) {
613
- throw "Physics-lite don't support setCollisionDetectionMode. Use Physics-PhysX instead!";
622
+ console.error("Physics-lite don't support setCollisionDetectionMode. Use Physics-PhysX instead!");
614
623
  };
615
624
  /**
616
625
  * {@inheritDoc IDynamicCollider.setConstraints }
617
626
  */ _proto.setConstraints = function setConstraints(flags) {
618
- throw "Physics-lite don't support setConstraints. Use Physics-PhysX instead!";
627
+ console.error("Physics-lite don't support setConstraints. Use Physics-PhysX instead!");
619
628
  };
620
629
  /**
621
630
  * {@inheritDoc IDynamicCollider.setInertiaTensor }
622
631
  */ _proto.setInertiaTensor = function setInertiaTensor(value) {
623
- throw "Physics-lite don't support setInertiaTensor. Use Physics-PhysX instead!";
632
+ console.error("Physics-lite don't support setInertiaTensor. Use Physics-PhysX instead!");
624
633
  };
625
634
  /**
626
635
  * {@inheritDoc IDynamicCollider.setIsKinematic }
627
636
  */ _proto.setIsKinematic = function setIsKinematic(value) {
628
- throw "Physics-lite don't support setIsKinematic. Use Physics-PhysX instead!";
637
+ console.error("Physics-lite don't support setIsKinematic. Use Physics-PhysX instead!");
638
+ };
639
+ /**
640
+ * {@inheritDoc IDynamicCollider.setLinearDamping }
641
+ */ _proto.getLinearDamping = function getLinearDamping() {
642
+ throw "Physics-lite don't support getLinearDamping. Use Physics-PhysX instead!";
629
643
  };
630
644
  /**
631
645
  * {@inheritDoc IDynamicCollider.setLinearDamping }
632
646
  */ _proto.setLinearDamping = function setLinearDamping(value) {
633
- throw "Physics-lite don't support setLinearDamping. Use Physics-PhysX instead!";
647
+ console.error("Physics-lite don't support setLinearDamping. Use Physics-PhysX instead!");
648
+ };
649
+ /**
650
+ * {@inheritDoc IDynamicCollider.getLinearVelocity }
651
+ */ _proto.getLinearVelocity = function getLinearVelocity(out) {
652
+ console.error("Physics-lite don't support getLinearVelocity. Use Physics-PhysX instead!");
653
+ return out;
634
654
  };
635
655
  /**
636
656
  * {@inheritDoc IDynamicCollider.setLinearVelocity }
637
657
  */ _proto.setLinearVelocity = function setLinearVelocity(value) {
638
- throw "Physics-lite don't support setLinearVelocity. Use Physics-PhysX instead!";
658
+ console.error("Physics-lite don't support setLinearVelocity. Use Physics-PhysX instead!");
639
659
  };
640
660
  /**
641
661
  * {@inheritDoc IDynamicCollider.setMass }
642
662
  */ _proto.setMass = function setMass(value) {
643
- throw "Physics-lite don't support setMass. Use Physics-PhysX instead!";
663
+ console.error("Physics-lite don't support setMass. Use Physics-PhysX instead!");
644
664
  };
645
665
  /**
646
666
  * {@inheritDoc IDynamicCollider.setMaxAngularVelocity }
647
667
  */ _proto.setMaxAngularVelocity = function setMaxAngularVelocity(value) {
648
- throw "Physics-lite don't support setMaxAngularVelocity. Use Physics-PhysX instead!";
668
+ console.error("Physics-lite don't support setMaxAngularVelocity. Use Physics-PhysX instead!");
669
+ };
670
+ /**
671
+ * {@inheritDoc IDynamicCollider.setMaxDepenetrationVelocity }
672
+ */ _proto.getMaxDepenetrationVelocity = function getMaxDepenetrationVelocity() {
673
+ throw "Physics-lite don't support getMaxDepenetrationVelocity. Use Physics-PhysX instead!";
649
674
  };
650
675
  /**
651
676
  * {@inheritDoc IDynamicCollider.setMaxDepenetrationVelocity }
652
677
  */ _proto.setMaxDepenetrationVelocity = function setMaxDepenetrationVelocity(value) {
653
- throw "Physics-lite don't support setMaxDepenetrationVelocity. Use Physics-PhysX instead!";
678
+ console.error("Physics-lite don't support setMaxDepenetrationVelocity. Use Physics-PhysX instead!");
654
679
  };
655
680
  /**
656
681
  * {@inheritDoc IDynamicCollider.setSleepThreshold }
657
682
  */ _proto.setSleepThreshold = function setSleepThreshold(value) {
658
- throw "Physics-lite don't support setSleepThreshold. Use Physics-PhysX instead!";
683
+ console.error("Physics-lite don't support setSleepThreshold. Use Physics-PhysX instead!");
659
684
  };
660
685
  /**
661
686
  * {@inheritDoc IDynamicCollider.setSolverIterations }
662
687
  */ _proto.setSolverIterations = function setSolverIterations(value) {
663
- throw "Physics-lite don't support setSolverIterations. Use Physics-PhysX instead!";
688
+ console.error("Physics-lite don't support setSolverIterations. Use Physics-PhysX instead!");
664
689
  };
665
690
  /**
666
691
  * {@inheritDoc IDynamicCollider.wakeUp }
@@ -718,15 +743,11 @@
718
743
 
719
744
  /**
720
745
  * Box collider shape in Lite.
721
- */ var LiteBoxColliderShape = /*#__PURE__*/ function(LiteColliderShape1) {
722
- _inherits(LiteBoxColliderShape, LiteColliderShape1);
746
+ */ var LiteBoxColliderShape = /*#__PURE__*/ function(LiteColliderShape) {
747
+ _inherits(LiteBoxColliderShape, LiteColliderShape);
723
748
  function LiteBoxColliderShape(uniqueID, size, material) {
724
749
  var _this;
725
- _this = LiteColliderShape1.call(this) || this;
726
- _this._halfSize = new engine.Vector3();
727
- _this._sizeScale = new engine.Vector3(1, 1, 1);
728
- /** @internal */ _this._boxMin = new engine.Vector3(-0.5, -0.5, -0.5);
729
- /** @internal */ _this._boxMax = new engine.Vector3(0.5, 0.5, 0.5);
750
+ _this = LiteColliderShape.call(this) || this, _this._halfSize = new engine.Vector3(), _this._sizeScale = new engine.Vector3(1, 1, 1), /** @internal */ _this._boxMin = new engine.Vector3(-0.5, -0.5, -0.5), /** @internal */ _this._boxMax = new engine.Vector3(0.5, 0.5, 0.5);
730
751
  _this._id = uniqueID;
731
752
  _this._halfSize.set(size.x * 0.5, size.y * 0.5, size.z * 0.5);
732
753
  _this._setBondingBox();
@@ -736,13 +757,13 @@
736
757
  /**
737
758
  * {@inheritDoc IColliderShape.setPosition }
738
759
  */ _proto.setPosition = function setPosition(position) {
739
- LiteColliderShape1.prototype.setPosition.call(this, position);
760
+ LiteColliderShape.prototype.setPosition.call(this, position);
740
761
  this._setBondingBox();
741
762
  };
742
763
  /**
743
764
  * {@inheritDoc IColliderShape.setWorldScale }
744
765
  */ _proto.setWorldScale = function setWorldScale(scale) {
745
- LiteColliderShape1.prototype.setWorldScale.call(this, scale);
766
+ LiteColliderShape.prototype.setWorldScale.call(this, scale);
746
767
  this._sizeScale.set(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z));
747
768
  this._setBondingBox();
748
769
  };
@@ -778,19 +799,15 @@
778
799
  };
779
800
  return LiteBoxColliderShape;
780
801
  }(LiteColliderShape);
781
- (function() {
782
- LiteBoxColliderShape._tempBox = new engine.BoundingBox();
783
- })();
802
+ LiteBoxColliderShape._tempBox = new engine.BoundingBox();
784
803
 
785
804
  /**
786
805
  * Sphere collider shape in Lite.
787
- */ var LiteSphereColliderShape = /*#__PURE__*/ function(LiteColliderShape1) {
788
- _inherits(LiteSphereColliderShape, LiteColliderShape1);
806
+ */ var LiteSphereColliderShape = /*#__PURE__*/ function(LiteColliderShape) {
807
+ _inherits(LiteSphereColliderShape, LiteColliderShape);
789
808
  function LiteSphereColliderShape(uniqueID, radius, material) {
790
809
  var _this;
791
- _this = LiteColliderShape1.call(this) || this;
792
- _this._radius = 1;
793
- _this._maxScale = 1;
810
+ _this = LiteColliderShape.call(this) || this, _this._radius = 1, _this._maxScale = 1;
794
811
  _this._radius = radius;
795
812
  _this._id = uniqueID;
796
813
  return _this;
@@ -804,7 +821,7 @@
804
821
  /**
805
822
  * {@inheritDoc IColliderShape.setWorldScale }
806
823
  */ _proto.setWorldScale = function setWorldScale(scale) {
807
- LiteColliderShape1.prototype.setWorldScale.call(this, scale);
824
+ LiteColliderShape.prototype.setWorldScale.call(this, scale);
808
825
  this._maxScale = Math.max(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z));
809
826
  };
810
827
  /**
@@ -831,9 +848,7 @@
831
848
  ]);
832
849
  return LiteSphereColliderShape;
833
850
  }(LiteColliderShape);
834
- (function() {
835
- LiteSphereColliderShape._tempSphere = new engine.BoundingSphere();
836
- })();
851
+ LiteSphereColliderShape._tempSphere = new engine.BoundingSphere();
837
852
 
838
853
  /**
839
854
  * A manager is a collection of colliders and constraints which can interact.
@@ -860,41 +875,26 @@
860
875
  console.log("Physics-lite don't support gravity. Use Physics-PhysX instead!");
861
876
  };
862
877
  /**
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
878
  * {@inheritDoc IPhysicsManager.addCollider }
887
879
  */ _proto.addCollider = function addCollider(actor) {
880
+ actor._scene = this;
888
881
  var colliders = actor._isStaticCollider ? this._staticColliders : this._dynamicColliders;
889
882
  colliders.push(actor);
883
+ var shapes = actor._shapes;
884
+ for(var i = 0, n = shapes.length; i < n; i++){
885
+ this._addColliderShape(shapes[i]);
886
+ }
890
887
  };
891
888
  /**
892
889
  * {@inheritDoc IPhysicsManager.removeCollider }
893
890
  */ _proto.removeCollider = function removeCollider(collider) {
891
+ collider._scene = null;
894
892
  var colliders = collider._isStaticCollider ? this._staticColliders : this._dynamicColliders;
895
893
  var index = colliders.indexOf(collider);
896
- if (index !== -1) {
897
- colliders.splice(index, 1);
894
+ index > -1 && colliders.splice(index, 1);
895
+ var shapes = collider._shapes;
896
+ for(var i = 0, n = shapes.length; i < n; i++){
897
+ this._removeColliderShape(shapes[i]);
898
898
  }
899
899
  };
900
900
  /**
@@ -942,6 +942,29 @@
942
942
  */ _proto.removeCharacterController = function removeCharacterController(characterController) {
943
943
  throw "Physics-lite don't support removeCharacterController. Use Physics-PhysX instead!";
944
944
  };
945
+ /**
946
+ * @internal
947
+ */ _proto._addColliderShape = function _addColliderShape(colliderShape) {
948
+ this._eventMap[colliderShape._id] = {};
949
+ };
950
+ /**
951
+ * @internal
952
+ */ _proto._removeColliderShape = function _removeColliderShape(colliderShape) {
953
+ var _this = this, eventPool = _this._eventPool, currentEvents = _this._currentEvents, eventMap = _this._eventMap;
954
+ var id = colliderShape._id;
955
+ currentEvents.forEach(function(event, i) {
956
+ if (event.index1 == id) {
957
+ currentEvents.deleteByIndex(i);
958
+ eventPool.push(event);
959
+ } else if (event.index2 == id) {
960
+ currentEvents.deleteByIndex(i);
961
+ eventPool.push(event);
962
+ // If the shape is big index, should clear from the small index shape subMap
963
+ eventMap[event.index1][id] = undefined;
964
+ }
965
+ });
966
+ delete eventMap[id];
967
+ };
945
968
  _proto._getTrigger = function _getTrigger(index1, index2) {
946
969
  var event;
947
970
  if (this._eventPool.length) {
@@ -1099,26 +1122,10 @@
1099
1122
  };
1100
1123
  return LitePhysicsScene;
1101
1124
  }();
1102
- (function() {
1103
- LitePhysicsScene._tempSphere = new engine.BoundingSphere();
1104
- })();
1105
- (function() {
1106
- LitePhysicsScene._tempBox = new engine.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 = {}));
1125
+ LitePhysicsScene._tempSphere = new engine.BoundingSphere();
1126
+ LitePhysicsScene._tempBox = new engine.BoundingBox();
1127
+ LitePhysicsScene._currentHit = new LiteHitResult();
1128
+ LitePhysicsScene._hitResult = new LiteHitResult();
1122
1129
  /**
1123
1130
  * Trigger event to store interactive object ids and state.
1124
1131
  */ var TriggerEvent = function TriggerEvent(index1, index2) {
@@ -1130,12 +1137,11 @@
1130
1137
  /**
1131
1138
  * A static collider component that will not move.
1132
1139
  * @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);
1140
+ */ var LiteStaticCollider = /*#__PURE__*/ function(LiteCollider) {
1141
+ _inherits(LiteStaticCollider, LiteCollider);
1135
1142
  function LiteStaticCollider(position, rotation) {
1136
1143
  var _this;
1137
- _this = LiteCollider1.call(this) || this;
1138
- /** @internal */ _this._isStaticCollider = true;
1144
+ _this = LiteCollider.call(this) || this, /** @internal */ _this._isStaticCollider = true;
1139
1145
  _this._transform.setPosition(position.x, position.y, position.z);
1140
1146
  _this._transform.setRotationQuaternion(rotation.x, rotation.y, rotation.z, rotation.w);
1141
1147
  return _this;
@@ -1220,7 +1226,7 @@
1220
1226
  }();
1221
1227
 
1222
1228
  //@ts-ignore
1223
- var version = "1.3.24";
1229
+ var version = "1.4.0-alpha.1";
1224
1230
  console.log("Galacean PhysicsLite version: " + version);
1225
1231
 
1226
1232
  exports.LitePhysics = LitePhysics;