@galacean/engine-core 1.3.23 → 1.3.25

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 CHANGED
@@ -161,6 +161,34 @@ function __decorate(decorators, target, key, desc) {
161
161
  return c > 3 && r && Object.defineProperty(target, key, r), r;
162
162
  }
163
163
 
164
+ function __generator(thisArg, body) {
165
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
166
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
167
+ function verb(n) { return function (v) { return step([n, v]); }; }
168
+ function step(op) {
169
+ if (f) throw new TypeError("Generator is already executing.");
170
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
171
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
172
+ if (y = 0, t) op = [op[0] & 2, t.value];
173
+ switch (op[0]) {
174
+ case 0: case 1: t = op; break;
175
+ case 4: _.label++; return { value: op[1], done: false };
176
+ case 5: _.label++; y = op[1]; op = [0]; continue;
177
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
178
+ default:
179
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
180
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
181
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
182
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
183
+ if (t[2]) _.ops.pop();
184
+ _.trys.pop(); continue;
185
+ }
186
+ op = body.call(thisArg, _);
187
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
188
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
189
+ }
190
+ }
191
+
164
192
  typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
165
193
  var e = new Error(message);
166
194
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
@@ -3855,11 +3883,13 @@ __decorate([
3855
3883
  /**
3856
3884
  * @internal
3857
3885
  * @todo Should merge when we can delete material render state
3858
- */ _proto._applyRenderQueueByShaderData = function _applyRenderQueueByShaderData(renderStateDataMap, shaderData) {
3886
+ */ _proto._getRenderQueueByShaderData = function _getRenderQueueByShaderData(renderStateDataMap, shaderData) {
3859
3887
  var renderQueueType = renderStateDataMap[exports.RenderStateDataKey.RenderQueueType];
3860
- if (renderQueueType !== undefined) {
3888
+ if (renderQueueType === undefined) {
3889
+ return this.renderQueueType;
3890
+ } else {
3861
3891
  var _shaderData_getFloat;
3862
- this.renderQueueType = (_shaderData_getFloat = shaderData.getFloat(renderQueueType)) != null ? _shaderData_getFloat : exports.RenderQueueType.Opaque;
3892
+ return (_shaderData_getFloat = shaderData.getFloat(renderQueueType)) != null ? _shaderData_getFloat : exports.RenderQueueType.Opaque;
3863
3893
  }
3864
3894
  };
3865
3895
  _proto._applyStatesByShaderData = function _applyStatesByShaderData(renderStateDataMap, shaderData) {
@@ -5074,9 +5104,11 @@ exports.DependentMode = void 0;
5074
5104
  _this._rotation = new engineMath.Vector3();
5075
5105
  _this._rotationQuaternion = new engineMath.Quaternion();
5076
5106
  _this._scale = new engineMath.Vector3(1, 1, 1);
5107
+ _this._localUniformScaling = true;
5077
5108
  _this._worldPosition = new engineMath.Vector3();
5078
5109
  _this._worldRotation = new engineMath.Vector3();
5079
5110
  _this._worldRotationQuaternion = new engineMath.Quaternion();
5111
+ _this._worldUniformScaling = true;
5080
5112
  _this._lossyWorldScale = new engineMath.Vector3(1, 1, 1);
5081
5113
  _this._localMatrix = new engineMath.Matrix();
5082
5114
  _this._worldMatrix = new engineMath.Matrix();
@@ -5243,7 +5275,7 @@ exports.DependentMode = void 0;
5243
5275
  * @internal
5244
5276
  */ _proto._parentChange = function _parentChange() {
5245
5277
  this._isParentDirty = true;
5246
- this._updateAllWorldFlag();
5278
+ this._updateAllWorldFlag(0x1bc);
5247
5279
  };
5248
5280
  /**
5249
5281
  * @internal
@@ -5278,10 +5310,10 @@ exports.DependentMode = void 0;
5278
5310
  */ _proto._updateWorldPositionFlag = function _updateWorldPositionFlag() {
5279
5311
  if (!this._isContainDirtyFlags(0x84)) {
5280
5312
  this._worldAssociatedChange(0x84);
5281
- var nodeChildren = this._entity._children;
5282
- for(var i = 0, n = nodeChildren.length; i < n; i++){
5283
- var _nodeChildren_i_transform;
5284
- (_nodeChildren_i_transform = nodeChildren[i].transform) == null ? void 0 : _nodeChildren_i_transform._updateWorldPositionFlag();
5313
+ var children = this._entity._children;
5314
+ for(var i = 0, n = children.length; i < n; i++){
5315
+ var _children_i_transform;
5316
+ (_children_i_transform = children[i].transform) == null ? void 0 : _children_i_transform._updateWorldPositionFlag();
5285
5317
  }
5286
5318
  }
5287
5319
  };
@@ -5290,14 +5322,19 @@ exports.DependentMode = void 0;
5290
5322
  * Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
5291
5323
  * Get worldRotationQuaternion: Will trigger the world rotation (in quaternion) update of itself and all parent entities.
5292
5324
  * Get worldRotation: Will trigger the world rotation(in euler and quaternion) update of itself and world rotation(in quaternion) update of all parent entities.
5325
+ * Get worldScale: Will trigger the scaling update of itself and all parent entities.
5293
5326
  * In summary, any update of related variables will cause the dirty mark of one of the full process (worldMatrix or worldRotationQuaternion) to be false.
5294
5327
  */ _proto._updateWorldRotationFlag = function _updateWorldRotationFlag() {
5295
- if (!this._isContainDirtyFlags(0x98)) {
5296
- this._worldAssociatedChange(0x98);
5297
- var nodeChildren = this._entity._children;
5298
- for(var i = 0, n = nodeChildren.length; i < n; i++){
5299
- var _nodeChildren_i_transform;
5300
- (_nodeChildren_i_transform = nodeChildren[i].transform) == null ? void 0 : _nodeChildren_i_transform._updateWorldPositionAndRotationFlag(); // Rotation update of parent entity will trigger world position and rotation update of all child entity.
5328
+ var parent = this._getParentTransform();
5329
+ var parentWorldUniformScaling = parent ? parent._getWorldUniformScaling() : true;
5330
+ var flags = parentWorldUniformScaling ? 0x98 : 0xb8;
5331
+ if (!this._isContainDirtyFlags(flags)) {
5332
+ this._worldAssociatedChange(flags);
5333
+ flags = this._getWorldUniformScaling() ? 0x9c : 0xbc;
5334
+ var children = this._entity._children;
5335
+ for(var i = 0, n = children.length; i < n; i++){
5336
+ var _children_i_transform;
5337
+ (_children_i_transform = children[i].transform) == null ? void 0 : _children_i_transform._updateWorldPositionAndRotationFlag(flags); // Rotation update of parent entity will trigger world position, rotation and scale update of all child entity.
5301
5338
  }
5302
5339
  }
5303
5340
  };
@@ -5306,14 +5343,17 @@ exports.DependentMode = void 0;
5306
5343
  * Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
5307
5344
  * Get worldRotationQuaternion: Will trigger the world rotation (in quaternion) update of itself and all parent entities.
5308
5345
  * Get worldRotation: Will trigger the world rotation(in euler and quaternion) update of itself and world rotation(in quaternion) update of all parent entities.
5346
+ * Get worldScale: Will trigger the scaling update of itself and all parent entities.
5309
5347
  * In summary, any update of related variables will cause the dirty mark of one of the full process (worldMatrix or worldRotationQuaternion) to be false.
5310
- */ _proto._updateWorldPositionAndRotationFlag = function _updateWorldPositionAndRotationFlag() {
5311
- if (!this._isContainDirtyFlags(0x9c)) {
5312
- this._worldAssociatedChange(0x9c);
5313
- var nodeChildren = this._entity._children;
5314
- for(var i = 0, n = nodeChildren.length; i < n; i++){
5315
- var _nodeChildren_i_transform;
5316
- (_nodeChildren_i_transform = nodeChildren[i].transform) == null ? void 0 : _nodeChildren_i_transform._updateWorldPositionAndRotationFlag();
5348
+ * @param flags - Dirty flag
5349
+ */ _proto._updateWorldPositionAndRotationFlag = function _updateWorldPositionAndRotationFlag(flags) {
5350
+ if (!this._isContainDirtyFlags(flags)) {
5351
+ this._worldAssociatedChange(flags);
5352
+ flags = this._getWorldUniformScaling() ? 0x9c : 0xbc;
5353
+ var children = this._entity._children;
5354
+ for(var i = 0, n = children.length; i < n; i++){
5355
+ var _children_i_transform;
5356
+ (_children_i_transform = children[i].transform) == null ? void 0 : _children_i_transform._updateWorldPositionAndRotationFlag(flags);
5317
5357
  }
5318
5358
  }
5319
5359
  };
@@ -5322,13 +5362,15 @@ exports.DependentMode = void 0;
5322
5362
  * Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
5323
5363
  * Get worldScale: Will trigger the scaling update of itself and all parent entities.
5324
5364
  * In summary, any update of related variables will cause the dirty mark of one of the full process (worldMatrix) to be false.
5325
- */ _proto._updateWorldScaleFlag = function _updateWorldScaleFlag() {
5326
- if (!this._isContainDirtyFlags(0xa0)) {
5327
- this._worldAssociatedChange(0xa0);
5328
- var nodeChildren = this._entity._children;
5329
- for(var i = 0, n = nodeChildren.length; i < n; i++){
5330
- var _nodeChildren_i_transform;
5331
- (_nodeChildren_i_transform = nodeChildren[i].transform) == null ? void 0 : _nodeChildren_i_transform._updateWorldPositionAndScaleFlag();
5365
+ * @param flags - Dirty flag
5366
+ */ _proto._updateWorldScaleFlag = function _updateWorldScaleFlag(flags) {
5367
+ if (!this._isContainDirtyFlags(flags)) {
5368
+ this._worldAssociatedChange(flags);
5369
+ flags |= 0x4;
5370
+ var children = this._entity._children;
5371
+ for(var i = 0, n = children.length; i < n; i++){
5372
+ var _children_i_transform;
5373
+ (_children_i_transform = children[i].transform) == null ? void 0 : _children_i_transform._updateWorldPositionAndScaleFlag(flags);
5332
5374
  }
5333
5375
  }
5334
5376
  };
@@ -5337,25 +5379,27 @@ exports.DependentMode = void 0;
5337
5379
  * Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
5338
5380
  * Get worldScale: Will trigger the scaling update of itself and all parent entities.
5339
5381
  * In summary, any update of related variables will cause the dirty mark of one of the full process (worldMatrix) to be false.
5340
- */ _proto._updateWorldPositionAndScaleFlag = function _updateWorldPositionAndScaleFlag() {
5341
- if (!this._isContainDirtyFlags(0xa4)) {
5342
- this._worldAssociatedChange(0xa4);
5343
- var nodeChildren = this._entity._children;
5344
- for(var i = 0, n = nodeChildren.length; i < n; i++){
5345
- var _nodeChildren_i_transform;
5346
- (_nodeChildren_i_transform = nodeChildren[i].transform) == null ? void 0 : _nodeChildren_i_transform._updateWorldPositionAndScaleFlag();
5382
+ * @param flags - Dirty flag
5383
+ */ _proto._updateWorldPositionAndScaleFlag = function _updateWorldPositionAndScaleFlag(flags) {
5384
+ if (!this._isContainDirtyFlags(flags)) {
5385
+ this._worldAssociatedChange(flags);
5386
+ var children = this._entity._children;
5387
+ for(var i = 0, n = children.length; i < n; i++){
5388
+ var _children_i_transform;
5389
+ (_children_i_transform = children[i].transform) == null ? void 0 : _children_i_transform._updateWorldPositionAndScaleFlag(flags);
5347
5390
  }
5348
5391
  }
5349
5392
  };
5350
5393
  /**
5351
5394
  * Update all world transform property dirty flag, the principle is the same as above.
5352
- */ _proto._updateAllWorldFlag = function _updateAllWorldFlag() {
5353
- if (!this._isContainDirtyFlags(0xbc)) {
5354
- this._worldAssociatedChange(0xbc);
5355
- var nodeChildren = this._entity._children;
5356
- for(var i = 0, n = nodeChildren.length; i < n; i++){
5357
- var _nodeChildren_i_transform;
5358
- (_nodeChildren_i_transform = nodeChildren[i].transform) == null ? void 0 : _nodeChildren_i_transform._updateAllWorldFlag();
5395
+ * @param flags - Dirty flag
5396
+ */ _proto._updateAllWorldFlag = function _updateAllWorldFlag(flags) {
5397
+ if (!this._isContainDirtyFlags(flags)) {
5398
+ this._worldAssociatedChange(flags);
5399
+ var children = this._entity._children;
5400
+ for(var i = 0, n = children.length; i < n; i++){
5401
+ var _children_i_transform;
5402
+ (_children_i_transform = children[i].transform) == null ? void 0 : _children_i_transform._updateAllWorldFlag(flags);
5359
5403
  }
5360
5404
  }
5361
5405
  };
@@ -5403,7 +5447,7 @@ exports.DependentMode = void 0;
5403
5447
  };
5404
5448
  _proto._worldAssociatedChange = function _worldAssociatedChange(type) {
5405
5449
  this._dirtyFlag |= type;
5406
- this._updateFlagManager.dispatch(0x80);
5450
+ this._updateFlagManager.dispatch(type);
5407
5451
  };
5408
5452
  _proto._rotateByQuat = function _rotateByQuat(rotateQuat, relativeToLocal) {
5409
5453
  if (relativeToLocal) {
@@ -5472,8 +5516,28 @@ exports.DependentMode = void 0;
5472
5516
  this._setDirtyFlagFalse(0x10);
5473
5517
  };
5474
5518
  _proto._onScaleChanged = function _onScaleChanged() {
5519
+ var _this__scale = this._scale, x = _this__scale.x, y = _this__scale.y, z = _this__scale.z;
5475
5520
  this._setDirtyFlagTrue(0x40);
5476
- this._updateWorldScaleFlag();
5521
+ var localUniformScaling = x == y && y == z;
5522
+ if (this._localUniformScaling !== localUniformScaling) {
5523
+ this._localUniformScaling = localUniformScaling;
5524
+ this._updateWorldScaleFlag(0x1a0);
5525
+ } else {
5526
+ this._updateWorldScaleFlag(0xa0);
5527
+ }
5528
+ };
5529
+ _proto._getWorldUniformScaling = function _getWorldUniformScaling() {
5530
+ if (this._isContainDirtyFlag(0x100)) {
5531
+ var localUniformScaling = this._localUniformScaling;
5532
+ if (localUniformScaling) {
5533
+ var parent = this._getParentTransform();
5534
+ this._worldUniformScaling = localUniformScaling && (parent ? parent._getWorldUniformScaling() : true);
5535
+ } else {
5536
+ this._worldUniformScaling = false;
5537
+ }
5538
+ this._setDirtyFlagFalse(0x100);
5539
+ }
5540
+ return this._worldUniformScaling;
5477
5541
  };
5478
5542
  _create_class(Transform, [
5479
5543
  {
@@ -5640,11 +5704,12 @@ exports.DependentMode = void 0;
5640
5704
  key: "lossyWorldScale",
5641
5705
  get: /**
5642
5706
  * Local lossy scaling.
5643
- * @remarks The value obtained may not be correct under certain conditions(for example, the parent node has scaling,
5644
- * and the child node has a rotation), the scaling will be tilted. Vector3 cannot be used to correctly represent the scaling. Must use Matrix3x3.
5707
+ * @remarks The value obtained may not be correct under certain conditions(for example, the parent node has non-uniform world scaling,
5708
+ * and the child node has a rotation), the scaling will be tilted.
5645
5709
  */ function get() {
5646
5710
  if (this._isContainDirtyFlag(0x20)) {
5647
5711
  if (this._getParentTransform()) {
5712
+ // Vector3 cannot be used to correctly represent the scaling. Must use Matrix3x3
5648
5713
  var scaleMat = this._getScaleMatrix();
5649
5714
  var e = scaleMat.elements;
5650
5715
  this._lossyWorldScale.set(e[0], e[4], e[8]);
@@ -5672,18 +5737,25 @@ exports.DependentMode = void 0;
5672
5737
  if (this._localMatrix !== value) {
5673
5738
  this._localMatrix.copyFrom(value);
5674
5739
  }
5740
+ var _this = this, position = _this._position, rotationQuaternion = _this._rotationQuaternion, scale = _this._scale;
5675
5741
  // @ts-ignore
5676
- this._position._onValueChanged = this._rotationQuaternion._onValueChanged = this._scale._onValueChanged = null;
5677
- this._localMatrix.decompose(this._position, this._rotationQuaternion, this._scale);
5742
+ position._onValueChanged = rotationQuaternion._onValueChanged = scale._onValueChanged = null;
5743
+ this._localMatrix.decompose(position, rotationQuaternion, scale);
5678
5744
  // @ts-ignore
5679
- this._position._onValueChanged = this._onPositionChanged;
5745
+ position._onValueChanged = this._onPositionChanged;
5680
5746
  // @ts-ignore
5681
- this._rotationQuaternion._onValueChanged = this._onRotationQuaternionChanged;
5747
+ rotationQuaternion._onValueChanged = this._onRotationQuaternionChanged;
5682
5748
  // @ts-ignore
5683
- this._scale._onValueChanged = this._onScaleChanged;
5749
+ scale._onValueChanged = this._onScaleChanged;
5684
5750
  this._setDirtyFlagTrue(0x1);
5685
5751
  this._setDirtyFlagFalse(0x40 | 0x2);
5686
- this._updateAllWorldFlag();
5752
+ var localUniformScaling = scale.x === scale.y && scale.y === scale.z;
5753
+ if (this._localUniformScaling !== localUniformScaling) {
5754
+ this._localUniformScaling = localUniformScaling;
5755
+ this._updateAllWorldFlag(0x1bc);
5756
+ } else {
5757
+ this._updateAllWorldFlag(0xbc);
5758
+ }
5687
5759
  }
5688
5760
  },
5689
5761
  {
@@ -5793,6 +5865,9 @@ __decorate([
5793
5865
  __decorate([
5794
5866
  deepClone
5795
5867
  ], Transform.prototype, "_scale", void 0);
5868
+ __decorate([
5869
+ assignmentClone
5870
+ ], Transform.prototype, "_localUniformScaling", void 0);
5796
5871
  __decorate([
5797
5872
  deepClone
5798
5873
  ], Transform.prototype, "_worldPosition", void 0);
@@ -5802,6 +5877,9 @@ __decorate([
5802
5877
  __decorate([
5803
5878
  deepClone
5804
5879
  ], Transform.prototype, "_worldRotationQuaternion", void 0);
5880
+ __decorate([
5881
+ assignmentClone
5882
+ ], Transform.prototype, "_worldUniformScaling", void 0);
5805
5883
  __decorate([
5806
5884
  deepClone
5807
5885
  ], Transform.prototype, "_lossyWorldScale", void 0);
@@ -5860,12 +5938,18 @@ var TransformModifyFlags;
5860
5938
  TransformModifyFlags[TransformModifyFlags["WorldScale"] = 0x20] = "WorldScale";
5861
5939
  TransformModifyFlags[TransformModifyFlags["LocalMatrix"] = 0x40] = "LocalMatrix";
5862
5940
  TransformModifyFlags[TransformModifyFlags["WorldMatrix"] = 0x80] = "WorldMatrix";
5941
+ TransformModifyFlags[TransformModifyFlags[/** This is an internal flag used to assist in determining the dispatch
5942
+ * of world scaling dirty flags in the case of non-uniform scaling.
5943
+ */ "IsWorldUniformScaling"] = 0x100] = "IsWorldUniformScaling";
5863
5944
  TransformModifyFlags[TransformModifyFlags[/** WorldMatrix | WorldPosition */ "WmWp"] = 0x84] = "WmWp";
5864
5945
  TransformModifyFlags[TransformModifyFlags[/** WorldMatrix | WorldEuler | WorldQuat */ "WmWeWq"] = 0x98] = "WmWeWq";
5946
+ TransformModifyFlags[TransformModifyFlags[/** WorldMatrix | WorldEuler | WorldQuat | WorldScale*/ "WmWeWqWs"] = 0xb8] = "WmWeWqWs";
5865
5947
  TransformModifyFlags[TransformModifyFlags[/** WorldMatrix | WorldPosition | WorldEuler | WorldQuat */ "WmWpWeWq"] = 0x9c] = "WmWpWeWq";
5866
5948
  TransformModifyFlags[TransformModifyFlags[/** WorldMatrix | WorldScale */ "WmWs"] = 0xa0] = "WmWs";
5949
+ TransformModifyFlags[TransformModifyFlags[/** WorldMatrix | WorldScale | WorldUniformScaling */ "WmWsWus"] = 0x1a0] = "WmWsWus";
5867
5950
  TransformModifyFlags[TransformModifyFlags[/** WorldMatrix | WorldPosition | WorldScale */ "WmWpWs"] = 0xa4] = "WmWpWs";
5868
5951
  TransformModifyFlags[TransformModifyFlags[/** WorldMatrix | WorldPosition | WorldEuler | WorldQuat | WorldScale */ "WmWpWeWqWs"] = 0xbc] = "WmWpWeWqWs";
5952
+ TransformModifyFlags[TransformModifyFlags[/** WorldMatrix | WorldPosition | WorldEuler | WorldQuat | WorldScale | WorldUniformScaling */ "WmWpWeWqWsWus"] = 0x1bc] = "WmWpWeWqWsWus";
5869
5953
  })(TransformModifyFlags || (TransformModifyFlags = {}));
5870
5954
 
5871
5955
  // @ts-ignore
@@ -8195,11 +8279,13 @@ var /**
8195
8279
  * @param viewport - Viewport
8196
8280
  * @param material - The material to use when blitting
8197
8281
  * @param passIndex - Pass index to use of the provided material
8198
- */ PipelineUtils.blitTexture = function blitTexture(engine, source, destination, mipLevel, viewport, material, passIndex) {
8282
+ * @param flipYOfSource - Whether flip Y axis of source texture
8283
+ */ PipelineUtils.blitTexture = function blitTexture(engine, source, destination, mipLevel, viewport, material, passIndex, flipYOfSource) {
8199
8284
  if (mipLevel === void 0) mipLevel = 0;
8200
8285
  if (viewport === void 0) viewport = PipelineUtils.defaultViewport;
8201
8286
  if (material === void 0) material = null;
8202
8287
  if (passIndex === void 0) passIndex = 0;
8288
+ if (flipYOfSource === void 0) flipYOfSource = false;
8203
8289
  var basicResources = engine._basicResources;
8204
8290
  var blitMesh = destination ? basicResources.flipYBlitMesh : basicResources.blitMesh;
8205
8291
  var blitMaterial = material || basicResources.blitMaterial;
@@ -8213,9 +8299,15 @@ var /**
8213
8299
  rendererShaderData.setFloat(PipelineUtils._blitMipLevelProperty, mipLevel);
8214
8300
  PipelineUtils._texelSize.set(1 / source.width, 1 / source.height, source.width, source.height);
8215
8301
  rendererShaderData.setVector4(PipelineUtils._blitTexelSizeProperty, PipelineUtils._texelSize);
8302
+ if (flipYOfSource) {
8303
+ rendererShaderData.enableMacro(PipelineUtils._flipYTextureMacro);
8304
+ } else {
8305
+ rendererShaderData.disableMacro(PipelineUtils._flipYTextureMacro);
8306
+ }
8216
8307
  var pass = blitMaterial.shader.subShaders[0].passes[passIndex];
8217
8308
  var compileMacros = Shader._compileMacros;
8218
- ShaderMacroCollection.unionCollection(context.camera._globalShaderMacro, blitMaterial.shaderData._macroCollection, compileMacros);
8309
+ ShaderMacroCollection.unionCollection(context.camera._globalShaderMacro, rendererShaderData._macroCollection, compileMacros);
8310
+ ShaderMacroCollection.unionCollection(compileMacros, blitMaterial.shaderData._macroCollection, compileMacros);
8219
8311
  var program = pass._getShaderProgram(engine, compileMacros);
8220
8312
  program.bind();
8221
8313
  program.groupingOtherUniformBlock();
@@ -8237,6 +8329,9 @@ var /**
8237
8329
  PipelineUtils._blitTexelSizeProperty = ShaderProperty.getByName("renderer_texelSize") // x: 1/width, y: 1/height, z: width, w: height
8238
8330
  ;
8239
8331
  })();
8332
+ (function() {
8333
+ PipelineUtils._flipYTextureMacro = ShaderMacro.getByName("renderer_FlipYBlitTexture");
8334
+ })();
8240
8335
  (function() {
8241
8336
  PipelineUtils._rendererShaderData = new ShaderData(ShaderDataGroup.Renderer);
8242
8337
  })();
@@ -8360,7 +8455,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8360
8455
  /**
8361
8456
  * Multi-sample anti-aliasing samples when use independent canvas mode.
8362
8457
  *
8363
- * @remarks The `independentCanvasEnabled` property should be `true` to take effect, otherwise it will be invalid.
8458
+ * @remarks It will take effect when `independentCanvasEnabled` property is `true`, otherwise it will be invalid.
8364
8459
  */ _this.msaaSamples = exports.MSAASamples.None;
8365
8460
  /** @internal */ _this._cameraType = exports.CameraType.Normal;
8366
8461
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
@@ -8721,13 +8816,17 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8721
8816
  key: "independentCanvasEnabled",
8722
8817
  get: /**
8723
8818
  * Whether independent canvas is enabled.
8724
- *
8725
8819
  * @remarks If true, the msaa in viewport can turn or off independently by `msaaSamples` property.
8726
8820
  */ function get() {
8727
- if (this.enableHDR || this.enablePostProcess && this.scene._postProcessManager.hasActiveEffect) {
8821
+ // Uber pass need internal RT
8822
+ if (this.enablePostProcess && this.scene._postProcessManager.hasActiveEffect) {
8728
8823
  return true;
8729
8824
  }
8730
- return this.opaqueTextureEnabled && !this._renderTarget;
8825
+ if (this.enableHDR || this.opaqueTextureEnabled) {
8826
+ var _this_renderTarget;
8827
+ return this._getInternalColorTextureFormat() !== ((_this_renderTarget = this.renderTarget) == null ? void 0 : _this_renderTarget.getColorTexture(0).format);
8828
+ }
8829
+ return false;
8731
8830
  }
8732
8831
  },
8733
8832
  {
@@ -9232,8 +9331,15 @@ var ContextRendererUpdateFlag;
9232
9331
  if (shaderPass.getTagValue(pipelineStageKey) !== pipelineStageTagValue) {
9233
9332
  continue;
9234
9333
  }
9235
- var _shaderPass__renderState;
9236
- if (((_shaderPass__renderState = shaderPass._renderState) != null ? _shaderPass__renderState : renderStates[j]).renderQueueType !== renderQueueType) {
9334
+ var renderState = shaderPass._renderState;
9335
+ var passQueueType = void 0;
9336
+ if (renderState) {
9337
+ passQueueType = renderState._getRenderQueueByShaderData(shaderPass._renderStateDataMap, materialData);
9338
+ } else {
9339
+ renderState = renderStates[j];
9340
+ passQueueType = renderState.renderQueueType;
9341
+ }
9342
+ if (passQueueType !== renderQueueType) {
9237
9343
  continue;
9238
9344
  }
9239
9345
  var program = shaderPass._getShaderProgram(engine, compileMacros);
@@ -9287,8 +9393,6 @@ var ContextRendererUpdateFlag;
9287
9393
  program.uploadUnGroupTextures();
9288
9394
  }
9289
9395
  }
9290
- var _shaderPass__renderState1;
9291
- var renderState = (_shaderPass__renderState1 = shaderPass._renderState) != null ? _shaderPass__renderState1 : renderStates[j];
9292
9396
  renderState._applyStates(engine, renderer.entity.transform._isFrontFaceInvert(), shaderPass._renderStateDataMap, material.shaderData);
9293
9397
  rhi.drawPrimitive(primitive, subElement.subPrimitive, program);
9294
9398
  }
@@ -10245,6 +10349,8 @@ var /**
10245
10349
  function BasicRenderPipeline(camera) {
10246
10350
  this._lastCanvasSize = new engineMath.Vector2();
10247
10351
  this._internalColorTarget = null;
10352
+ this._canUseBlitFrameBuffer = false;
10353
+ this._shouldGrabColor = false;
10248
10354
  this._camera = camera;
10249
10355
  var engine = camera.engine;
10250
10356
  this._cullingResults = new CullingResults();
@@ -10269,10 +10375,19 @@ var /**
10269
10375
  context.rendererUpdateFlag = ContextRendererUpdateFlag.All;
10270
10376
  var camera = this._camera;
10271
10377
  var scene = camera.scene, engine = camera.engine;
10378
+ var rhi = engine._hardwareRenderer;
10272
10379
  var cullingResults = this._cullingResults;
10273
10380
  var sunlight = scene._lightManager._sunlight;
10274
10381
  var depthOnlyPass = this._depthOnlyPass;
10275
10382
  var depthPassEnabled = camera.depthTextureMode === exports.DepthTextureMode.PrePass && depthOnlyPass._supportDepthTexture;
10383
+ var finalClearFlags = camera.clearFlags & ~(ignoreClear != null ? ignoreClear : exports.CameraClearFlags.None);
10384
+ var independentCanvasEnabled = camera.independentCanvasEnabled;
10385
+ var msaaSamples = camera.renderTarget ? camera.renderTarget.antiAliasing : camera.msaaSamples;
10386
+ this._shouldGrabColor = independentCanvasEnabled && !(finalClearFlags & exports.CameraClearFlags.Color);
10387
+ // 1. Only support blitFramebuffer in webgl2 context
10388
+ // 2. Can't blit normal FBO to MSAA FBO
10389
+ // 3. Can't blit screen MSAA FBO to normal FBO in mac safari platform and mobile, but mac chrome and firfox is OK
10390
+ this._canUseBlitFrameBuffer = rhi.isWebGL2 && msaaSamples === 1 && (!!camera.renderTarget || !rhi.context.antialias);
10276
10391
  if (scene.castShadows && sunlight && sunlight.shadowType !== exports.ShadowType.None) {
10277
10392
  this._cascadedShadowCasterPass.onRender(context);
10278
10393
  context.rendererUpdateFlag = ContextRendererUpdateFlag.None;
@@ -10292,24 +10407,46 @@ var /**
10292
10407
  } else {
10293
10408
  camera.shaderData.setTexture(exports.Camera._cameraDepthTextureProperty, engine._basicResources.whiteTexture2D);
10294
10409
  }
10295
- // Check if need to create internal color texture
10296
- var independentCanvasEnabled = camera.independentCanvasEnabled;
10410
+ // Check if need to create internal color texture or grab texture
10297
10411
  if (independentCanvasEnabled) {
10412
+ var depthFormat;
10413
+ if (camera.renderTarget) {
10414
+ depthFormat = camera.renderTarget._depthFormat;
10415
+ } else if (rhi.context.depth && rhi.context.stencil) {
10416
+ depthFormat = exports.TextureFormat.Depth24Stencil8;
10417
+ } else if (rhi.context.depth) {
10418
+ depthFormat = exports.TextureFormat.Depth24;
10419
+ } else if (rhi.context.stencil) {
10420
+ depthFormat = exports.TextureFormat.Stencil;
10421
+ } else {
10422
+ depthFormat = null;
10423
+ }
10298
10424
  var viewport = camera.pixelViewport;
10299
- var internalColorTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._internalColorTarget, viewport.width, viewport.height, camera._getInternalColorTextureFormat(), exports.TextureFormat.Depth24Stencil8, false, false, camera.msaaSamples, exports.TextureWrapMode.Clamp, exports.TextureFilterMode.Bilinear);
10425
+ var internalColorTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._internalColorTarget, viewport.width, viewport.height, camera._getInternalColorTextureFormat(), depthFormat, false, false, msaaSamples, exports.TextureWrapMode.Clamp, exports.TextureFilterMode.Bilinear);
10426
+ if (!this._canUseBlitFrameBuffer && this._shouldGrabColor) {
10427
+ var _camera_renderTarget;
10428
+ var _camera_renderTarget_getColorTexture_format;
10429
+ var grabTexture = PipelineUtils.recreateTextureIfNeeded(engine, this._grabTexture, viewport.width, viewport.height, (_camera_renderTarget_getColorTexture_format = (_camera_renderTarget = camera.renderTarget) == null ? void 0 : _camera_renderTarget.getColorTexture(0).format) != null ? _camera_renderTarget_getColorTexture_format : exports.TextureFormat.R8G8B8A8, false, exports.TextureWrapMode.Clamp, exports.TextureFilterMode.Bilinear);
10430
+ this._grabTexture = grabTexture;
10431
+ }
10300
10432
  this._internalColorTarget = internalColorTarget;
10301
10433
  } else {
10302
10434
  var internalColorTarget1 = this._internalColorTarget;
10435
+ var grabTexture1 = this._grabTexture;
10303
10436
  if (internalColorTarget1) {
10304
10437
  var _internalColorTarget_getColorTexture;
10305
10438
  (_internalColorTarget_getColorTexture = internalColorTarget1.getColorTexture(0)) == null ? void 0 : _internalColorTarget_getColorTexture.destroy(true);
10306
10439
  internalColorTarget1.destroy(true);
10307
10440
  this._internalColorTarget = null;
10308
10441
  }
10442
+ if (grabTexture1) {
10443
+ grabTexture1.destroy(true);
10444
+ this._grabTexture = null;
10445
+ }
10309
10446
  }
10310
- this._drawRenderPass(context, camera, cubeFace, mipLevel, ignoreClear);
10447
+ this._drawRenderPass(context, camera, finalClearFlags, cubeFace, mipLevel);
10311
10448
  };
10312
- _proto._drawRenderPass = function _drawRenderPass(context, camera, cubeFace, mipLevel, ignoreClear) {
10449
+ _proto._drawRenderPass = function _drawRenderPass(context, camera, finalClearFlags, cubeFace, mipLevel) {
10313
10450
  var _cameraRenderTarget, _cameraRenderTarget1;
10314
10451
  var cullingResults = this._cullingResults;
10315
10452
  var opaqueQueue = cullingResults.opaqueQueue, alphaTestQueue = cullingResults.alphaTestQueue, transparentQueue = cullingResults.transparentQueue;
@@ -10326,14 +10463,34 @@ var /**
10326
10463
  context.applyVirtualCamera(camera._virtualCamera, needFlipProjection);
10327
10464
  }
10328
10465
  rhi.activeRenderTarget(colorTarget, colorViewport, context.flipProjection, mipLevel, cubeFace);
10329
- var clearFlags = camera.clearFlags & ~(ignoreClear != null ? ignoreClear : exports.CameraClearFlags.None);
10330
10466
  var color = background.solidColor;
10331
- if (clearFlags !== exports.CameraClearFlags.None) {
10332
- rhi.clearRenderTarget(camera.engine, clearFlags, color);
10467
+ if (internalColorTarget && finalClearFlags !== exports.CameraClearFlags.All) {
10468
+ // Can use `blitFramebuffer` API to copy color/depth/stencil buffer from back buffer to internal RT
10469
+ if (this._canUseBlitFrameBuffer) {
10470
+ finalClearFlags !== exports.CameraClearFlags.None && rhi.clearRenderTarget(engine, finalClearFlags, color);
10471
+ rhi.blitInternalRTByBlitFrameBuffer(camera.renderTarget, internalColorTarget, finalClearFlags, camera.viewport);
10472
+ } else {
10473
+ if (!(finalClearFlags & exports.CameraClearFlags.Depth) || !(finalClearFlags & exports.CameraClearFlags.Stencil)) {
10474
+ Logger.warn("We clear all depth/stencil state cause of the internalRT can't copy depth/stencil buffer from back buffer when use copy plan");
10475
+ }
10476
+ if (this._shouldGrabColor) {
10477
+ rhi.clearRenderTarget(engine, exports.CameraClearFlags.DepthStencil);
10478
+ // Copy RT's color buffer to grab texture
10479
+ rhi.copyRenderTargetToSubTexture(camera.renderTarget, this._grabTexture, camera.viewport);
10480
+ // Then blit grab texture to internal RT's color buffer
10481
+ PipelineUtils.blitTexture(engine, this._grabTexture, internalColorTarget, 0, undefined, undefined, undefined, // Only flip Y axis in webgl context
10482
+ !camera.renderTarget);
10483
+ } else {
10484
+ rhi.clearRenderTarget(engine, exports.CameraClearFlags.All, color);
10485
+ }
10486
+ }
10487
+ rhi.activeRenderTarget(colorTarget, colorViewport, context.flipProjection, mipLevel, cubeFace);
10488
+ } else if (finalClearFlags !== exports.CameraClearFlags.None) {
10489
+ rhi.clearRenderTarget(engine, finalClearFlags, color);
10333
10490
  }
10334
10491
  opaqueQueue.render(context, exports.PipelineStage.Forward);
10335
10492
  alphaTestQueue.render(context, exports.PipelineStage.Forward);
10336
- if (clearFlags & exports.CameraClearFlags.Color) {
10493
+ if (finalClearFlags & exports.CameraClearFlags.Color) {
10337
10494
  if (background.mode === exports.BackgroundMode.Sky) {
10338
10495
  background.sky._render(context);
10339
10496
  } else if (background.mode === exports.BackgroundMode.Texture && background.texture) {
@@ -10408,8 +10565,7 @@ var /**
10408
10565
  var shaderPass = shaderPasses[i];
10409
10566
  var renderState = shaderPass._renderState;
10410
10567
  if (renderState) {
10411
- renderState._applyRenderQueueByShaderData(shaderPass._renderStateDataMap, subRenderElement.material.shaderData);
10412
- renderQueueType = renderState.renderQueueType;
10568
+ renderQueueType = renderState._getRenderQueueByShaderData(shaderPass._renderStateDataMap, subRenderElement.material.shaderData);
10413
10569
  } else {
10414
10570
  renderQueueType = renderStates[i].renderQueueType;
10415
10571
  }
@@ -19994,7 +20150,7 @@ var MultiExecutor = /*#__PURE__*/ function() {
19994
20150
  var assetBaseURL = baseUrl;
19995
20151
  if (searchStr) {
19996
20152
  var params = searchStr.split("&");
19997
- for(var i = 0; i < params.length; i++){
20153
+ for(var i = params.length - 1; i >= 0; i--){
19998
20154
  var param = params[i];
19999
20155
  if (param.startsWith("q=")) {
20000
20156
  queryPath = decodeURIComponent(param.split("=")[1]);
@@ -20043,11 +20199,9 @@ var MultiExecutor = /*#__PURE__*/ function() {
20043
20199
  Logger.warn("refId:" + refId + " is not find in this._editorResourceConfig.");
20044
20200
  return Promise.resolve(null);
20045
20201
  }
20046
- var remoteUrl = resourceConfig.path;
20047
- var queryPath = new URL(remoteUrl).search;
20048
- var url = resourceConfig.virtualPath + queryPath;
20202
+ var url = resourceConfig.virtualPath;
20049
20203
  if (key) {
20050
- url += (url.indexOf("?") > -1 ? "&" : "?") + "q=" + key;
20204
+ url += "?q=" + key;
20051
20205
  }
20052
20206
  promise = this.load({
20053
20207
  url: url,
@@ -23257,7 +23411,7 @@ __decorate([
23257
23411
  ParticleBufferUtils.boundsMaxLifetimeOffset = 7;
23258
23412
  })();
23259
23413
 
23260
- var blitFs = "#define GLSLIFY 1\nuniform mediump sampler2D renderer_BlitTexture;\n#ifdef HAS_TEX_LOD\nuniform float renderer_BlitMipLevel;\n#endif\nvarying vec2 v_uv;void main(){\n#ifdef HAS_TEX_LOD\ngl_FragColor=texture2DLodEXT(renderer_BlitTexture,v_uv,renderer_BlitMipLevel);\n#else\ngl_FragColor=texture2D(renderer_BlitTexture,v_uv);\n#endif\n}"; // eslint-disable-line
23414
+ var blitFs = "#define GLSLIFY 1\nuniform mediump sampler2D renderer_BlitTexture;\n#ifdef HAS_TEX_LOD\nuniform float renderer_BlitMipLevel;\n#endif\nvarying vec2 v_uv;void main(){vec2 uv=v_uv;\n#ifdef renderer_FlipYBlitTexture\nuv.y=1.0-uv.y;\n#endif\n#ifdef HAS_TEX_LOD\ngl_FragColor=texture2DLodEXT(renderer_BlitTexture,uv,renderer_BlitMipLevel);\n#else\ngl_FragColor=texture2D(renderer_BlitTexture,uv);\n#endif\n}"; // eslint-disable-line
23261
23415
 
23262
23416
  var blitVs = "#define GLSLIFY 1\nattribute vec4 POSITION_UV;varying vec2 v_uv;void main(){gl_Position=vec4(POSITION_UV.xy,0.0,1.0);v_uv=POSITION_UV.zw;}"; // eslint-disable-line
23263
23417
 
@@ -29157,13 +29311,11 @@ exports.AnimatorLayerBlendingMode = void 0;
29157
29311
  return true;
29158
29312
  };
29159
29313
  _proto._applyTransition = function _applyTransition(layerIndex, layerData, layer, transition, aniUpdate) {
29160
- // Need prepare first, it should crossFade when to exit
29161
- var success = this._prepareCrossFadeByTransition(transition, layerIndex);
29162
29314
  if (transition.isExit) {
29163
29315
  this._checkAnyAndEntryState(layerIndex, layerData, layer, 0, aniUpdate);
29164
- return true;
29316
+ return false;
29165
29317
  }
29166
- return success;
29318
+ return this._prepareCrossFadeByTransition(transition, layerIndex);
29167
29319
  };
29168
29320
  _proto._checkConditions = function _checkConditions(state, transition) {
29169
29321
  var _state;
@@ -34560,6 +34712,74 @@ var cacheDir = new engineMath.Vector3();
34560
34712
  return CubeProbe;
34561
34713
  }(Probe);
34562
34714
 
34715
+ /**
34716
+ * @internal
34717
+ */ var Polyfill = /*#__PURE__*/ function() {
34718
+ function Polyfill() {}
34719
+ Polyfill.registerPolyfill = function registerPolyfill() {
34720
+ Polyfill._registerMatchAll();
34721
+ };
34722
+ Polyfill._registerMatchAll = function _registerMatchAll() {
34723
+ if (!String.prototype.matchAll) {
34724
+ Logger.info("polyfill String.prototype.matchAll");
34725
+ String.prototype.matchAll = function(pattern) {
34726
+ var flags = pattern.flags;
34727
+ var globalFlagIdx = flags.indexOf("g");
34728
+ if (globalFlagIdx === -1) {
34729
+ throw TypeError("String.prototype.matchAll called with a non-global RegExp argument");
34730
+ }
34731
+ var bindThis = this;
34732
+ return function() {
34733
+ var matchResult, matchFlag, matchPattern, _tmp, _tmp1, _i, index, item;
34734
+ return __generator(this, function(_state) {
34735
+ switch(_state.label){
34736
+ case 0:
34737
+ matchResult = bindThis.match(pattern);
34738
+ if (matchResult == null) return [
34739
+ 2,
34740
+ null
34741
+ ];
34742
+ matchFlag = flags.split("g").join("");
34743
+ matchPattern = new RegExp(pattern.source, matchFlag);
34744
+ _tmp = [];
34745
+ for(_tmp1 in matchResult)_tmp.push(_tmp1);
34746
+ _i = 0;
34747
+ _state.label = 1;
34748
+ case 1:
34749
+ if (!(_i < _tmp.length)) return [
34750
+ 3,
34751
+ 4
34752
+ ];
34753
+ index = _tmp[_i];
34754
+ item = matchResult[index];
34755
+ return [
34756
+ 4,
34757
+ item.match(matchPattern)
34758
+ ];
34759
+ case 2:
34760
+ _state.sent();
34761
+ _state.label = 3;
34762
+ case 3:
34763
+ _i++;
34764
+ return [
34765
+ 3,
34766
+ 1
34767
+ ];
34768
+ case 4:
34769
+ return [
34770
+ 2
34771
+ ];
34772
+ }
34773
+ });
34774
+ }();
34775
+ };
34776
+ }
34777
+ };
34778
+ return Polyfill;
34779
+ }();
34780
+
34781
+ Polyfill.registerPolyfill();
34782
+
34563
34783
  exports.AmbientLight = AmbientLight;
34564
34784
  exports.AnimationClip = AnimationClip;
34565
34785
  exports.AnimationClipCurveBinding = AnimationClipCurveBinding;