@galacean/engine-core 1.3.24 → 1.3.26

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
  }
@@ -9316,9 +9420,12 @@ var ContextRendererUpdateFlag;
9316
9420
  var camera = context.camera;
9317
9421
  var engine = camera.engine;
9318
9422
  camera.scene._maskManager.buildMaskRenderElement(master, incrementMaskQueue, decrementMaskQueue);
9423
+ var primitiveChunkManagerMask = engine._batcherManager.primitiveChunkManagerMask;
9319
9424
  incrementMaskQueue._batch(engine._batcherManager);
9425
+ primitiveChunkManagerMask.uploadBuffer();
9320
9426
  incrementMaskQueue.render(context, pipelineStageTagValue, 1);
9321
9427
  decrementMaskQueue._batch(engine._batcherManager);
9428
+ primitiveChunkManagerMask.uploadBuffer();
9322
9429
  decrementMaskQueue.render(context, pipelineStageTagValue, 2);
9323
9430
  };
9324
9431
  RenderQueue.compareForOpaque = function compareForOpaque(a, b) {
@@ -10246,6 +10353,8 @@ var /**
10246
10353
  function BasicRenderPipeline(camera) {
10247
10354
  this._lastCanvasSize = new miniprogram.Vector2();
10248
10355
  this._internalColorTarget = null;
10356
+ this._canUseBlitFrameBuffer = false;
10357
+ this._shouldGrabColor = false;
10249
10358
  this._camera = camera;
10250
10359
  var engine = camera.engine;
10251
10360
  this._cullingResults = new CullingResults();
@@ -10270,10 +10379,19 @@ var /**
10270
10379
  context.rendererUpdateFlag = ContextRendererUpdateFlag.All;
10271
10380
  var camera = this._camera;
10272
10381
  var scene = camera.scene, engine = camera.engine;
10382
+ var rhi = engine._hardwareRenderer;
10273
10383
  var cullingResults = this._cullingResults;
10274
10384
  var sunlight = scene._lightManager._sunlight;
10275
10385
  var depthOnlyPass = this._depthOnlyPass;
10276
10386
  var depthPassEnabled = camera.depthTextureMode === exports.DepthTextureMode.PrePass && depthOnlyPass._supportDepthTexture;
10387
+ var finalClearFlags = camera.clearFlags & ~(ignoreClear != null ? ignoreClear : exports.CameraClearFlags.None);
10388
+ var independentCanvasEnabled = camera.independentCanvasEnabled;
10389
+ var msaaSamples = camera.renderTarget ? camera.renderTarget.antiAliasing : camera.msaaSamples;
10390
+ this._shouldGrabColor = independentCanvasEnabled && !(finalClearFlags & exports.CameraClearFlags.Color);
10391
+ // 1. Only support blitFramebuffer in webgl2 context
10392
+ // 2. Can't blit normal FBO to MSAA FBO
10393
+ // 3. Can't blit screen MSAA FBO to normal FBO in mac safari platform and mobile, but mac chrome and firfox is OK
10394
+ this._canUseBlitFrameBuffer = rhi.isWebGL2 && msaaSamples === 1 && (!!camera.renderTarget || !rhi.context.antialias);
10277
10395
  if (scene.castShadows && sunlight && sunlight.shadowType !== exports.ShadowType.None) {
10278
10396
  this._cascadedShadowCasterPass.onRender(context);
10279
10397
  context.rendererUpdateFlag = ContextRendererUpdateFlag.None;
@@ -10293,24 +10411,46 @@ var /**
10293
10411
  } else {
10294
10412
  camera.shaderData.setTexture(exports.Camera._cameraDepthTextureProperty, engine._basicResources.whiteTexture2D);
10295
10413
  }
10296
- // Check if need to create internal color texture
10297
- var independentCanvasEnabled = camera.independentCanvasEnabled;
10414
+ // Check if need to create internal color texture or grab texture
10298
10415
  if (independentCanvasEnabled) {
10416
+ var depthFormat;
10417
+ if (camera.renderTarget) {
10418
+ depthFormat = camera.renderTarget._depthFormat;
10419
+ } else if (rhi.context.depth && rhi.context.stencil) {
10420
+ depthFormat = exports.TextureFormat.Depth24Stencil8;
10421
+ } else if (rhi.context.depth) {
10422
+ depthFormat = exports.TextureFormat.Depth24;
10423
+ } else if (rhi.context.stencil) {
10424
+ depthFormat = exports.TextureFormat.Stencil;
10425
+ } else {
10426
+ depthFormat = null;
10427
+ }
10299
10428
  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);
10429
+ var internalColorTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._internalColorTarget, viewport.width, viewport.height, camera._getInternalColorTextureFormat(), depthFormat, false, false, msaaSamples, exports.TextureWrapMode.Clamp, exports.TextureFilterMode.Bilinear);
10430
+ if (!this._canUseBlitFrameBuffer && this._shouldGrabColor) {
10431
+ var _camera_renderTarget;
10432
+ var _camera_renderTarget_getColorTexture_format;
10433
+ 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);
10434
+ this._grabTexture = grabTexture;
10435
+ }
10301
10436
  this._internalColorTarget = internalColorTarget;
10302
10437
  } else {
10303
10438
  var internalColorTarget1 = this._internalColorTarget;
10439
+ var grabTexture1 = this._grabTexture;
10304
10440
  if (internalColorTarget1) {
10305
10441
  var _internalColorTarget_getColorTexture;
10306
10442
  (_internalColorTarget_getColorTexture = internalColorTarget1.getColorTexture(0)) == null ? void 0 : _internalColorTarget_getColorTexture.destroy(true);
10307
10443
  internalColorTarget1.destroy(true);
10308
10444
  this._internalColorTarget = null;
10309
10445
  }
10446
+ if (grabTexture1) {
10447
+ grabTexture1.destroy(true);
10448
+ this._grabTexture = null;
10449
+ }
10310
10450
  }
10311
- this._drawRenderPass(context, camera, cubeFace, mipLevel, ignoreClear);
10451
+ this._drawRenderPass(context, camera, finalClearFlags, cubeFace, mipLevel);
10312
10452
  };
10313
- _proto._drawRenderPass = function _drawRenderPass(context, camera, cubeFace, mipLevel, ignoreClear) {
10453
+ _proto._drawRenderPass = function _drawRenderPass(context, camera, finalClearFlags, cubeFace, mipLevel) {
10314
10454
  var _cameraRenderTarget, _cameraRenderTarget1;
10315
10455
  var cullingResults = this._cullingResults;
10316
10456
  var opaqueQueue = cullingResults.opaqueQueue, alphaTestQueue = cullingResults.alphaTestQueue, transparentQueue = cullingResults.transparentQueue;
@@ -10327,14 +10467,34 @@ var /**
10327
10467
  context.applyVirtualCamera(camera._virtualCamera, needFlipProjection);
10328
10468
  }
10329
10469
  rhi.activeRenderTarget(colorTarget, colorViewport, context.flipProjection, mipLevel, cubeFace);
10330
- var clearFlags = camera.clearFlags & ~(ignoreClear != null ? ignoreClear : exports.CameraClearFlags.None);
10331
10470
  var color = background.solidColor;
10332
- if (clearFlags !== exports.CameraClearFlags.None) {
10333
- rhi.clearRenderTarget(camera.engine, clearFlags, color);
10471
+ if (internalColorTarget && finalClearFlags !== exports.CameraClearFlags.All) {
10472
+ // Can use `blitFramebuffer` API to copy color/depth/stencil buffer from back buffer to internal RT
10473
+ if (this._canUseBlitFrameBuffer) {
10474
+ finalClearFlags !== exports.CameraClearFlags.None && rhi.clearRenderTarget(engine, finalClearFlags, color);
10475
+ rhi.blitInternalRTByBlitFrameBuffer(camera.renderTarget, internalColorTarget, finalClearFlags, camera.viewport);
10476
+ } else {
10477
+ if (!(finalClearFlags & exports.CameraClearFlags.Depth) || !(finalClearFlags & exports.CameraClearFlags.Stencil)) {
10478
+ 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");
10479
+ }
10480
+ if (this._shouldGrabColor) {
10481
+ rhi.clearRenderTarget(engine, exports.CameraClearFlags.DepthStencil);
10482
+ // Copy RT's color buffer to grab texture
10483
+ rhi.copyRenderTargetToSubTexture(camera.renderTarget, this._grabTexture, camera.viewport);
10484
+ // Then blit grab texture to internal RT's color buffer
10485
+ PipelineUtils.blitTexture(engine, this._grabTexture, internalColorTarget, 0, undefined, undefined, undefined, // Only flip Y axis in webgl context
10486
+ !camera.renderTarget);
10487
+ } else {
10488
+ rhi.clearRenderTarget(engine, exports.CameraClearFlags.All, color);
10489
+ }
10490
+ }
10491
+ rhi.activeRenderTarget(colorTarget, colorViewport, context.flipProjection, mipLevel, cubeFace);
10492
+ } else if (finalClearFlags !== exports.CameraClearFlags.None) {
10493
+ rhi.clearRenderTarget(engine, finalClearFlags, color);
10334
10494
  }
10335
10495
  opaqueQueue.render(context, exports.PipelineStage.Forward);
10336
10496
  alphaTestQueue.render(context, exports.PipelineStage.Forward);
10337
- if (clearFlags & exports.CameraClearFlags.Color) {
10497
+ if (finalClearFlags & exports.CameraClearFlags.Color) {
10338
10498
  if (background.mode === exports.BackgroundMode.Sky) {
10339
10499
  background.sky._render(context);
10340
10500
  } else if (background.mode === exports.BackgroundMode.Texture && background.texture) {
@@ -10409,8 +10569,7 @@ var /**
10409
10569
  var shaderPass = shaderPasses[i];
10410
10570
  var renderState = shaderPass._renderState;
10411
10571
  if (renderState) {
10412
- renderState._applyRenderQueueByShaderData(shaderPass._renderStateDataMap, subRenderElement.material.shaderData);
10413
- renderQueueType = renderState.renderQueueType;
10572
+ renderQueueType = renderState._getRenderQueueByShaderData(shaderPass._renderStateDataMap, subRenderElement.material.shaderData);
10414
10573
  } else {
10415
10574
  renderQueueType = renderStates[i].renderQueueType;
10416
10575
  }
@@ -23256,7 +23415,7 @@ __decorate([
23256
23415
  ParticleBufferUtils.boundsMaxLifetimeOffset = 7;
23257
23416
  })();
23258
23417
 
23259
- 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
23418
+ 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
23260
23419
 
23261
23420
  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
23262
23421
 
@@ -29156,13 +29315,11 @@ exports.AnimatorLayerBlendingMode = void 0;
29156
29315
  return true;
29157
29316
  };
29158
29317
  _proto._applyTransition = function _applyTransition(layerIndex, layerData, layer, transition, aniUpdate) {
29159
- // Need prepare first, it should crossFade when to exit
29160
- var success = this._prepareCrossFadeByTransition(transition, layerIndex);
29161
29318
  if (transition.isExit) {
29162
29319
  this._checkAnyAndEntryState(layerIndex, layerData, layer, 0, aniUpdate);
29163
- return true;
29320
+ return false;
29164
29321
  }
29165
- return success;
29322
+ return this._prepareCrossFadeByTransition(transition, layerIndex);
29166
29323
  };
29167
29324
  _proto._checkConditions = function _checkConditions(state, transition) {
29168
29325
  var _state;
@@ -34559,6 +34716,74 @@ var cacheDir = new miniprogram.Vector3();
34559
34716
  return CubeProbe;
34560
34717
  }(Probe);
34561
34718
 
34719
+ /**
34720
+ * @internal
34721
+ */ var Polyfill = /*#__PURE__*/ function() {
34722
+ function Polyfill() {}
34723
+ Polyfill.registerPolyfill = function registerPolyfill() {
34724
+ Polyfill._registerMatchAll();
34725
+ };
34726
+ Polyfill._registerMatchAll = function _registerMatchAll() {
34727
+ if (!String.prototype.matchAll) {
34728
+ Logger.info("polyfill String.prototype.matchAll");
34729
+ String.prototype.matchAll = function(pattern) {
34730
+ var flags = pattern.flags;
34731
+ var globalFlagIdx = flags.indexOf("g");
34732
+ if (globalFlagIdx === -1) {
34733
+ throw TypeError("String.prototype.matchAll called with a non-global RegExp argument");
34734
+ }
34735
+ var bindThis = this;
34736
+ return function() {
34737
+ var matchResult, matchFlag, matchPattern, _tmp, _tmp1, _i, index, item;
34738
+ return __generator(this, function(_state) {
34739
+ switch(_state.label){
34740
+ case 0:
34741
+ matchResult = bindThis.match(pattern);
34742
+ if (matchResult == null) return [
34743
+ 2,
34744
+ null
34745
+ ];
34746
+ matchFlag = flags.split("g").join("");
34747
+ matchPattern = new RegExp(pattern.source, matchFlag);
34748
+ _tmp = [];
34749
+ for(_tmp1 in matchResult)_tmp.push(_tmp1);
34750
+ _i = 0;
34751
+ _state.label = 1;
34752
+ case 1:
34753
+ if (!(_i < _tmp.length)) return [
34754
+ 3,
34755
+ 4
34756
+ ];
34757
+ index = _tmp[_i];
34758
+ item = matchResult[index];
34759
+ return [
34760
+ 4,
34761
+ item.match(matchPattern)
34762
+ ];
34763
+ case 2:
34764
+ _state.sent();
34765
+ _state.label = 3;
34766
+ case 3:
34767
+ _i++;
34768
+ return [
34769
+ 3,
34770
+ 1
34771
+ ];
34772
+ case 4:
34773
+ return [
34774
+ 2
34775
+ ];
34776
+ }
34777
+ });
34778
+ }();
34779
+ };
34780
+ }
34781
+ };
34782
+ return Polyfill;
34783
+ }();
34784
+
34785
+ Polyfill.registerPolyfill();
34786
+
34562
34787
  exports.AmbientLight = AmbientLight;
34563
34788
  exports.AnimationClip = AnimationClip;
34564
34789
  exports.AnimationClipCurveBinding = AnimationClipCurveBinding;