@galacean/engine 1.3.24 → 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/browser.js CHANGED
@@ -5203,6 +5203,101 @@
5203
5203
  else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5204
5204
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5205
5205
  }
5206
+ function __generator$1(thisArg, body) {
5207
+ var verb = function verb(n) {
5208
+ return function(v) {
5209
+ return step([
5210
+ n,
5211
+ v
5212
+ ]);
5213
+ };
5214
+ };
5215
+ var step = function step(op) {
5216
+ if (f) throw new TypeError("Generator is already executing.");
5217
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
5218
+ 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;
5219
+ if (y = 0, t) op = [
5220
+ op[0] & 2,
5221
+ t.value
5222
+ ];
5223
+ switch(op[0]){
5224
+ case 0:
5225
+ case 1:
5226
+ t = op;
5227
+ break;
5228
+ case 4:
5229
+ _.label++;
5230
+ return {
5231
+ value: op[1],
5232
+ done: false
5233
+ };
5234
+ case 5:
5235
+ _.label++;
5236
+ y = op[1];
5237
+ op = [
5238
+ 0
5239
+ ];
5240
+ continue;
5241
+ case 7:
5242
+ op = _.ops.pop();
5243
+ _.trys.pop();
5244
+ continue;
5245
+ default:
5246
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
5247
+ _ = 0;
5248
+ continue;
5249
+ }
5250
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
5251
+ _.label = op[1];
5252
+ break;
5253
+ }
5254
+ if (op[0] === 6 && _.label < t[1]) {
5255
+ _.label = t[1];
5256
+ t = op;
5257
+ break;
5258
+ }
5259
+ if (t && _.label < t[2]) {
5260
+ _.label = t[2];
5261
+ _.ops.push(op);
5262
+ break;
5263
+ }
5264
+ if (t[2]) _.ops.pop();
5265
+ _.trys.pop();
5266
+ continue;
5267
+ }
5268
+ op = body.call(thisArg, _);
5269
+ } catch (e) {
5270
+ op = [
5271
+ 6,
5272
+ e
5273
+ ];
5274
+ y = 0;
5275
+ } finally{
5276
+ f = t = 0;
5277
+ }
5278
+ if (op[0] & 5) throw op[1];
5279
+ return {
5280
+ value: op[0] ? op[1] : void 0,
5281
+ done: true
5282
+ };
5283
+ };
5284
+ var _ = {
5285
+ label: 0,
5286
+ sent: function sent() {
5287
+ if (t[0] & 1) throw t[1];
5288
+ return t[1];
5289
+ },
5290
+ trys: [],
5291
+ ops: []
5292
+ }, f, y, t, g;
5293
+ return g = {
5294
+ next: verb(0),
5295
+ "throw": verb(1),
5296
+ "return": verb(2)
5297
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
5298
+ return this;
5299
+ }), g;
5300
+ }
5206
5301
  typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
5207
5302
  var e = new Error(message);
