@galacean/engine-core 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/main.js +386 -355
- package/dist/main.js.map +1 -1
- package/dist/module.js +386 -355
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
package/dist/module.js
CHANGED
|
@@ -2583,7 +2583,7 @@ var Utils = /*#__PURE__*/ function() {
|
|
|
2583
2583
|
return relativeUrl;
|
|
2584
2584
|
}
|
|
2585
2585
|
if (!/^https?:/.test(baseUrl)) {
|
|
2586
|
-
var fileSchema = "
|
|
2586
|
+
var fileSchema = "file://";
|
|
2587
2587
|
baseUrl = fileSchema + baseUrl;
|
|
2588
2588
|
return new URL(relativeUrl, baseUrl).href.substring(fileSchema.length);
|
|
2589
2589
|
}
|
|
@@ -20831,347 +20831,6 @@ Collider = __decorate([
|
|
|
20831
20831
|
dependentComponents(Transform, DependentMode.CheckOnly)
|
|
20832
20832
|
], Collider);
|
|
20833
20833
|
|
|
20834
|
-
/**
|
|
20835
|
-
* Describes a contact point where the collision occurs.
|
|
20836
|
-
*/ var ContactPoint = function ContactPoint() {
|
|
20837
|
-
/** The position of the contact point between the shapes, in world space. */ this.position = new Vector3();
|
|
20838
|
-
/** 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();
|
|
20839
|
-
/** 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();
|
|
20840
|
-
};
|
|
20841
|
-
|
|
20842
|
-
/**
|
|
20843
|
-
* Collision information between two shapes when they collide.
|
|
20844
|
-
*/ var Collision = /*#__PURE__*/ function() {
|
|
20845
|
-
function Collision() {}
|
|
20846
|
-
var _proto = Collision.prototype;
|
|
20847
|
-
/**
|
|
20848
|
-
* Get contact points.
|
|
20849
|
-
* @param outContacts - The result of contact points
|
|
20850
|
-
* @returns The actual count of contact points
|
|
20851
|
-
*
|
|
20852
|
-
* @remarks To optimize performance, the engine does not modify the length of the array you pass.
|
|
20853
|
-
* You need to obtain the actual number of contact points from the function's return value.
|
|
20854
|
-
*/ _proto.getContacts = function getContacts(outContacts) {
|
|
20855
|
-
var nativeCollision = this._nativeCollision;
|
|
20856
|
-
var smallerShapeId = Math.min(nativeCollision.shape0Id, nativeCollision.shape1Id);
|
|
20857
|
-
var factor = this.shape.id === smallerShapeId ? 1 : -1;
|
|
20858
|
-
var nativeContactPoints = nativeCollision.getContacts();
|
|
20859
|
-
var length = nativeContactPoints.size();
|
|
20860
|
-
for(var i = 0; i < length; i++){
|
|
20861
|
-
var _outContacts, _i;
|
|
20862
|
-
var nativeContractPoint = nativeContactPoints.get(i);
|
|
20863
|
-
var contact = (_outContacts = outContacts)[_i = i] || (_outContacts[_i] = new ContactPoint());
|
|
20864
|
-
contact.position.copyFrom(nativeContractPoint.position);
|
|
20865
|
-
contact.normal.copyFrom(nativeContractPoint.normal).scale(factor);
|
|
20866
|
-
contact.impulse.copyFrom(nativeContractPoint.impulse).scale(factor);
|
|
20867
|
-
contact.separation = nativeContractPoint.separation;
|
|
20868
|
-
}
|
|
20869
|
-
return length;
|
|
20870
|
-
};
|
|
20871
|
-
_create_class(Collision, [
|
|
20872
|
-
{
|
|
20873
|
-
key: "contactCount",
|
|
20874
|
-
get: /**
|
|
20875
|
-
* Count of contact points.
|
|
20876
|
-
*/ function get() {
|
|
20877
|
-
return this._nativeCollision.contactCount;
|
|
20878
|
-
}
|
|
20879
|
-
}
|
|
20880
|
-
]);
|
|
20881
|
-
return Collision;
|
|
20882
|
-
}();
|
|
20883
|
-
|
|
20884
|
-
/**
|
|
20885
|
-
* A physics scene is a collection of colliders and constraints which can interact.
|
|
20886
|
-
*/ var PhysicsScene = /*#__PURE__*/ function() {
|
|
20887
|
-
function PhysicsScene(scene) {
|
|
20888
|
-
this._restTime = 0;
|
|
20889
|
-
this._fixedTimeStep = 1 / 60;
|
|
20890
|
-
this._colliders = new DisorderedArray();
|
|
20891
|
-
this._gravity = new Vector3(0, -9.81, 0);
|
|
20892
|
-
this._onContactEnter = function(nativeCollision) {
|
|
20893
|
-
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
20894
|
-
var shape0Id = nativeCollision.shape0Id, shape1Id = nativeCollision.shape1Id;
|
|
20895
|
-
var shape1 = physicalObjectsMap[shape0Id];
|
|
20896
|
-
var shape2 = physicalObjectsMap[shape1Id];
|
|
20897
|
-
var collision = PhysicsScene._collision;
|
|
20898
|
-
collision._nativeCollision = nativeCollision;
|
|
20899
|
-
shape1.collider.entity._scripts.forEach(function(element) {
|
|
20900
|
-
collision.shape = shape2;
|
|
20901
|
-
element.onCollisionEnter(collision);
|
|
20902
|
-
}, function(element, index) {
|
|
20903
|
-
element._entityScriptsIndex = index;
|
|
20904
|
-
});
|
|
20905
|
-
shape2.collider.entity._scripts.forEach(function(element) {
|
|
20906
|
-
collision.shape = shape1;
|
|
20907
|
-
element.onCollisionEnter(collision);
|
|
20908
|
-
}, function(element, index) {
|
|
20909
|
-
element._entityScriptsIndex = index;
|
|
20910
|
-
});
|
|
20911
|
-
};
|
|
20912
|
-
this._onContactExit = function(nativeCollision) {
|
|
20913
|
-
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
20914
|
-
var shape0Id = nativeCollision.shape0Id, shape1Id = nativeCollision.shape1Id;
|
|
20915
|
-
var shape1 = physicalObjectsMap[shape0Id];
|
|
20916
|
-
var shape2 = physicalObjectsMap[shape1Id];
|
|
20917
|
-
var collision = PhysicsScene._collision;
|
|
20918
|
-
collision._nativeCollision = nativeCollision;
|
|
20919
|
-
shape1.collider.entity._scripts.forEach(function(element) {
|
|
20920
|
-
collision.shape = shape2;
|
|
20921
|
-
element.onCollisionExit(collision);
|
|
20922
|
-
}, function(element, index) {
|
|
20923
|
-
element._entityScriptsIndex = index;
|
|
20924
|
-
});
|
|
20925
|
-
shape2.collider.entity._scripts.forEach(function(element) {
|
|
20926
|
-
collision.shape = shape1;
|
|
20927
|
-
element.onCollisionExit(collision);
|
|
20928
|
-
}, function(element, index) {
|
|
20929
|
-
element._entityScriptsIndex = index;
|
|
20930
|
-
});
|
|
20931
|
-
};
|
|
20932
|
-
this._onContactStay = function(nativeCollision) {
|
|
20933
|
-
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
20934
|
-
var shape0Id = nativeCollision.shape0Id, shape1Id = nativeCollision.shape1Id;
|
|
20935
|
-
var shape1 = physicalObjectsMap[shape0Id];
|
|
20936
|
-
var shape2 = physicalObjectsMap[shape1Id];
|
|
20937
|
-
var collision = PhysicsScene._collision;
|
|
20938
|
-
collision._nativeCollision = nativeCollision;
|
|
20939
|
-
shape1.collider.entity._scripts.forEach(function(element) {
|
|
20940
|
-
collision.shape = shape2;
|
|
20941
|
-
element.onCollisionStay(collision);
|
|
20942
|
-
}, function(element, index) {
|
|
20943
|
-
element._entityScriptsIndex = index;
|
|
20944
|
-
});
|
|
20945
|
-
shape2.collider.entity._scripts.forEach(function(element) {
|
|
20946
|
-
collision.shape = shape1;
|
|
20947
|
-
element.onCollisionStay(collision);
|
|
20948
|
-
}, function(element, index) {
|
|
20949
|
-
element._entityScriptsIndex = index;
|
|
20950
|
-
});
|
|
20951
|
-
};
|
|
20952
|
-
this._onTriggerEnter = function(obj1, obj2) {
|
|
20953
|
-
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
20954
|
-
var shape1 = physicalObjectsMap[obj1];
|
|
20955
|
-
var shape2 = physicalObjectsMap[obj2];
|
|
20956
|
-
shape1.collider.entity._scripts.forEach(function(element) {
|
|
20957
|
-
element.onTriggerEnter(shape2);
|
|
20958
|
-
}, function(element, index) {
|
|
20959
|
-
element._entityScriptsIndex = index;
|
|
20960
|
-
});
|
|
20961
|
-
shape2.collider.entity._scripts.forEach(function(element) {
|
|
20962
|
-
element.onTriggerEnter(shape1);
|
|
20963
|
-
}, function(element, index) {
|
|
20964
|
-
element._entityScriptsIndex = index;
|
|
20965
|
-
});
|
|
20966
|
-
};
|
|
20967
|
-
this._onTriggerExit = function(obj1, obj2) {
|
|
20968
|
-
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
20969
|
-
var shape1 = physicalObjectsMap[obj1];
|
|
20970
|
-
var shape2 = physicalObjectsMap[obj2];
|
|
20971
|
-
shape1.collider.entity._scripts.forEach(function(element) {
|
|
20972
|
-
element.onTriggerExit(shape2);
|
|
20973
|
-
}, function(element, index) {
|
|
20974
|
-
element._entityScriptsIndex = index;
|
|
20975
|
-
});
|
|
20976
|
-
shape2.collider.entity._scripts.forEach(function(element) {
|
|
20977
|
-
element.onTriggerExit(shape1);
|
|
20978
|
-
}, function(element, index) {
|
|
20979
|
-
element._entityScriptsIndex = index;
|
|
20980
|
-
});
|
|
20981
|
-
};
|
|
20982
|
-
this._onTriggerStay = function(obj1, obj2) {
|
|
20983
|
-
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
20984
|
-
var shape1 = physicalObjectsMap[obj1];
|
|
20985
|
-
var shape2 = physicalObjectsMap[obj2];
|
|
20986
|
-
shape1.collider.entity._scripts.forEach(function(element) {
|
|
20987
|
-
element.onTriggerStay(shape2);
|
|
20988
|
-
}, function(element, index) {
|
|
20989
|
-
element._entityScriptsIndex = index;
|
|
20990
|
-
});
|
|
20991
|
-
shape2.collider.entity._scripts.forEach(function(element) {
|
|
20992
|
-
element.onTriggerStay(shape1);
|
|
20993
|
-
}, function(element, index) {
|
|
20994
|
-
element._entityScriptsIndex = index;
|
|
20995
|
-
});
|
|
20996
|
-
};
|
|
20997
|
-
this._scene = scene;
|
|
20998
|
-
this._setGravity = this._setGravity.bind(this);
|
|
20999
|
-
//@ts-ignore
|
|
21000
|
-
this._gravity._onValueChanged = this._setGravity;
|
|
21001
|
-
var engine = scene.engine;
|
|
21002
|
-
if (engine._physicsInitialized) {
|
|
21003
|
-
this._nativePhysicsScene = PhysicsScene._nativePhysics.createPhysicsScene(engine._nativePhysicsManager, this._onContactEnter, this._onContactExit, this._onContactStay, this._onTriggerEnter, this._onTriggerExit, this._onTriggerStay);
|
|
21004
|
-
}
|
|
21005
|
-
}
|
|
21006
|
-
var _proto = PhysicsScene.prototype;
|
|
21007
|
-
_proto.raycast = function raycast(ray, distanceOrResult, layerMaskOrResult, outHitResult) {
|
|
21008
|
-
var hitResult;
|
|
21009
|
-
var distance = Number.MAX_VALUE;
|
|
21010
|
-
if (typeof distanceOrResult === "number") {
|
|
21011
|
-
distance = distanceOrResult;
|
|
21012
|
-
} else if (distanceOrResult != undefined) {
|
|
21013
|
-
hitResult = distanceOrResult;
|
|
21014
|
-
}
|
|
21015
|
-
var layerMask = Layer.Everything;
|
|
21016
|
-
if (typeof layerMaskOrResult === "number") {
|
|
21017
|
-
layerMask = layerMaskOrResult;
|
|
21018
|
-
} else if (layerMaskOrResult != undefined) {
|
|
21019
|
-
hitResult = layerMaskOrResult;
|
|
21020
|
-
}
|
|
21021
|
-
if (outHitResult) {
|
|
21022
|
-
hitResult = outHitResult;
|
|
21023
|
-
}
|
|
21024
|
-
var onRaycast = function(obj) {
|
|
21025
|
-
var shape = Engine._physicalObjectsMap[obj];
|
|
21026
|
-
if (!shape) {
|
|
21027
|
-
return false;
|
|
21028
|
-
}
|
|
21029
|
-
return shape.collider.entity.layer & layerMask && shape.isSceneQuery;
|
|
21030
|
-
};
|
|
21031
|
-
var outIDX;
|
|
21032
|
-
var outDistance;
|
|
21033
|
-
var outPosition;
|
|
21034
|
-
var outNormal;
|
|
21035
|
-
if (hitResult != undefined) {
|
|
21036
|
-
var result = this._nativePhysicsScene.raycast(ray, distance, onRaycast, function(idx, distance, position, normal) {
|
|
21037
|
-
outIDX = idx;
|
|
21038
|
-
outDistance = distance;
|
|
21039
|
-
outPosition = position;
|
|
21040
|
-
outNormal = normal;
|
|
21041
|
-
});
|
|
21042
|
-
if (result) {
|
|
21043
|
-
var hitShape = Engine._physicalObjectsMap[outIDX];
|
|
21044
|
-
hitResult.entity = hitShape._collider.entity;
|
|
21045
|
-
hitResult.shape = hitShape;
|
|
21046
|
-
hitResult.distance = outDistance;
|
|
21047
|
-
hitResult.point.copyFrom(outPosition);
|
|
21048
|
-
hitResult.normal.copyFrom(outNormal);
|
|
21049
|
-
return true;
|
|
21050
|
-
} else {
|
|
21051
|
-
hitResult.entity = null;
|
|
21052
|
-
hitResult.shape = null;
|
|
21053
|
-
hitResult.distance = 0;
|
|
21054
|
-
hitResult.point.set(0, 0, 0);
|
|
21055
|
-
hitResult.normal.set(0, 0, 0);
|
|
21056
|
-
return false;
|
|
21057
|
-
}
|
|
21058
|
-
} else {
|
|
21059
|
-
return this._nativePhysicsScene.raycast(ray, distance, onRaycast);
|
|
21060
|
-
}
|
|
21061
|
-
};
|
|
21062
|
-
/**
|
|
21063
|
-
* Call on every frame to update pose of objects.
|
|
21064
|
-
* @internal
|
|
21065
|
-
*/ _proto._update = function _update(deltaTime) {
|
|
21066
|
-
var _this = this, fixedTimeStep = _this._fixedTimeStep, nativePhysicsManager = _this._nativePhysicsScene;
|
|
21067
|
-
var componentsManager = this._scene._componentsManager;
|
|
21068
|
-
var simulateTime = this._restTime + deltaTime;
|
|
21069
|
-
var step = Math.floor(simulateTime / fixedTimeStep);
|
|
21070
|
-
this._restTime = simulateTime - step * fixedTimeStep;
|
|
21071
|
-
for(var i = 0; i < step; i++){
|
|
21072
|
-
componentsManager.callScriptOnPhysicsUpdate();
|
|
21073
|
-
this._callColliderOnUpdate();
|
|
21074
|
-
nativePhysicsManager.update(fixedTimeStep);
|
|
21075
|
-
this._callColliderOnLateUpdate();
|
|
21076
|
-
}
|
|
21077
|
-
};
|
|
21078
|
-
/**
|
|
21079
|
-
* Add collider into the manager.
|
|
21080
|
-
* @param collider - StaticCollider or DynamicCollider.
|
|
21081
|
-
* @internal
|
|
21082
|
-
*/ _proto._addCollider = function _addCollider(collider) {
|
|
21083
|
-
if (collider._index === -1) {
|
|
21084
|
-
collider._index = this._colliders.length;
|
|
21085
|
-
this._colliders.add(collider);
|
|
21086
|
-
}
|
|
21087
|
-
this._nativePhysicsScene.addCollider(collider._nativeCollider);
|
|
21088
|
-
};
|
|
21089
|
-
/**
|
|
21090
|
-
* Add character controller into the manager.
|
|
21091
|
-
* @param controller - Character Controller.
|
|
21092
|
-
* @internal
|
|
21093
|
-
*/ _proto._addCharacterController = function _addCharacterController(controller) {
|
|
21094
|
-
if (controller._index === -1) {
|
|
21095
|
-
controller._index = this._colliders.length;
|
|
21096
|
-
this._colliders.add(controller);
|
|
21097
|
-
}
|
|
21098
|
-
this._nativePhysicsScene.addCharacterController(controller._nativeCollider);
|
|
21099
|
-
};
|
|
21100
|
-
/**
|
|
21101
|
-
* Remove collider.
|
|
21102
|
-
* @param collider - StaticCollider or DynamicCollider.
|
|
21103
|
-
* @internal
|
|
21104
|
-
*/ _proto._removeCollider = function _removeCollider(collider) {
|
|
21105
|
-
var replaced = this._colliders.deleteByIndex(collider._index);
|
|
21106
|
-
replaced && (replaced._index = collider._index);
|
|
21107
|
-
collider._index = -1;
|
|
21108
|
-
this._nativePhysicsScene.removeCollider(collider._nativeCollider);
|
|
21109
|
-
};
|
|
21110
|
-
/**
|
|
21111
|
-
* Remove collider.
|
|
21112
|
-
* @param controller - Character Controller.
|
|
21113
|
-
* @internal
|
|
21114
|
-
*/ _proto._removeCharacterController = function _removeCharacterController(controller) {
|
|
21115
|
-
var replaced = this._colliders.deleteByIndex(controller._index);
|
|
21116
|
-
replaced && (replaced._index = controller._index);
|
|
21117
|
-
controller._index = -1;
|
|
21118
|
-
this._nativePhysicsScene.removeCharacterController(controller._nativeCollider);
|
|
21119
|
-
};
|
|
21120
|
-
/**
|
|
21121
|
-
* @internal
|
|
21122
|
-
*/ _proto._callColliderOnUpdate = function _callColliderOnUpdate() {
|
|
21123
|
-
var elements = this._colliders._elements;
|
|
21124
|
-
for(var i = this._colliders.length - 1; i >= 0; --i){
|
|
21125
|
-
elements[i]._onUpdate();
|
|
21126
|
-
}
|
|
21127
|
-
};
|
|
21128
|
-
/**
|
|
21129
|
-
* @internal
|
|
21130
|
-
*/ _proto._callColliderOnLateUpdate = function _callColliderOnLateUpdate() {
|
|
21131
|
-
var elements = this._colliders._elements;
|
|
21132
|
-
for(var i = this._colliders.length - 1; i >= 0; --i){
|
|
21133
|
-
elements[i]._onLateUpdate();
|
|
21134
|
-
}
|
|
21135
|
-
};
|
|
21136
|
-
/**
|
|
21137
|
-
* @internal
|
|
21138
|
-
*/ _proto._gc = function _gc() {
|
|
21139
|
-
this._colliders.garbageCollection();
|
|
21140
|
-
};
|
|
21141
|
-
_proto._setGravity = function _setGravity() {
|
|
21142
|
-
this._nativePhysicsScene.setGravity(this._gravity);
|
|
21143
|
-
};
|
|
21144
|
-
_create_class(PhysicsScene, [
|
|
21145
|
-
{
|
|
21146
|
-
key: "gravity",
|
|
21147
|
-
get: /**
|
|
21148
|
-
* The gravity of physics scene.
|
|
21149
|
-
*/ function get() {
|
|
21150
|
-
return this._gravity;
|
|
21151
|
-
},
|
|
21152
|
-
set: function set(value) {
|
|
21153
|
-
var gravity = this._gravity;
|
|
21154
|
-
if (gravity !== value) {
|
|
21155
|
-
gravity.copyFrom(value);
|
|
21156
|
-
}
|
|
21157
|
-
}
|
|
21158
|
-
},
|
|
21159
|
-
{
|
|
21160
|
-
key: "fixedTimeStep",
|
|
21161
|
-
get: /**
|
|
21162
|
-
* The fixed time step in seconds at which physics are performed.
|
|
21163
|
-
*/ function get() {
|
|
21164
|
-
return this._fixedTimeStep;
|
|
21165
|
-
},
|
|
21166
|
-
set: function set(value) {
|
|
21167
|
-
this._fixedTimeStep = Math.max(value, MathUtil.zeroTolerance);
|
|
21168
|
-
}
|
|
21169
|
-
}
|
|
21170
|
-
]);
|
|
21171
|
-
return PhysicsScene;
|
|
21172
|
-
}();
|
|
21173
|
-
PhysicsScene._collision = new Collision();
|
|
21174
|
-
|
|
21175
20834
|
/**
|
|
21176
20835
|
* The up axis of the collider shape.
|
|
21177
20836
|
*/ var ControllerNonWalkableMode = /*#__PURE__*/ function(ControllerNonWalkableMode) {
|
|
@@ -21187,7 +20846,7 @@ PhysicsScene._collision = new Collision();
|
|
|
21187
20846
|
function CharacterController(entity) {
|
|
21188
20847
|
var _this;
|
|
21189
20848
|
_this = Collider.call(this, entity) || this, _this._stepOffset = 0.5, _this._nonWalkableMode = ControllerNonWalkableMode.PreventClimbing, _this._upDirection = new Vector3(0, 1, 0), _this._slopeLimit = 45;
|
|
21190
|
-
_this._nativeCollider =
|
|
20849
|
+
_this._nativeCollider = Engine._nativePhysics.createCharacterController();
|
|
21191
20850
|
_this._setUpDirection = _this._setUpDirection.bind(_this);
|
|
21192
20851
|
//@ts-ignore
|
|
21193
20852
|
_this._upDirection._onValueChanged = _this._setUpDirection;
|
|
@@ -21337,7 +20996,7 @@ __decorate([
|
|
|
21337
20996
|
var _this;
|
|
21338
20997
|
_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;
|
|
21339
20998
|
var transform = _this.entity.transform;
|
|
21340
|
-
_this._nativeCollider =
|
|
20999
|
+
_this._nativeCollider = Engine._nativePhysics.createDynamicCollider(transform.worldPosition, transform.worldRotationQuaternion);
|
|
21341
21000
|
_this._setLinearVelocity = _this._setLinearVelocity.bind(_this);
|
|
21342
21001
|
_this._setAngularVelocity = _this._setAngularVelocity.bind(_this);
|
|
21343
21002
|
_this._handleCenterOfMassChanged = _this._handleCenterOfMassChanged.bind(_this);
|
|
@@ -21811,7 +21470,7 @@ __decorate([
|
|
|
21811
21470
|
this._staticFriction = 0.6;
|
|
21812
21471
|
this._bounceCombine = PhysicsMaterialCombineMode.Average;
|
|
21813
21472
|
this._frictionCombine = PhysicsMaterialCombineMode.Average;
|
|
21814
|
-
this._nativeMaterial =
|
|
21473
|
+
this._nativeMaterial = Engine._nativePhysics.createPhysicsMaterial(this._staticFriction, this._dynamicFriction, this._bounciness, this._bounceCombine, this._frictionCombine);
|
|
21815
21474
|
}
|
|
21816
21475
|
var _proto = PhysicsMaterial.prototype;
|
|
21817
21476
|
/**
|
|
@@ -21895,6 +21554,353 @@ __decorate([
|
|
|
21895
21554
|
return PhysicsMaterial;
|
|
21896
21555
|
}();
|
|
21897
21556
|
|
|
21557
|
+
/**
|
|
21558
|
+
* Describes a contact point where the collision occurs.
|
|
21559
|
+
*/ var ContactPoint = function ContactPoint() {
|
|
21560
|
+
/** The position of the contact point between the shapes, in world space. */ this.position = new Vector3();
|
|
21561
|
+
/** 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();
|
|
21562
|
+
/** 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();
|
|
21563
|
+
};
|
|
21564
|
+
|
|
21565
|
+
/**
|
|
21566
|
+
* Collision information between two shapes when they collide.
|
|
21567
|
+
*/ var Collision = /*#__PURE__*/ function() {
|
|
21568
|
+
function Collision() {}
|
|
21569
|
+
var _proto = Collision.prototype;
|
|
21570
|
+
/**
|
|
21571
|
+
* Get contact points.
|
|
21572
|
+
* @param outContacts - The result of contact points
|
|
21573
|
+
* @returns The actual count of contact points
|
|
21574
|
+
*
|
|
21575
|
+
* @remarks To optimize performance, the engine does not modify the length of the array you pass.
|
|
21576
|
+
* You need to obtain the actual number of contact points from the function's return value.
|
|
21577
|
+
*/ _proto.getContacts = function getContacts(outContacts) {
|
|
21578
|
+
var nativeCollision = this._nativeCollision;
|
|
21579
|
+
var smallerShapeId = Math.min(nativeCollision.shape0Id, nativeCollision.shape1Id);
|
|
21580
|
+
var factor = this.shape.id === smallerShapeId ? 1 : -1;
|
|
21581
|
+
var nativeContactPoints = nativeCollision.getContacts();
|
|
21582
|
+
var length = nativeContactPoints.size();
|
|
21583
|
+
for(var i = 0; i < length; i++){
|
|
21584
|
+
var _outContacts, _i;
|
|
21585
|
+
var nativeContractPoint = nativeContactPoints.get(i);
|
|
21586
|
+
var contact = (_outContacts = outContacts)[_i = i] || (_outContacts[_i] = new ContactPoint());
|
|
21587
|
+
contact.position.copyFrom(nativeContractPoint.position);
|
|
21588
|
+
contact.normal.copyFrom(nativeContractPoint.normal).scale(factor);
|
|
21589
|
+
contact.impulse.copyFrom(nativeContractPoint.impulse).scale(factor);
|
|
21590
|
+
contact.separation = nativeContractPoint.separation;
|
|
21591
|
+
}
|
|
21592
|
+
return length;
|
|
21593
|
+
};
|
|
21594
|
+
_create_class(Collision, [
|
|
21595
|
+
{
|
|
21596
|
+
key: "contactCount",
|
|
21597
|
+
get: /**
|
|
21598
|
+
* Count of contact points.
|
|
21599
|
+
*/ function get() {
|
|
21600
|
+
return this._nativeCollision.contactCount;
|
|
21601
|
+
}
|
|
21602
|
+
}
|
|
21603
|
+
]);
|
|
21604
|
+
return Collision;
|
|
21605
|
+
}();
|
|
21606
|
+
|
|
21607
|
+
/**
|
|
21608
|
+
* A physics scene is a collection of colliders and constraints which can interact.
|
|
21609
|
+
*/ var PhysicsScene = /*#__PURE__*/ function() {
|
|
21610
|
+
function PhysicsScene(scene) {
|
|
21611
|
+
this._restTime = 0;
|
|
21612
|
+
this._fixedTimeStep = 1 / 60;
|
|
21613
|
+
this._colliders = new DisorderedArray();
|
|
21614
|
+
this._gravity = new Vector3(0, -9.81, 0);
|
|
21615
|
+
this._onContactEnter = function(nativeCollision) {
|
|
21616
|
+
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
21617
|
+
var shape0Id = nativeCollision.shape0Id, shape1Id = nativeCollision.shape1Id;
|
|
21618
|
+
var shape1 = physicalObjectsMap[shape0Id];
|
|
21619
|
+
var shape2 = physicalObjectsMap[shape1Id];
|
|
21620
|
+
var collision = PhysicsScene._collision;
|
|
21621
|
+
collision._nativeCollision = nativeCollision;
|
|
21622
|
+
shape1.collider.entity._scripts.forEach(function(element) {
|
|
21623
|
+
collision.shape = shape2;
|
|
21624
|
+
element.onCollisionEnter(collision);
|
|
21625
|
+
}, function(element, index) {
|
|
21626
|
+
element._entityScriptsIndex = index;
|
|
21627
|
+
});
|
|
21628
|
+
shape2.collider.entity._scripts.forEach(function(element) {
|
|
21629
|
+
collision.shape = shape1;
|
|
21630
|
+
element.onCollisionEnter(collision);
|
|
21631
|
+
}, function(element, index) {
|
|
21632
|
+
element._entityScriptsIndex = index;
|
|
21633
|
+
});
|
|
21634
|
+
};
|
|
21635
|
+
this._onContactExit = function(nativeCollision) {
|
|
21636
|
+
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
21637
|
+
var shape0Id = nativeCollision.shape0Id, shape1Id = nativeCollision.shape1Id;
|
|
21638
|
+
var shape1 = physicalObjectsMap[shape0Id];
|
|
21639
|
+
var shape2 = physicalObjectsMap[shape1Id];
|
|
21640
|
+
var collision = PhysicsScene._collision;
|
|
21641
|
+
collision._nativeCollision = nativeCollision;
|
|
21642
|
+
shape1.collider.entity._scripts.forEach(function(element) {
|
|
21643
|
+
collision.shape = shape2;
|
|
21644
|
+
element.onCollisionExit(collision);
|
|
21645
|
+
}, function(element, index) {
|
|
21646
|
+
element._entityScriptsIndex = index;
|
|
21647
|
+
});
|
|
21648
|
+
shape2.collider.entity._scripts.forEach(function(element) {
|
|
21649
|
+
collision.shape = shape1;
|
|
21650
|
+
element.onCollisionExit(collision);
|
|
21651
|
+
}, function(element, index) {
|
|
21652
|
+
element._entityScriptsIndex = index;
|
|
21653
|
+
});
|
|
21654
|
+
};
|
|
21655
|
+
this._onContactStay = function(nativeCollision) {
|
|
21656
|
+
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
21657
|
+
var shape0Id = nativeCollision.shape0Id, shape1Id = nativeCollision.shape1Id;
|
|
21658
|
+
var shape1 = physicalObjectsMap[shape0Id];
|
|
21659
|
+
var shape2 = physicalObjectsMap[shape1Id];
|
|
21660
|
+
var collision = PhysicsScene._collision;
|
|
21661
|
+
collision._nativeCollision = nativeCollision;
|
|
21662
|
+
shape1.collider.entity._scripts.forEach(function(element) {
|
|
21663
|
+
collision.shape = shape2;
|
|
21664
|
+
element.onCollisionStay(collision);
|
|
21665
|
+
}, function(element, index) {
|
|
21666
|
+
element._entityScriptsIndex = index;
|
|
21667
|
+
});
|
|
21668
|
+
shape2.collider.entity._scripts.forEach(function(element) {
|
|
21669
|
+
collision.shape = shape1;
|
|
21670
|
+
element.onCollisionStay(collision);
|
|
21671
|
+
}, function(element, index) {
|
|
21672
|
+
element._entityScriptsIndex = index;
|
|
21673
|
+
});
|
|
21674
|
+
};
|
|
21675
|
+
this._onTriggerEnter = function(obj1, obj2) {
|
|
21676
|
+
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
21677
|
+
var shape1 = physicalObjectsMap[obj1];
|
|
21678
|
+
var shape2 = physicalObjectsMap[obj2];
|
|
21679
|
+
shape1.collider.entity._scripts.forEach(function(element) {
|
|
21680
|
+
element.onTriggerEnter(shape2);
|
|
21681
|
+
}, function(element, index) {
|
|
21682
|
+
element._entityScriptsIndex = index;
|
|
21683
|
+
});
|
|
21684
|
+
shape2.collider.entity._scripts.forEach(function(element) {
|
|
21685
|
+
element.onTriggerEnter(shape1);
|
|
21686
|
+
}, function(element, index) {
|
|
21687
|
+
element._entityScriptsIndex = index;
|
|
21688
|
+
});
|
|
21689
|
+
};
|
|
21690
|
+
this._onTriggerExit = function(obj1, obj2) {
|
|
21691
|
+
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
21692
|
+
var shape1 = physicalObjectsMap[obj1];
|
|
21693
|
+
var shape2 = physicalObjectsMap[obj2];
|
|
21694
|
+
shape1.collider.entity._scripts.forEach(function(element) {
|
|
21695
|
+
element.onTriggerExit(shape2);
|
|
21696
|
+
}, function(element, index) {
|
|
21697
|
+
element._entityScriptsIndex = index;
|
|
21698
|
+
});
|
|
21699
|
+
shape2.collider.entity._scripts.forEach(function(element) {
|
|
21700
|
+
element.onTriggerExit(shape1);
|
|
21701
|
+
}, function(element, index) {
|
|
21702
|
+
element._entityScriptsIndex = index;
|
|
21703
|
+
});
|
|
21704
|
+
};
|
|
21705
|
+
this._onTriggerStay = function(obj1, obj2) {
|
|
21706
|
+
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
21707
|
+
var shape1 = physicalObjectsMap[obj1];
|
|
21708
|
+
var shape2 = physicalObjectsMap[obj2];
|
|
21709
|
+
shape1.collider.entity._scripts.forEach(function(element) {
|
|
21710
|
+
element.onTriggerStay(shape2);
|
|
21711
|
+
}, function(element, index) {
|
|
21712
|
+
element._entityScriptsIndex = index;
|
|
21713
|
+
});
|
|
21714
|
+
shape2.collider.entity._scripts.forEach(function(element) {
|
|
21715
|
+
element.onTriggerStay(shape1);
|
|
21716
|
+
}, function(element, index) {
|
|
21717
|
+
element._entityScriptsIndex = index;
|
|
21718
|
+
});
|
|
21719
|
+
};
|
|
21720
|
+
this._scene = scene;
|
|
21721
|
+
this._setGravity = this._setGravity.bind(this);
|
|
21722
|
+
//@ts-ignore
|
|
21723
|
+
this._gravity._onValueChanged = this._setGravity;
|
|
21724
|
+
var engine = scene.engine;
|
|
21725
|
+
if (engine._physicsInitialized) {
|
|
21726
|
+
this._nativePhysicsScene = Engine._nativePhysics.createPhysicsScene(engine._nativePhysicsManager, this._onContactEnter, this._onContactExit, this._onContactStay, this._onTriggerEnter, this._onTriggerExit, this._onTriggerStay);
|
|
21727
|
+
}
|
|
21728
|
+
}
|
|
21729
|
+
var _proto = PhysicsScene.prototype;
|
|
21730
|
+
_proto.raycast = function raycast(ray, distanceOrResult, layerMaskOrResult, outHitResult) {
|
|
21731
|
+
var hitResult;
|
|
21732
|
+
var distance = Number.MAX_VALUE;
|
|
21733
|
+
if (typeof distanceOrResult === "number") {
|
|
21734
|
+
distance = distanceOrResult;
|
|
21735
|
+
} else if (distanceOrResult != undefined) {
|
|
21736
|
+
hitResult = distanceOrResult;
|
|
21737
|
+
}
|
|
21738
|
+
var layerMask = Layer.Everything;
|
|
21739
|
+
if (typeof layerMaskOrResult === "number") {
|
|
21740
|
+
layerMask = layerMaskOrResult;
|
|
21741
|
+
} else if (layerMaskOrResult != undefined) {
|
|
21742
|
+
hitResult = layerMaskOrResult;
|
|
21743
|
+
}
|
|
21744
|
+
if (outHitResult) {
|
|
21745
|
+
hitResult = outHitResult;
|
|
21746
|
+
}
|
|
21747
|
+
var onRaycast = function(obj) {
|
|
21748
|
+
var shape = Engine._physicalObjectsMap[obj];
|
|
21749
|
+
if (!shape) {
|
|
21750
|
+
return false;
|
|
21751
|
+
}
|
|
21752
|
+
return shape.collider.entity.layer & layerMask && shape.isSceneQuery;
|
|
21753
|
+
};
|
|
21754
|
+
var outIDX;
|
|
21755
|
+
var outDistance;
|
|
21756
|
+
var outPosition;
|
|
21757
|
+
var outNormal;
|
|
21758
|
+
if (hitResult != undefined) {
|
|
21759
|
+
var result = this._nativePhysicsScene.raycast(ray, distance, onRaycast, function(idx, distance, position, normal) {
|
|
21760
|
+
outIDX = idx;
|
|
21761
|
+
outDistance = distance;
|
|
21762
|
+
outPosition = position;
|
|
21763
|
+
outNormal = normal;
|
|
21764
|
+
});
|
|
21765
|
+
if (result) {
|
|
21766
|
+
var hitShape = Engine._physicalObjectsMap[outIDX];
|
|
21767
|
+
hitResult.entity = hitShape._collider.entity;
|
|
21768
|
+
hitResult.shape = hitShape;
|
|
21769
|
+
hitResult.distance = outDistance;
|
|
21770
|
+
hitResult.point.copyFrom(outPosition);
|
|
21771
|
+
hitResult.normal.copyFrom(outNormal);
|
|
21772
|
+
return true;
|
|
21773
|
+
} else {
|
|
21774
|
+
hitResult.entity = null;
|
|
21775
|
+
hitResult.shape = null;
|
|
21776
|
+
hitResult.distance = 0;
|
|
21777
|
+
hitResult.point.set(0, 0, 0);
|
|
21778
|
+
hitResult.normal.set(0, 0, 0);
|
|
21779
|
+
return false;
|
|
21780
|
+
}
|
|
21781
|
+
} else {
|
|
21782
|
+
return this._nativePhysicsScene.raycast(ray, distance, onRaycast);
|
|
21783
|
+
}
|
|
21784
|
+
};
|
|
21785
|
+
/**
|
|
21786
|
+
* Call on every frame to update pose of objects.
|
|
21787
|
+
* @internal
|
|
21788
|
+
*/ _proto._update = function _update(deltaTime) {
|
|
21789
|
+
var _this = this, fixedTimeStep = _this._fixedTimeStep, nativePhysicsManager = _this._nativePhysicsScene;
|
|
21790
|
+
var componentsManager = this._scene._componentsManager;
|
|
21791
|
+
var simulateTime = this._restTime + deltaTime;
|
|
21792
|
+
var step = Math.floor(simulateTime / fixedTimeStep);
|
|
21793
|
+
this._restTime = simulateTime - step * fixedTimeStep;
|
|
21794
|
+
for(var i = 0; i < step; i++){
|
|
21795
|
+
componentsManager.callScriptOnPhysicsUpdate();
|
|
21796
|
+
this._callColliderOnUpdate();
|
|
21797
|
+
nativePhysicsManager.update(fixedTimeStep);
|
|
21798
|
+
this._callColliderOnLateUpdate();
|
|
21799
|
+
}
|
|
21800
|
+
};
|
|
21801
|
+
/**
|
|
21802
|
+
* Add collider into the manager.
|
|
21803
|
+
* @param collider - StaticCollider or DynamicCollider.
|
|
21804
|
+
* @internal
|
|
21805
|
+
*/ _proto._addCollider = function _addCollider(collider) {
|
|
21806
|
+
if (collider._index === -1) {
|
|
21807
|
+
collider._index = this._colliders.length;
|
|
21808
|
+
this._colliders.add(collider);
|
|
21809
|
+
}
|
|
21810
|
+
this._nativePhysicsScene.addCollider(collider._nativeCollider);
|
|
21811
|
+
};
|
|
21812
|
+
/**
|
|
21813
|
+
* Add character controller into the manager.
|
|
21814
|
+
* @param controller - Character Controller.
|
|
21815
|
+
* @internal
|
|
21816
|
+
*/ _proto._addCharacterController = function _addCharacterController(controller) {
|
|
21817
|
+
if (controller._index === -1) {
|
|
21818
|
+
controller._index = this._colliders.length;
|
|
21819
|
+
this._colliders.add(controller);
|
|
21820
|
+
}
|
|
21821
|
+
this._nativePhysicsScene.addCharacterController(controller._nativeCollider);
|
|
21822
|
+
};
|
|
21823
|
+
/**
|
|
21824
|
+
* Remove collider.
|
|
21825
|
+
* @param collider - StaticCollider or DynamicCollider.
|
|
21826
|
+
* @internal
|
|
21827
|
+
*/ _proto._removeCollider = function _removeCollider(collider) {
|
|
21828
|
+
var replaced = this._colliders.deleteByIndex(collider._index);
|
|
21829
|
+
replaced && (replaced._index = collider._index);
|
|
21830
|
+
collider._index = -1;
|
|
21831
|
+
this._nativePhysicsScene.removeCollider(collider._nativeCollider);
|
|
21832
|
+
};
|
|
21833
|
+
/**
|
|
21834
|
+
* Remove collider.
|
|
21835
|
+
* @param controller - Character Controller.
|
|
21836
|
+
* @internal
|
|
21837
|
+
*/ _proto._removeCharacterController = function _removeCharacterController(controller) {
|
|
21838
|
+
var replaced = this._colliders.deleteByIndex(controller._index);
|
|
21839
|
+
replaced && (replaced._index = controller._index);
|
|
21840
|
+
controller._index = -1;
|
|
21841
|
+
this._nativePhysicsScene.removeCharacterController(controller._nativeCollider);
|
|
21842
|
+
};
|
|
21843
|
+
/**
|
|
21844
|
+
* @internal
|
|
21845
|
+
*/ _proto._callColliderOnUpdate = function _callColliderOnUpdate() {
|
|
21846
|
+
var elements = this._colliders._elements;
|
|
21847
|
+
for(var i = this._colliders.length - 1; i >= 0; --i){
|
|
21848
|
+
elements[i]._onUpdate();
|
|
21849
|
+
}
|
|
21850
|
+
};
|
|
21851
|
+
/**
|
|
21852
|
+
* @internal
|
|
21853
|
+
*/ _proto._callColliderOnLateUpdate = function _callColliderOnLateUpdate() {
|
|
21854
|
+
var elements = this._colliders._elements;
|
|
21855
|
+
for(var i = this._colliders.length - 1; i >= 0; --i){
|
|
21856
|
+
elements[i]._onLateUpdate();
|
|
21857
|
+
}
|
|
21858
|
+
};
|
|
21859
|
+
/**
|
|
21860
|
+
* @internal
|
|
21861
|
+
*/ _proto._gc = function _gc() {
|
|
21862
|
+
this._colliders.garbageCollection();
|
|
21863
|
+
};
|
|
21864
|
+
/**
|
|
21865
|
+
* @internal
|
|
21866
|
+
*/ _proto._destroy = function _destroy() {
|
|
21867
|
+
var _this__nativePhysicsScene;
|
|
21868
|
+
(_this__nativePhysicsScene = this._nativePhysicsScene) == null ? void 0 : _this__nativePhysicsScene.destroy();
|
|
21869
|
+
};
|
|
21870
|
+
_proto._setGravity = function _setGravity() {
|
|
21871
|
+
this._nativePhysicsScene.setGravity(this._gravity);
|
|
21872
|
+
};
|
|
21873
|
+
_create_class(PhysicsScene, [
|
|
21874
|
+
{
|
|
21875
|
+
key: "gravity",
|
|
21876
|
+
get: /**
|
|
21877
|
+
* The gravity of physics scene.
|
|
21878
|
+
*/ function get() {
|
|
21879
|
+
return this._gravity;
|
|
21880
|
+
},
|
|
21881
|
+
set: function set(value) {
|
|
21882
|
+
var gravity = this._gravity;
|
|
21883
|
+
if (gravity !== value) {
|
|
21884
|
+
gravity.copyFrom(value);
|
|
21885
|
+
}
|
|
21886
|
+
}
|
|
21887
|
+
},
|
|
21888
|
+
{
|
|
21889
|
+
key: "fixedTimeStep",
|
|
21890
|
+
get: /**
|
|
21891
|
+
* The fixed time step in seconds at which physics are performed.
|
|
21892
|
+
*/ function get() {
|
|
21893
|
+
return this._fixedTimeStep;
|
|
21894
|
+
},
|
|
21895
|
+
set: function set(value) {
|
|
21896
|
+
this._fixedTimeStep = Math.max(value, MathUtil.zeroTolerance);
|
|
21897
|
+
}
|
|
21898
|
+
}
|
|
21899
|
+
]);
|
|
21900
|
+
return PhysicsScene;
|
|
21901
|
+
}();
|
|
21902
|
+
PhysicsScene._collision = new Collision();
|
|
21903
|
+
|
|
21898
21904
|
/**
|
|
21899
21905
|
* A static collider component that will not move.
|
|
21900
21906
|
* @remarks Mostly used for object which always stays at the same place and never moves around.
|
|
@@ -21904,7 +21910,7 @@ __decorate([
|
|
|
21904
21910
|
var _this;
|
|
21905
21911
|
_this = Collider.call(this, entity) || this;
|
|
21906
21912
|
var transform = _this.entity.transform;
|
|
21907
|
-
_this._nativeCollider =
|
|
21913
|
+
_this._nativeCollider = Engine._nativePhysics.createStaticCollider(transform.worldPosition, transform.worldRotationQuaternion);
|
|
21908
21914
|
return _this;
|
|
21909
21915
|
}
|
|
21910
21916
|
return StaticCollider;
|
|
@@ -22260,7 +22266,7 @@ __decorate([
|
|
|
22260
22266
|
_proto._createJoint = function _createJoint() {
|
|
22261
22267
|
var colliderInfo = this._colliderInfo;
|
|
22262
22268
|
colliderInfo.collider = this.entity.getComponent(Collider);
|
|
22263
|
-
this._nativeJoint =
|
|
22269
|
+
this._nativeJoint = Engine._nativePhysics.createFixedJoint(colliderInfo.collider._nativeCollider);
|
|
22264
22270
|
};
|
|
22265
22271
|
return FixedJoint;
|
|
22266
22272
|
}(Joint);
|
|
@@ -22302,7 +22308,7 @@ __decorate([
|
|
|
22302
22308
|
_proto._createJoint = function _createJoint() {
|
|
22303
22309
|
var colliderInfo = this._colliderInfo;
|
|
22304
22310
|
colliderInfo.collider = this.entity.getComponent(Collider);
|
|
22305
|
-
this._nativeJoint =
|
|
22311
|
+
this._nativeJoint = Engine._nativePhysics.createHingeJoint(colliderInfo.collider._nativeCollider);
|
|
22306
22312
|
};
|
|
22307
22313
|
_proto._syncNative = function _syncNative() {
|
|
22308
22314
|
Joint.prototype._syncNative.call(this);
|
|
@@ -22497,7 +22503,7 @@ __decorate([
|
|
|
22497
22503
|
_proto._createJoint = function _createJoint() {
|
|
22498
22504
|
var colliderInfo = this._colliderInfo;
|
|
22499
22505
|
colliderInfo.collider = this.entity.getComponent(Collider);
|
|
22500
|
-
this._nativeJoint =
|
|
22506
|
+
this._nativeJoint = Engine._nativePhysics.createSpringJoint(colliderInfo.collider._nativeCollider);
|
|
22501
22507
|
};
|
|
22502
22508
|
_proto._syncNative = function _syncNative() {
|
|
22503
22509
|
Joint.prototype._syncNative.call(this);
|
|
@@ -22957,7 +22963,7 @@ __decorate([
|
|
|
22957
22963
|
function BoxColliderShape() {
|
|
22958
22964
|
var _this;
|
|
22959
22965
|
_this = ColliderShape.call(this) || this, _this._size = new Vector3(1, 1, 1);
|
|
22960
|
-
_this._nativeShape =
|
|
22966
|
+
_this._nativeShape = Engine._nativePhysics.createBoxColliderShape(_this._id, _this._size, _this._material._nativeMaterial);
|
|
22961
22967
|
//@ts-ignore
|
|
22962
22968
|
_this._size._onValueChanged = _this._setSize.bind(_this);
|
|
22963
22969
|
return _this;
|
|
@@ -23001,7 +23007,7 @@ __decorate([
|
|
|
23001
23007
|
function SphereColliderShape() {
|
|
23002
23008
|
var _this;
|
|
23003
23009
|
_this = ColliderShape.call(this) || this, _this._radius = 1;
|
|
23004
|
-
_this._nativeShape =
|
|
23010
|
+
_this._nativeShape = Engine._nativePhysics.createSphereColliderShape(_this._id, _this._radius, _this._material._nativeMaterial);
|
|
23005
23011
|
return _this;
|
|
23006
23012
|
}
|
|
23007
23013
|
var _proto = SphereColliderShape.prototype;
|
|
@@ -23035,7 +23041,7 @@ __decorate([
|
|
|
23035
23041
|
function PlaneColliderShape() {
|
|
23036
23042
|
var _this;
|
|
23037
23043
|
_this = ColliderShape.call(this) || this;
|
|
23038
|
-
_this._nativeShape =
|
|
23044
|
+
_this._nativeShape = Engine._nativePhysics.createPlaneColliderShape(_this._id, _this._material._nativeMaterial);
|
|
23039
23045
|
return _this;
|
|
23040
23046
|
}
|
|
23041
23047
|
var _proto = PlaneColliderShape.prototype;
|
|
@@ -23053,7 +23059,7 @@ __decorate([
|
|
|
23053
23059
|
function CapsuleColliderShape() {
|
|
23054
23060
|
var _this;
|
|
23055
23061
|
_this = ColliderShape.call(this) || this, _this._radius = 1, _this._height = 2, _this._upAxis = ColliderShapeUpAxis.Y;
|
|
23056
|
-
_this._nativeShape =
|
|
23062
|
+
_this._nativeShape = Engine._nativePhysics.createCapsuleColliderShape(_this._id, _this._radius, _this._height, _this._material._nativeMaterial);
|
|
23057
23063
|
return _this;
|
|
23058
23064
|
}
|
|
23059
23065
|
var _proto = CapsuleColliderShape.prototype;
|
|
@@ -25121,7 +25127,10 @@ ShaderPool.init();
|
|
|
25121
25127
|
var initializePromises = new Array();
|
|
25122
25128
|
if (physics) {
|
|
25123
25129
|
initializePromises.push(physics.initialize().then(function() {
|
|
25124
|
-
|
|
25130
|
+
if (Engine._nativePhysics) {
|
|
25131
|
+
console.warn("A physics engine has already been configured. All physics operations will now be handled by the newly specified physics engine.");
|
|
25132
|
+
}
|
|
25133
|
+
Engine._nativePhysics = physics;
|
|
25125
25134
|
_this._nativePhysicsManager = physics.createPhysicsManager();
|
|
25126
25135
|
_this._physicsInitialized = true;
|
|
25127
25136
|
return _this;
|
|
@@ -27193,6 +27202,7 @@ PostProcessManager._tempVector3 = new Vector3();
|
|
|
27193
27202
|
this._maskManager.destroy();
|
|
27194
27203
|
var allCreatedScenes = sceneManager._allCreatedScenes;
|
|
27195
27204
|
allCreatedScenes.splice(allCreatedScenes.indexOf(this), 1);
|
|
27205
|
+
this.physics._destroy();
|
|
27196
27206
|
};
|
|
27197
27207
|
_proto._computeLinearFogParams = function _computeLinearFogParams(fogStart, fogEnd) {
|
|
27198
27208
|
var fogRange = fogEnd - fogStart;
|
|
@@ -35869,10 +35879,11 @@ __decorate([
|
|
|
35869
35879
|
function Polyfill() {}
|
|
35870
35880
|
Polyfill.registerPolyfill = function registerPolyfill() {
|
|
35871
35881
|
Polyfill._registerMatchAll();
|
|
35882
|
+
Polyfill._registerAudioContext();
|
|
35872
35883
|
};
|
|
35873
35884
|
Polyfill._registerMatchAll = function _registerMatchAll() {
|
|
35874
35885
|
if (!String.prototype.matchAll) {
|
|
35875
|
-
Logger.info("
|
|
35886
|
+
Logger.info("Polyfill String.prototype.matchAll");
|
|
35876
35887
|
String.prototype.matchAll = function(pattern) {
|
|
35877
35888
|
var flags = pattern.flags;
|
|
35878
35889
|
var globalFlagIdx = flags.indexOf("g");
|
|
@@ -35926,6 +35937,26 @@ __decorate([
|
|
|
35926
35937
|
};
|
|
35927
35938
|
}
|
|
35928
35939
|
};
|
|
35940
|
+
Polyfill._registerAudioContext = function _registerAudioContext() {
|
|
35941
|
+
// IOS 12 and the following system do not support AudioContext, need to switch to webkitAudioContext
|
|
35942
|
+
if (!window.AudioContext && window.webkitAudioContext) {
|
|
35943
|
+
Logger.info("Polyfill window.AudioContext");
|
|
35944
|
+
window.AudioContext = window.webkitAudioContext;
|
|
35945
|
+
var originalDecodeAudioData = AudioContext.prototype.decodeAudioData;
|
|
35946
|
+
AudioContext.prototype.decodeAudioData = function(arrayBuffer, successCallback, errorCallback) {
|
|
35947
|
+
var _this = this;
|
|
35948
|
+
return new Promise(function(resolve, reject) {
|
|
35949
|
+
originalDecodeAudioData.call(_this, arrayBuffer, function(buffer) {
|
|
35950
|
+
successCallback == null ? void 0 : successCallback(buffer);
|
|
35951
|
+
resolve(buffer);
|
|
35952
|
+
}, function(error) {
|
|
35953
|
+
errorCallback == null ? void 0 : errorCallback(error);
|
|
35954
|
+
reject(error);
|
|
35955
|
+
});
|
|
35956
|
+
});
|
|
35957
|
+
};
|
|
35958
|
+
}
|
|
35959
|
+
};
|
|
35929
35960
|
return Polyfill;
|
|
35930
35961
|
}();
|
|
35931
35962
|
|