@galacean/engine-core 1.4.0-beta.2 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.js CHANGED
@@ -5861,8 +5861,6 @@ var Camera = /*#__PURE__*/ function(Component) {
5861
5861
  //@ts-ignore
5862
5862
  this._viewport._onValueChanged = null;
5863
5863
  this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onPixelViewportChanged);
5864
- this._updateFlagManager = null;
5865
- this._entity = null;
5866
5864
  this._globalShaderMacro = null;
5867
5865
  this._frustum = null;
5868
5866
  this._renderPipeline = null;
@@ -10259,7 +10257,6 @@ var Renderer = /*#__PURE__*/ function(Component) {
10259
10257
  var material = materials[i];
10260
10258
  material && this._addResourceReferCount(material, -1);
10261
10259
  }
10262
- this._entity = null;
10263
10260
  this._globalShaderMacro = null;
10264
10261
  this._bounds = null;
10265
10262
  this._materials = null;
@@ -17616,7 +17613,6 @@ var ComponentCloner = /*#__PURE__*/ function() {
17616
17613
  this._setParent(null);
17617
17614
  }
17618
17615
  this.isActive = false;
17619
- this._updateFlagManager = null;
17620
17616
  };
17621
17617
  /**
17622
17618
  * @internal
@@ -20761,7 +20757,7 @@ Collider = __decorate([
20761
20757
  * Describes a contact point where the collision occurs.
20762
20758
  */ var ContactPoint = function ContactPoint() {
20763
20759
  /** The position of the contact point between the shapes, in world space. */ this.position = new Vector3();
20764
- /** The normal of the contacting surfaces at the contact point. The normal direction points from the second shape to the first shape. */ this.normal = new Vector3();
20760
+ /** 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();
20765
20761
  /** 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();
20766
20762
  };
20767
20763
 
@@ -20779,7 +20775,8 @@ Collider = __decorate([
20779
20775
  * You need to obtain the actual number of contact points from the function's return value.
20780
20776
  */ _proto.getContacts = function getContacts(outContacts) {
20781
20777
  var nativeCollision = this._nativeCollision;
20782
- var factor = nativeCollision.shape0Id < nativeCollision.shape1Id ? 1 : -1;
20778
+ var smallerShapeId = Math.min(nativeCollision.shape0Id, nativeCollision.shape1Id);
20779
+ var factor = this.shape.id === smallerShapeId ? 1 : -1;
20783
20780
  var nativeContactPoints = nativeCollision.getContacts();
20784
20781
  var length = nativeContactPoints.size();
20785
20782
  for(var i = 0; i < length; i++){
@@ -21840,9 +21837,9 @@ var Joint = /*#__PURE__*/ function(Component) {
21840
21837
  _this = Component.call(this, entity) || this, _this._colliderInfo = new JointColliderInfo(), _this._connectedColliderInfo = new JointColliderInfo(), _this._force = Infinity, _this._torque = Infinity, _this._automaticConnectedAnchor = true;
21841
21838
  //@ts-ignore
21842
21839
  _this._colliderInfo.anchor._onValueChanged = _this._updateActualAnchor.bind(_this, 1);
21843
- _this._updateConnectedActualAnchor = _this._updateActualAnchor.bind(_this, 2);
21840
+ _this._handleConnectedAnchorChanged = _this._handleConnectedAnchorChanged.bind(_this);
21844
21841
  //@ts-ignore
21845
- _this._connectedColliderInfo.anchor._onValueChanged = _this._updateConnectedActualAnchor;
21842
+ _this._connectedColliderInfo.anchor._onValueChanged = _this._handleConnectedAnchorChanged.bind(_this);
21846
21843
  _this._onSelfTransformChanged = _this._onSelfTransformChanged.bind(_this);
21847
21844
  _this._onConnectedTransformChanged = _this._onConnectedTransformChanged.bind(_this);
21848
21845
  // @ts-ignore
@@ -21888,6 +21885,8 @@ var Joint = /*#__PURE__*/ function(Component) {
21888
21885
  var connectedAnchor = connectedColliderInfo.anchor;
21889
21886
  var connectedActualAnchor = connectedColliderInfo.actualAnchor;
21890
21887
  var connectedCollider = connectedColliderInfo.collider;
21888
+ // @ts-ignore
21889
+ connectedAnchor._onValueChanged = null;
21891
21890
  if (connectedCollider) {
21892
21891
  var _connectedCollider_entity_transform = connectedCollider.entity.transform, connectedPos = _connectedCollider_entity_transform.worldPosition, connectedWorldScale = _connectedCollider_entity_transform.lossyWorldScale;
21893
21892
  Vector3.subtract(selfPos, connectedPos, Joint._tempVector3);
@@ -21897,6 +21896,16 @@ var Joint = /*#__PURE__*/ function(Component) {
21897
21896
  Vector3.add(selfPos, selfActualAnchor, connectedActualAnchor);
21898
21897
  connectedAnchor.copyFrom(connectedActualAnchor);
21899
21898
  }
21899
+ // @ts-ignore
21900
+ connectedAnchor._onValueChanged = this._handleConnectedAnchorChanged;
21901
+ this._updateActualAnchor(2);
21902
+ };
21903
+ _proto._handleConnectedAnchorChanged = function _handleConnectedAnchorChanged() {
21904
+ if (this._automaticConnectedAnchor) {
21905
+ console.warn("Cannot set connectedAnchor when automaticConnectedAnchor is true.");
21906
+ } else {
21907
+ this._updateActualAnchor(2);
21908
+ }
21900
21909
  };
21901
21910
  _proto._onSelfTransformChanged = function _onSelfTransformChanged(type) {
21902
21911
  if (type & TransformModifyFlags.WorldScale) {
@@ -21976,25 +21985,12 @@ var Joint = /*#__PURE__*/ function(Component) {
21976
21985
  * @remarks If connectedCollider is set, this anchor is relative offset, or the anchor is world position.
21977
21986
  * The connectedAnchor is automatically calculated, if you want to set it manually, please set automaticConnectedAnchor to false
21978
21987
  */ function get() {
21979
- var connectedColliderAnchor = this._connectedColliderInfo.anchor;
21980
- if (this._automaticConnectedAnchor) {
21981
- //@ts-ignore
21982
- connectedColliderAnchor._onValueChanged = null;
21983
- this._calculateConnectedAnchor();
21984
- //@ts-ignore
21985
- connectedColliderAnchor._onValueChanged = this._updateConnectedActualAnchor;
21986
- }
21987
- return connectedColliderAnchor;
21988
+ return this._connectedColliderInfo.anchor;
21988
21989
  },
21989
21990
  set: function set(value) {
21990
- if (this._automaticConnectedAnchor) {
21991
- console.warn("Cannot set connectedAnchor when automaticConnectedAnchor is true.");
21992
- return;
21993
- }
21994
21991
  var connectedAnchor = this._connectedColliderInfo.anchor;
21995
21992
  if (value !== connectedAnchor) {
21996
21993
  connectedAnchor.copyFrom(value);
21997
- this._updateActualAnchor(2);
21998
21994
  }
21999
21995
  }
22000
21996
  },
@@ -22115,7 +22111,7 @@ __decorate([
22115
22111
  ], Joint.prototype, "_nativeJoint", void 0);
22116
22112
  __decorate([
22117
22113
  ignoreClone
22118
- ], Joint.prototype, "_updateConnectedActualAnchor", void 0);
22114
+ ], Joint.prototype, "_handleConnectedAnchorChanged", null);
22119
22115
  __decorate([
22120
22116
  ignoreClone
22121
22117
  ], Joint.prototype, "_onSelfTransformChanged", null);
@@ -22177,6 +22173,9 @@ __decorate([
22177
22173
  _this = Joint.call(this, entity) || this, _this._axis = new Vector3(1, 0, 0), _this._hingeFlags = HingeJointFlag.None, _this._useSpring = false, _this._angle = 0, _this._velocity = 0;
22178
22174
  _this._onMotorChanged = _this._onMotorChanged.bind(_this);
22179
22175
  _this._onLimitsChanged = _this._onLimitsChanged.bind(_this);
22176
+ _this._onAxisChanged = _this._onAxisChanged.bind(_this);
22177
+ //@ts-ignore
22178
+ _this._axis._onValueChanged = _this._onAxisChanged;
22180
22179
  return _this;
22181
22180
  }
22182
22181
  var _proto = HingeJoint.prototype;
@@ -22225,20 +22224,27 @@ __decorate([
22225
22224
  }
22226
22225
  }
22227
22226
  };
22227
+ _proto._onAxisChanged = function _onAxisChanged() {
22228
+ var _this__nativeJoint;
22229
+ //@ts-ignore
22230
+ this._axis._onValueChanged = null;
22231
+ this._axis.normalize();
22232
+ (_this__nativeJoint = this._nativeJoint) == null ? void 0 : _this__nativeJoint.setAxis(this._axis);
22233
+ //@ts-ignore
22234
+ this._axis._onValueChanged = this._onAxisChanged;
22235
+ };
22228
22236
  _create_class(HingeJoint, [
22229
22237
  {
22230
22238
  key: "axis",
22231
22239
  get: /**
22232
- * The anchor rotation.
22240
+ * The Direction of the axis around which the hingeJoint.
22233
22241
  */ function get() {
22234
22242
  return this._axis;
22235
22243
  },
22236
22244
  set: function set(value) {
22237
22245
  var axis = this._axis;
22238
22246
  if (value !== axis) {
22239
- var _this__nativeJoint;
22240
22247
  axis.copyFrom(value);
22241
- (_this__nativeJoint = this._nativeJoint) == null ? void 0 : _this__nativeJoint.setAxis(axis);
22242
22248
  }
22243
22249
  }
22244
22250
  },
@@ -22362,6 +22368,9 @@ __decorate([
22362
22368
  __decorate([
22363
22369
  ignoreClone
22364
22370
  ], HingeJoint.prototype, "_onLimitsChanged", null);
22371
+ __decorate([
22372
+ ignoreClone
22373
+ ], HingeJoint.prototype, "_onAxisChanged", null);
22365
22374
 
22366
22375
  /**
22367
22376
  * A joint that maintains an upper or lower bound (or both) on the distance between two points on different objects.
@@ -23360,6 +23369,8 @@ PointerEventEmitter._tempRay = new Ray();
23360
23369
  var currY = (latestEvent.clientY - top) * heightPixelRatio;
23361
23370
  pointer.deltaPosition.set(currX - position.x, currY - position.y);
23362
23371
  position.set(currX, currY);
23372
+ pointer.button = _pointerDec2BinMap[latestEvent.button] || PointerButton.None;
23373
+ pointer.pressedButtons = latestEvent.buttons;
23363
23374
  for(var i = 0; i < length; i++){
23364
23375
  var event = events[i];
23365
23376
  switch(event.type){
@@ -24582,11 +24593,16 @@ var unlitVs = "#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#in
24582
24593
 
24583
24594
  var UIUtils = /*#__PURE__*/ function() {
24584
24595
  function UIUtils() {}
24585
- UIUtils.renderOverlay = function renderOverlay(engine, uiCanvases) {
24596
+ UIUtils.renderOverlay = function renderOverlay(engine, scene, uiCanvases) {
24597
+ var canvas = engine.canvas, rhi = engine._hardwareRenderer, renderContext = engine._renderContext, batcherManager = engine._batcherManager;
24586
24598
  var uiRenderQueue = this._renderQueue || (this._renderQueue = new RenderQueue(RenderQueueType.Transparent));
24587
24599
  var virtualCamera = this._virtualCamera || (this._virtualCamera = new VirtualCamera());
24588
24600
  var viewport = this._viewport || (this._viewport = new Vector4(0, 0, 1, 1));
24589
- var canvas = engine.canvas, rhi = engine._hardwareRenderer, renderContext = engine._renderContext, batcherManager = engine._batcherManager;
24601
+ // @ts-ignore
24602
+ var camera = this._overlayCamera || (this._overlayCamera = new OverlayCamera());
24603
+ camera.engine = engine;
24604
+ camera.scene = scene;
24605
+ renderContext.camera = camera;
24590
24606
  var _virtualCamera_projectionMatrix = virtualCamera.projectionMatrix, projectE = _virtualCamera_projectionMatrix.elements;
24591
24607
  var _virtualCamera_viewMatrix = virtualCamera.viewMatrix, viewE = _virtualCamera_viewMatrix.elements;
24592
24608
  projectE[0] = 2 / canvas.width, projectE[5] = 2 / canvas.height, projectE[10] = 0;
@@ -24594,8 +24610,8 @@ var UIUtils = /*#__PURE__*/ function() {
24594
24610
  for(var i = 0, n = uiCanvases.length; i < n; i++){
24595
24611
  var uiCanvas = uiCanvases.get(i);
24596
24612
  if (uiCanvas) {
24597
- var transform = uiCanvas.entity.transform;
24598
- viewE[12] = -transform.position.x, viewE[13] = -transform.position.y;
24613
+ var position = uiCanvas.entity.transform.position;
24614
+ viewE[12] = -position.x, viewE[13] = -position.y;
24599
24615
  Matrix.multiply(virtualCamera.projectionMatrix, virtualCamera.viewMatrix, virtualCamera.viewProjectionMatrix);
24600
24616
  renderContext.applyVirtualCamera(virtualCamera, false);
24601
24617
  renderContext.rendererUpdateFlag |= ContextRendererUpdateFlag.ProjectionMatrix;
@@ -24611,6 +24627,14 @@ var UIUtils = /*#__PURE__*/ function() {
24611
24627
  };
24612
24628
  return UIUtils;
24613
24629
  }();
24630
+ var OverlayCamera = function OverlayCamera() {
24631
+ // @ts-ignore
24632
+ this.instanceId = ++EngineObject._instanceIdCounter;
24633
+ this.shaderData = new ShaderData(ShaderDataGroup.Camera);
24634
+ this.enableFrustumCulling = true;
24635
+ this.cullingMask = Layer.Everything;
24636
+ this._globalShaderMacro = new ShaderMacroCollection();
24637
+ };
24614
24638
 
24615
24639
  /**
24616
24640
  * XRManager located in the main package, its implementation logic is XRManagerExtended in the sub-package engine-xr.
@@ -24937,25 +24961,25 @@ ShaderPool.init();
24937
24961
  var cameras = componentsManager._activeCameras;
24938
24962
  if (cameras.length === 0) {
24939
24963
  Logger.debug("No active camera in scene.");
24940
- return "continue";
24941
- }
24942
- cameras.forEach(function(camera) {
24943
- componentsManager.callCameraOnBeginRender(camera);
24944
- // Update post process manager
24945
- scene.postProcessManager._update(camera);
24946
- camera.render();
24947
- componentsManager.callCameraOnEndRender(camera);
24948
- // Temp solution for webgl implement bug
24949
- if (_this1._hardwareRenderer._options._forceFlush) {
24950
- _this1._hardwareRenderer.flush();
24951
- }
24952
- }, function(camera, index) {
24953
- camera._cameraIndex = index;
24954
- });
24964
+ } else {
24965
+ cameras.forEach(function(camera) {
24966
+ componentsManager.callCameraOnBeginRender(camera);
24967
+ // Update post process manager
24968
+ scene.postProcessManager._update(camera);
24969
+ camera.render();
24970
+ componentsManager.callCameraOnEndRender(camera);
24971
+ // Temp solution for webgl implement bug
24972
+ if (_this1._hardwareRenderer._options._forceFlush) {
24973
+ _this1._hardwareRenderer.flush();
24974
+ }
24975
+ }, function(camera, index) {
24976
+ camera._cameraIndex = index;
24977
+ });
24978
+ }
24955
24979
  var uiCanvas = componentsManager._overlayCanvases;
24956
24980
  if (uiCanvas.length > 0) {
24957
24981
  componentsManager.sortOverlayUICanvases();
24958
- UIUtils.renderOverlay(_this, uiCanvas);
24982
+ UIUtils.renderOverlay(_this, scene, uiCanvas);
24959
24983
  }
24960
24984
  };
24961
24985
  var _this1 = this;