@galacean/engine 1.4.15 → 1.4.16

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
@@ -7625,7 +7625,7 @@
7625
7625
  return relativeUrl;
7626
7626
  }
7627
7627
  if (!/^https?:/.test(baseUrl)) {
7628
- var fileSchema = "files://";
7628
+ var fileSchema = "file://";
7629
7629
  baseUrl = fileSchema + baseUrl;
7630
7630
  return new URL(relativeUrl, baseUrl).href.substring(fileSchema.length);
7631
7631
  }
@@ -25626,344 +25626,6 @@
25626
25626
  exports.Collider = __decorate$1([
25627
25627
  dependentComponents(Transform, DependentMode.CheckOnly)
25628
25628
  ], exports.Collider);
25629
- /**
25630
- * Describes a contact point where the collision occurs.
25631
- */ var ContactPoint = function ContactPoint() {
25632
- /** The position of the contact point between the shapes, in world space. */ this.position = new Vector3();
25633
- /** The normal of the contacting surfaces at the contact point. The normal direction points from the other shape to the self shape. */ this.normal = new Vector3();
25634
- /** The impulse applied at the contact point, in world space. Divide by the simulation time step to get a force value. */ this.impulse = new Vector3();
25635
- };
25636
- /**
25637
- * Collision information between two shapes when they collide.
25638
- */ var Collision = /*#__PURE__*/ function() {
25639
- function Collision() {}
25640
- var _proto = Collision.prototype;
25641
- /**
25642
- * Get contact points.
25643
- * @param outContacts - The result of contact points
25644
- * @returns The actual count of contact points
25645
- *
25646
- * @remarks To optimize performance, the engine does not modify the length of the array you pass.
25647
- * You need to obtain the actual number of contact points from the function's return value.
25648
- */ _proto.getContacts = function getContacts(outContacts) {
25649
- var nativeCollision = this._nativeCollision;
25650
- var smallerShapeId = Math.min(nativeCollision.shape0Id, nativeCollision.shape1Id);
25651
- var factor = this.shape.id === smallerShapeId ? 1 : -1;
25652
- var nativeContactPoints = nativeCollision.getContacts();
25653
- var length = nativeContactPoints.size();
25654
- for(var i = 0; i < length; i++){
25655
- var _outContacts, _i;
25656
- var nativeContractPoint = nativeContactPoints.get(i);
25657
- var contact = (_outContacts = outContacts)[_i = i] || (_outContacts[_i] = new ContactPoint());
25658
- contact.position.copyFrom(nativeContractPoint.position);
25659
- contact.normal.copyFrom(nativeContractPoint.normal).scale(factor);
25660
- contact.impulse.copyFrom(nativeContractPoint.impulse).scale(factor);
25661
- contact.separation = nativeContractPoint.separation;
25662
- }
25663
- return length;
25664
- };
25665
- _create_class$2(Collision, [
25666
- {
25667
- key: "contactCount",
25668
- get: /**
25669
- * Count of contact points.
25670
- */ function get() {
25671
- return this._nativeCollision.contactCount;
25672
- }
25673
- }
25674
- ]);
25675
- return Collision;
25676
- }();
25677
- /**
25678
- * A physics scene is a collection of colliders and constraints which can interact.
25679
- */ var PhysicsScene = /*#__PURE__*/ function() {
25680
- function PhysicsScene(scene) {
25681
- this._restTime = 0;
25682
- this._fixedTimeStep = 1 / 60;
25683
- this._colliders = new DisorderedArray();
25684
- this._gravity = new Vector3(0, -9.81, 0);
25685
- this._onContactEnter = function(nativeCollision) {
25686
- var physicalObjectsMap = Engine._physicalObjectsMap;
25687
- var shape0Id = nativeCollision.shape0Id, shape1Id = nativeCollision.shape1Id;
25688
- var shape1 = physicalObjectsMap[shape0Id];
25689
- var shape2 = physicalObjectsMap[shape1Id];
25690
- var collision = PhysicsScene._collision;
25691
- collision._nativeCollision = nativeCollision;
25692
- shape1.collider.entity._scripts.forEach(function(element) {
25693
- collision.shape = shape2;
25694
- element.onCollisionEnter(collision);
25695
- }, function(element, index) {
25696
- element._entityScriptsIndex = index;
25697
- });
25698
- shape2.collider.entity._scripts.forEach(function(element) {
25699
- collision.shape = shape1;
25700
- element.onCollisionEnter(collision);
25701
- }, function(element, index) {
25702
- element._entityScriptsIndex = index;
25703
- });
25704
- };
25705
- this._onContactExit = function(nativeCollision) {
25706
- var physicalObjectsMap = Engine._physicalObjectsMap;
25707
- var shape0Id = nativeCollision.shape0Id, shape1Id = nativeCollision.shape1Id;
25708
- var shape1 = physicalObjectsMap[shape0Id];
25709
- var shape2 = physicalObjectsMap[shape1Id];
25710
- var collision = PhysicsScene._collision;
25711
- collision._nativeCollision = nativeCollision;
25712
- shape1.collider.entity._scripts.forEach(function(element) {
25713
- collision.shape = shape2;
25714
- element.onCollisionExit(collision);
25715
- }, function(element, index) {
25716
- element._entityScriptsIndex = index;
25717
- });
25718
- shape2.collider.entity._scripts.forEach(function(element) {
25719
- collision.shape = shape1;
25720
- element.onCollisionExit(collision);
25721
- }, function(element, index) {
25722
- element._entityScriptsIndex = index;
25723
- });
25724
- };
25725
- this._onContactStay = function(nativeCollision) {
25726
- var physicalObjectsMap = Engine._physicalObjectsMap;
25727
- var shape0Id = nativeCollision.shape0Id, shape1Id = nativeCollision.shape1Id;
25728
- var shape1 = physicalObjectsMap[shape0Id];
25729
- var shape2 = physicalObjectsMap[shape1Id];
25730
- var collision = PhysicsScene._collision;
25731
- collision._nativeCollision = nativeCollision;
25732
- shape1.collider.entity._scripts.forEach(function(element) {
25733
- collision.shape = shape2;
25734
- element.onCollisionStay(collision);
25735
- }, function(element, index) {
25736
- element._entityScriptsIndex = index;
25737
- });
25738
- shape2.collider.entity._scripts.forEach(function(element) {
25739
- collision.shape = shape1;
25740
- element.onCollisionStay(collision);
25741
- }, function(element, index) {
25742
- element._entityScriptsIndex = index;
25743
- });
25744
- };
25745
- this._onTriggerEnter = function(obj1, obj2) {
25746
- var physicalObjectsMap = Engine._physicalObjectsMap;
25747
- var shape1 = physicalObjectsMap[obj1];
25748
- var shape2 = physicalObjectsMap[obj2];
25749
- shape1.collider.entity._scripts.forEach(function(element) {
25750
- element.onTriggerEnter(shape2);
25751
- }, function(element, index) {
25752
- element._entityScriptsIndex = index;
25753
- });
25754
- shape2.collider.entity._scripts.forEach(function(element) {
25755
- element.onTriggerEnter(shape1);
25756
- }, function(element, index) {
25757
- element._entityScriptsIndex = index;
25758
- });
25759
- };
25760
- this._onTriggerExit = function(obj1, obj2) {
25761
- var physicalObjectsMap = Engine._physicalObjectsMap;
25762
- var shape1 = physicalObjectsMap[obj1];
25763
- var shape2 = physicalObjectsMap[obj2];
25764
- shape1.collider.entity._scripts.forEach(function(element) {
25765
- element.onTriggerExit(shape2);
25766
- }, function(element, index) {
25767
- element._entityScriptsIndex = index;
25768
- });
25769
- shape2.collider.entity._scripts.forEach(function(element) {
25770
- element.onTriggerExit(shape1);
25771
- }, function(element, index) {
25772
- element._entityScriptsIndex = index;
25773
- });
25774
- };
25775
- this._onTriggerStay = function(obj1, obj2) {
25776
- var physicalObjectsMap = Engine._physicalObjectsMap;
25777
- var shape1 = physicalObjectsMap[obj1];
25778
- var shape2 = physicalObjectsMap[obj2];
25779
- shape1.collider.entity._scripts.forEach(function(element) {
25780
- element.onTriggerStay(shape2);
25781
- }, function(element, index) {
25782
- element._entityScriptsIndex = index;
25783
- });
25784
- shape2.collider.entity._scripts.forEach(function(element) {
25785
- element.onTriggerStay(shape1);
25786
- }, function(element, index) {
25787
- element._entityScriptsIndex = index;
25788
- });
25789
- };
25790
- this._scene = scene;
25791
- this._setGravity = this._setGravity.bind(this);
25792
- //@ts-ignore
25793
- this._gravity._onValueChanged = this._setGravity;
25794
- var engine = scene.engine;
25795
- if (engine._physicsInitialized) {
25796
- this._nativePhysicsScene = PhysicsScene._nativePhysics.createPhysicsScene(engine._nativePhysicsManager, this._onContactEnter, this._onContactExit, this._onContactStay, this._onTriggerEnter, this._onTriggerExit, this._onTriggerStay);
25797
- }
25798
- }
25799
- var _proto = PhysicsScene.prototype;
25800
- _proto.raycast = function raycast(ray, distanceOrResult, layerMaskOrResult, outHitResult) {
25801
- var hitResult;
25802
- var distance = Number.MAX_VALUE;
25803
- if (typeof distanceOrResult === "number") {
25804
- distance = distanceOrResult;
25805
- } else if (distanceOrResult != undefined) {
25806
- hitResult = distanceOrResult;
25807
- }
25808
- var layerMask = Layer.Everything;
25809
- if (typeof layerMaskOrResult === "number") {
25810
- layerMask = layerMaskOrResult;
25811
- } else if (layerMaskOrResult != undefined) {
25812
- hitResult = layerMaskOrResult;
25813
- }
25814
- if (outHitResult) {
25815
- hitResult = outHitResult;
25816
- }
25817
- var onRaycast = function onRaycast(obj) {
25818
- var shape = Engine._physicalObjectsMap[obj];
25819
- if (!shape) {
25820
- return false;
25821
- }
25822
- return shape.collider.entity.layer & layerMask && shape.isSceneQuery;
25823
- };
25824
- var outIDX;
25825
- var outDistance;
25826
- var outPosition;
25827
- var outNormal;
25828
- if (hitResult != undefined) {
25829
- var result = this._nativePhysicsScene.raycast(ray, distance, onRaycast, function(idx, distance, position, normal) {
25830
- outIDX = idx;
25831
- outDistance = distance;
25832
- outPosition = position;
25833
- outNormal = normal;
25834
- });
25835
- if (result) {
25836
- var hitShape = Engine._physicalObjectsMap[outIDX];
25837
- hitResult.entity = hitShape._collider.entity;
25838
- hitResult.shape = hitShape;
25839
- hitResult.distance = outDistance;
25840
- hitResult.point.copyFrom(outPosition);
25841
- hitResult.normal.copyFrom(outNormal);
25842
- return true;
25843
- } else {
25844
- hitResult.entity = null;
25845
- hitResult.shape = null;
25846
- hitResult.distance = 0;
25847
- hitResult.point.set(0, 0, 0);
25848
- hitResult.normal.set(0, 0, 0);
25849
- return false;
25850
- }
25851
- } else {
25852
- return this._nativePhysicsScene.raycast(ray, distance, onRaycast);
25853
- }
25854
- };
25855
- /**
25856
- * Call on every frame to update pose of objects.
25857
- * @internal
25858
- */ _proto._update = function _update(deltaTime) {
25859
- var _this = this, fixedTimeStep = _this._fixedTimeStep, nativePhysicsManager = _this._nativePhysicsScene;
25860
- var componentsManager = this._scene._componentsManager;
25861
- var simulateTime = this._restTime + deltaTime;
25862
- var step = Math.floor(simulateTime / fixedTimeStep);
25863
- this._restTime = simulateTime - step * fixedTimeStep;
25864
- for(var i = 0; i < step; i++){
25865
- componentsManager.callScriptOnPhysicsUpdate();
25866
- this._callColliderOnUpdate();
25867
- nativePhysicsManager.update(fixedTimeStep);
25868
- this._callColliderOnLateUpdate();
25869
- }
25870
- };
25871
- /**
25872
- * Add collider into the manager.
25873
- * @param collider - StaticCollider or DynamicCollider.
25874
- * @internal
25875
- */ _proto._addCollider = function _addCollider(collider) {
25876
- if (collider._index === -1) {
25877
- collider._index = this._colliders.length;
25878
- this._colliders.add(collider);
25879
- }
25880
- this._nativePhysicsScene.addCollider(collider._nativeCollider);
25881
- };
25882
- /**
25883
- * Add character controller into the manager.
25884
- * @param controller - Character Controller.
25885
- * @internal
25886
- */ _proto._addCharacterController = function _addCharacterController(controller) {
25887
- if (controller._index === -1) {
25888
- controller._index = this._colliders.length;
25889
- this._colliders.add(controller);
25890
- }
25891
- this._nativePhysicsScene.addCharacterController(controller._nativeCollider);
25892
- };
25893
- /**
25894
- * Remove collider.
25895
- * @param collider - StaticCollider or DynamicCollider.
25896
- * @internal
25897
- */ _proto._removeCollider = function _removeCollider(collider) {
25898
- var replaced = this._colliders.deleteByIndex(collider._index);
25899
- replaced && (replaced._index = collider._index);
25900
- collider._index = -1;
25901
- this._nativePhysicsScene.removeCollider(collider._nativeCollider);
25902
- };
25903
- /**
25904
- * Remove collider.
25905
- * @param controller - Character Controller.
25906
- * @internal
25907
- */ _proto._removeCharacterController = function _removeCharacterController(controller) {
25908
- var replaced = this._colliders.deleteByIndex(controller._index);
25909
- replaced && (replaced._index = controller._index);
25910
- controller._index = -1;
25911
- this._nativePhysicsScene.removeCharacterController(controller._nativeCollider);
25912
- };
25913
- /**
25914
- * @internal
25915
- */ _proto._callColliderOnUpdate = function _callColliderOnUpdate() {
25916
- var elements = this._colliders._elements;
25917
- for(var i = this._colliders.length - 1; i >= 0; --i){
25918
- elements[i]._onUpdate();
25919
- }
25920
- };
25921
- /**
25922
- * @internal
25923
- */ _proto._callColliderOnLateUpdate = function _callColliderOnLateUpdate() {
25924
- var elements = this._colliders._elements;
25925
- for(var i = this._colliders.length - 1; i >= 0; --i){
25926
- elements[i]._onLateUpdate();
25927
- }
25928
- };
25929
- /**
25930
- * @internal
25931
- */ _proto._gc = function _gc() {
25932
- this._colliders.garbageCollection();
25933
- };
25934
- _proto._setGravity = function _setGravity() {
25935
- this._nativePhysicsScene.setGravity(this._gravity);
25936
- };
25937
- _create_class$2(PhysicsScene, [
25938
- {
25939
- key: "gravity",
25940
- get: /**
25941
- * The gravity of physics scene.
25942
- */ function get() {
25943
- return this._gravity;
25944
- },
25945
- set: function set(value) {
25946
- var gravity = this._gravity;
25947
- if (gravity !== value) {
25948
- gravity.copyFrom(value);
25949
- }
25950
- }
25951
- },
25952
- {
25953
- key: "fixedTimeStep",
25954
- get: /**
25955
- * The fixed time step in seconds at which physics are performed.
25956
- */ function get() {
25957
- return this._fixedTimeStep;
25958
- },
25959
- set: function set(value) {
25960
- this._fixedTimeStep = Math.max(value, MathUtil.zeroTolerance);
25961
- }
25962
- }
25963
- ]);
25964
- return PhysicsScene;
25965
- }();
25966
- PhysicsScene._collision = new Collision();
25967
25629
  /**
25968
25630
  * The up axis of the collider shape.
25969
25631
  */ var ControllerNonWalkableMode = /*#__PURE__*/ function(ControllerNonWalkableMode) {
@@ -25978,7 +25640,7 @@
25978
25640
  function CharacterController(entity) {
25979
25641
  var _this;
25980
25642
  _this = Collider.call(this, entity) || this, _this._stepOffset = 0.5, _this._nonWalkableMode = ControllerNonWalkableMode.PreventClimbing, _this._upDirection = new Vector3(0, 1, 0), _this._slopeLimit = 45;
25981
- _this._nativeCollider = PhysicsScene._nativePhysics.createCharacterController();
25643
+ _this._nativeCollider = Engine._nativePhysics.createCharacterController();
25982
25644
  _this._setUpDirection = _this._setUpDirection.bind(_this);
25983
25645
  //@ts-ignore
25984
25646
  _this._upDirection._onValueChanged = _this._setUpDirection;
@@ -26127,7 +25789,7 @@
26127
25789
  var _this;
26128
25790
  _this = Collider.call(this, entity) || this, _this._linearDamping = 0, _this._angularDamping = 0.05, _this._linearVelocity = new Vector3(), _this._angularVelocity = new Vector3(), _this._mass = 1.0, _this._centerOfMass = new Vector3(), _this._inertiaTensor = new Vector3(1, 1, 1), _this._maxAngularVelocity = 18000 / Math.PI, _this._maxDepenetrationVelocity = 1.0000000331813535e32, _this._solverIterations = 4, _this._useGravity = true, _this._isKinematic = false, _this._constraints = 0, _this._collisionDetectionMode = 0, _this._sleepThreshold = 5e-3, _this._automaticCenterOfMass = true, _this._automaticInertiaTensor = true;
26129
25791
  var transform = _this.entity.transform;
26130
- _this._nativeCollider = PhysicsScene._nativePhysics.createDynamicCollider(transform.worldPosition, transform.worldRotationQuaternion);
25792
+ _this._nativeCollider = Engine._nativePhysics.createDynamicCollider(transform.worldPosition, transform.worldRotationQuaternion);
26131
25793
  _this._setLinearVelocity = _this._setLinearVelocity.bind(_this);
26132
25794
  _this._setAngularVelocity = _this._setAngularVelocity.bind(_this);
26133
25795
  _this._handleCenterOfMassChanged = _this._handleCenterOfMassChanged.bind(_this);
@@ -26598,7 +26260,7 @@
26598
26260
  this._staticFriction = 0.6;
26599
26261
  this._bounceCombine = PhysicsMaterialCombineMode.Average;
26600
26262
  this._frictionCombine = PhysicsMaterialCombineMode.Average;
26601
- this._nativeMaterial = PhysicsScene._nativePhysics.createPhysicsMaterial(this._staticFriction, this._dynamicFriction, this._bounciness, this._bounceCombine, this._frictionCombine);
26263
+ this._nativeMaterial = Engine._nativePhysics.createPhysicsMaterial(this._staticFriction, this._dynamicFriction, this._bounciness, this._bounceCombine, this._frictionCombine);
26602
26264
  }
26603
26265
  var _proto = PhysicsMaterial.prototype;
26604
26266
  /**
@@ -26681,6 +26343,350 @@
26681
26343
  ]);
26682
26344
  return PhysicsMaterial;
26683
26345
  }();
26346
+ /**
26347
+ * Describes a contact point where the collision occurs.
26348
+ */ var ContactPoint = function ContactPoint() {
26349
+ /** The position of the contact point between the shapes, in world space. */ this.position = new Vector3();
26350
+ /** The normal of the contacting surfaces at the contact point. The normal direction points from the other shape to the self shape. */ this.normal = new Vector3();
26351
+ /** The impulse applied at the contact point, in world space. Divide by the simulation time step to get a force value. */ this.impulse = new Vector3();
26352
+ };
26353
+ /**
26354
+ * Collision information between two shapes when they collide.
26355
+ */ var Collision = /*#__PURE__*/ function() {
26356
+ function Collision() {}
26357
+ var _proto = Collision.prototype;
26358
+ /**
26359
+ * Get contact points.
26360
+ * @param outContacts - The result of contact points
26361
+ * @returns The actual count of contact points
26362
+ *
26363
+ * @remarks To optimize performance, the engine does not modify the length of the array you pass.
26364
+ * You need to obtain the actual number of contact points from the function's return value.
26365
+ */ _proto.getContacts = function getContacts(outContacts) {
26366
+ var nativeCollision = this._nativeCollision;
26367
+ var smallerShapeId = Math.min(nativeCollision.shape0Id, nativeCollision.shape1Id);
26368
+ var factor = this.shape.id === smallerShapeId ? 1 : -1;
26369
+ var nativeContactPoints = nativeCollision.getContacts();
26370
+ var length = nativeContactPoints.size();
26371
+ for(var i = 0; i < length; i++){
26372
+ var _outContacts, _i;
26373
+ var nativeContractPoint = nativeContactPoints.get(i);
26374
+ var contact = (_outContacts = outContacts)[_i = i] || (_outContacts[_i] = new ContactPoint());
26375
+ contact.position.copyFrom(nativeContractPoint.position);
26376
+ contact.normal.copyFrom(nativeContractPoint.normal).scale(factor);
26377
+ contact.impulse.copyFrom(nativeContractPoint.impulse).scale(factor);
26378
+ contact.separation = nativeContractPoint.separation;
26379
+ }
26380
+ return length;
26381
+ };
26382
+ _create_class$2(Collision, [
26383
+ {
26384
+ key: "contactCount",
26385
+ get: /**
26386
+ * Count of contact points.
26387
+ */ function get() {
26388
+ return this._nativeCollision.contactCount;
26389
+ }
26390
+ }
26391
+ ]);
26392
+ return Collision;
26393
+ }();
26394
+ /**
26395
+ * A physics scene is a collection of colliders and constraints which can interact.
26396
+ */ var PhysicsScene = /*#__PURE__*/ function() {
26397
+ function PhysicsScene(scene) {
26398
+ this._restTime = 0;
26399
+ this._fixedTimeStep = 1 / 60;
26400
+ this._colliders = new DisorderedArray();
26401
+ this._gravity = new Vector3(0, -9.81, 0);
26402
+ this._onContactEnter = function(nativeCollision) {
26403
+ var physicalObjectsMap = Engine._physicalObjectsMap;
26404
+ var shape0Id = nativeCollision.shape0Id, shape1Id = nativeCollision.shape1Id;
26405
+ var shape1 = physicalObjectsMap[shape0Id];
26406
+ var shape2 = physicalObjectsMap[shape1Id];
26407
+ var collision = PhysicsScene._collision;
26408
+ collision._nativeCollision = nativeCollision;
26409
+ shape1.collider.entity._scripts.forEach(function(element) {
26410
+ collision.shape = shape2;
26411
+ element.onCollisionEnter(collision);
26412
+ }, function(element, index) {
26413
+ element._entityScriptsIndex = index;
26414
+ });
26415
+ shape2.collider.entity._scripts.forEach(function(element) {
26416
+ collision.shape = shape1;
26417
+ element.onCollisionEnter(collision);
26418
+ }, function(element, index) {
26419
+ element._entityScriptsIndex = index;
26420
+ });
26421
+ };
26422
+ this._onContactExit = function(nativeCollision) {
26423
+ var physicalObjectsMap = Engine._physicalObjectsMap;
26424
+ var shape0Id = nativeCollision.shape0Id, shape1Id = nativeCollision.shape1Id;
26425
+ var shape1 = physicalObjectsMap[shape0Id];
26426
+ var shape2 = physicalObjectsMap[shape1Id];
26427
+ var collision = PhysicsScene._collision;
26428
+ collision._nativeCollision = nativeCollision;
26429
+ shape1.collider.entity._scripts.forEach(function(element) {
26430
+ collision.shape = shape2;
26431
+ element.onCollisionExit(collision);
26432
+ }, function(element, index) {
26433
+ element._entityScriptsIndex = index;
26434
+ });
26435
+ shape2.collider.entity._scripts.forEach(function(element) {
26436
+ collision.shape = shape1;
26437
+ element.onCollisionExit(collision);
26438
+ }, function(element, index) {
26439
+ element._entityScriptsIndex = index;
26440
+ });
26441
+ };
26442
+ this._onContactStay = function(nativeCollision) {
26443
+ var physicalObjectsMap = Engine._physicalObjectsMap;
26444
+ var shape0Id = nativeCollision.shape0Id, shape1Id = nativeCollision.shape1Id;
26445
+ var shape1 = physicalObjectsMap[shape0Id];
26446
+ var shape2 = physicalObjectsMap[shape1Id];
26447
+ var collision = PhysicsScene._collision;
26448
+ collision._nativeCollision = nativeCollision;
26449
+ shape1.collider.entity._scripts.forEach(function(element) {
26450
+ collision.shape = shape2;
26451
+ element.onCollisionStay(collision);
26452
+ }, function(element, index) {
26453
+ element._entityScriptsIndex = index;
26454
+ });
26455
+ shape2.collider.entity._scripts.forEach(function(element) {
26456
+ collision.shape = shape1;
26457
+ element.onCollisionStay(collision);
26458
+ }, function(element, index) {
26459
+ element._entityScriptsIndex = index;
26460
+ });
26461
+ };
26462
+ this._onTriggerEnter = function(obj1, obj2) {
26463
+ var physicalObjectsMap = Engine._physicalObjectsMap;
26464
+ var shape1 = physicalObjectsMap[obj1];
26465
+ var shape2 = physicalObjectsMap[obj2];
26466
+ shape1.collider.entity._scripts.forEach(function(element) {
26467
+ element.onTriggerEnter(shape2);
26468
+ }, function(element, index) {
26469
+ element._entityScriptsIndex = index;
26470
+ });
26471
+ shape2.collider.entity._scripts.forEach(function(element) {
26472
+ element.onTriggerEnter(shape1);
26473
+ }, function(element, index) {
26474
+ element._entityScriptsIndex = index;
26475
+ });
26476
+ };
26477
+ this._onTriggerExit = function(obj1, obj2) {
26478
+ var physicalObjectsMap = Engine._physicalObjectsMap;
26479
+ var shape1 = physicalObjectsMap[obj1];
26480
+ var shape2 = physicalObjectsMap[obj2];
26481
+ shape1.collider.entity._scripts.forEach(function(element) {
26482
+ element.onTriggerExit(shape2);
26483
+ }, function(element, index) {
26484
+ element._entityScriptsIndex = index;
26485
+ });
26486
+ shape2.collider.entity._scripts.forEach(function(element) {
26487
+ element.onTriggerExit(shape1);
26488
+ }, function(element, index) {
26489
+ element._entityScriptsIndex = index;
26490
+ });
26491
+ };
26492
+ this._onTriggerStay = function(obj1, obj2) {
26493
+ var physicalObjectsMap = Engine._physicalObjectsMap;
26494
+ var shape1 = physicalObjectsMap[obj1];
26495
+ var shape2 = physicalObjectsMap[obj2];
26496
+ shape1.collider.entity._scripts.forEach(function(element) {
26497
+ element.onTriggerStay(shape2);
26498
+ }, function(element, index) {
26499
+ element._entityScriptsIndex = index;
26500
+ });
26501
+ shape2.collider.entity._scripts.forEach(function(element) {
26502
+ element.onTriggerStay(shape1);
26503
+ }, function(element, index) {
26504
+ element._entityScriptsIndex = index;
26505
+ });
26506
+ };
26507
+ this._scene = scene;
26508
+ this._setGravity = this._setGravity.bind(this);
26509
+ //@ts-ignore
26510
+ this._gravity._onValueChanged = this._setGravity;
26511
+ var engine = scene.engine;
26512
+ if (engine._physicsInitialized) {
26513
+ this._nativePhysicsScene = Engine._nativePhysics.createPhysicsScene(engine._nativePhysicsManager, this._onContactEnter, this._onContactExit, this._onContactStay, this._onTriggerEnter, this._onTriggerExit, this._onTriggerStay);
26514
+ }
26515
+ }
26516
+ var _proto = PhysicsScene.prototype;
26517
+ _proto.raycast = function raycast(ray, distanceOrResult, layerMaskOrResult, outHitResult) {
26518
+ var hitResult;
26519
+ var distance = Number.MAX_VALUE;
26520
+ if (typeof distanceOrResult === "number") {
26521
+ distance = distanceOrResult;
26522
+ } else if (distanceOrResult != undefined) {
26523
+ hitResult = distanceOrResult;
26524
+ }
26525
+ var layerMask = Layer.Everything;
26526
+ if (typeof layerMaskOrResult === "number") {
26527
+ layerMask = layerMaskOrResult;
26528
+ } else if (layerMaskOrResult != undefined) {
26529
+ hitResult = layerMaskOrResult;
26530
+ }
26531
+ if (outHitResult) {
26532
+ hitResult = outHitResult;
26533
+ }
26534
+ var onRaycast = function onRaycast(obj) {
26535
+ var shape = Engine._physicalObjectsMap[obj];
26536
+ if (!shape) {
26537
+ return false;
26538
+ }
26539
+ return shape.collider.entity.layer & layerMask && shape.isSceneQuery;
26540
+ };
26541
+ var outIDX;
26542
+ var outDistance;
26543
+ var outPosition;
26544
+ var outNormal;
26545
+ if (hitResult != undefined) {
26546
+ var result = this._nativePhysicsScene.raycast(ray, distance, onRaycast, function(idx, distance, position, normal) {
26547
+ outIDX = idx;
26548
+ outDistance = distance;
26549
+ outPosition = position;
26550
+ outNormal = normal;
26551
+ });
26552
+ if (result) {
26553
+ var hitShape = Engine._physicalObjectsMap[outIDX];
26554
+ hitResult.entity = hitShape._collider.entity;
26555
+ hitResult.shape = hitShape;
26556
+ hitResult.distance = outDistance;
26557
+ hitResult.point.copyFrom(outPosition);
26558
+ hitResult.normal.copyFrom(outNormal);
26559
+ return true;
26560
+ } else {
26561
+ hitResult.entity = null;
26562
+ hitResult.shape = null;
26563
+ hitResult.distance = 0;
26564
+ hitResult.point.set(0, 0, 0);
26565
+ hitResult.normal.set(0, 0, 0);
26566
+ return false;
26567
+ }
26568
+ } else {
26569
+ return this._nativePhysicsScene.raycast(ray, distance, onRaycast);
26570
+ }
26571
+ };
26572
+ /**
26573
+ * Call on every frame to update pose of objects.
26574
+ * @internal
26575
+ */ _proto._update = function _update(deltaTime) {
26576
+ var _this = this, fixedTimeStep = _this._fixedTimeStep, nativePhysicsManager = _this._nativePhysicsScene;
26577
+ var componentsManager = this._scene._componentsManager;
26578
+ var simulateTime = this._restTime + deltaTime;
26579
+ var step = Math.floor(simulateTime / fixedTimeStep);
26580
+ this._restTime = simulateTime - step * fixedTimeStep;
26581
+ for(var i = 0; i < step; i++){
26582
+ componentsManager.callScriptOnPhysicsUpdate();
26583
+ this._callColliderOnUpdate();
26584
+ nativePhysicsManager.update(fixedTimeStep);
26585
+ this._callColliderOnLateUpdate();
26586
+ }
26587
+ };
26588
+ /**
26589
+ * Add collider into the manager.
26590
+ * @param collider - StaticCollider or DynamicCollider.
26591
+ * @internal
26592
+ */ _proto._addCollider = function _addCollider(collider) {
26593
+ if (collider._index === -1) {
26594
+ collider._index = this._colliders.length;
26595
+ this._colliders.add(collider);
26596
+ }
26597
+ this._nativePhysicsScene.addCollider(collider._nativeCollider);
26598
+ };
26599
+ /**
26600
+ * Add character controller into the manager.
26601
+ * @param controller - Character Controller.
26602
+ * @internal
26603
+ */ _proto._addCharacterController = function _addCharacterController(controller) {
26604
+ if (controller._index === -1) {
26605
+ controller._index = this._colliders.length;
26606
+ this._colliders.add(controller);
26607
+ }
26608
+ this._nativePhysicsScene.addCharacterController(controller._nativeCollider);
26609
+ };
26610
+ /**
26611
+ * Remove collider.
26612
+ * @param collider - StaticCollider or DynamicCollider.
26613
+ * @internal
26614
+ */ _proto._removeCollider = function _removeCollider(collider) {
26615
+ var replaced = this._colliders.deleteByIndex(collider._index);
26616
+ replaced && (replaced._index = collider._index);
26617
+ collider._index = -1;
26618
+ this._nativePhysicsScene.removeCollider(collider._nativeCollider);
26619
+ };
26620
+ /**
26621
+ * Remove collider.
26622
+ * @param controller - Character Controller.
26623
+ * @internal
26624
+ */ _proto._removeCharacterController = function _removeCharacterController(controller) {
26625
+ var replaced = this._colliders.deleteByIndex(controller._index);
26626
+ replaced && (replaced._index = controller._index);
26627
+ controller._index = -1;
26628
+ this._nativePhysicsScene.removeCharacterController(controller._nativeCollider);
26629
+ };
26630
+ /**
26631
+ * @internal
26632
+ */ _proto._callColliderOnUpdate = function _callColliderOnUpdate() {
26633
+ var elements = this._colliders._elements;
26634
+ for(var i = this._colliders.length - 1; i >= 0; --i){
26635
+ elements[i]._onUpdate();
26636
+ }
26637
+ };
26638
+ /**
26639
+ * @internal
26640
+ */ _proto._callColliderOnLateUpdate = function _callColliderOnLateUpdate() {
26641
+ var elements = this._colliders._elements;
26642
+ for(var i = this._colliders.length - 1; i >= 0; --i){
26643
+ elements[i]._onLateUpdate();
26644
+ }
26645
+ };
26646
+ /**
26647
+ * @internal
26648
+ */ _proto._gc = function _gc() {
26649
+ this._colliders.garbageCollection();
26650
+ };
26651
+ /**
26652
+ * @internal
26653
+ */ _proto._destroy = function _destroy() {
26654
+ var _this__nativePhysicsScene;
26655
+ (_this__nativePhysicsScene = this._nativePhysicsScene) == null ? void 0 : _this__nativePhysicsScene.destroy();
26656
+ };
26657
+ _proto._setGravity = function _setGravity() {
26658
+ this._nativePhysicsScene.setGravity(this._gravity);
26659
+ };
26660
+ _create_class$2(PhysicsScene, [
26661
+ {
26662
+ key: "gravity",
26663
+ get: /**
26664
+ * The gravity of physics scene.
26665
+ */ function get() {
26666
+ return this._gravity;
26667
+ },
26668
+ set: function set(value) {
26669
+ var gravity = this._gravity;
26670
+ if (gravity !== value) {
26671
+ gravity.copyFrom(value);
26672
+ }
26673
+ }
26674
+ },
26675
+ {
26676
+ key: "fixedTimeStep",
26677
+ get: /**
26678
+ * The fixed time step in seconds at which physics are performed.
26679
+ */ function get() {
26680
+ return this._fixedTimeStep;
26681
+ },
26682
+ set: function set(value) {
26683
+ this._fixedTimeStep = Math.max(value, MathUtil.zeroTolerance);
26684
+ }
26685
+ }
26686
+ ]);
26687
+ return PhysicsScene;
26688
+ }();
26689
+ PhysicsScene._collision = new Collision();
26684
26690
  /**
26685
26691
  * A static collider component that will not move.
26686
26692
  * @remarks Mostly used for object which always stays at the same place and never moves around.
@@ -26690,7 +26696,7 @@
26690
26696
  var _this;
26691
26697
  _this = Collider.call(this, entity) || this;
26692
26698
  var transform = _this.entity.transform;
26693
- _this._nativeCollider = PhysicsScene._nativePhysics.createStaticCollider(transform.worldPosition, transform.worldRotationQuaternion);
26699
+ _this._nativeCollider = Engine._nativePhysics.createStaticCollider(transform.worldPosition, transform.worldRotationQuaternion);
26694
26700
  return _this;
26695
26701
  }
26696
26702
  return StaticCollider;
@@ -27042,7 +27048,7 @@
27042
27048
  _proto._createJoint = function _createJoint() {
27043
27049
  var colliderInfo = this._colliderInfo;
27044
27050
  colliderInfo.collider = this.entity.getComponent(exports.Collider);
27045
- this._nativeJoint = PhysicsScene._nativePhysics.createFixedJoint(colliderInfo.collider._nativeCollider);
27051
+ this._nativeJoint = Engine._nativePhysics.createFixedJoint(colliderInfo.collider._nativeCollider);
27046
27052
  };
27047
27053
  return FixedJoint;
27048
27054
  }(exports.Joint);
@@ -27082,7 +27088,7 @@
27082
27088
  _proto._createJoint = function _createJoint() {
27083
27089
  var colliderInfo = this._colliderInfo;
27084
27090
  colliderInfo.collider = this.entity.getComponent(exports.Collider);
27085
- this._nativeJoint = PhysicsScene._nativePhysics.createHingeJoint(colliderInfo.collider._nativeCollider);
27091
+ this._nativeJoint = Engine._nativePhysics.createHingeJoint(colliderInfo.collider._nativeCollider);
27086
27092
  };
27087
27093
  _proto._syncNative = function _syncNative() {
27088
27094
  Joint.prototype._syncNative.call(this);
@@ -27276,7 +27282,7 @@
27276
27282
  _proto._createJoint = function _createJoint() {
27277
27283
  var colliderInfo = this._colliderInfo;
27278
27284
  colliderInfo.collider = this.entity.getComponent(exports.Collider);
27279
- this._nativeJoint = PhysicsScene._nativePhysics.createSpringJoint(colliderInfo.collider._nativeCollider);
27285
+ this._nativeJoint = Engine._nativePhysics.createSpringJoint(colliderInfo.collider._nativeCollider);
27280
27286
  };
27281
27287
  _proto._syncNative = function _syncNative() {
27282
27288
  Joint.prototype._syncNative.call(this);
@@ -27732,7 +27738,7 @@
27732
27738
  function BoxColliderShape() {
27733
27739
  var _this;
27734
27740
  _this = ColliderShape.call(this) || this, _this._size = new Vector3(1, 1, 1);
27735
- _this._nativeShape = PhysicsScene._nativePhysics.createBoxColliderShape(_this._id, _this._size, _this._material._nativeMaterial);
27741
+ _this._nativeShape = Engine._nativePhysics.createBoxColliderShape(_this._id, _this._size, _this._material._nativeMaterial);
27736
27742
  //@ts-ignore
27737
27743
  _this._size._onValueChanged = _this._setSize.bind(_this);
27738
27744
  return _this;
@@ -27775,7 +27781,7 @@
27775
27781
  function SphereColliderShape() {
27776
27782
  var _this;
27777
27783
  _this = ColliderShape.call(this) || this, _this._radius = 1;
27778
- _this._nativeShape = PhysicsScene._nativePhysics.createSphereColliderShape(_this._id, _this._radius, _this._material._nativeMaterial);
27784
+ _this._nativeShape = Engine._nativePhysics.createSphereColliderShape(_this._id, _this._radius, _this._material._nativeMaterial);
27779
27785
  return _this;
27780
27786
  }
27781
27787
  var _proto = SphereColliderShape.prototype;
@@ -27808,7 +27814,7 @@
27808
27814
  function PlaneColliderShape() {
27809
27815
  var _this;
27810
27816
  _this = ColliderShape.call(this) || this;
27811
- _this._nativeShape = PhysicsScene._nativePhysics.createPlaneColliderShape(_this._id, _this._material._nativeMaterial);
27817
+ _this._nativeShape = Engine._nativePhysics.createPlaneColliderShape(_this._id, _this._material._nativeMaterial);
27812
27818
  return _this;
27813
27819
  }
27814
27820
  var _proto = PlaneColliderShape.prototype;
@@ -27825,7 +27831,7 @@
27825
27831
  function CapsuleColliderShape() {
27826
27832
  var _this;
27827
27833
  _this = ColliderShape.call(this) || this, _this._radius = 1, _this._height = 2, _this._upAxis = ColliderShapeUpAxis.Y;
27828
- _this._nativeShape = PhysicsScene._nativePhysics.createCapsuleColliderShape(_this._id, _this._radius, _this._height, _this._material._nativeMaterial);
27834
+ _this._nativeShape = Engine._nativePhysics.createCapsuleColliderShape(_this._id, _this._radius, _this._height, _this._material._nativeMaterial);
27829
27835
  return _this;
27830
27836
  }
27831
27837
  var _proto = CapsuleColliderShape.prototype;
@@ -29833,7 +29839,10 @@
29833
29839
  var initializePromises = new Array();
29834
29840
  if (physics) {
29835
29841
  initializePromises.push(physics.initialize().then(function() {
29836
- PhysicsScene._nativePhysics = physics;
29842
+ if (Engine._nativePhysics) {
29843
+ console.warn("A physics engine has already been configured. All physics operations will now be handled by the newly specified physics engine.");
29844
+ }
29845
+ Engine._nativePhysics = physics;
29837
29846
  _this._nativePhysicsManager = physics.createPhysicsManager();
29838
29847
  _this._physicsInitialized = true;
29839
29848
  return _this;
@@ -31889,6 +31898,7 @@
31889
31898
  this._maskManager.destroy();
31890
31899
  var allCreatedScenes = sceneManager._allCreatedScenes;
31891
31900
  allCreatedScenes.splice(allCreatedScenes.indexOf(this), 1);
31901
+ this.physics._destroy();
31892
31902
  };
31893
31903
  _proto._computeLinearFogParams = function _computeLinearFogParams(fogStart, fogEnd) {
31894
31904
  var fogRange = fogEnd - fogStart;
@@ -40460,10 +40470,11 @@
40460
40470
  function Polyfill() {}
40461
40471
  Polyfill.registerPolyfill = function registerPolyfill() {
40462
40472
  Polyfill._registerMatchAll();
40473
+ Polyfill._registerAudioContext();
40463
40474
  };
40464
40475
  Polyfill._registerMatchAll = function _registerMatchAll() {
40465
40476
  if (!String.prototype.matchAll) {
40466
- Logger.info("polyfill String.prototype.matchAll");
40477
+ Logger.info("Polyfill String.prototype.matchAll");
40467
40478
  String.prototype.matchAll = function(pattern) {
40468
40479
  var flags = pattern.flags;
40469
40480
  var globalFlagIdx = flags.indexOf("g");
@@ -40517,6 +40528,26 @@
40517
40528
  };
40518
40529
  }
40519
40530
  };
40531
+ Polyfill._registerAudioContext = function _registerAudioContext() {
40532
+ // IOS 12 and the following system do not support AudioContext, need to switch to webkitAudioContext
40533
+ if (!window.AudioContext && window.webkitAudioContext) {
40534
+ Logger.info("Polyfill window.AudioContext");
40535
+ window.AudioContext = window.webkitAudioContext;
40536
+ var originalDecodeAudioData = AudioContext.prototype.decodeAudioData;
40537
+ AudioContext.prototype.decodeAudioData = function(arrayBuffer, successCallback, errorCallback) {
40538
+ var _this = this;
40539
+ return new Promise(function(resolve, reject) {
40540
+ originalDecodeAudioData.call(_this, arrayBuffer, function(buffer) {
40541
+ successCallback == null ? void 0 : successCallback(buffer);
40542
+ resolve(buffer);
40543
+ }, function(error) {
40544
+ errorCallback == null ? void 0 : errorCallback(error);
40545
+ reject(error);
40546
+ });
40547
+ });
40548
+ };
40549
+ }
40550
+ };
40520
40551
  return Polyfill;
40521
40552
  }();
40522
40553
  Polyfill.registerPolyfill();
@@ -43261,11 +43292,215 @@
43261
43292
  ]);
43262
43293
  return FileHeader;
43263
43294
  }();
43295
+ var InterpolableValueType = /*#__PURE__*/ function(InterpolableValueType) {
43296
+ InterpolableValueType[InterpolableValueType["Float"] = 0] = "Float";
43297
+ InterpolableValueType[InterpolableValueType["FloatArray"] = 1] = "FloatArray";
43298
+ InterpolableValueType[InterpolableValueType["Vector2"] = 2] = "Vector2";
43299
+ InterpolableValueType[InterpolableValueType["Vector3"] = 3] = "Vector3";
43300
+ InterpolableValueType[InterpolableValueType["Vector4"] = 4] = "Vector4";
43301
+ InterpolableValueType[InterpolableValueType["Quaternion"] = 5] = "Quaternion";
43302
+ InterpolableValueType[InterpolableValueType["Color"] = 6] = "Color";
43303
+ InterpolableValueType[InterpolableValueType["Array"] = 7] = "Array";
43304
+ InterpolableValueType[InterpolableValueType["Boolean"] = 8] = "Boolean";
43305
+ InterpolableValueType[InterpolableValueType["Rect"] = 9] = "Rect";
43306
+ InterpolableValueType[InterpolableValueType["ReferResource"] = 10] = "ReferResource";
43307
+ return InterpolableValueType;
43308
+ }({});
43309
+ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
43310
+ function AnimationClipDecoder() {}
43311
+ AnimationClipDecoder.decode = function decode(engine, bufferReader) {
43312
+ return new AssetPromise(function(resolve) {
43313
+ var name = bufferReader.nextStr();
43314
+ var clip = new AnimationClip(name);
43315
+ var eventsLen = bufferReader.nextUint16();
43316
+ for(var i = 0; i < eventsLen; ++i){
43317
+ var event = new AnimationEvent();
43318
+ event.time = bufferReader.nextFloat32();
43319
+ event.functionName = bufferReader.nextStr();
43320
+ event.parameter = JSON.parse(bufferReader.nextStr()).val;
43321
+ clip.addEvent(event);
43322
+ }
43323
+ var curveBindingsLen = bufferReader.nextUint16();
43324
+ for(var i1 = 0; i1 < curveBindingsLen; ++i1){
43325
+ var relativePath = bufferReader.nextStr();
43326
+ var componentStr = bufferReader.nextStr();
43327
+ var componentType = Loader.getClass(componentStr);
43328
+ var property = bufferReader.nextStr();
43329
+ var getProperty = bufferReader.nextStr();
43330
+ var curve = void 0;
43331
+ var interpolation = bufferReader.nextUint8();
43332
+ var keysLen = bufferReader.nextUint16();
43333
+ var curveType = bufferReader.nextStr();
43334
+ switch(curveType){
43335
+ case "AnimationFloatCurve":
43336
+ {
43337
+ curve = new exports.AnimationFloatCurve();
43338
+ curve.interpolation = interpolation;
43339
+ for(var j = 0; j < keysLen; ++j){
43340
+ var keyframe = new Keyframe();
43341
+ keyframe.time = bufferReader.nextFloat32();
43342
+ keyframe.value = bufferReader.nextFloat32();
43343
+ keyframe.inTangent = bufferReader.nextFloat32();
43344
+ keyframe.outTangent = bufferReader.nextFloat32();
43345
+ curve.addKey(keyframe);
43346
+ }
43347
+ break;
43348
+ }
43349
+ case "AnimationArrayCurve":
43350
+ {
43351
+ curve = new exports.AnimationArrayCurve();
43352
+ curve.interpolation = interpolation;
43353
+ for(var j1 = 0; j1 < keysLen; ++j1){
43354
+ var keyframe1 = new Keyframe();
43355
+ keyframe1.time = bufferReader.nextFloat32();
43356
+ var len = bufferReader.nextUint16();
43357
+ keyframe1.value = Array.from(bufferReader.nextFloat32Array(len));
43358
+ keyframe1.inTangent = Array.from(bufferReader.nextFloat32Array(len));
43359
+ keyframe1.outTangent = Array.from(bufferReader.nextFloat32Array(len));
43360
+ curve.addKey(keyframe1);
43361
+ }
43362
+ break;
43363
+ }
43364
+ case "AnimationFloatArrayCurve":
43365
+ {
43366
+ curve = new exports.AnimationFloatArrayCurve();
43367
+ curve.interpolation = interpolation;
43368
+ for(var j2 = 0; j2 < keysLen; ++j2){
43369
+ var keyframe2 = new Keyframe();
43370
+ keyframe2.time = bufferReader.nextFloat32();
43371
+ var len1 = bufferReader.nextUint16();
43372
+ keyframe2.value = bufferReader.nextFloat32Array(len1);
43373
+ keyframe2.inTangent = Array.from(bufferReader.nextFloat32Array(len1));
43374
+ keyframe2.outTangent = Array.from(bufferReader.nextFloat32Array(len1));
43375
+ curve.addKey(keyframe2);
43376
+ }
43377
+ break;
43378
+ }
43379
+ case "AnimationVector2Curve":
43380
+ {
43381
+ curve = new exports.AnimationVector2Curve();
43382
+ curve.interpolation = interpolation;
43383
+ for(var j3 = 0; j3 < keysLen; ++j3){
43384
+ var keyframe3 = new Keyframe();
43385
+ keyframe3.time = bufferReader.nextFloat32();
43386
+ keyframe3.value = new Vector2(bufferReader.nextFloat32(), bufferReader.nextFloat32());
43387
+ keyframe3.inTangent = new Vector2(bufferReader.nextFloat32(), bufferReader.nextFloat32());
43388
+ keyframe3.outTangent = new Vector2(bufferReader.nextFloat32(), bufferReader.nextFloat32());
43389
+ curve.addKey(keyframe3);
43390
+ }
43391
+ break;
43392
+ }
43393
+ case "AnimationVector3Curve":
43394
+ {
43395
+ curve = new exports.AnimationVector3Curve();
43396
+ curve.interpolation = interpolation;
43397
+ for(var j4 = 0; j4 < keysLen; ++j4){
43398
+ var keyframe4 = new Keyframe();
43399
+ keyframe4.time = bufferReader.nextFloat32();
43400
+ keyframe4.value = new Vector3(bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32());
43401
+ keyframe4.inTangent = new Vector3(bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32());
43402
+ keyframe4.outTangent = new Vector3(bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32());
43403
+ curve.addKey(keyframe4);
43404
+ }
43405
+ break;
43406
+ }
43407
+ case "AnimationVector4Curve":
43408
+ {
43409
+ curve = new exports.AnimationVector4Curve();
43410
+ curve.interpolation = interpolation;
43411
+ var keyframe5 = new Keyframe();
43412
+ keyframe5.time = bufferReader.nextFloat32();
43413
+ keyframe5.value = new Vector4(bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32());
43414
+ keyframe5.inTangent = new Vector4(bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32());
43415
+ keyframe5.outTangent = new Vector4(bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32());
43416
+ curve.addKey(keyframe5);
43417
+ break;
43418
+ }
43419
+ case "AnimationColorCurve":
43420
+ {
43421
+ curve = new exports.AnimationColorCurve();
43422
+ curve.interpolation = interpolation;
43423
+ for(var j5 = 0; j5 < keysLen; ++j5){
43424
+ var keyframe6 = new Keyframe();
43425
+ keyframe6.time = bufferReader.nextFloat32();
43426
+ keyframe6.value = new Color(bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32());
43427
+ keyframe6.inTangent = new Vector4(bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32());
43428
+ keyframe6.outTangent = new Vector4(bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32());
43429
+ curve.addKey(keyframe6);
43430
+ }
43431
+ break;
43432
+ }
43433
+ case "AnimationQuaternionCurve":
43434
+ {
43435
+ curve = new exports.AnimationQuaternionCurve();
43436
+ curve.interpolation = interpolation;
43437
+ for(var j6 = 0; j6 < keysLen; ++j6){
43438
+ var keyframe7 = new Keyframe();
43439
+ keyframe7.time = bufferReader.nextFloat32();
43440
+ keyframe7.value = new Quaternion(bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32());
43441
+ keyframe7.inTangent = new Vector4(bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32());
43442
+ keyframe7.outTangent = new Vector4(bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32());
43443
+ curve.addKey(keyframe7);
43444
+ }
43445
+ break;
43446
+ }
43447
+ case "AnimationRefCurve":
43448
+ {
43449
+ curve = new exports.AnimationRefCurve();
43450
+ curve.interpolation = interpolation;
43451
+ for(var j7 = 0; j7 < keysLen; ++j7){
43452
+ var keyframe8 = new Keyframe();
43453
+ keyframe8.time = bufferReader.nextFloat32();
43454
+ var str = bufferReader.nextStr();
43455
+ if (str) {
43456
+ keyframe8.value = JSON.parse(str);
43457
+ } else {
43458
+ keyframe8.value = null;
43459
+ }
43460
+ curve.addKey(keyframe8);
43461
+ }
43462
+ break;
43463
+ }
43464
+ case "AnimationBoolCurve":
43465
+ {
43466
+ curve = new exports.AnimationBoolCurve();
43467
+ curve.interpolation = interpolation;
43468
+ for(var j8 = 0; j8 < keysLen; ++j8){
43469
+ var keyframe9 = new Keyframe();
43470
+ keyframe9.time = bufferReader.nextFloat32();
43471
+ keyframe9.value = bufferReader.nextUint8() === 1;
43472
+ curve.addKey(keyframe9);
43473
+ }
43474
+ break;
43475
+ }
43476
+ case "AnimationStringCurve":
43477
+ {
43478
+ curve = new exports.AnimationStringCurve();
43479
+ curve.interpolation = interpolation;
43480
+ for(var j9 = 0; j9 < keysLen; ++j9){
43481
+ var keyframe10 = new Keyframe();
43482
+ keyframe10.time = bufferReader.nextFloat32();
43483
+ keyframe10.value = bufferReader.nextStr();
43484
+ curve.addKey(keyframe10);
43485
+ }
43486
+ break;
43487
+ }
43488
+ }
43489
+ clip.addCurveBinding(relativePath, componentType, property, getProperty, curve);
43490
+ }
43491
+ resolve(clip);
43492
+ });
43493
+ };
43494
+ return AnimationClipDecoder;
43495
+ }();
43496
+ exports.AnimationClipDecoder = __decorate([
43497
+ decoder("AnimationClip")
43498
+ ], exports.AnimationClipDecoder);
43264
43499
  exports.MeshDecoder = /*#__PURE__*/ function() {
43265
43500
  function MeshDecoder() {}
43266
- MeshDecoder.decode = function decode(engine, bufferReader) {
43501
+ MeshDecoder.decode = function decode(engine, bufferReader, restoredMesh) {
43267
43502
  return new AssetPromise(function(resolve) {
43268
- var modelMesh = new ModelMesh(engine);
43503
+ var modelMesh = restoredMesh || new ModelMesh(engine);
43269
43504
  var jsonDataString = bufferReader.nextStr();
43270
43505
  var encodedMeshData = JSON.parse(jsonDataString);
43271
43506
  // @ts-ignore Vector3 is not compatible with {x: number, y: number, z: number}.
@@ -43394,80 +43629,6 @@
43394
43629
  }
43395
43630
  return array;
43396
43631
  }
43397
- exports.Texture2DDecoder = /*#__PURE__*/ function() {
43398
- function Texture2DDecoder() {}
43399
- Texture2DDecoder.decode = function decode(engine, bufferReader) {
43400
- return new AssetPromise(function(resolve, reject) {
43401
- var objectId = bufferReader.nextStr();
43402
- var mipmap = !!bufferReader.nextUint8();
43403
- var filterMode = bufferReader.nextUint8();
43404
- var anisoLevel = bufferReader.nextUint8();
43405
- var wrapModeU = bufferReader.nextUint8();
43406
- var wrapModeV = bufferReader.nextUint8();
43407
- var format = bufferReader.nextUint8();
43408
- var width = bufferReader.nextUint16();
43409
- var height = bufferReader.nextUint16();
43410
- var isPixelBuffer = bufferReader.nextUint8();
43411
- var mipCount = bufferReader.nextUint8();
43412
- var imagesData = bufferReader.nextImagesData(mipCount);
43413
- var texture2D = new Texture2D(engine, width, height, format, mipmap);
43414
- texture2D.filterMode = filterMode;
43415
- texture2D.anisoLevel = anisoLevel;
43416
- texture2D.wrapModeU = wrapModeU;
43417
- texture2D.wrapModeV = wrapModeV;
43418
- if (isPixelBuffer) {
43419
- var pixelBuffer = imagesData[0];
43420
- texture2D.setPixelBuffer(pixelBuffer);
43421
- if (mipmap) {
43422
- texture2D.generateMipmaps();
43423
- for(var i = 1; i < mipCount; i++){
43424
- var pixelBuffer1 = imagesData[i];
43425
- texture2D.setPixelBuffer(pixelBuffer1, i);
43426
- }
43427
- }
43428
- // @ts-ignore
43429
- engine.resourceManager._objectPool[objectId] = texture2D;
43430
- resolve(texture2D);
43431
- } else {
43432
- var blob = new window.Blob([
43433
- imagesData[0]
43434
- ]);
43435
- var img = new Image();
43436
- img.onload = function() {
43437
- texture2D.setImageSource(img);
43438
- var completedCount = 0;
43439
- var onComplete = function onComplete() {
43440
- completedCount++;
43441
- if (completedCount >= mipCount) {
43442
- resolve(texture2D);
43443
- }
43444
- };
43445
- onComplete();
43446
- if (mipmap) {
43447
- var _loop = function _loop(i) {
43448
- var blob = new window.Blob([
43449
- imagesData[i]
43450
- ]);
43451
- var img = new Image();
43452
- img.onload = function() {
43453
- texture2D.setImageSource(img, i);
43454
- onComplete();
43455
- };
43456
- img.src = URL.createObjectURL(blob);
43457
- };
43458
- texture2D.generateMipmaps();
43459
- for(var i = 1; i < mipCount; i++)_loop(i);
43460
- }
43461
- };
43462
- img.src = URL.createObjectURL(blob);
43463
- }
43464
- });
43465
- };
43466
- return Texture2DDecoder;
43467
- }();
43468
- exports.Texture2DDecoder = __decorate([
43469
- decoder("Texture2D")
43470
- ], exports.Texture2DDecoder);
43471
43632
  function _is_native_reflect_construct() {
43472
43633
  // Since Reflect.construct can't be properly polyfilled, some
43473
43634
  // implementations (e.g. core-js@2) don't set the correct internal slots.
@@ -43746,226 +43907,126 @@
43746
43907
  return ReflectionParser;
43747
43908
  }();
43748
43909
  ReflectionParser.customParseComponentHandles = new Map();
43749
- var InterpolableValueType = /*#__PURE__*/ function(InterpolableValueType) {
43750
- InterpolableValueType[InterpolableValueType["Float"] = 0] = "Float";
43751
- InterpolableValueType[InterpolableValueType["FloatArray"] = 1] = "FloatArray";
43752
- InterpolableValueType[InterpolableValueType["Vector2"] = 2] = "Vector2";
43753
- InterpolableValueType[InterpolableValueType["Vector3"] = 3] = "Vector3";
43754
- InterpolableValueType[InterpolableValueType["Vector4"] = 4] = "Vector4";
43755
- InterpolableValueType[InterpolableValueType["Quaternion"] = 5] = "Quaternion";
43756
- InterpolableValueType[InterpolableValueType["Color"] = 6] = "Color";
43757
- InterpolableValueType[InterpolableValueType["Array"] = 7] = "Array";
43758
- InterpolableValueType[InterpolableValueType["Boolean"] = 8] = "Boolean";
43759
- InterpolableValueType[InterpolableValueType["Rect"] = 9] = "Rect";
43760
- InterpolableValueType[InterpolableValueType["ReferResource"] = 10] = "ReferResource";
43761
- return InterpolableValueType;
43762
- }({});
43763
- exports.AnimationClipDecoder = /*#__PURE__*/ function() {
43764
- function AnimationClipDecoder() {}
43765
- AnimationClipDecoder.decode = function decode(engine, bufferReader) {
43766
- return new AssetPromise(function(resolve) {
43767
- var name = bufferReader.nextStr();
43768
- var clip = new AnimationClip(name);
43769
- var eventsLen = bufferReader.nextUint16();
43770
- for(var i = 0; i < eventsLen; ++i){
43771
- var event = new AnimationEvent();
43772
- event.time = bufferReader.nextFloat32();
43773
- event.functionName = bufferReader.nextStr();
43774
- event.parameter = JSON.parse(bufferReader.nextStr()).val;
43775
- clip.addEvent(event);
43776
- }
43777
- var curveBindingsLen = bufferReader.nextUint16();
43778
- for(var i1 = 0; i1 < curveBindingsLen; ++i1){
43779
- var relativePath = bufferReader.nextStr();
43780
- var componentStr = bufferReader.nextStr();
43781
- var componentType = Loader.getClass(componentStr);
43782
- var property = bufferReader.nextStr();
43783
- var getProperty = bufferReader.nextStr();
43784
- var curve = void 0;
43785
- var interpolation = bufferReader.nextUint8();
43786
- var keysLen = bufferReader.nextUint16();
43787
- var curveType = bufferReader.nextStr();
43788
- switch(curveType){
43789
- case "AnimationFloatCurve":
43790
- {
43791
- curve = new exports.AnimationFloatCurve();
43792
- curve.interpolation = interpolation;
43793
- for(var j = 0; j < keysLen; ++j){
43794
- var keyframe = new Keyframe();
43795
- keyframe.time = bufferReader.nextFloat32();
43796
- keyframe.value = bufferReader.nextFloat32();
43797
- keyframe.inTangent = bufferReader.nextFloat32();
43798
- keyframe.outTangent = bufferReader.nextFloat32();
43799
- curve.addKey(keyframe);
43800
- }
43801
- break;
43802
- }
43803
- case "AnimationArrayCurve":
43804
- {
43805
- curve = new exports.AnimationArrayCurve();
43806
- curve.interpolation = interpolation;
43807
- for(var j1 = 0; j1 < keysLen; ++j1){
43808
- var keyframe1 = new Keyframe();
43809
- keyframe1.time = bufferReader.nextFloat32();
43810
- var len = bufferReader.nextUint16();
43811
- keyframe1.value = Array.from(bufferReader.nextFloat32Array(len));
43812
- keyframe1.inTangent = Array.from(bufferReader.nextFloat32Array(len));
43813
- keyframe1.outTangent = Array.from(bufferReader.nextFloat32Array(len));
43814
- curve.addKey(keyframe1);
43815
- }
43816
- break;
43817
- }
43818
- case "AnimationFloatArrayCurve":
43819
- {
43820
- curve = new exports.AnimationFloatArrayCurve();
43821
- curve.interpolation = interpolation;
43822
- for(var j2 = 0; j2 < keysLen; ++j2){
43823
- var keyframe2 = new Keyframe();
43824
- keyframe2.time = bufferReader.nextFloat32();
43825
- var len1 = bufferReader.nextUint16();
43826
- keyframe2.value = bufferReader.nextFloat32Array(len1);
43827
- keyframe2.inTangent = Array.from(bufferReader.nextFloat32Array(len1));
43828
- keyframe2.outTangent = Array.from(bufferReader.nextFloat32Array(len1));
43829
- curve.addKey(keyframe2);
43830
- }
43831
- break;
43832
- }
43833
- case "AnimationVector2Curve":
43834
- {
43835
- curve = new exports.AnimationVector2Curve();
43836
- curve.interpolation = interpolation;
43837
- for(var j3 = 0; j3 < keysLen; ++j3){
43838
- var keyframe3 = new Keyframe();
43839
- keyframe3.time = bufferReader.nextFloat32();
43840
- keyframe3.value = new Vector2(bufferReader.nextFloat32(), bufferReader.nextFloat32());
43841
- keyframe3.inTangent = new Vector2(bufferReader.nextFloat32(), bufferReader.nextFloat32());
43842
- keyframe3.outTangent = new Vector2(bufferReader.nextFloat32(), bufferReader.nextFloat32());
43843
- curve.addKey(keyframe3);
43844
- }
43845
- break;
43846
- }
43847
- case "AnimationVector3Curve":
43848
- {
43849
- curve = new exports.AnimationVector3Curve();
43850
- curve.interpolation = interpolation;
43851
- for(var j4 = 0; j4 < keysLen; ++j4){
43852
- var keyframe4 = new Keyframe();
43853
- keyframe4.time = bufferReader.nextFloat32();
43854
- keyframe4.value = new Vector3(bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32());
43855
- keyframe4.inTangent = new Vector3(bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32());
43856
- keyframe4.outTangent = new Vector3(bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32());
43857
- curve.addKey(keyframe4);
43858
- }
43859
- break;
43860
- }
43861
- case "AnimationVector4Curve":
43862
- {
43863
- curve = new exports.AnimationVector4Curve();
43864
- curve.interpolation = interpolation;
43865
- var keyframe5 = new Keyframe();
43866
- keyframe5.time = bufferReader.nextFloat32();
43867
- keyframe5.value = new Vector4(bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32());
43868
- keyframe5.inTangent = new Vector4(bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32());
43869
- keyframe5.outTangent = new Vector4(bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32());
43870
- curve.addKey(keyframe5);
43871
- break;
43872
- }
43873
- case "AnimationColorCurve":
43874
- {
43875
- curve = new exports.AnimationColorCurve();
43876
- curve.interpolation = interpolation;
43877
- for(var j5 = 0; j5 < keysLen; ++j5){
43878
- var keyframe6 = new Keyframe();
43879
- keyframe6.time = bufferReader.nextFloat32();
43880
- keyframe6.value = new Color(bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32());
43881
- keyframe6.inTangent = new Vector4(bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32());
43882
- keyframe6.outTangent = new Vector4(bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32());
43883
- curve.addKey(keyframe6);
43884
- }
43885
- break;
43886
- }
43887
- case "AnimationQuaternionCurve":
43888
- {
43889
- curve = new exports.AnimationQuaternionCurve();
43890
- curve.interpolation = interpolation;
43891
- for(var j6 = 0; j6 < keysLen; ++j6){
43892
- var keyframe7 = new Keyframe();
43893
- keyframe7.time = bufferReader.nextFloat32();
43894
- keyframe7.value = new Quaternion(bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32());
43895
- keyframe7.inTangent = new Vector4(bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32());
43896
- keyframe7.outTangent = new Vector4(bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32(), bufferReader.nextFloat32());
43897
- curve.addKey(keyframe7);
43898
- }
43899
- break;
43900
- }
43901
- case "AnimationRefCurve":
43902
- {
43903
- curve = new exports.AnimationRefCurve();
43904
- curve.interpolation = interpolation;
43905
- for(var j7 = 0; j7 < keysLen; ++j7){
43906
- var keyframe8 = new Keyframe();
43907
- keyframe8.time = bufferReader.nextFloat32();
43908
- var str = bufferReader.nextStr();
43909
- if (str) {
43910
- keyframe8.value = JSON.parse(str);
43911
- } else {
43912
- keyframe8.value = null;
43913
- }
43914
- curve.addKey(keyframe8);
43915
- }
43916
- break;
43917
- }
43918
- case "AnimationBoolCurve":
43919
- {
43920
- curve = new exports.AnimationBoolCurve();
43921
- curve.interpolation = interpolation;
43922
- for(var j8 = 0; j8 < keysLen; ++j8){
43923
- var keyframe9 = new Keyframe();
43924
- keyframe9.time = bufferReader.nextFloat32();
43925
- keyframe9.value = bufferReader.nextUint8() === 1;
43926
- curve.addKey(keyframe9);
43927
- }
43928
- break;
43929
- }
43930
- case "AnimationStringCurve":
43931
- {
43932
- curve = new exports.AnimationStringCurve();
43933
- curve.interpolation = interpolation;
43934
- for(var j9 = 0; j9 < keysLen; ++j9){
43935
- var keyframe10 = new Keyframe();
43936
- keyframe10.time = bufferReader.nextFloat32();
43937
- keyframe10.value = bufferReader.nextStr();
43938
- curve.addKey(keyframe10);
43939
- }
43940
- break;
43941
- }
43910
+ exports.Texture2DDecoder = /*#__PURE__*/ function() {
43911
+ function Texture2DDecoder() {}
43912
+ Texture2DDecoder.decode = function decode(engine, bufferReader, restoredTexture) {
43913
+ return new AssetPromise(function(resolve, reject) {
43914
+ var objectId = bufferReader.nextStr();
43915
+ var mipmap = !!bufferReader.nextUint8();
43916
+ var filterMode = bufferReader.nextUint8();
43917
+ var anisoLevel = bufferReader.nextUint8();
43918
+ var wrapModeU = bufferReader.nextUint8();
43919
+ var wrapModeV = bufferReader.nextUint8();
43920
+ var format = bufferReader.nextUint8();
43921
+ var width = bufferReader.nextUint16();
43922
+ var height = bufferReader.nextUint16();
43923
+ var isPixelBuffer = bufferReader.nextUint8();
43924
+ var mipCount = bufferReader.nextUint8();
43925
+ var imagesData = bufferReader.nextImagesData(mipCount);
43926
+ var texture2D = restoredTexture || new Texture2D(engine, width, height, format, mipmap);
43927
+ texture2D.filterMode = filterMode;
43928
+ texture2D.anisoLevel = anisoLevel;
43929
+ texture2D.wrapModeU = wrapModeU;
43930
+ texture2D.wrapModeV = wrapModeV;
43931
+ if (isPixelBuffer) {
43932
+ var pixelBuffer = imagesData[0];
43933
+ texture2D.setPixelBuffer(pixelBuffer);
43934
+ if (mipmap) {
43935
+ texture2D.generateMipmaps();
43936
+ for(var i = 1; i < mipCount; i++){
43937
+ var pixelBuffer1 = imagesData[i];
43938
+ texture2D.setPixelBuffer(pixelBuffer1, i);
43939
+ }
43942
43940
  }
43943
- clip.addCurveBinding(relativePath, componentType, property, getProperty, curve);
43941
+ // @ts-ignore
43942
+ engine.resourceManager._objectPool[objectId] = texture2D;
43943
+ resolve(texture2D);
43944
+ } else {
43945
+ var blob = new window.Blob([
43946
+ imagesData[0]
43947
+ ]);
43948
+ var img = new Image();
43949
+ img.onload = function() {
43950
+ texture2D.setImageSource(img);
43951
+ var completedCount = 0;
43952
+ var onComplete = function onComplete() {
43953
+ completedCount++;
43954
+ if (completedCount >= mipCount) {
43955
+ resolve(texture2D);
43956
+ }
43957
+ };
43958
+ onComplete();
43959
+ if (mipmap) {
43960
+ var _loop = function _loop(i) {
43961
+ var blob = new window.Blob([
43962
+ imagesData[i]
43963
+ ]);
43964
+ var img = new Image();
43965
+ img.onload = function() {
43966
+ texture2D.setImageSource(img, i);
43967
+ onComplete();
43968
+ };
43969
+ img.src = URL.createObjectURL(blob);
43970
+ };
43971
+ texture2D.generateMipmaps();
43972
+ for(var i = 1; i < mipCount; i++)_loop(i);
43973
+ }
43974
+ };
43975
+ img.src = URL.createObjectURL(blob);
43944
43976
  }
43945
- resolve(clip);
43946
43977
  });
43947
43978
  };
43948
- return AnimationClipDecoder;
43979
+ return Texture2DDecoder;
43949
43980
  }();
43950
- exports.AnimationClipDecoder = __decorate([
43951
- decoder("AnimationClip")
43952
- ], exports.AnimationClipDecoder);
43953
- var MaterialLoaderType = /*#__PURE__*/ function(MaterialLoaderType) {
43954
- MaterialLoaderType["Vector2"] = "Vector2";
43955
- MaterialLoaderType["Vector3"] = "Vector3";
43956
- MaterialLoaderType["Vector4"] = "Vector4";
43957
- MaterialLoaderType["Color"] = "Color";
43958
- MaterialLoaderType["Float"] = "Float";
43959
- MaterialLoaderType["Texture"] = "Texture";
43960
- MaterialLoaderType["Boolean"] = "Boolean";
43961
- MaterialLoaderType["Integer"] = "Integer";
43962
- return MaterialLoaderType;
43963
- }({});
43964
- var SpecularMode = /*#__PURE__*/ function(SpecularMode) {
43965
- SpecularMode["Sky"] = "Sky";
43966
- SpecularMode["Custom"] = "Custom";
43967
- return SpecularMode;
43968
- }({});
43981
+ exports.Texture2DDecoder = __decorate([
43982
+ decoder("Texture2D")
43983
+ ], exports.Texture2DDecoder);
43984
+ exports.EditorTextureLoader = /*#__PURE__*/ function(Loader) {
43985
+ _inherits(EditorTextureLoader, Loader);
43986
+ function EditorTextureLoader() {
43987
+ return Loader.apply(this, arguments) || this;
43988
+ }
43989
+ var _proto = EditorTextureLoader.prototype;
43990
+ _proto.load = function load(item, resourceManager) {
43991
+ var requestConfig = _extends({}, item, {
43992
+ type: "arraybuffer"
43993
+ });
43994
+ var url = item.url;
43995
+ return new AssetPromise(function(resolve, reject) {
43996
+ resourceManager // @ts-ignore
43997
+ ._request(url, requestConfig).then(function(data) {
43998
+ decode(data, resourceManager.engine).then(function(texture) {
43999
+ resourceManager.addContentRestorer(new EditorTexture2DContentRestorer(texture, url, requestConfig));
44000
+ resolve(texture);
44001
+ });
44002
+ }).catch(reject);
44003
+ });
44004
+ };
44005
+ return EditorTextureLoader;
44006
+ }(Loader);
44007
+ exports.EditorTextureLoader = __decorate([
44008
+ resourceLoader("EditorTexture2D", [
44009
+ "prefab"
44010
+ ], true)
44011
+ ], exports.EditorTextureLoader);
44012
+ var EditorTexture2DContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
44013
+ _inherits(EditorTexture2DContentRestorer, ContentRestorer);
44014
+ function EditorTexture2DContentRestorer(resource, url, requestConfig) {
44015
+ var _this;
44016
+ _this = ContentRestorer.call(this, resource) || this, _this.url = url, _this.requestConfig = requestConfig;
44017
+ return _this;
44018
+ }
44019
+ var _proto = EditorTexture2DContentRestorer.prototype;
44020
+ _proto.restoreContent = function restoreContent() {
44021
+ var texture = this.resource;
44022
+ var engine = texture.engine;
44023
+ return engine.resourceManager // @ts-ignore
44024
+ ._request(this.url, this.requestConfig).then(function(data) {
44025
+ return decode(data, engine, texture);
44026
+ });
44027
+ };
44028
+ return EditorTexture2DContentRestorer;
44029
+ }(ContentRestorer);
43969
44030
  function _instanceof1(left, right) {
43970
44031
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
43971
44032
  return !!right[Symbol.hasInstance](left);
@@ -44368,40 +44429,38 @@
44368
44429
  };
44369
44430
  return SceneParser;
44370
44431
  }(HierarchyParser);
44371
- exports.EditorTextureLoader = /*#__PURE__*/ function(Loader) {
44372
- _inherits(EditorTextureLoader, Loader);
44373
- function EditorTextureLoader() {
44374
- return Loader.apply(this, arguments) || this;
44375
- }
44376
- var _proto = EditorTextureLoader.prototype;
44377
- _proto.load = function load(item, resourceManager) {
44378
- return new AssetPromise(function(resolve, reject) {
44379
- resourceManager // @ts-ignore
44380
- ._request(item.url, _extends({}, item, {
44381
- type: "arraybuffer"
44382
- })).then(function(data) {
44383
- decode(data, resourceManager.engine).then(function(texture) {
44384
- resolve(texture);
44385
- });
44386
- }).catch(reject);
44387
- });
44388
- };
44389
- return EditorTextureLoader;
44390
- }(Loader);
44391
- exports.EditorTextureLoader = __decorate([
44392
- resourceLoader("EditorTexture2D", [
44393
- "prefab"
44394
- ], true)
44395
- ], exports.EditorTextureLoader);
44432
+ var MaterialLoaderType = /*#__PURE__*/ function(MaterialLoaderType) {
44433
+ MaterialLoaderType["Vector2"] = "Vector2";
44434
+ MaterialLoaderType["Vector3"] = "Vector3";
44435
+ MaterialLoaderType["Vector4"] = "Vector4";
44436
+ MaterialLoaderType["Color"] = "Color";
44437
+ MaterialLoaderType["Float"] = "Float";
44438
+ MaterialLoaderType["Texture"] = "Texture";
44439
+ MaterialLoaderType["Boolean"] = "Boolean";
44440
+ MaterialLoaderType["Integer"] = "Integer";
44441
+ return MaterialLoaderType;
44442
+ }({});
44443
+ var SpecularMode = /*#__PURE__*/ function(SpecularMode) {
44444
+ SpecularMode["Sky"] = "Sky";
44445
+ SpecularMode["Custom"] = "Custom";
44446
+ return SpecularMode;
44447
+ }({});
44396
44448
  /**
44397
44449
  * Decode engine binary resource.
44398
44450
  * @param arrayBuffer - array buffer of decode binary file
44399
44451
  * @param engine - engine
44400
44452
  * @returns
44401
44453
  */ function decode(arrayBuffer, engine) {
44454
+ for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
44455
+ args[_key - 2] = arguments[_key];
44456
+ }
44457
+ var _decoderMap_header_type;
44402
44458
  var header = FileHeader.decode(arrayBuffer);
44403
44459
  var bufferReader = new BufferReader(new Uint8Array(arrayBuffer), header.headerLength, header.dataLength);
44404
- return decoderMap[header.type].decode(engine, bufferReader).then(function(object) {
44460
+ return (_decoderMap_header_type = decoderMap[header.type]).decode.apply(_decoderMap_header_type, [].concat([
44461
+ engine,
44462
+ bufferReader
44463
+ ], args)).then(function(object) {
44405
44464
  object.name = header.name;
44406
44465
  return object;
44407
44466
  });
@@ -44613,10 +44672,11 @@
44613
44672
  type: "arraybuffer"
44614
44673
  });
44615
44674
  var engine = resourceManager.engine;
44675
+ var url = item.url;
44616
44676
  resourceManager // @ts-ignore
44617
- ._request(item.url, requestConfig).then(function(arraybuffer) {
44677
+ ._request(url, requestConfig).then(function(arraybuffer) {
44618
44678
  var texture = EnvLoader._setTextureByBuffer(engine, arraybuffer);
44619
- engine.resourceManager.addContentRestorer(new EnvContentRestorer(texture, item.url, requestConfig));
44679
+ engine.resourceManager.addContentRestorer(new EnvContentRestorer(texture, url, requestConfig));
44620
44680
  var ambientLight = new AmbientLight(engine);
44621
44681
  var sh = new SphericalHarmonics3();
44622
44682
  ambientLight.diffuseMode = DiffuseMode.SphericalHarmonics;
@@ -44671,9 +44731,12 @@
44671
44731
  _proto.restoreContent = function restoreContent() {
44672
44732
  var _this = this;
44673
44733
  return new AssetPromise(function(resolve, reject) {
44674
- request(_this.url, _this.requestConfig).then(function(buffer) {
44675
- EnvLoader._setTextureByBuffer(_this.resource.engine, buffer, _this.resource);
44676
- resolve(_this.resource);
44734
+ var resource = _this.resource;
44735
+ var engine = resource.engine;
44736
+ engine.resourceManager // @ts-ignore
44737
+ ._request(_this.url, _this.requestConfig).then(function(buffer) {
44738
+ EnvLoader._setTextureByBuffer(engine, buffer, resource);
44739
+ resolve(resource);
44677
44740
  }).catch(reject);
44678
44741
  });
44679
44742
  };
@@ -46530,15 +46593,20 @@
46530
46593
  * @internal
46531
46594
  */ _proto.load = function load(item, resourceManager) {
46532
46595
  return new AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
46533
- resourceManager // @ts-ignore
46534
- ._request(item.url, {
46596
+ var requestConfig = _extends({}, item, {
46535
46597
  type: "arraybuffer"
46536
- }).onProgress(setTaskCompleteProgress, setTaskDetailProgress).then(function(buffer) {
46598
+ });
46599
+ var url = item.url;
46600
+ resourceManager // @ts-ignore
46601
+ ._request(url, requestConfig).onProgress(setTaskCompleteProgress, setTaskDetailProgress).then(function(buffer) {
46537
46602
  return KTX2Loader._parseBuffer(new Uint8Array(buffer), resourceManager.engine, item.params).then(function(param) {
46538
46603
  var engine = param.engine, result = param.result, targetFormat = param.targetFormat, params = param.params;
46539
46604
  return KTX2Loader._createTextureByBuffer(engine, result, targetFormat, params);
46605
+ }).then(function(texture) {
46606
+ resourceManager.addContentRestorer(new KTX2ContentRestorer(texture, url, requestConfig));
46607
+ resolve(texture);
46540
46608
  });
46541
- }).then(resolve).catch(reject);
46609
+ }).catch(reject);
46542
46610
  });
46543
46611
  };
46544
46612
  /**
@@ -46577,7 +46645,7 @@
46577
46645
  };
46578
46646
  });
46579
46647
  };
46580
- /** @internal */ KTX2Loader._createTextureByBuffer = function _createTextureByBuffer(engine, transcodeResult, targetFormat, params) {
46648
+ /** @internal */ KTX2Loader._createTextureByBuffer = function _createTextureByBuffer(engine, transcodeResult, targetFormat, params, restoredTexture) {
46581
46649
  var width = transcodeResult.width, height = transcodeResult.height, faces = transcodeResult.faces;
46582
46650
  var faceCount = faces.length;
46583
46651
  var mipmaps = faces[0];
@@ -46585,13 +46653,13 @@
46585
46653
  var engineFormat = this._getEngineTextureFormat(targetFormat, transcodeResult);
46586
46654
  var texture;
46587
46655
  if (faceCount !== 6) {
46588
- texture = new Texture2D(engine, width, height, engineFormat, mipmap);
46656
+ texture = restoredTexture || new Texture2D(engine, width, height, engineFormat, mipmap);
46589
46657
  for(var mipLevel = 0; mipLevel < mipmaps.length; mipLevel++){
46590
46658
  var data = mipmaps[mipLevel].data;
46591
46659
  texture.setPixelBuffer(data, mipLevel);
46592
46660
  }
46593
46661
  } else {
46594
- texture = new TextureCube(engine, height, engineFormat, mipmap);
46662
+ texture = restoredTexture || new TextureCube(engine, height, engineFormat, mipmap);
46595
46663
  for(var i = 0; i < faces.length; i++){
46596
46664
  var faceData = faces[i];
46597
46665
  for(var mipLevel1 = 0; mipLevel1 < mipmaps.length; mipLevel1++){
@@ -46707,6 +46775,30 @@
46707
46775
  "ktx2"
46708
46776
  ])
46709
46777
  ], exports.KTX2Loader);
46778
+ var KTX2ContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
46779
+ _inherits(KTX2ContentRestorer, ContentRestorer);
46780
+ function KTX2ContentRestorer(resource, url, requestConfig) {
46781
+ var _this;
46782
+ _this = ContentRestorer.call(this, resource) || this, _this.url = url, _this.requestConfig = requestConfig;
46783
+ return _this;
46784
+ }
46785
+ var _proto = KTX2ContentRestorer.prototype;
46786
+ _proto.restoreContent = function restoreContent() {
46787
+ var _this = this;
46788
+ var _this1 = this, resource = _this1.resource, requestConfig = _this1.requestConfig;
46789
+ var engine = resource.engine;
46790
+ return new AssetPromise(function(resolve, reject) {
46791
+ engine.resourceManager // @ts-ignore
46792
+ ._request(_this.url, requestConfig).then(function(buffer) {
46793
+ return exports.KTX2Loader._parseBuffer(new Uint8Array(buffer), engine, requestConfig.params).then(function(param) {
46794
+ var engine = param.engine, result = param.result, targetFormat = param.targetFormat, params = param.params;
46795
+ return exports.KTX2Loader._createTextureByBuffer(engine, result, targetFormat, params, resource);
46796
+ });
46797
+ }).then(resolve).catch(reject);
46798
+ });
46799
+ };
46800
+ return KTX2ContentRestorer;
46801
+ }(ContentRestorer);
46710
46802
  /** Used for initialize KTX2 transcoder. */ var KTX2Transcoder = /*#__PURE__*/ function(KTX2Transcoder) {
46711
46803
  /** BinomialLLC transcoder. */ KTX2Transcoder[KTX2Transcoder["BinomialLLC"] = 0] = "BinomialLLC";
46712
46804
  /** Khronos transcoder. */ KTX2Transcoder[KTX2Transcoder["Khronos"] = 1] = "Khronos";
@@ -48264,10 +48356,11 @@
48264
48356
  var requestConfig = _extends({}, item, {
48265
48357
  type: "arraybuffer"
48266
48358
  });
48359
+ var url = item.url;
48267
48360
  resourceManager // @ts-ignore
48268
- ._request(item.url, requestConfig).then(function(buffer) {
48361
+ ._request(url, requestConfig).then(function(buffer) {
48269
48362
  var texture = HDRLoader._setTextureByBuffer(engine, buffer);
48270
- engine.resourceManager.addContentRestorer(new HDRContentRestorer(texture, item.url, requestConfig));
48363
+ engine.resourceManager.addContentRestorer(new HDRContentRestorer(texture, url, requestConfig));
48271
48364
  resolve(texture);
48272
48365
  }).catch(reject);
48273
48366
  });
@@ -48572,9 +48665,12 @@
48572
48665
  _proto.restoreContent = function restoreContent() {
48573
48666
  var _this = this;
48574
48667
  return new AssetPromise(function(resolve, reject) {
48575
- request(_this.url, _this.requestConfig).then(function(buffer) {
48576
- HDRLoader._setTextureByBuffer(_this.resource.engine, buffer, _this.resource);
48577
- resolve(_this.resource);
48668
+ var resource = _this.resource;
48669
+ var engine = resource.engine;
48670
+ engine.resourceManager // @ts-ignore
48671
+ ._request(_this.url, _this.requestConfig).then(function(buffer) {
48672
+ HDRLoader._setTextureByBuffer(engine, buffer, resource);
48673
+ resolve(resource);
48578
48674
  }).catch(reject);
48579
48675
  });
48580
48676
  };
@@ -48824,11 +48920,12 @@
48824
48920
  }
48825
48921
  var _proto = KTXLoader.prototype;
48826
48922
  _proto.load = function load(item, resourceManager) {
48923
+ var requestConfig = _extends({}, item, {
48924
+ type: "arraybuffer"
48925
+ });
48827
48926
  return new AssetPromise(function(resolve, reject) {
48828
48927
  resourceManager // @ts-ignore
48829
- ._request(item.url, _extends({}, item, {
48830
- type: "arraybuffer"
48831
- })).then(function(bin) {
48928
+ ._request(item.url, requestConfig).then(function(bin) {
48832
48929
  var parsedData = parseSingleKTX(bin);
48833
48930
  var width = parsedData.width, height = parsedData.height, mipmaps = parsedData.mipmaps, engineFormat = parsedData.engineFormat;
48834
48931
  var mipmap = mipmaps.length > 1;
@@ -48837,6 +48934,7 @@
48837
48934
  var _mipmaps_miplevel = mipmaps[miplevel], width1 = _mipmaps_miplevel.width, height1 = _mipmaps_miplevel.height, data = _mipmaps_miplevel.data;
48838
48935
  texture.setPixelBuffer(data, miplevel, 0, 0, width1, height1);
48839
48936
  }
48937
+ resourceManager.addContentRestorer(new KTXContentRestorer(texture, item.url, requestConfig));
48840
48938
  resolve(texture);
48841
48939
  }).catch(function(e) {
48842
48940
  reject(e);
@@ -48850,6 +48948,34 @@
48850
48948
  "ktx"
48851
48949
  ])
48852
48950
  ], KTXLoader);
48951
+ var KTXContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
48952
+ _inherits(KTXContentRestorer, ContentRestorer);
48953
+ function KTXContentRestorer(resource, url, requestConfig) {
48954
+ var _this;
48955
+ _this = ContentRestorer.call(this, resource) || this, _this.url = url, _this.requestConfig = requestConfig;
48956
+ return _this;
48957
+ }
48958
+ var _proto = KTXContentRestorer.prototype;
48959
+ _proto.restoreContent = function restoreContent() {
48960
+ var _this = this;
48961
+ var resource = this.resource;
48962
+ var engine = resource.engine;
48963
+ return new AssetPromise(function(resolve, reject) {
48964
+ engine.resourceManager // @ts-ignore
48965
+ ._request(_this.url, _this.requestConfig).then(function(bin) {
48966
+ var mipmaps = parseSingleKTX(bin).mipmaps;
48967
+ for(var miplevel = 0; miplevel < mipmaps.length; miplevel++){
48968
+ var _mipmaps_miplevel = mipmaps[miplevel], width = _mipmaps_miplevel.width, height = _mipmaps_miplevel.height, data = _mipmaps_miplevel.data;
48969
+ resource.setPixelBuffer(data, miplevel, 0, 0, width, height);
48970
+ }
48971
+ resolve(resource);
48972
+ }).catch(function(e) {
48973
+ reject(e);
48974
+ });
48975
+ });
48976
+ };
48977
+ return KTXContentRestorer;
48978
+ }(ContentRestorer);
48853
48979
  function parseProperty(object, key, value) {
48854
48980
  if ((typeof value === "undefined" ? "undefined" : _type_of1(value)) === "object") {
48855
48981
  for(var subKey in value){
@@ -48951,13 +49077,16 @@
48951
49077
  }
48952
49078
  var _proto = MeshLoader.prototype;
48953
49079
  _proto.load = function load(item, resourceManager) {
49080
+ var requestConfig = _extends({}, item, {
49081
+ type: "arraybuffer"
49082
+ });
49083
+ var url = item.url;
48954
49084
  return new AssetPromise(function(resolve, reject) {
48955
49085
  resourceManager // @ts-ignore
48956
- ._request(item.url, _extends({}, item, {
48957
- type: "arraybuffer"
48958
- })).then(function(data) {
49086
+ ._request(url, requestConfig).then(function(data) {
48959
49087
  return decode(data, resourceManager.engine);
48960
49088
  }).then(function(mesh) {
49089
+ resourceManager.addContentRestorer(new MeshContentRestorer(mesh, url, requestConfig));
48961
49090
  resolve(mesh);
48962
49091
  }).catch(reject);
48963
49092
  });
@@ -48969,6 +49098,29 @@
48969
49098
  "mesh"
48970
49099
  ])
48971
49100
  ], MeshLoader);
49101
+ var MeshContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
49102
+ _inherits(MeshContentRestorer, ContentRestorer);
49103
+ function MeshContentRestorer(resource, url, requestConfig) {
49104
+ var _this;
49105
+ _this = ContentRestorer.call(this, resource) || this, _this.url = url, _this.requestConfig = requestConfig;
49106
+ return _this;
49107
+ }
49108
+ var _proto = MeshContentRestorer.prototype;
49109
+ _proto.restoreContent = function restoreContent() {
49110
+ var _this = this;
49111
+ var resource = this.resource;
49112
+ var engine = resource.engine;
49113
+ return new AssetPromise(function(resolve, reject) {
49114
+ engine.resourceManager // @ts-ignore
49115
+ ._request(_this.url, _this.requestConfig).then(function(data) {
49116
+ return decode(data, engine, resource);
49117
+ }).then(function(mesh) {
49118
+ resolve(mesh);
49119
+ }).catch(reject);
49120
+ });
49121
+ };
49122
+ return MeshContentRestorer;
49123
+ }(ContentRestorer);
48972
49124
  var PrimitiveMeshLoader = /*#__PURE__*/ function(Loader) {
48973
49125
  _inherits(PrimitiveMeshLoader, Loader);
48974
49126
  function PrimitiveMeshLoader() {
@@ -50157,7 +50309,7 @@
50157
50309
  ], EXT_texture_webp);
50158
50310
 
50159
50311
  //@ts-ignore
50160
- var version = "1.4.15";
50312
+ var version = "1.4.16";
50161
50313
  console.log("Galacean Engine Version: " + version);
50162
50314
  for(var key in CoreObjects){
50163
50315
  Loader.registerClass(key, CoreObjects[key]);