5208
5303
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
@@ -8768,11 +8863,13 @@
8768
8863
  /**
8769
8864
  * @internal
8770
8865
  * @todo Should merge when we can delete material render state
8771
- */ _proto._applyRenderQueueByShaderData = function _applyRenderQueueByShaderData(renderStateDataMap, shaderData) {
8866
+ */ _proto._getRenderQueueByShaderData = function _getRenderQueueByShaderData(renderStateDataMap, shaderData) {
8772
8867
  var renderQueueType = renderStateDataMap[exports.RenderStateDataKey.RenderQueueType];
8773
- if (renderQueueType !== undefined) {
8868
+ if (renderQueueType === undefined) {
8869
+ return this.renderQueueType;
8870
+ } else {
8774
8871
  var _shaderData_getFloat;
8775
- this.renderQueueType = (_shaderData_getFloat = shaderData.getFloat(renderQueueType)) != null ? _shaderData_getFloat : exports.RenderQueueType.Opaque;
8872
+ return (_shaderData_getFloat = shaderData.getFloat(renderQueueType)) != null ? _shaderData_getFloat : exports.RenderQueueType.Opaque;
8776
8873
  }
8777
8874
  };
8778
8875
  _proto._applyStatesByShaderData = function _applyStatesByShaderData(renderStateDataMap, shaderData) {
@@ -9973,9 +10070,11 @@
9973
10070
  _this._rotation = new Vector3();
9974
10071
  _this._rotationQuaternion = new Quaternion();
9975
10072
  _this._scale = new Vector3(1, 1, 1);
10073
+ _this._localUniformScaling = true;
9976
10074
  _this._worldPosition = new Vector3();
9977
10075
  _this._worldRotation = new Vector3();
9978
10076
  _this._worldRotationQuaternion = new Quaternion();
10077
+ _this._worldUniformScaling = true;
9979
10078
  _this._lossyWorldScale = new Vector3(1, 1, 1);
9980
10079
  _this._localMatrix = new Matrix();
9981
10080
  _this._worldMatrix = new Matrix();
@@ -10143,7 +10242,7 @@
10143
10242
  * @internal
10144
10243
  */ _proto._parentChange = function _parentChange() {
10145
10244
  this._isParentDirty = true;
10146
- this._updateAllWorldFlag();
10245
+ this._updateAllWorldFlag(0x1bc);
10147
10246
  };
10148
10247
  /**
10149
10248
  * @internal
@@ -10178,10 +10277,10 @@
10178
10277
  */ _proto._updateWorldPositionFlag = function _updateWorldPositionFlag() {
10179
10278
  if (!this._isContainDirtyFlags(0x84)) {
10180
10279
  this._worldAssociatedChange(0x84);
10181
- var nodeChildren = this._entity._children;
10182
- for(var i = 0, n = nodeChildren.length; i < n; i++){
10183
- var _nodeChildren_i_transform;
10184
- (_nodeChildren_i_transform = nodeChildren[i].transform) == null ? void 0 : _nodeChildren_i_transform._updateWorldPositionFlag();
10280
+ var children = this._entity._children;
10281
+ for(var i = 0, n = children.length; i < n; i++){
10282
+ var _children_i_transform;
10283
+ (_children_i_transform = children[i].transform) == null ? void 0 : _children_i_transform._updateWorldPositionFlag();
10185
10284
  }
10186
10285
  }
10187
10286
  };
@@ -10190,14 +10289,19 @@
10190
10289
  * Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
10191
10290
  * Get worldRotationQuaternion: Will trigger the world rotation (in quaternion) update of itself and all parent entities.
10192
10291
  * Get worldRotation: Will trigger the world rotation(in euler and quaternion) update of itself and world rotation(in quaternion) update of all parent entities.
10292
+ * Get worldScale: Will trigger the scaling update of itself and all parent entities.
10193
10293
  * In summary, any update of related variables will cause the dirty mark of one of the full process (worldMatrix or worldRotationQuaternion) to be false.
10194
10294
  */ _proto._updateWorldRotationFlag = function _updateWorldRotationFlag() {
10195
- if (!this._isContainDirtyFlags(0x98)) {
10196
- this._worldAssociatedChange(0x98);
10197
- var nodeChildren = this._entity._children;
10198
- for(var i = 0, n = nodeChildren.length; i < n; i++){
10199
- var _nodeChildren_i_transform;
10200
- (_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.
10295
+ var parent = this._getParentTransform();
10296
+ var parentWorldUniformScaling = parent ? parent._getWorldUniformScaling() : true;
10297
+ var flags = parentWorldUniformScaling ? 0x98 : 0xb8;
10298
+ if (!this._isContainDirtyFlags(flags)) {
10299
+ this._worldAssociatedChange(flags);
10300
+ flags = this._getWorldUniformScaling() ? 0x9c : 0xbc;
10301
+ var children = this._entity._children;
10302
+ for(var i = 0, n = children.length; i < n; i++){
10303
+ var _children_i_transform;
10304
+ (_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.
10201
10305
  }
10202
10306
  }
10203
10307
  };
@@ -10206,14 +10310,17 @@
10206
10310
  * Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
10207
10311
  * Get worldRotationQuaternion: Will trigger the world rotation (in quaternion) update of itself and all parent entities.
10208
10312
  * Get worldRotation: Will trigger the world rotation(in euler and quaternion) update of itself and world rotation(in quaternion) update of all parent entities.
10313
+ * Get worldScale: Will trigger the scaling update of itself and all parent entities.
10209
10314
  * In summary, any update of related variables will cause the dirty mark of one of the full process (worldMatrix or worldRotationQuaternion) to be false.
10210
- */ _proto._updateWorldPositionAndRotationFlag = function _updateWorldPositionAndRotationFlag() {
10211
- if (!this._isContainDirtyFlags(0x9c)) {
10212
- this._worldAssociatedChange(0x9c);
10213
- var nodeChildren = this._entity._children;
10214
- for(var i = 0, n = nodeChildren.length; i < n; i++){
10215
- var _nodeChildren_i_transform;
10216
- (_nodeChildren_i_transform = nodeChildren[i].transform) == null ? void 0 : _nodeChildren_i_transform._updateWorldPositionAndRotationFlag();
10315
+ * @param flags - Dirty flag
10316
+ */ _proto._updateWorldPositionAndRotationFlag = function _updateWorldPositionAndRotationFlag(flags) {
10317
+ if (!this._isContainDirtyFlags(flags)) {
10318
+ this._worldAssociatedChange(flags);
10319
+ flags = this._getWorldUniformScaling() ? 0x9c : 0xbc;
10320
+ var children = this._entity._children;
10321
+ for(var i = 0, n = children.length; i < n; i++){
10322
+ var _children_i_transform;
10323
+ (_children_i_transform = children[i].transform) == null ? void 0 : _children_i_transform._updateWorldPositionAndRotationFlag(flags);
10217
10324
  }
10218
10325
  }
10219
10326
  };
@@ -10222,13 +10329,15 @@
10222
10329
  * Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
10223
10330
  * Get worldScale: Will trigger the scaling update of itself and all parent entities.
10224
10331
  * In summary, any update of related variables will cause the dirty mark of one of the full process (worldMatrix) to be false.
10225
- */ _proto._updateWorldScaleFlag = function _updateWorldScaleFlag() {
10226
- if (!this._isContainDirtyFlags(0xa0)) {
10227
- this._worldAssociatedChange(0xa0);
10228
- var nodeChildren = this._entity._children;
10229
- for(var i = 0, n = nodeChildren.length; i < n; i++){
10230
- var _nodeChildren_i_transform;
10231
- (_nodeChildren_i_transform = nodeChildren[i].transform) == null ? void 0 : _nodeChildren_i_transform._updateWorldPositionAndScaleFlag();
10332
+ * @param flags - Dirty flag
10333
+ */ _proto._updateWorldScaleFlag = function _updateWorldScaleFlag(flags) {
10334
+ if (!this._isContainDirtyFlags(flags)) {
10335
+ this._worldAssociatedChange(flags);
10336
+ flags |= 0x4;
10337
+ var children = this._entity._children;
10338
+ for(var i = 0, n = children.length; i < n; i++){
10339
+ var _children_i_transform;
10340
+ (_children_i_transform = children[i].transform) == null ? void 0 : _children_i_transform._updateWorldPositionAndScaleFlag(flags);
10232
10341
  }
10233
10342
  }
10234
10343
  };
@@ -10237,25 +10346,27 @@
10237
10346
  * Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
10238
10347
  * Get worldScale: Will trigger the scaling update of itself and all parent entities.
10239
10348
  * In summary, any update of related variables will cause the dirty mark of one of the full process (worldMatrix) to be false.
10240
- */ _proto._updateWorldPositionAndScaleFlag = function _updateWorldPositionAndScaleFlag() {
10241
- if (!this._isContainDirtyFlags(0xa4)) {
10242
- this._worldAssociatedChange(0xa4);
10243
- var nodeChildren = this._entity._children;
10244
- for(var i = 0, n = nodeChildren.length; i < n; i++){
10245
- var _nodeChildren_i_transform;
10246
- (_nodeChildren_i_transform = nodeChildren[i].transform) == null ? void 0 : _nodeChildren_i_transform._updateWorldPositionAndScaleFlag();
10349
+ * @param flags - Dirty flag
10350
+ */ _proto._updateWorldPositionAndScaleFlag = function _updateWorldPositionAndScaleFlag(flags) {
10351
+ if (!this._isContainDirtyFlags(flags)) {
10352
+ this._worldAssociatedChange(flags);
10353
+ var children = this._entity._children;
10354
+ for(var i = 0, n = children.length; i < n; i++){
10355
+ var _children_i_transform;
10356
+ (_children_i_transform = children[i].transform) == null ? void 0 : _children_i_transform._updateWorldPositionAndScaleFlag(flags);
10247
10357
  }
10248
10358
  }
10249
10359
  };
10250
10360
  /**
10251
10361
  * Update all world transform property dirty flag, the principle is the same as above.
10252
- */ _proto._updateAllWorldFlag = function _updateAllWorldFlag() {
10253
- if (!this._isContainDirtyFlags(0xbc)) {
10254
- this._worldAssociatedChange(0xbc);
10255
- var nodeChildren = this._entity._children;
10256
- for(var i = 0, n = nodeChildren.length; i < n; i++){
10257
- var _nodeChildren_i_transform;
10258
- (_nodeChildren_i_transform = nodeChildren[i].transform) == null ? void 0 : _nodeChildren_i_transform._updateAllWorldFlag();
10362
+ * @param flags - Dirty flag
10363
+ */ _proto._updateAllWorldFlag = function _updateAllWorldFlag(flags) {
10364
+ if (!this._isContainDirtyFlags(flags)) {
10365
+ this._worldAssociatedChange(flags);
10366
+ var children = this._entity._children;
10367
+ for(var i = 0, n = children.length; i < n; i++){
10368
+ var _children_i_transform;
10369
+ (_children_i_transform = children[i].transform) == null ? void 0 : _children_i_transform._updateAllWorldFlag(flags);
10259
10370
  }
10260
10371
  }
10261
10372
  };
@@ -10303,7 +10414,7 @@
10303
10414
  };
10304
10415
  _proto._worldAssociatedChange = function _worldAssociatedChange(type) {
10305
10416
  this._dirtyFlag |= type;
10306
- this._updateFlagManager.dispatch(0x80);
10417
+ this._updateFlagManager.dispatch(type);
10307
10418
  };
10308
10419
  _proto._rotateByQuat = function _rotateByQuat(rotateQuat, relativeToLocal) {
10309
10420
  if (relativeToLocal) {
@@ -10372,8 +10483,28 @@
10372
10483
  this._setDirtyFlagFalse(0x10);
10373
10484
  };
10374
10485
  _proto._onScaleChanged = function _onScaleChanged() {
10486
+ var _this__scale = this._scale, x = _this__scale.x, y = _this__scale.y, z = _this__scale.z;
10375
10487
  this._setDirtyFlagTrue(0x40);
10376
- this._updateWorldScaleFlag();
10488
+ var localUniformScaling = x == y && y == z;
10489
+ if (this._localUniformScaling !== localUniformScaling) {
10490
+ this._localUniformScaling = localUniformScaling;
10491
+ this._updateWorldScaleFlag(0x1a0);
10492
+ } else {
10493
+ this._updateWorldScaleFlag(0xa0);
10494
+ }
10495
+ };
10496
+ _proto._getWorldUniformScaling = function _getWorldUniformScaling() {
10497
+ if (this._isContainDirtyFlag(0x100)) {
10498
+ var localUniformScaling = this._localUniformScaling;
10499
+ if (localUniformScaling) {
10500
+ var parent = this._getParentTransform();
10501
+ this._worldUniformScaling = localUniformScaling && (parent ? parent._getWorldUniformScaling() : true);
10502
+ } else {
10503
+ this._worldUniformScaling = false;
10504
+ }
10505
+ this._setDirtyFlagFalse(0x100);
10506
+ }
10507
+ return this._worldUniformScaling;
10377
10508
  };
10378
10509
  _create_class$2(Transform, [
10379
10510
  {
@@ -10540,11 +10671,12 @@
10540
10671
  key: "lossyWorldScale",
10541
10672
  get: /**
10542
10673
  * Local lossy scaling.
10543
- * @remarks The value obtained may not be correct under certain conditions(for example, the parent node has scaling,
10544
- * and the child node has a rotation), the scaling will be tilted. Vector3 cannot be used to correctly represent the scaling. Must use Matrix3x3.
10674
+ * @remarks The value obtained may not be correct under certain conditions(for example, the parent node has non-uniform world scaling,
10675
+ * and the child node has a rotation), the scaling will be tilted.
10545
10676
  */ function get() {
10546
10677
  if (this._isContainDirtyFlag(0x20)) {
10547
10678
  if (this._getParentTransform()) {
10679
+ // Vector3 cannot be used to correctly represent the scaling. Must use Matrix3x3
10548
10680
  var scaleMat = this._getScaleMatrix();
10549
10681
  var e = scaleMat.elements;
10550
10682
  this._lossyWorldScale.set(e[0], e[4], e[8]);
@@ -10572,18 +10704,25 @@
10572
10704
  if (this._localMatrix !== value) {
10573
10705
  this._localMatrix.copyFrom(value);
10574
10706
  }
10707
+ var _this = this, position = _this._position, rotationQuaternion = _this._rotationQuaternion, scale = _this._scale;
10575
10708
  // @ts-ignore
10576
- this._position._onValueChanged = this._rotationQuaternion._onValueChanged = this._scale._onValueChanged = null;
10577
- this._localMatrix.decompose(this._position, this._rotationQuaternion, this._scale);
10709
+ position._onValueChanged = rotationQuaternion._onValueChanged = scale._onValueChanged = null;
10710
+ this._localMatrix.decompose(position, rotationQuaternion, scale);
10578
10711
  // @ts-ignore
10579
- this._position._onValueChanged = this._onPositionChanged;
10712
+ position._onValueChanged = this._onPositionChanged;
10580
10713
  // @ts-ignore
10581
- this._rotationQuaternion._onValueChanged = this._onRotationQuaternionChanged;
10714
+ rotationQuaternion._onValueChanged = this._onRotationQuaternionChanged;
10582
10715
  // @ts-ignore
10583
- this._scale._onValueChanged = this._onScaleChanged;
10716
+ scale._onValueChanged = this._onScaleChanged;
10584
10717
  this._setDirtyFlagTrue(0x1);
10585
10718
  this._setDirtyFlagFalse(0x40 | 0x2);
10586
- this._updateAllWorldFlag();
10719
+ var localUniformScaling = scale.x === scale.y && scale.y === scale.z;
10720
+ if (this._localUniformScaling !== localUniformScaling) {
10721
+ this._localUniformScaling = localUniformScaling;
10722
+ this._updateAllWorldFlag(0x1bc);
10723
+ } else {
10724
+ this._updateAllWorldFlag(0xbc);
10725
+ }
10587
10726
  }
10588
10727
  },
10589
10728
  {
@@ -10693,6 +10832,9 @@
10693
10832
  __decorate$1([
10694
10833
  deepClone
10695
10834
  ], Transform.prototype, "_scale", void 0);
10835
+ __decorate$1([
10836
+ assignmentClone
10837
+ ], Transform.prototype, "_localUniformScaling", void 0);
10696
10838
  __decorate$1([
10697
10839
  deepClone
10698
10840
  ], Transform.prototype, "_worldPosition", void 0);
@@ -10702,6 +10844,9 @@
10702
10844
  __decorate$1([
10703
10845
  deepClone
10704
10846
  ], Transform.prototype, "_worldRotationQuaternion", void 0);
10847
+ __decorate$1([
10848
+ assignmentClone
10849
+ ], Transform.prototype, "_worldUniformScaling", void 0);
10705
10850
  __decorate$1([
10706
10851
  deepClone
10707
10852
  ], Transform.prototype, "_lossyWorldScale", void 0);
@@ -10760,12 +10905,18 @@
10760
10905
  TransformModifyFlags[TransformModifyFlags["WorldScale"] = 0x20] = "WorldScale";
10761
10906
  TransformModifyFlags[TransformModifyFlags["LocalMatrix"] = 0x40] = "LocalMatrix";
10762
10907
  TransformModifyFlags[TransformModifyFlags["WorldMatrix"] = 0x80] = "WorldMatrix";
10908
+ TransformModifyFlags[TransformModifyFlags[/** This is an internal flag used to assist in determining the dispatch
10909
+ * of world scaling dirty flags in the case of non-uniform scaling.
10910
+ */ "IsWorldUniformScaling"] = 0x100] = "IsWorldUniformScaling";
10763
10911
  TransformModifyFlags[TransformModifyFlags[/** WorldMatrix | WorldPosition */ "WmWp"] = 0x84] = "WmWp";
10764
10912
  TransformModifyFlags[TransformModifyFlags[/** WorldMatrix | WorldEuler | WorldQuat */ "WmWeWq"] = 0x98] = "WmWeWq";
10913
+ TransformModifyFlags[TransformModifyFlags[/** WorldMatrix | WorldEuler | WorldQuat | WorldScale*/ "WmWeWqWs"] = 0xb8] = "WmWeWqWs";
10765
10914
  TransformModifyFlags[TransformModifyFlags[/** WorldMatrix | WorldPosition | WorldEuler | WorldQuat */ "WmWpWeWq"] = 0x9c] = "WmWpWeWq";
10766
10915
  TransformModifyFlags[TransformModifyFlags[/** WorldMatrix | WorldScale */ "WmWs"] = 0xa0] = "WmWs";
10916
+ TransformModifyFlags[TransformModifyFlags[/** WorldMatrix | WorldScale | WorldUniformScaling */ "WmWsWus"] = 0x1a0] = "WmWsWus";
10767
10917
  TransformModifyFlags[TransformModifyFlags[/** WorldMatrix | WorldPosition | WorldScale */ "WmWpWs"] = 0xa4] = "WmWpWs";
10768
10918
  TransformModifyFlags[TransformModifyFlags[/** WorldMatrix | WorldPosition | WorldEuler | WorldQuat | WorldScale */ "WmWpWeWqWs"] = 0xbc] = "WmWpWeWqWs";
10919
+ TransformModifyFlags[TransformModifyFlags[/** WorldMatrix | WorldPosition | WorldEuler | WorldQuat | WorldScale | WorldUniformScaling */ "WmWpWeWqWsWus"] = 0x1bc] = "WmWpWeWqWsWus";
10769
10920
  })(TransformModifyFlags || (TransformModifyFlags = {}));
10770
10921
  // @ts-ignore
10771
10922
  var _Renderer;
@@ -13076,11 +13227,13 @@
13076
13227
  * @param viewport - Viewport
13077
13228
  * @param material - The material to use when blitting
13078
13229
  * @param passIndex - Pass index to use of the provided material
13079
- */ PipelineUtils.blitTexture = function blitTexture(engine, source, destination, mipLevel, viewport, material, passIndex) {
13230
+ * @param flipYOfSource - Whether flip Y axis of source texture
13231
+ */ PipelineUtils.blitTexture = function blitTexture(engine, source, destination, mipLevel, viewport, material, passIndex, flipYOfSource) {
13080
13232
  if (mipLevel === void 0) mipLevel = 0;
13081
13233
  if (viewport === void 0) viewport = PipelineUtils.defaultViewport;
13082
13234
  if (material === void 0) material = null;
13083
13235
  if (passIndex === void 0) passIndex = 0;
13236
+ if (flipYOfSource === void 0) flipYOfSource = false;
13084
13237
  var basicResources = engine._basicResources;
13085
13238
  var blitMesh = destination ? basicResources.flipYBlitMesh : basicResources.blitMesh;
13086
13239
  var blitMaterial = material || basicResources.blitMaterial;
@@ -13094,9 +13247,15 @@
13094
13247
  rendererShaderData.setFloat(PipelineUtils._blitMipLevelProperty, mipLevel);
13095
13248
  PipelineUtils._texelSize.set(1 / source.width, 1 / source.height, source.width, source.height);
13096
13249
  rendererShaderData.setVector4(PipelineUtils._blitTexelSizeProperty, PipelineUtils._texelSize);
13250
+ if (flipYOfSource) {
13251
+ rendererShaderData.enableMacro(PipelineUtils._flipYTextureMacro);
13252
+ } else {
13253
+ rendererShaderData.disableMacro(PipelineUtils._flipYTextureMacro);
13254
+ }
13097
13255
  var pass = blitMaterial.shader.subShaders[0].passes[passIndex];
13098
13256
  var compileMacros = Shader._compileMacros;
13099
- ShaderMacroCollection.unionCollection(context.camera._globalShaderMacro, blitMaterial.shaderData._macroCollection, compileMacros);
13257
+ ShaderMacroCollection.unionCollection(context.camera._globalShaderMacro, rendererShaderData._macroCollection, compileMacros);
13258
+ ShaderMacroCollection.unionCollection(compileMacros, blitMaterial.shaderData._macroCollection, compileMacros);
13100
13259
  var program = pass._getShaderProgram(engine, compileMacros);
13101
13260
  program.bind();
13102
13261
  program.groupingOtherUniformBlock();
@@ -13118,6 +13277,9 @@
13118
13277
  PipelineUtils._blitTexelSizeProperty = ShaderProperty.getByName("renderer_texelSize") // x: 1/width, y: 1/height, z: width, w: height
13119
13278
  ;
13120
13279
  })();
13280
+ (function() {
13281
+ PipelineUtils._flipYTextureMacro = ShaderMacro.getByName("renderer_FlipYBlitTexture");
13282
+ })();
13121
13283
  (function() {
13122
13284
  PipelineUtils._rendererShaderData = new ShaderData(ShaderDataGroup.Renderer);
13123
13285
  })();
@@ -13231,7 +13393,7 @@
13231
13393
  /**
13232
13394
  * Multi-sample anti-aliasing samples when use independent canvas mode.
13233
13395
  *
13234
- * @remarks The `independentCanvasEnabled` property should be `true` to take effect, otherwise it will be invalid.
13396
+ * @remarks It will take effect when `independentCanvasEnabled` property is `true`, otherwise it will be invalid.
13235
13397
  */ _this.msaaSamples = exports.MSAASamples.None;
13236
13398
  /** @internal */ _this._cameraType = exports.CameraType.Normal;
13237
13399
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
@@ -13593,13 +13755,17 @@
13593
13755
  key: "independentCanvasEnabled",
13594
13756
  get: /**
13595
13757
  * Whether independent canvas is enabled.
13596
- *
13597
13758
  * @remarks If true, the msaa in viewport can turn or off independently by `msaaSamples` property.
13598
13759
  */ function get() {
13599
- if (this.enableHDR || this.enablePostProcess && this.scene._postProcessManager.hasActiveEffect) {
13760
+ // Uber pass need internal RT
13761
+ if (this.enablePostProcess && this.scene._postProcessManager.hasActiveEffect) {
13600
13762
  return true;
13601
13763
  }
13602
- return this.opaqueTextureEnabled && !this._renderTarget;
13764
+ if (this.enableHDR || this.opaqueTextureEnabled) {
13765
+ var _this_renderTarget;
13766
+ return this._getInternalColorTextureFormat() !== ((_this_renderTarget = this.renderTarget) == null ? void 0 : _this_renderTarget.getColorTexture(0).format);
13767
+ }
13768
+ return false;
13603
13769
  }
13604
13770
  },
13605
13771
  {
@@ -14098,8 +14264,15 @@
14098
14264
  if (shaderPass.getTagValue(pipelineStageKey) !== pipelineStageTagValue) {
14099
14265
  continue;
14100
14266
  }
14101
- var _shaderPass__renderState;
14102
- if (((_shaderPass__renderState = shaderPass._renderState) != null ? _shaderPass__renderState : renderStates[j]).renderQueueType !== renderQueueType) {
14267
+ var renderState = shaderPass._renderState;
14268
+ var passQueueType = void 0;
14269
+ if (renderState) {
14270
+ passQueueType = renderState._getRenderQueueByShaderData(shaderPass._renderStateDataMap, materialData);
14271
+ } else {
14272
+ renderState = renderStates[j];
14273
+ passQueueType = renderState.renderQueueType;
14274
+ }
14275
+ if (passQueueType !== renderQueueType) {
14103
14276
  continue;
14104
14277
  }
14105
14278
  var program = shaderPass._getShaderProgram(engine, compileMacros);
@@ -14153,8 +14326,6 @@
14153
14326
  program.uploadUnGroupTextures();
14154
14327
  }
14155
14328
  }
14156
- var _shaderPass__renderState1;
14157
- var renderState = (_shaderPass__renderState1 = shaderPass._renderState) != null ? _shaderPass__renderState1 : renderStates[j];
14158
14329
  renderState._applyStates(engine, renderer.entity.transform._isFrontFaceInvert(), shaderPass._renderStateDataMap, material.shaderData);
14159
14330
  rhi.drawPrimitive(primitive, subElement.subPrimitive, program);
14160
14331
  }
@@ -15101,6 +15272,8 @@
15101
15272
  var BasicRenderPipeline = function BasicRenderPipeline(camera) {
15102
15273
  this._lastCanvasSize = new Vector2();
15103
15274
  this._internalColorTarget = null;
15275
+ this._canUseBlitFrameBuffer = false;
15276
+ this._shouldGrabColor = false;
15104
15277
  this._camera = camera;
15105
15278
  var engine = camera.engine;
15106
15279
  this._cullingResults = new CullingResults();
@@ -15125,10 +15298,19 @@
15125
15298
  context.rendererUpdateFlag = ContextRendererUpdateFlag.All;
15126
15299
  var camera = this._camera;
15127
15300
  var scene = camera.scene, engine = camera.engine;
15301
+ var rhi = engine._hardwareRenderer;
15128
15302
  var cullingResults = this._cullingResults;
15129
15303
  var sunlight = scene._lightManager._sunlight;
15130
15304
  var depthOnlyPass = this._depthOnlyPass;
15131
15305
  var depthPassEnabled = camera.depthTextureMode === exports.DepthTextureMode.PrePass && depthOnlyPass._supportDepthTexture;
15306
+ var finalClearFlags = camera.clearFlags & ~(ignoreClear != null ? ignoreClear : exports.CameraClearFlags.None);
15307
+ var independentCanvasEnabled = camera.independentCanvasEnabled;
15308
+ var msaaSamples = camera.renderTarget ? camera.renderTarget.antiAliasing : camera.msaaSamples;
15309
+ this._shouldGrabColor = independentCanvasEnabled && !(finalClearFlags & exports.CameraClearFlags.Color);
15310
+ // 1. Only support blitFramebuffer in webgl2 context
15311
+ // 2. Can't blit normal FBO to MSAA FBO
15312
+ // 3. Can't blit screen MSAA FBO to normal FBO in mac safari platform and mobile, but mac chrome and firfox is OK
15313
+ this._canUseBlitFrameBuffer = rhi.isWebGL2 && msaaSamples === 1 && (!!camera.renderTarget || !rhi.context.antialias);
15132
15314
  if (scene.castShadows && sunlight && sunlight.shadowType !== exports.ShadowType.None) {
15133
15315
  this._cascadedShadowCasterPass.onRender(context);
15134
15316
  context.rendererUpdateFlag = ContextRendererUpdateFlag.None;
@@ -15148,24 +15330,46 @@
15148
15330
  } else {
15149
15331
  camera.shaderData.setTexture(exports.Camera._cameraDepthTextureProperty, engine._basicResources.whiteTexture2D);
15150
15332
  }
15151
- // Check if need to create internal color texture
15152
- var independentCanvasEnabled = camera.independentCanvasEnabled;
15333
+ // Check if need to create internal color texture or grab texture
15153
15334
  if (independentCanvasEnabled) {
15335
+ var depthFormat;
15336
+ if (camera.renderTarget) {
15337
+ depthFormat = camera.renderTarget._depthFormat;
15338
+ } else if (rhi.context.depth && rhi.context.stencil) {
15339
+ depthFormat = exports.TextureFormat.Depth24Stencil8;
15340
+ } else if (rhi.context.depth) {
15341
+ depthFormat = exports.TextureFormat.Depth24;
15342
+ } else if (rhi.context.stencil) {
15343
+ depthFormat = exports.TextureFormat.Stencil;
15344
+ } else {
15345
+ depthFormat = null;
15346
+ }
15154
15347
  var viewport = camera.pixelViewport;
15155
- 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);
15348
+ var internalColorTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._internalColorTarget, viewport.width, viewport.height, camera._getInternalColorTextureFormat(), depthFormat, false, false, msaaSamples, exports.TextureWrapMode.Clamp, exports.TextureFilterMode.Bilinear);
15349
+ if (!this._canUseBlitFrameBuffer && this._shouldGrabColor) {
15350
+ var _camera_renderTarget;
15351
+ var _camera_renderTarget_getColorTexture_format;
15352
+ 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);
15353
+ this._grabTexture = grabTexture;
15354
+ }
15156
15355
  this._internalColorTarget = internalColorTarget;
15157
15356
  } else {
15158
15357
  var internalColorTarget1 = this._internalColorTarget;
15358
+ var grabTexture1 = this._grabTexture;
15159
15359
  if (internalColorTarget1) {
15160
15360
  var _internalColorTarget_getColorTexture;
15161
15361
  (_internalColorTarget_getColorTexture = internalColorTarget1.getColorTexture(0)) == null ? void 0 : _internalColorTarget_getColorTexture.destroy(true);
15162
15362
  internalColorTarget1.destroy(true);
15163
15363
  this._internalColorTarget = null;
15164
15364
  }
15365
+ if (grabTexture1) {
15366
+ grabTexture1.destroy(true);
15367
+ this._grabTexture = null;
15368
+ }
15165
15369
  }
15166
- this._drawRenderPass(context, camera, cubeFace, mipLevel, ignoreClear);
15370
+ this._drawRenderPass(context, camera, finalClearFlags, cubeFace, mipLevel);
15167
15371
  };
15168
- _proto._drawRenderPass = function _drawRenderPass(context, camera, cubeFace, mipLevel, ignoreClear) {
15372
+ _proto._drawRenderPass = function _drawRenderPass(context, camera, finalClearFlags, cubeFace, mipLevel) {
15169
15373
  var _cameraRenderTarget, _cameraRenderTarget1;
15170
15374
  var cullingResults = this._cullingResults;
15171
15375
  var opaqueQueue = cullingResults.opaqueQueue, alphaTestQueue = cullingResults.alphaTestQueue, transparentQueue = cullingResults.transparentQueue;
@@ -15182,14 +15386,33 @@
15182
15386
  context.applyVirtualCamera(camera._virtualCamera, needFlipProjection);
15183
15387
  }
15184
15388
  rhi.activeRenderTarget(colorTarget, colorViewport, context.flipProjection, mipLevel, cubeFace);
15185
- var clearFlags = camera.clearFlags & ~(ignoreClear != null ? ignoreClear : exports.CameraClearFlags.None);
15186
15389
  var color = background.solidColor;
15187
- if (clearFlags !== exports.CameraClearFlags.None) {
15188
- rhi.clearRenderTarget(camera.engine, clearFlags, color);
15390
+ if (internalColorTarget && finalClearFlags !== exports.CameraClearFlags.All) {
15391
+ // Can use `blitFramebuffer` API to copy color/depth/stencil buffer from back buffer to internal RT
15392
+ if (this._canUseBlitFrameBuffer) {
15393
+ finalClearFlags !== exports.CameraClearFlags.None && rhi.clearRenderTarget(engine, finalClearFlags, color);
15394
+ rhi.blitInternalRTByBlitFrameBuffer(camera.renderTarget, internalColorTarget, finalClearFlags, camera.viewport);
15395
+ } else {
15396
+ if (!(finalClearFlags & exports.CameraClearFlags.Depth) || !(finalClearFlags & exports.CameraClearFlags.Stencil)) {
15397
+ 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");
15398
+ }
15399
+ if (this._shouldGrabColor) {
15400
+ rhi.clearRenderTarget(engine, exports.CameraClearFlags.DepthStencil);
15401
+ // Copy RT's color buffer to grab texture
15402
+ rhi.copyRenderTargetToSubTexture(camera.renderTarget, this._grabTexture, camera.viewport);
15403
+ // Then blit grab texture to internal RT's color buffer
15404
+ PipelineUtils.blitTexture(engine, this._grabTexture, internalColorTarget, 0, undefined, undefined, undefined, !camera.renderTarget);
15405
+ } else {
15406
+ rhi.clearRenderTarget(engine, exports.CameraClearFlags.All, color);
15407
+ }
15408
+ }
15409
+ rhi.activeRenderTarget(colorTarget, colorViewport, context.flipProjection, mipLevel, cubeFace);
15410
+ } else if (finalClearFlags !== exports.CameraClearFlags.None) {
15411
+ rhi.clearRenderTarget(engine, finalClearFlags, color);
15189
15412
  }
15190
15413
  opaqueQueue.render(context, exports.PipelineStage.Forward);
15191
15414
  alphaTestQueue.render(context, exports.PipelineStage.Forward);
15192
- if (clearFlags & exports.CameraClearFlags.Color) {
15415
+ if (finalClearFlags & exports.CameraClearFlags.Color) {
15193
15416
  if (background.mode === exports.BackgroundMode.Sky) {
15194
15417
  background.sky._render(context);
15195
15418
  } else if (background.mode === exports.BackgroundMode.Texture && background.texture) {
@@ -15264,8 +15487,7 @@
15264
15487
  var shaderPass = shaderPasses[i];
15265
15488
  var renderState = shaderPass._renderState;
15266
15489
  if (renderState) {
15267
- renderState._applyRenderQueueByShaderData(shaderPass._renderStateDataMap, subRenderElement.material.shaderData);
15268
- renderQueueType = renderState.renderQueueType;
15490
+ renderQueueType = renderState._getRenderQueueByShaderData(shaderPass._renderStateDataMap, subRenderElement.material.shaderData);
15269
15491
  } else {
15270
15492
  renderQueueType = renderStates[i].renderQueueType;
15271
15493
  }
@@ -27996,7 +28218,7 @@
27996
28218
  (function() {
27997
28219
  ParticleBufferUtils.boundsMaxLifetimeOffset = 7;
27998
28220
  })();
27999
- 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
28221
+ 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
28000
28222
  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
28001
28223
  var skyProceduralFs = "#define GLSLIFY 1\n#include <common>\nconst float MIE_G=-0.990;const float MIE_G2=0.9801;const float SKY_GROUND_THRESHOLD=0.02;uniform float material_SunSize;uniform float material_SunSizeConvergence;uniform vec4 scene_SunlightColor;uniform vec3 scene_SunlightDirection;varying vec3 v_GroundColor;varying vec3 v_SkyColor;\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nvarying vec3 v_Vertex;\n#elif defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_RayDir;\n#else\nvarying float v_SkyGroundFactor;\n#endif\n#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_SunColor;\n#endif\n#if defined(ENGINE_IS_COLORSPACE_GAMMA)\n#define LINEAR_2_OUTPUT(color) sqrt(color)\n#endif\nfloat getMiePhase(float eyeCos,float eyeCos2){float temp=1.0+MIE_G2-2.0*MIE_G*eyeCos;temp=pow(temp,pow(material_SunSize,0.65)*10.0);temp=max(temp,1.0e-4);temp=1.5*((1.0-MIE_G2)/(2.0+MIE_G2))*(1.0+eyeCos2)/temp;return temp;}float calcSunAttenuation(vec3 lightPos,vec3 ray){\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nfloat focusedEyeCos=pow(clamp(dot(lightPos,ray),0.0,1.0),material_SunSizeConvergence);return getMiePhase(-focusedEyeCos,focusedEyeCos*focusedEyeCos);\n#else\nvec3 delta=lightPos-ray;float dist=length(delta);float spot=1.0-smoothstep(0.0,material_SunSize,dist);return spot*spot;\n#endif\n}void main(){vec3 col=vec3(0.0,0.0,0.0);\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nvec3 ray=normalize(v_Vertex);float y=ray.y/SKY_GROUND_THRESHOLD;\n#elif defined(MATERIAL_SUN_SIMPLE)\nvec3 ray=v_RayDir;float y=ray.y/SKY_GROUND_THRESHOLD;\n#else\nfloat y=v_SkyGroundFactor;\n#endif\ncol=mix(v_SkyColor,v_GroundColor,clamp(y,0.0,1.0));\n#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\nif(y<0.0)col+=v_SunColor*calcSunAttenuation(-scene_SunlightDirection,-ray);\n#endif\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\ncol=LINEAR_2_OUTPUT(col);\n#endif\ngl_FragColor=vec4(col,1.0);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"; // eslint-disable-line
28002
28224
  var skyProceduralVs = "#define GLSLIFY 1\n#define OUTER_RADIUS 1.025\n#define RAYLEIGH (mix(0.0, 0.0025, pow(material_AtmosphereThickness,2.5)))\n#define MIE 0.0010\n#define SUN_BRIGHTNESS 20.0\n#define MAX_SCATTER 50.0\nconst float SKY_GROUND_THRESHOLD=0.02;const float outerRadius=OUTER_RADIUS;const float outerRadius2=OUTER_RADIUS*OUTER_RADIUS;const float innerRadius=1.0;const float innerRadius2=1.0;const float cameraHeight=0.0001;const float HDSundiskIntensityFactor=15.0;const float simpleSundiskIntensityFactor=27.0;const float sunScale=400.0*SUN_BRIGHTNESS;const float kmESun=MIE*SUN_BRIGHTNESS;const float km4PI=MIE*4.0*3.14159265;const float scale=1.0/(OUTER_RADIUS-1.0);const float scaleDepth=0.25;const float scaleOverScaleDepth=(1.0/(OUTER_RADIUS-1.0))/0.25;const float samples=2.0;const vec3 c_DefaultScatteringWavelength=vec3(0.65,0.57,0.475);const vec3 c_VariableRangeForScatteringWavelength=vec3(0.15,0.15,0.15);attribute vec4 POSITION;uniform mat4 camera_VPMat;uniform vec3 material_SkyTint;uniform vec3 material_GroundTint;uniform float material_Exposure;uniform float material_AtmosphereThickness;uniform vec4 scene_SunlightColor;uniform vec3 scene_SunlightDirection;varying vec3 v_GroundColor;varying vec3 v_SkyColor;\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nvarying vec3 v_Vertex;\n#elif defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_RayDir;\n#else\nvarying float v_SkyGroundFactor;\n#endif\n#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_SunColor;\n#endif\n#if defined(ENGINE_IS_COLORSPACE_GAMMA)\n#define COLOR_2_GAMMA(color) color\n#define COLOR_2_LINEAR(color) color*color\n#else\n#define GAMMA 2.2\n#define COLOR_2_GAMMA(color) pow(color,vec3(1.0/GAMMA))\n#define COLOR_2_LINEAR(color) color\n#endif\nfloat getRayleighPhase(vec3 light,vec3 ray){float eyeCos=dot(light,ray);return 0.75+0.75*eyeCos*eyeCos;}float scaleAngle(float inCos){float x=1.0-inCos;return 0.25*exp(-0.00287+x*(0.459+x*(3.83+x*(-6.80+x*5.25))));}void main(){gl_Position=camera_VPMat*vec4(POSITION.xyz,1.0);vec3 skyTintInGammaSpace=COLOR_2_GAMMA(material_SkyTint);vec3 scatteringWavelength=mix(c_DefaultScatteringWavelength-c_VariableRangeForScatteringWavelength,c_DefaultScatteringWavelength+c_VariableRangeForScatteringWavelength,vec3(1.0)-skyTintInGammaSpace);vec3 invWavelength=1.0/pow(scatteringWavelength,vec3(4.0));float krESun=RAYLEIGH*SUN_BRIGHTNESS;float kr4PI=RAYLEIGH*4.0*3.14159265;vec3 cameraPos=vec3(0.0,innerRadius+cameraHeight,0.0);vec3 eyeRay=normalize(POSITION.xyz);float far=0.0;vec3 cIn,cOut;if(eyeRay.y>=0.0){far=sqrt(outerRadius2+innerRadius2*eyeRay.y*eyeRay.y-innerRadius2)-innerRadius*eyeRay.y;float height=innerRadius+cameraHeight;float depth=exp(scaleOverScaleDepth*-cameraHeight);float startAngle=dot(eyeRay,cameraPos)/height;float startOffset=depth*scaleAngle(startAngle);float sampleLength=far/samples;float scaledLength=sampleLength*scale;vec3 sampleRay=eyeRay*sampleLength;vec3 samplePoint=cameraPos+sampleRay*0.5;vec3 frontColor=vec3(0.0);{float height=length(samplePoint);float depth=exp(scaleOverScaleDepth*(innerRadius-height));float lightAngle=dot(-scene_SunlightDirection,samplePoint)/height;float cameraAngle=dot(eyeRay,samplePoint)/height;float scatter=(startOffset+depth*(scaleAngle(lightAngle)-scaleAngle(cameraAngle)));vec3 attenuate=exp(-clamp(scatter,0.0,MAX_SCATTER)*(invWavelength*kr4PI+km4PI));frontColor+=attenuate*(depth*scaledLength);samplePoint+=sampleRay;}{float height=length(samplePoint);float depth=exp(scaleOverScaleDepth*(innerRadius-height));float lightAngle=dot(-scene_SunlightDirection,samplePoint)/height;float cameraAngle=dot(eyeRay,samplePoint)/height;float scatter=(startOffset+depth*(scaleAngle(lightAngle)-scaleAngle(cameraAngle)));vec3 attenuate=exp(-clamp(scatter,0.0,MAX_SCATTER)*(invWavelength*kr4PI+km4PI));frontColor+=attenuate*(depth*scaledLength);samplePoint+=sampleRay;}cIn=frontColor*(invWavelength*krESun);cOut=frontColor*kmESun;}else{far=(-cameraHeight)/(min(-0.001,eyeRay.y));vec3 pos=cameraPos+far*eyeRay;float depth=exp((-cameraHeight)*(1.0/scaleDepth));float cameraAngle=dot(-eyeRay,pos);float lightAngle=dot(-scene_SunlightDirection,pos);float cameraScale=scaleAngle(cameraAngle);float lightScale=scaleAngle(lightAngle);float cameraOffset=depth*cameraScale;float temp=lightScale+cameraScale;float sampleLength=far/samples;float scaledLength=sampleLength*scale;vec3 sampleRay=eyeRay*sampleLength;vec3 samplePoint=cameraPos+sampleRay*0.5;vec3 frontColor=vec3(0.0,0.0,0.0);vec3 attenuate;{float height=length(samplePoint);float depth=exp(scaleOverScaleDepth*(innerRadius-height));float scatter=depth*temp-cameraOffset;attenuate=exp(-clamp(scatter,0.0,MAX_SCATTER)*(invWavelength*kr4PI+km4PI));frontColor+=attenuate*(depth*scaledLength);samplePoint+=sampleRay;}cIn=frontColor*(invWavelength*krESun+kmESun);cOut=clamp(attenuate,0.0,1.0);}\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nv_Vertex=-POSITION.xyz;\n#elif defined(MATERIAL_SUN_SIMPLE)\nv_RayDir=-eyeRay;\n#else\nv_SkyGroundFactor=-eyeRay.y/SKY_GROUND_THRESHOLD;\n#endif\nv_GroundColor=material_Exposure*(cIn+COLOR_2_LINEAR(material_GroundTint)*cOut);v_SkyColor=material_Exposure*(cIn*getRayleighPhase(-scene_SunlightDirection,-eyeRay));float lightColorIntensity=clamp(length(scene_SunlightColor.xyz),0.25,1.0);\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nv_SunColor=HDSundiskIntensityFactor*clamp(cOut,0.0,1.0)*scene_SunlightColor.xyz/lightColorIntensity;\n#elif defined(MATERIAL_SUN_SIMPLE)\nv_SunColor=simpleSundiskIntensityFactor*clamp(cOut*sunScale,0.0,1.0)*scene_SunlightColor.xyz/lightColorIntensity;\n#endif\n}"; // eslint-disable-line
@@ -33790,13 +34012,11 @@
33790
34012
  return true;
33791
34013
  };
33792
34014
  _proto._applyTransition = function _applyTransition(layerIndex, layerData, layer, transition, aniUpdate) {
33793
- // Need prepare first, it should crossFade when to exit
33794
- var success = this._prepareCrossFadeByTransition(transition, layerIndex);
33795
34015
  if (transition.isExit) {
33796
34016
  this._checkAnyAndEntryState(layerIndex, layerData, layer, 0, aniUpdate);
33797
- return true;
34017
+ return false;
33798
34018
  }
33799
- return success;
34019
+ return this._prepareCrossFadeByTransition(transition, layerIndex);
33800
34020
  };
33801
34021
  _proto._checkConditions = function _checkConditions(state, transition) {
33802
34022
  var _state;
@@ -39137,6 +39357,72 @@
39137
39357
  };
39138
39358
  return CubeProbe;
39139
39359
  }(Probe);
39360
+ /**
39361
+ * @internal
39362
+ */ var Polyfill = /*#__PURE__*/ function() {
39363
+ var Polyfill = function Polyfill() {};
39364
+ Polyfill.registerPolyfill = function registerPolyfill() {
39365
+ Polyfill._registerMatchAll();
39366
+ };
39367
+ Polyfill._registerMatchAll = function _registerMatchAll() {
39368
+ if (!String.prototype.matchAll) {
39369
+ Logger.info("polyfill String.prototype.matchAll");
39370
+ String.prototype.matchAll = function(pattern) {
39371
+ var flags = pattern.flags;
39372
+ var globalFlagIdx = flags.indexOf("g");
39373
+ if (globalFlagIdx === -1) {
39374
+ throw TypeError("String.prototype.matchAll called with a non-global RegExp argument");
39375
+ }
39376
+ var bindThis = this;
39377
+ return function() {
39378
+ var matchResult, matchFlag, matchPattern, _tmp, _tmp1, _i, index, item;
39379
+ return __generator$1(this, function(_state) {
39380
+ switch(_state.label){
39381
+ case 0:
39382
+ matchResult = bindThis.match(pattern);
39383
+ if (matchResult == null) return [
39384
+ 2,
39385
+ null
39386
+ ];
39387
+ matchFlag = flags.split("g").join("");
39388
+ matchPattern = new RegExp(pattern.source, matchFlag);
39389
+ _tmp = [];
39390
+ for(_tmp1 in matchResult)_tmp.push(_tmp1);
39391
+ _i = 0;
39392
+ _state.label = 1;
39393
+ case 1:
39394
+ if (!(_i < _tmp.length)) return [
39395
+ 3,
39396
+ 4
39397
+ ];
39398
+ index = _tmp[_i];
39399
+ item = matchResult[index];
39400
+ return [
39401
+ 4,
39402
+ item.match(matchPattern)
39403
+ ];
39404
+ case 2:
39405
+ _state.sent();
39406
+ _state.label = 3;
39407
+ case 3:
39408
+ _i++;
39409
+ return [
39410
+ 3,
39411
+ 1
39412
+ ];
39413
+ case 4:
39414
+ return [
39415
+ 2
39416
+ ];
39417
+ }
39418
+ });
39419
+ }();
39420
+ };
39421
+ }
39422
+ };
39423
+ return Polyfill;
39424
+ }();
39425
+ Polyfill.registerPolyfill();
39140
39426
 
39141
39427
  var CoreObjects = /*#__PURE__*/Object.freeze({
39142
39428
  __proto__: null,
@@ -41246,7 +41532,7 @@
41246
41532
  var gl = this._gl;
41247
41533
  var _engine__lastRenderState = engine._lastRenderState, targetBlendState = _engine__lastRenderState.blendState.targetBlendState, depthState = _engine__lastRenderState.depthState, stencilState = _engine__lastRenderState.stencilState;
41248
41534
  var clearFlag = 0;
41249
- if (clearFlags & exports.CameraClearFlags.Color) {
41535
+ if (clearFlags & exports.CameraClearFlags.Color && clearColor) {
41250
41536
  clearFlag |= gl.COLOR_BUFFER_BIT;
41251
41537
  var lc = this._lastClearColor;
41252
41538
  var r = clearColor.r, g = clearColor.g, b = clearColor.b, a = clearColor.a;
@@ -41310,6 +41596,75 @@
41310
41596
  this.viewport(x, y, width, height);
41311
41597
  this.scissor(x, y, width, height);
41312
41598
  };
41599
+ _proto.blitInternalRTByBlitFrameBuffer = function blitInternalRTByBlitFrameBuffer(srcRT, destRT, clearFlags, viewport) {
41600
+ if (!this._isWebGL2) {
41601
+ Logger.warn("WebGL1.0 not support blit frame buffer.");
41602
+ return;
41603
+ }
41604
+ var gl = this._gl;
41605
+ // @ts-ignore
41606
+ var srcFrameBuffer = srcRT ? srcRT._platformRenderTarget._frameBuffer : null;
41607
+ // @ts-ignore
41608
+ var destFrameBuffer = destRT ? destRT._platformRenderTarget._frameBuffer : null;
41609
+ var bufferWidth = this.getMainFrameBufferWidth();
41610
+ var bufferHeight = this.getMainFrameBufferHeight();
41611
+ var srcWidth = srcRT ? srcRT.width : bufferWidth;
41612
+ var srcHeight = srcRT ? srcRT.height : bufferHeight;
41613
+ var blitWidth = destRT.width;
41614
+ var blitHeight = destRT.height;
41615
+ var needFlipY = !srcRT;
41616
+ var needBlitColor = (clearFlags & exports.CameraClearFlags.Color) === 0;
41617
+ var needBlitDepth = (clearFlags & exports.CameraClearFlags.Depth) === 0;
41618
+ var needBlitStencil = (clearFlags & exports.CameraClearFlags.Stencil) === 0;
41619
+ gl.bindFramebuffer(gl.READ_FRAMEBUFFER, srcFrameBuffer);
41620
+ gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, destFrameBuffer);
41621
+ var blitMask = needBlitColor ? gl.COLOR_BUFFER_BIT : 0;
41622
+ if (needBlitDepth || needBlitStencil) {
41623
+ // @ts-ignore
41624
+ var depthFormat = destRT._depthFormat;
41625
+ if (needBlitDepth) {
41626
+ if (depthFormat === exports.TextureFormat.Depth || depthFormat >= exports.TextureFormat.DepthStencil && depthFormat <= exports.TextureFormat.Depth32Stencil8) {
41627
+ blitMask |= gl.DEPTH_BUFFER_BIT;
41628
+ } else {
41629
+ Logger.warn("Do not clear depth, or set depth format of target which is " + exports.TextureFormat[depthFormat] + " now.");
41630
+ }
41631
+ }
41632
+ if (needBlitStencil) {
41633
+ if (depthFormat === exports.TextureFormat.Stencil || depthFormat === exports.TextureFormat.DepthStencil || depthFormat >= exports.TextureFormat.Depth24Stencil8 || depthFormat >= exports.TextureFormat.Depth32Stencil8) {
41634
+ blitMask |= gl.STENCIL_BUFFER_BIT;
41635
+ } else {
41636
+ Logger.warn("Do not clear stencil, or set stencil format of target which is " + exports.TextureFormat[depthFormat] + " now.");
41637
+ }
41638
+ }
41639
+ }
41640
+ var xStart = viewport.x * srcWidth;
41641
+ var xEnd = xStart + blitWidth;
41642
+ var yStart = needFlipY ? srcHeight - viewport.y * srcHeight : srcHeight - viewport.y * srcHeight - blitHeight;
41643
+ var yEnd = needFlipY ? yStart - blitHeight : yStart + blitHeight;
41644
+ gl.blitFramebuffer(xStart, yStart, xEnd, yEnd, 0, 0, blitWidth, blitHeight, blitMask, gl.NEAREST);
41645
+ };
41646
+ _proto.copyRenderTargetToSubTexture = function copyRenderTargetToSubTexture(srcRT, grabTexture, viewport) {
41647
+ var _srcRT;
41648
+ var gl = this._gl;
41649
+ var bufferWidth = this.getMainFrameBufferWidth();
41650
+ var bufferHeight = this.getMainFrameBufferHeight();
41651
+ var srcWidth = srcRT ? srcRT.width : bufferWidth;
41652
+ var srcHeight = srcRT ? srcRT.height : bufferHeight;
41653
+ var copyWidth = grabTexture.width;
41654
+ var copyHeight = grabTexture.height;
41655
+ var flipY = !srcRT;
41656
+ var xStart = viewport.x * srcWidth;
41657
+ var yStart = flipY ? srcHeight - viewport.y * srcHeight - copyHeight : viewport.y * srcHeight;
41658
+ var _srcRT__platformRenderTarget__frameBuffer;
41659
+ // @ts-ignore
41660
+ var frameBuffer = (_srcRT__platformRenderTarget__frameBuffer = (_srcRT = srcRT) == null ? void 0 : _srcRT._platformRenderTarget._frameBuffer) != null ? _srcRT__platformRenderTarget__frameBuffer : null;
41661
+ // @ts-ignore
41662
+ gl.bindFramebuffer(gl.FRAMEBUFFER, frameBuffer);
41663
+ // @ts-ignore
41664
+ var glTexture = grabTexture._platformTexture;
41665
+ glTexture._bind();
41666
+ gl.copyTexSubImage2D(glTexture._target, 0, 0, 0, xStart, yStart, copyWidth, copyHeight);
41667
+ };
41313
41668
  _proto.activeTexture = function activeTexture(textureID) {
41314
41669
  if (this._activeTextureID !== textureID) {
41315
41670
  this._gl.activeTexture(textureID);
@@ -41370,6 +41725,7 @@
41370
41725
  if (debugRenderInfo != null) {
41371
41726
  this._renderer = gl.getParameter(debugRenderInfo.UNMASKED_RENDERER_WEBGL);
41372
41727
  }
41728
+ this._contextAttributes = gl.getContextAttributes();
41373
41729
  };
41374
41730
  _proto.destroy = function destroy() {
41375
41731
  var webCanvas = this._webCanvas;
@@ -41426,6 +41782,12 @@
41426
41782
  get: function get() {
41427
41783
  return this.capability.canIUseMoreJoints;
41428
41784
  }
41785
+ },
41786
+ {
41787
+ key: "context",
41788
+ get: function get() {
41789
+ return this._contextAttributes;
41790
+ }
41429
41791
  }
41430
41792
  ]);
41431
41793
  return WebGLGraphicDevice;
@@ -47821,7 +48183,7 @@
47821
48183
  };
47822
48184
  return ShaderChunkLoader1;
47823
48185
  }(Loader), function() {
47824
- _ShaderChunkLoader._shaderIncludeRegex = /\s#include\s+"([./][^\\"]+)"/gm;
48186
+ _ShaderChunkLoader._shaderIncludeRegex = /#include\s+"([./][^\\"]+)"/gm;
47825
48187
  }(), _ShaderChunkLoader);
47826
48188
  ShaderChunkLoader = __decorate([
47827
48189
  resourceLoader("ShaderChunk", [
@@ -48427,7 +48789,7 @@
48427
48789
  ], EXT_texture_webp);
48428
48790
 
48429
48791
  //@ts-ignore
48430
- var version = "1.3.24";
48792
+ var version = "1.3.25";
48431
48793
  console.log("Galacean engine version: " + version);
48432
48794
  for(var key in CoreObjects){
48433
48795
  Loader.registerClass(key, CoreObjects[key]);