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