@galacean/engine 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/browser.js CHANGED
@@ -10868,8 +10868,6 @@
10868
10868
  //@ts-ignore
10869
10869
  this._viewport._onValueChanged = null;
10870
10870
  this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onPixelViewportChanged);
10871
- this._updateFlagManager = null;
10872
- this._entity = null;
10873
10871
  this._globalShaderMacro = null;
10874
10872
  this._frustum = null;
10875
10873
  this._renderPipeline = null;
@@ -15137,7 +15135,6 @@
15137
15135
  var material = materials[i];
15138
15136
  material && this._addResourceReferCount(material, -1);
15139
15137
  }
15140
- this._entity = null;
15141
15138
  this._globalShaderMacro = null;
15142
15139
  this._bounds = null;
15143
15140
  this._materials = null;
@@ -22443,7 +22440,6 @@
22443
22440
  this._setParent(null);
22444
22441
  }
22445
22442
  this.isActive = false;
22446
- this._updateFlagManager = null;
22447
22443
  };
22448
22444
  /**
22449
22445
  * @internal
@@ -25558,7 +25554,7 @@
25558
25554
  * Describes a contact point where the collision occurs.
25559
25555
  */ var ContactPoint = function ContactPoint() {
25560
25556
  /** The position of the contact point between the shapes, in world space. */ this.position = new Vector3();
25561
- /** 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();
25557
+ /** 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();
25562
25558
  /** 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();
25563
25559
  };
25564
25560
  /**
@@ -25575,7 +25571,8 @@
25575
25571
  * You need to obtain the actual number of contact points from the function's return value.
25576
25572
  */ _proto.getContacts = function getContacts(outContacts) {
25577
25573
  var nativeCollision = this._nativeCollision;
25578
- var factor = nativeCollision.shape0Id < nativeCollision.shape1Id ? 1 : -1;
25574
+ var smallerShapeId = Math.min(nativeCollision.shape0Id, nativeCollision.shape1Id);
25575
+ var factor = this.shape.id === smallerShapeId ? 1 : -1;
25579
25576
  var nativeContactPoints = nativeCollision.getContacts();
25580
25577
  var length = nativeContactPoints.size();
25581
25578
  for(var i = 0; i < length; i++){
@@ -26625,9 +26622,9 @@
26625
26622
  _this = Component.call(this, entity) || this, _this._colliderInfo = new JointColliderInfo(), _this._connectedColliderInfo = new JointColliderInfo(), _this._force = Infinity, _this._torque = Infinity, _this._automaticConnectedAnchor = true;
26626
26623
  //@ts-ignore
26627
26624
  _this._colliderInfo.anchor._onValueChanged = _this._updateActualAnchor.bind(_this, 1);
26628
- _this._updateConnectedActualAnchor = _this._updateActualAnchor.bind(_this, 2);
26625
+ _this._handleConnectedAnchorChanged = _this._handleConnectedAnchorChanged.bind(_this);
26629
26626
  //@ts-ignore
26630
- _this._connectedColliderInfo.anchor._onValueChanged = _this._updateConnectedActualAnchor;
26627
+ _this._connectedColliderInfo.anchor._onValueChanged = _this._handleConnectedAnchorChanged.bind(_this);
26631
26628
  _this._onSelfTransformChanged = _this._onSelfTransformChanged.bind(_this);
26632
26629
  _this._onConnectedTransformChanged = _this._onConnectedTransformChanged.bind(_this);
26633
26630
  // @ts-ignore
@@ -26673,6 +26670,8 @@
26673
26670
  var connectedAnchor = connectedColliderInfo.anchor;
26674
26671
  var connectedActualAnchor = connectedColliderInfo.actualAnchor;
26675
26672
  var connectedCollider = connectedColliderInfo.collider;
26673
+ // @ts-ignore
26674
+ connectedAnchor._onValueChanged = null;
26676
26675
  if (connectedCollider) {
26677
26676
  var _connectedCollider_entity_transform = connectedCollider.entity.transform, connectedPos = _connectedCollider_entity_transform.worldPosition, connectedWorldScale = _connectedCollider_entity_transform.lossyWorldScale;
26678
26677
  Vector3.subtract(selfPos, connectedPos, Joint._tempVector3);
@@ -26682,6 +26681,16 @@
26682
26681
  Vector3.add(selfPos, selfActualAnchor, connectedActualAnchor);
26683
26682
  connectedAnchor.copyFrom(connectedActualAnchor);
26684
26683
  }
26684
+ // @ts-ignore
26685
+ connectedAnchor._onValueChanged = this._handleConnectedAnchorChanged;
26686
+ this._updateActualAnchor(2);
26687
+ };
26688
+ _proto._handleConnectedAnchorChanged = function _handleConnectedAnchorChanged() {
26689
+ if (this._automaticConnectedAnchor) {
26690
+ console.warn("Cannot set connectedAnchor when automaticConnectedAnchor is true.");
26691
+ } else {
26692
+ this._updateActualAnchor(2);
26693
+ }
26685
26694
  };
26686
26695
  _proto._onSelfTransformChanged = function _onSelfTransformChanged(type) {
26687
26696
  if (type & TransformModifyFlags.WorldScale) {
@@ -26761,25 +26770,12 @@
26761
26770
  * @remarks If connectedCollider is set, this anchor is relative offset, or the anchor is world position.
26762
26771
  * The connectedAnchor is automatically calculated, if you want to set it manually, please set automaticConnectedAnchor to false
26763
26772
  */ function get() {
26764
- var connectedColliderAnchor = this._connectedColliderInfo.anchor;
26765
- if (this._automaticConnectedAnchor) {
26766
- //@ts-ignore
26767
- connectedColliderAnchor._onValueChanged = null;
26768
- this._calculateConnectedAnchor();
26769
- //@ts-ignore
26770
- connectedColliderAnchor._onValueChanged = this._updateConnectedActualAnchor;
26771
- }
26772
- return connectedColliderAnchor;
26773
+ return this._connectedColliderInfo.anchor;
26773
26774
  },
26774
26775
  set: function set(value) {
26775
- if (this._automaticConnectedAnchor) {
26776
- console.warn("Cannot set connectedAnchor when automaticConnectedAnchor is true.");
26777
- return;
26778
- }
26779
26776
  var connectedAnchor = this._connectedColliderInfo.anchor;
26780
26777
  if (value !== connectedAnchor) {
26781
26778
  connectedAnchor.copyFrom(value);
26782
- this._updateActualAnchor(2);
26783
26779
  }
26784
26780
  }
26785
26781
  },
@@ -26900,7 +26896,7 @@
26900
26896
  ], exports.Joint.prototype, "_nativeJoint", void 0);
26901
26897
  __decorate$1([
26902
26898
  ignoreClone
26903
- ], exports.Joint.prototype, "_updateConnectedActualAnchor", void 0);
26899
+ ], exports.Joint.prototype, "_handleConnectedAnchorChanged", null);
26904
26900
  __decorate$1([
26905
26901
  ignoreClone
26906
26902
  ], exports.Joint.prototype, "_onSelfTransformChanged", null);
@@ -26959,6 +26955,9 @@
26959
26955
  _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;
26960
26956
  _this._onMotorChanged = _this._onMotorChanged.bind(_this);
26961
26957
  _this._onLimitsChanged = _this._onLimitsChanged.bind(_this);
26958
+ _this._onAxisChanged = _this._onAxisChanged.bind(_this);
26959
+ //@ts-ignore
26960
+ _this._axis._onValueChanged = _this._onAxisChanged;
26962
26961
  return _this;
26963
26962
  }
26964
26963
  var _proto = HingeJoint.prototype;
@@ -27007,20 +27006,27 @@
27007
27006
  }
27008
27007
  }
27009
27008
  };
27009
+ _proto._onAxisChanged = function _onAxisChanged() {
27010
+ var _this__nativeJoint;
27011
+ //@ts-ignore
27012
+ this._axis._onValueChanged = null;
27013
+ this._axis.normalize();
27014
+ (_this__nativeJoint = this._nativeJoint) == null ? void 0 : _this__nativeJoint.setAxis(this._axis);
27015
+ //@ts-ignore
27016
+ this._axis._onValueChanged = this._onAxisChanged;
27017
+ };
27010
27018
  _create_class$2(HingeJoint, [
27011
27019
  {
27012
27020
  key: "axis",
27013
27021
  get: /**
27014
- * The anchor rotation.
27022
+ * The Direction of the axis around which the hingeJoint.
27015
27023
  */ function get() {
27016
27024
  return this._axis;
27017
27025
  },
27018
27026
  set: function set(value) {
27019
27027
  var axis = this._axis;
27020
27028
  if (value !== axis) {
27021
- var _this__nativeJoint;
27022
27029
  axis.copyFrom(value);
27023
- (_this__nativeJoint = this._nativeJoint) == null ? void 0 : _this__nativeJoint.setAxis(axis);
27024
27030
  }
27025
27031
  }
27026
27032
  },
@@ -27144,6 +27150,9 @@
27144
27150
  __decorate$1([
27145
27151
  ignoreClone
27146
27152
  ], HingeJoint.prototype, "_onLimitsChanged", null);
27153
+ __decorate$1([
27154
+ ignoreClone
27155
+ ], HingeJoint.prototype, "_onAxisChanged", null);
27147
27156
  /**
27148
27157
  * A joint that maintains an upper or lower bound (or both) on the distance between two points on different objects.
27149
27158
  */ var SpringJoint = /*#__PURE__*/ function(Joint) {
@@ -28131,6 +28140,8 @@
28131
28140
  var currY = (latestEvent.clientY - top) * heightPixelRatio;
28132
28141
  pointer.deltaPosition.set(currX - position.x, currY - position.y);
28133
28142
  position.set(currX, currY);
28143
+ pointer.button = _pointerDec2BinMap[latestEvent.button] || PointerButton.None;
28144
+ pointer.pressedButtons = latestEvent.buttons;
28134
28145
  for(var i = 0; i < length; i++){
28135
28146
  var event = events[i];
28136
28147
  switch(event.type){
@@ -29298,11 +29309,16 @@
29298
29309
  }();
29299
29310
  var UIUtils = /*#__PURE__*/ function() {
29300
29311
  function UIUtils() {}
29301
- UIUtils.renderOverlay = function renderOverlay(engine, uiCanvases) {
29312
+ UIUtils.renderOverlay = function renderOverlay(engine, scene, uiCanvases) {
29313
+ var canvas = engine.canvas, rhi = engine._hardwareRenderer, renderContext = engine._renderContext, batcherManager = engine._batcherManager;
29302
29314
  var uiRenderQueue = this._renderQueue || (this._renderQueue = new RenderQueue(RenderQueueType.Transparent));
29303
29315
  var virtualCamera = this._virtualCamera || (this._virtualCamera = new VirtualCamera());
29304
29316
  var viewport = this._viewport || (this._viewport = new Vector4(0, 0, 1, 1));
29305
- var canvas = engine.canvas, rhi = engine._hardwareRenderer, renderContext = engine._renderContext, batcherManager = engine._batcherManager;
29317
+ // @ts-ignore
29318
+ var camera = this._overlayCamera || (this._overlayCamera = new OverlayCamera());
29319
+ camera.engine = engine;
29320
+ camera.scene = scene;
29321
+ renderContext.camera = camera;
29306
29322
  var _virtualCamera_projectionMatrix = virtualCamera.projectionMatrix, projectE = _virtualCamera_projectionMatrix.elements;
29307
29323
  var _virtualCamera_viewMatrix = virtualCamera.viewMatrix, viewE = _virtualCamera_viewMatrix.elements;
29308
29324
  projectE[0] = 2 / canvas.width, projectE[5] = 2 / canvas.height, projectE[10] = 0;
@@ -29310,8 +29326,8 @@
29310
29326
  for(var i = 0, n = uiCanvases.length; i < n; i++){
29311
29327
  var uiCanvas = uiCanvases.get(i);
29312
29328
  if (uiCanvas) {
29313
- var transform = uiCanvas.entity.transform;
29314
- viewE[12] = -transform.position.x, viewE[13] = -transform.position.y;
29329
+ var position = uiCanvas.entity.transform.position;
29330
+ viewE[12] = -position.x, viewE[13] = -position.y;
29315
29331
  Matrix.multiply(virtualCamera.projectionMatrix, virtualCamera.viewMatrix, virtualCamera.viewProjectionMatrix);
29316
29332
  renderContext.applyVirtualCamera(virtualCamera, false);
29317
29333
  renderContext.rendererUpdateFlag |= ContextRendererUpdateFlag.ProjectionMatrix;
@@ -29327,6 +29343,14 @@
29327
29343
  };
29328
29344
  return UIUtils;
29329
29345
  }();
29346
+ var OverlayCamera = function OverlayCamera() {
29347
+ // @ts-ignore
29348
+ this.instanceId = ++EngineObject._instanceIdCounter;
29349
+ this.shaderData = new ShaderData(ShaderDataGroup.Camera);
29350
+ this.enableFrustumCulling = true;
29351
+ this.cullingMask = Layer.Everything;
29352
+ this._globalShaderMacro = new ShaderMacroCollection();
29353
+ };
29330
29354
  /**
29331
29355
  * XRManager located in the main package, its implementation logic is XRManagerExtended in the sub-package engine-xr.
29332
29356
  */ var XRManager = /*#__PURE__*/ function() {
@@ -29651,25 +29675,25 @@
29651
29675
  var cameras = componentsManager._activeCameras;
29652
29676
  if (cameras.length === 0) {
29653
29677
  Logger.debug("No active camera in scene.");
29654
- return "continue";
29655
- }
29656
- cameras.forEach(function(camera) {
29657
- componentsManager.callCameraOnBeginRender(camera);
29658
- // Update post process manager
29659
- scene.postProcessManager._update(camera);
29660
- camera.render();
29661
- componentsManager.callCameraOnEndRender(camera);
29662
- // Temp solution for webgl implement bug
29663
- if (_this1._hardwareRenderer._options._forceFlush) {
29664
- _this1._hardwareRenderer.flush();
29665
- }
29666
- }, function(camera, index) {
29667
- camera._cameraIndex = index;
29668
- });
29678
+ } else {
29679
+ cameras.forEach(function(camera) {
29680
+ componentsManager.callCameraOnBeginRender(camera);
29681
+ // Update post process manager
29682
+ scene.postProcessManager._update(camera);
29683
+ camera.render();
29684
+ componentsManager.callCameraOnEndRender(camera);
29685
+ // Temp solution for webgl implement bug
29686
+ if (_this1._hardwareRenderer._options._forceFlush) {
29687
+ _this1._hardwareRenderer.flush();
29688
+ }
29689
+ }, function(camera, index) {
29690
+ camera._cameraIndex = index;
29691
+ });
29692
+ }
29669
29693
  var uiCanvas = componentsManager._overlayCanvases;
29670
29694
  if (uiCanvas.length > 0) {
29671
29695
  componentsManager.sortOverlayUICanvases();
29672
- UIUtils.renderOverlay(_this, uiCanvas);
29696
+ UIUtils.renderOverlay(_this, scene, uiCanvas);
29673
29697
  }
29674
29698
  };
29675
29699
  var _this1 = this;
@@ -49945,7 +49969,7 @@
49945
49969
  ], EXT_texture_webp);
49946
49970
 
49947
49971
  //@ts-ignore
49948
- var version = "1.4.0-beta.2";
49972
+ var version = "1.4.1";
49949
49973
  console.log("Galacean engine version: " + version);
49950
49974
  for(var key in CoreObjects){
49951
49975
  Loader.registerClass(key, CoreObjects[key]);