@galacean/engine-core 0.0.0-experimental-shaderlab.0 → 0.0.0-experimental-renderSort.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -1947,13 +1947,15 @@ var Logger = {
1947
1947
  ];
1948
1948
  })();
1949
1949
  (function() {
1950
- /** These characters are all tall to help calculate the height required for text. */ TextUtils._measureString = "|\xc9q\xc5";
1950
+ // _heightMultiplier used to measure the height of text, but in miniprogram performance is different from h5.
1951
+ // so can set _heightMultiplier to adapt miniprogram, the larger the value, the worse the performance.
1952
+ /** @internal */ TextUtils._heightMultiplier = 2;
1951
1953
  })();
1952
1954
  (function() {
1953
- TextUtils._measureBaseline = "M";
1955
+ /** These characters are all tall to help calculate the height required for text. */ TextUtils._measureString = "|\xc9q\xc5";
1954
1956
  })();
1955
1957
  (function() {
1956
- TextUtils._heightMultiplier = 2;
1958
+ TextUtils._measureBaseline = "M";
1957
1959
  })();
1958
1960
  (function() {
1959
1961
  TextUtils._baselineMultiplier = 1.4;
@@ -2036,7 +2038,8 @@ var Logger = {
2036
2038
  _proto._createFontAtlas = function _createFontAtlas() {
2037
2039
  var _this = this, engine = _this._engine;
2038
2040
  var fontAtlas = new FontAtlas(engine);
2039
- var texture = new Texture2D(engine, 256, 256);
2041
+ var texture = new Texture2D(engine, 256, 256, exports.TextureFormat.R8G8B8A8, false);
2042
+ texture.filterMode = exports.TextureFilterMode.Bilinear;
2040
2043
  fontAtlas.texture = texture;
2041
2044
  fontAtlas.isGCIgnored = texture.isGCIgnored = true;
2042
2045
  this._fontAtlases.push(fontAtlas);
@@ -5979,7 +5982,6 @@ var ShaderFactory = /*#__PURE__*/ function() {
5979
5982
  _this = ShaderPart1.call(this) || this;
5980
5983
  /** @internal */ _this._shaderPassId = 0;
5981
5984
  /** @internal */ _this._renderStateDataMap = {};
5982
- /** @internal */ _this._shaderProgramPools = [];
5983
5985
  _this._shaderPassId = ShaderPass._shaderPassCounter++;
5984
5986
  if (typeof fragmentSourceOrTags === "string") {
5985
5987
  _this._name = nameOrVertexSource;
@@ -6033,15 +6035,6 @@ var ShaderFactory = /*#__PURE__*/ function() {
6033
6035
  shaderProgramPool.cache(shaderProgram);
6034
6036
  return shaderProgram;
6035
6037
  };
6036
- /**
6037
- * @internal
6038
- */ _proto._destroy = function _destroy() {
6039
- var shaderProgramPools = this._shaderProgramPools;
6040
- for(var i = 0, n = shaderProgramPools.length; i < n; i++){
6041
- shaderProgramPools[i]._destroy();
6042
- }
6043
- shaderProgramPools.length = 0;
6044
- };
6045
6038
  return ShaderPass;
6046
6039
  }(ShaderPart);
6047
6040
  (function() {
@@ -6672,8 +6665,6 @@ __decorate([
6672
6665
  */ var Shader = /*#__PURE__*/ function() {
6673
6666
  function Shader(name, subShaders) {
6674
6667
  this.name = name;
6675
- this._refCount = 0;
6676
- this._destroyed = false;
6677
6668
  this.name = name;
6678
6669
  this._subShaders = subShaders;
6679
6670
  }
@@ -6693,46 +6684,20 @@ __decorate([
6693
6684
  for(var i = 0, n = macros.length; i < n; i++){
6694
6685
  compileMacros.enable(ShaderMacro.getByName(macros[i]));
6695
6686
  }
6696
- var isValid = false;
6697
6687
  var subShaders = this._subShaders;
6698
6688
  for(var i1 = 0, n1 = subShaders.length; i1 < n1; i1++){
6689
+ var isValid = void 0;
6699
6690
  var passes = subShaders[i1].passes;
6700
6691
  for(var j = 0, m = passes.length; j < m; j++){
6701
- var shaderProgram = passes[j]._getShaderProgram(engine, compileMacros);
6702
- isValid = j === 0 ? shaderProgram.isValid : isValid && shaderProgram.isValid;
6703
- }
6704
- }
6705
- return isValid;
6706
- };
6707
- /**
6708
- * Destroy the shader.
6709
- * @param force - Whether to force the destruction, if it is false, refCount = 0 can be released successfully.
6710
- * @returns Whether the release was successful.
6711
- */ _proto.destroy = function destroy(force) {
6712
- if (force === void 0) force = false;
6713
- if (!force && this._refCount !== 0) {
6714
- return false;
6715
- }
6716
- var subShaders = this._subShaders;
6717
- for(var i = 0, n = subShaders.length; i < n; i++){
6718
- var passes = subShaders[i].passes;
6719
- for(var j = 0, m = passes.length; j < m; j++){
6720
- passes[j]._destroy();
6692
+ if (isValid === undefined) {
6693
+ isValid = passes[j]._getShaderProgram(engine, compileMacros).isValid;
6694
+ } else {
6695
+ isValid && (isValid = passes[j]._getShaderProgram(engine, compileMacros).isValid);
6696
+ }
6721
6697
  }
6698
+ if (isValid) return true;
6722
6699
  }
6723
- delete Shader._shaderMap[this.name];
6724
- this._destroyed = true;
6725
- return true;
6726
- };
6727
- /**
6728
- * @internal
6729
- */ _proto._getReferCount = function _getReferCount() {
6730
- return this._refCount;
6731
- };
6732
- /**
6733
- * @internal
6734
- */ _proto._addReferCount = function _addReferCount(value) {
6735
- this._refCount += value;
6700
+ return false;
6736
6701
  };
6737
6702
  Shader.create = function create(nameOrShaderSource, vertexSourceOrShaderPassesOrSubShaders, fragmentSource) {
6738
6703
  var shader;
@@ -6919,14 +6884,6 @@ __decorate([
6919
6884
  */ function get() {
6920
6885
  return this._subShaders;
6921
6886
  }
6922
- },
6923
- {
6924
- key: "destroyed",
6925
- get: /**
6926
- * Whether it has been destroyed.
6927
- */ function get() {
6928
- return this._destroyed;
6929
- }
6930
6887
  }
6931
6888
  ]);
6932
6889
  return Shader;
@@ -8055,6 +8012,9 @@ SimpleSpriteAssembler = __decorate([
8055
8012
  __decorate([
8056
8013
  assignmentClone
8057
8014
  ], SpriteMask.prototype, "influenceLayers", void 0);
8015
+ __decorate([
8016
+ ignoreClone
8017
+ ], SpriteMask.prototype, "_verticesData", void 0);
8058
8018
  __decorate([
8059
8019
  ignoreClone
8060
8020
  ], SpriteMask.prototype, "_sprite", void 0);
@@ -9187,7 +9147,7 @@ var BlendShapeFrameDirty;
9187
9147
  if (!material) {
9188
9148
  continue;
9189
9149
  }
9190
- if (material.destroyed || material.shader.destroyed) {
9150
+ if (material.destroyed) {
9191
9151
  material = this.engine._meshMagentaMaterial;
9192
9152
  }
9193
9153
  var renderData = meshRenderDataPool.getFromPool();
@@ -10842,6 +10802,10 @@ var VertexElementIndex;
10842
10802
  var sphereInfo = primitiveInfo;
10843
10803
  PrimitiveMesh._setSphereData(this.resource, sphereInfo.radius, sphereInfo.segments, sphereInfo.noLongerAccessible, true, sphereInfo.vertexBuffer);
10844
10804
  break;
10805
+ case 7:
10806
+ var CCSphereInfo = primitiveInfo;
10807
+ PrimitiveMesh._setSubdivisionSurfaceSphereData(this.resource, CCSphereInfo.radius, CCSphereInfo.step, CCSphereInfo.noLongerAccessible, true, CCSphereInfo.vertexBuffer);
10808
+ break;
10845
10809
  case 1:
10846
10810
  var cuboidInfo = primitiveInfo;
10847
10811
  PrimitiveMesh._setCuboidData(this.resource, cuboidInfo.width, cuboidInfo.height, cuboidInfo.depth, cuboidInfo.noLongerAccessible, true, cuboidInfo.vertexBuffer);
@@ -10879,6 +10843,7 @@ var PrimitiveType;
10879
10843
  PrimitiveType[PrimitiveType["Torus"] = 4] = "Torus";
10880
10844
  PrimitiveType[PrimitiveType["Cone"] = 5] = "Cone";
10881
10845
  PrimitiveType[PrimitiveType["Capsule"] = 6] = "Capsule";
10846
+ PrimitiveType[PrimitiveType["CCSphere"] = 7] = "CCSphere";
10882
10847
  })(PrimitiveType || (PrimitiveType = {}));
10883
10848
  /**
10884
10849
  * @internal
@@ -10900,6 +10865,19 @@ var PrimitiveType;
10900
10865
  }
10901
10866
  return SphereRestoreInfo;
10902
10867
  }(PrimitiveRestoreInfo);
10868
+ /**
10869
+ * @internal
10870
+ */ var SubdivisionSurfaceSphereRestoreInfo = /*#__PURE__*/ function(PrimitiveRestoreInfo) {
10871
+ _inherits(SubdivisionSurfaceSphereRestoreInfo, PrimitiveRestoreInfo);
10872
+ function SubdivisionSurfaceSphereRestoreInfo(radius, step, vertexBuffer, noLongerAccessible) {
10873
+ var _this;
10874
+ _this = PrimitiveRestoreInfo.call(this, 7, vertexBuffer, noLongerAccessible) || this;
10875
+ _this.radius = radius;
10876
+ _this.step = step;
10877
+ return _this;
10878
+ }
10879
+ return SubdivisionSurfaceSphereRestoreInfo;
10880
+ }(PrimitiveRestoreInfo);
10903
10881
  /**
10904
10882
  * @internal
10905
10883
  */ var CuboidRestoreInfo = /*#__PURE__*/ function(PrimitiveRestoreInfo) {
@@ -11014,6 +10992,24 @@ var PrimitiveType;
11014
10992
  return sphereMesh;
11015
10993
  };
11016
10994
  /**
10995
+ * Create a sphere mesh by implementing Catmull-Clark Surface Subdivision Algorithm.
10996
+ * Max step is limited to 6.
10997
+ * @param engine - Engine
10998
+ * @param radius - Sphere radius
10999
+ * @param step - Number of subdiv steps
11000
+ * @param noLongerAccessible - No longer access the vertices of the mesh after creation
11001
+ * @returns Sphere model mesh
11002
+ */ PrimitiveMesh.createSubdivisionSurfaceSphere = function createSubdivisionSurfaceSphere(engine, radius, step, noLongerAccessible) {
11003
+ if (radius === void 0) radius = 0.5;
11004
+ if (step === void 0) step = 3;
11005
+ if (noLongerAccessible === void 0) noLongerAccessible = true;
11006
+ var sphereMesh = new ModelMesh(engine);
11007
+ PrimitiveMesh._setSubdivisionSurfaceSphereData(sphereMesh, radius, step, noLongerAccessible, false);
11008
+ var vertexBuffer = sphereMesh.vertexBufferBindings[0].buffer;
11009
+ engine.resourceManager.addContentRestorer(new PrimitiveMeshRestorer(sphereMesh, new SubdivisionSurfaceSphereRestoreInfo(radius, step, vertexBuffer, noLongerAccessible)));
11010
+ return sphereMesh;
11011
+ };
11012
+ /**
11017
11013
  * Create a cuboid mesh.
11018
11014
  * @param engine - Engine
11019
11015
  * @param width - Cuboid width
@@ -11143,6 +11139,90 @@ var PrimitiveType;
11143
11139
  };
11144
11140
  /**
11145
11141
  * @internal
11142
+ */ PrimitiveMesh._setSubdivisionSurfaceSphereData = function _setSubdivisionSurfaceSphereData(sphereMesh, radius, step, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
11143
+ // Max step is limited to 6. Because 7 step will generate a single mesh with over 98306 vertices
11144
+ step = engineMath.MathUtil.clamp(Math.floor(step), 1, 6);
11145
+ var positions = new Float32Array(3 * (6 * Math.pow(4, step) + 2));
11146
+ var cells = new Float32Array(24 * Math.pow(4, step));
11147
+ PrimitiveMesh._subdiveCatmullClark(step, positions, cells);
11148
+ var positionCount = positions.length / 3;
11149
+ var cellsCount = cells.length / 4;
11150
+ var poleOffset = positionCount + Math.pow(2, step + 1) - 1;
11151
+ // 16 extra vertices for pole uv
11152
+ // 2 vertices at each pole are idle
11153
+ var vertexCount = poleOffset + 16;
11154
+ var vertices = new Float32Array(vertexCount * 8);
11155
+ var indices = PrimitiveMesh._generateIndices(sphereMesh.engine, positionCount, cellsCount * 6);
11156
+ var seamCount = 0;
11157
+ var seamVertices = {};
11158
+ // Get normals, uvs, and scale to radius
11159
+ for(var i = 0; i < positionCount; i++){
11160
+ var offset = 3 * i;
11161
+ var x = positions[offset];
11162
+ var y = positions[offset + 1];
11163
+ var z = positions[offset + 2];
11164
+ var reciprocalLength = 1 / Math.sqrt(x * x + y * y + z * z);
11165
+ x *= reciprocalLength;
11166
+ y *= reciprocalLength;
11167
+ z *= reciprocalLength;
11168
+ offset = 8 * i;
11169
+ vertices[offset] = x * radius;
11170
+ vertices[offset + 1] = y * radius;
11171
+ vertices[offset + 2] = z * radius;
11172
+ vertices[offset + 3] = x;
11173
+ vertices[offset + 4] = y;
11174
+ vertices[offset + 5] = z;
11175
+ vertices[offset + 6] = (Math.PI - Math.atan2(z, x)) / (2 * Math.PI);
11176
+ vertices[offset + 7] = Math.acos(y) / Math.PI;
11177
+ if (vertices[offset + 6] === 0) {
11178
+ // Generate seam vertex
11179
+ var seamOffset = 8 * (positionCount + seamCount++);
11180
+ vertices.set(vertices.subarray(offset, offset + 8), seamOffset);
11181
+ vertices[seamOffset + 6] = 1.0;
11182
+ // Cache seam vertex
11183
+ seamVertices[offset / 8] = seamOffset / 8;
11184
+ }
11185
+ }
11186
+ // Get indices
11187
+ var offset1 = 0;
11188
+ this._spherePoleIdx = 0;
11189
+ for(var i1 = 0; i1 < cellsCount; i1++){
11190
+ var idx = 4 * i1;
11191
+ var indexA = cells[idx];
11192
+ var indexB = cells[idx + 1];
11193
+ var indexC = cells[idx + 2];
11194
+ var indexD = cells[idx + 3];
11195
+ // Handle seam by replacing vertex index to seam vertex index if necessary
11196
+ var floatIndexA = 8 * indexA;
11197
+ var floatIndexB = 8 * indexB;
11198
+ var floatIndexC = 8 * indexC;
11199
+ var floatIndexD = 8 * indexD;
11200
+ // If center Z is negative
11201
+ if (vertices[floatIndexA + 2] + vertices[floatIndexB + 2] + vertices[floatIndexC + 2] < 0) {
11202
+ vertices[floatIndexA + 6] === 0 && (indexA = seamVertices[indexA]);
11203
+ vertices[floatIndexB + 6] === 0 && (indexB = seamVertices[indexB]);
11204
+ vertices[floatIndexC + 6] === 0 && (indexC = seamVertices[indexC]);
11205
+ vertices[floatIndexD + 6] === 0 && (indexD = seamVertices[indexD]);
11206
+ }
11207
+ indices[offset1] = indexA;
11208
+ indices[offset1 + 1] = indexB;
11209
+ indices[offset1 + 2] = indexC;
11210
+ this._generateAndReplacePoleUV(indices, vertices, offset1, poleOffset);
11211
+ indices[offset1 + 3] = indexA;
11212
+ indices[offset1 + 4] = indexC;
11213
+ indices[offset1 + 5] = indexD;
11214
+ this._generateAndReplacePoleUV(indices, vertices, offset1 + 3, poleOffset);
11215
+ offset1 += 6;
11216
+ }
11217
+ if (!isRestoreMode) {
11218
+ var bounds = sphereMesh.bounds;
11219
+ bounds.min.set(-radius, -radius, -radius);
11220
+ bounds.max.set(radius, radius, radius);
11221
+ }
11222
+ PrimitiveMesh._initialize(sphereMesh, vertices, indices, noLongerAccessible, isRestoreMode, restoreVertexBuffer);
11223
+ };
11224
+ /**
11225
+ * @internal
11146
11226
  */ PrimitiveMesh._setSphereData = function _setSphereData(sphereMesh, radius, segments, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
11147
11227
  segments = Math.max(2, Math.floor(segments));
11148
11228
  var count = segments + 1;
@@ -11203,6 +11283,135 @@ var PrimitiveType;
11203
11283
  };
11204
11284
  /**
11205
11285
  * @internal
11286
+ */ PrimitiveMesh._subdiveCatmullClark = function _subdiveCatmullClark(step, positions, cells) {
11287
+ var edges = new Map();
11288
+ var faces = new Array();
11289
+ positions.set(PrimitiveMesh._sphereSeedPositions);
11290
+ cells.set(PrimitiveMesh._sphereSeedCells);
11291
+ for(var i = 0; i < step; i++){
11292
+ var cellCount = 6 * Math.pow(4, i);
11293
+ var positionCount = 4 * cellCount + 2;
11294
+ edges.clear();
11295
+ faces.length = 0;
11296
+ // Get cell face's facePoint
11297
+ for(var j = 0; j < cellCount; j++){
11298
+ var face = faces[j] = {
11299
+ facePoint: new engineMath.Vector3(),
11300
+ adjacentEdges: new Array(4)
11301
+ };
11302
+ // Get cell's edgePoint
11303
+ for(var k = 0; k < 4; k++){
11304
+ var offset = 3 * cells[4 * j + k];
11305
+ face.facePoint.x += 0.25 * positions[offset];
11306
+ face.facePoint.y += 0.25 * positions[offset + 1];
11307
+ face.facePoint.z += 0.25 * positions[offset + 2];
11308
+ }
11309
+ // Get cell edges
11310
+ for(var k1 = 0; k1 < 4; k1++){
11311
+ var vertexIdxA = cells[4 * j + k1];
11312
+ var vertexIdxB = cells[4 * j + (k1 + 1) % 4];
11313
+ var edgeIdxKey = Math.min(vertexIdxA, vertexIdxB) * positionCount + Math.max(vertexIdxA, vertexIdxB);
11314
+ if (!edges.has(edgeIdxKey)) {
11315
+ var edge = {
11316
+ edgePoint: new engineMath.Vector3(),
11317
+ edgePointIndex: undefined
11318
+ };
11319
+ var offsetA = 3 * vertexIdxA;
11320
+ var offsetB = 3 * vertexIdxB;
11321
+ edge.edgePoint.set(0.25 * (positions[offsetA] + positions[offsetB]), 0.25 * (positions[offsetA + 1] + positions[offsetB + 1]), 0.25 * (positions[offsetA + 2] + positions[offsetB + 2]));
11322
+ edges.set(edgeIdxKey, edge);
11323
+ }
11324
+ var edge1 = edges.get(edgeIdxKey);
11325
+ face.adjacentEdges[k1] = edge1;
11326
+ var edgePoint = edge1.edgePoint;
11327
+ var facePoint = face.facePoint;
11328
+ edgePoint.x += 0.25 * facePoint.x;
11329
+ edgePoint.y += 0.25 * facePoint.y;
11330
+ edgePoint.z += 0.25 * facePoint.z;
11331
+ }
11332
+ }
11333
+ var prePointCount = cellCount + 2;
11334
+ var edgePointOffset = prePointCount + cellCount;
11335
+ var pointIdx = 0;
11336
+ this._sphereEdgeIdx = 0;
11337
+ var preCells = cells.slice(0, 4 * cellCount);
11338
+ // Get New positions, which consists of updated positions of existing points, face points and edge points
11339
+ for(var j1 = 0; j1 < cellCount; j1++){
11340
+ // Add face point to new positions
11341
+ var face1 = faces[j1];
11342
+ face1.facePoint.copyToArray(positions, 3 * (prePointCount + j1));
11343
+ // Get the face point index
11344
+ var ic = prePointCount + j1;
11345
+ var id = void 0, ib = void 0, temp = void 0;
11346
+ // ia -- id -- ia
11347
+ // | | |
11348
+ // ib -- ic -- ib
11349
+ // | | |
11350
+ // ia -- id -- ia
11351
+ for(var k2 = 0; k2 < 4; k2++){
11352
+ // Get the updated existing point index
11353
+ var ia = preCells[pointIdx++];
11354
+ // ib and id share four edge points in one cell
11355
+ switch(k2){
11356
+ case 0:
11357
+ {
11358
+ var edgeB = face1.adjacentEdges[k2 % 4];
11359
+ var edgeD = face1.adjacentEdges[(k2 + 3) % 4];
11360
+ ib = this._calculateEdgeIndex(positions, edgeB, edgePointOffset);
11361
+ id = this._calculateEdgeIndex(positions, edgeD, edgePointOffset);
11362
+ temp = id;
11363
+ break;
11364
+ }
11365
+ case 1:
11366
+ case 2:
11367
+ {
11368
+ var edgeB1 = face1.adjacentEdges[k2 % 4];
11369
+ id = ib;
11370
+ ib = this._calculateEdgeIndex(positions, edgeB1, edgePointOffset);
11371
+ break;
11372
+ }
11373
+ case 3:
11374
+ {
11375
+ id = ib;
11376
+ ib = temp;
11377
+ break;
11378
+ }
11379
+ }
11380
+ var idx = 4 * (4 * j1 + k2);
11381
+ cells[idx] = ia;
11382
+ cells[idx + 1] = ib;
11383
+ cells[idx + 2] = ic;
11384
+ cells[idx + 3] = id;
11385
+ }
11386
+ }
11387
+ }
11388
+ };
11389
+ /**
11390
+ * Duplicate vertices at the poles and adjust their UV coordinates.
11391
+ */ PrimitiveMesh._generateAndReplacePoleUV = function _generateAndReplacePoleUV(indices, vertices, idx, poleOffset) {
11392
+ var v = vertices[8 * indices[idx] + 7];
11393
+ if (v === 0 || v === 1) {
11394
+ var offset = 8 * indices[idx];
11395
+ var addedOffset = 8 * (poleOffset + this._spherePoleIdx);
11396
+ vertices.set(vertices.subarray(offset, offset + 8), addedOffset);
11397
+ vertices[addedOffset + 6] = 0.5 * (vertices[offset + 6] + vertices[8 * indices[idx + 1] + 6] + vertices[8 * indices[idx + 2] + 6] - 0.5);
11398
+ indices[idx] = poleOffset + this._spherePoleIdx++;
11399
+ }
11400
+ };
11401
+ /**
11402
+ * Get edge point index for subdivision surface sphere.
11403
+ */ PrimitiveMesh._calculateEdgeIndex = function _calculateEdgeIndex(positions, edge, offset) {
11404
+ if (edge.edgePointIndex !== undefined) {
11405
+ return edge.edgePointIndex;
11406
+ } else {
11407
+ edge.edgePoint.copyToArray(positions, 3 * (offset + PrimitiveMesh._sphereEdgeIdx));
11408
+ var index = offset + PrimitiveMesh._sphereEdgeIdx++;
11409
+ edge.edgePointIndex = index;
11410
+ return index;
11411
+ }
11412
+ };
11413
+ /**
11414
+ * @internal
11206
11415
  */ PrimitiveMesh._setCuboidData = function _setCuboidData(cuboidMesh, width, height, depth, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
11207
11416
  var halfWidth = width / 2;
11208
11417
  var halfHeight = height / 2;
@@ -11832,6 +12041,68 @@ var PrimitiveType;
11832
12041
  (function() {
11833
12042
  PrimitiveMesh._tempVec30 = new engineMath.Vector3();
11834
12043
  })();
12044
+ (function() {
12045
+ PrimitiveMesh._sphereSeedPositions = new Float32Array([
12046
+ -1,
12047
+ 1,
12048
+ 1,
12049
+ -1,
12050
+ -1,
12051
+ 1,
12052
+ 1,
12053
+ -1,
12054
+ 1,
12055
+ 1,
12056
+ 1,
12057
+ 1,
12058
+ 1,
12059
+ -1,
12060
+ -1,
12061
+ 1,
12062
+ 1,
12063
+ -1,
12064
+ -1,
12065
+ -1,
12066
+ -1,
12067
+ -1,
12068
+ 1,
12069
+ -1
12070
+ ]);
12071
+ })();
12072
+ (function() {
12073
+ PrimitiveMesh._sphereSeedCells = new Float32Array([
12074
+ 0,
12075
+ 1,
12076
+ 2,
12077
+ 3,
12078
+ 3,
12079
+ 2,
12080
+ 4,
12081
+ 5,
12082
+ 5,
12083
+ 4,
12084
+ 6,
12085
+ 7,
12086
+ 7,
12087
+ 0,
12088
+ 3,
12089
+ 5,
12090
+ 7,
12091
+ 6,
12092
+ 1,
12093
+ 0,
12094
+ 6,
12095
+ 4,
12096
+ 2,
12097
+ 1
12098
+ ]);
12099
+ })();
12100
+ (function() {
12101
+ PrimitiveMesh._sphereEdgeIdx = 0;
12102
+ })();
12103
+ (function() {
12104
+ PrimitiveMesh._spherePoleIdx = 0;
12105
+ })();
11835
12106
 
11836
12107
  /**
11837
12108
  * Mesh skin data, equal glTF skins define
@@ -12340,8 +12611,10 @@ var Basic2DBatcher = /*#__PURE__*/ function() {
12340
12611
  }
12341
12612
  mesh.addSubMesh(this._getSubMeshFromPool(vertexStartIndex, vertexCount));
12342
12613
  batchedQueue[curMeshIndex] = preElement;
12343
- this._vertexBuffers[_flushId].setData(vertices, 0, 0, vertexIndex);
12344
- this._indiceBuffers[_flushId].setData(indices, 0, 0, indiceIndex);
12614
+ // Set data option use Discard, or will resulted in performance slowdown when open antialias and cross-rendering of 3D and 2D elements.
12615
+ // Device: iphone X(16.7.2)、iphone 15 pro max(17.1.1)、iphone XR(17.1.2) etc.
12616
+ this._vertexBuffers[_flushId].setData(vertices, 0, 0, vertexIndex, exports.SetDataOptions.Discard);
12617
+ this._indiceBuffers[_flushId].setData(indices, 0, 0, indiceIndex, exports.SetDataOptions.Discard);
12345
12618
  };
12346
12619
  _proto._getSubMeshFromPool = function _getSubMeshFromPool(start, count) {
12347
12620
  var subMesh = this._subMeshPool.getFromPool();
@@ -16403,7 +16676,6 @@ __decorate([
16403
16676
  if (this._destroyed) return;
16404
16677
  ReferResource1.prototype._addReferCount.call(this, value);
16405
16678
  this.shaderData._addReferCount(value);
16406
- this._shader._addReferCount(value);
16407
16679
  };
16408
16680
  /**
16409
16681
  * @override
@@ -16431,12 +16703,6 @@ __decorate([
16431
16703
  return this._shader;
16432
16704
  },
16433
16705
  set: function set(value) {
16434
- var refCount = this._getReferCount();
16435
- if (refCount > 0) {
16436
- var _this__shader;
16437
- (_this__shader = this._shader) == null ? void 0 : _this__shader._addReferCount(-refCount);
16438
- value._addReferCount(refCount);
16439
- }
16440
16706
  this._shader = value;
16441
16707
  var renderStates = this._renderStates;
16442
16708
  var lastStatesCount = renderStates.length;
@@ -16700,24 +16966,6 @@ var unlitVs = "#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#in
16700
16966
  */ _proto.cache = function cache(shaderProgram) {
16701
16967
  this._lastQueryMap[this._lastQueryKey] = shaderProgram;
16702
16968
  };
16703
- /**
16704
- * @internal
16705
- */ _proto._destroy = function _destroy() {
16706
- this._recursiveDestroy(0, this._cacheMap);
16707
- this._cacheMap = Object.create(null);
16708
- };
16709
- _proto._recursiveDestroy = function _recursiveDestroy(hierarchy, cacheMap) {
16710
- if (hierarchy === this._cacheHierarchyDepth - 1) {
16711
- for(var k in cacheMap){
16712
- cacheMap[k].destroy();
16713
- }
16714
- return;
16715
- }
16716
- ++hierarchy;
16717
- for(var k1 in cacheMap){
16718
- this._recursiveDestroy(hierarchy, cacheMap[k1]);
16719
- }
16720
- };
16721
16969
  _proto._resizeCacheMapHierarchy = function _resizeCacheMapHierarchy(cacheMap, hierarchy, currentHierarchy, increaseHierarchy) {
16722
16970
  // Only expand but not shrink
16723
16971
  if (hierarchy == currentHierarchy - 1) {
@@ -18295,7 +18543,7 @@ var /**
18295
18543
  /**
18296
18544
  * @internal
18297
18545
  */ _proto._render = function _render(context) {
18298
- if (this._text === "" || this.enableWrapping && this.width <= 0 || this.overflowMode === exports.OverflowMode.Truncate && this.height <= 0) {
18546
+ if (this._isTextNoVisible()) {
18299
18547
  return;
18300
18548
  }
18301
18549
  if (this._isContainDirtyFlag(0x10)) {
@@ -18387,8 +18635,8 @@ var /**
18387
18635
  }
18388
18636
  };
18389
18637
  _proto._updateLocalData = function _updateLocalData() {
18390
- var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
18391
18638
  var _this__localBounds = this._localBounds, min = _this__localBounds.min, max = _this__localBounds.max;
18639
+ var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
18392
18640
  var textMetrics = this.enableWrapping ? TextUtils.measureTextWithWrap(this) : TextUtils.measureTextWithoutWrap(this);
18393
18641
  var height = textMetrics.height, lines = textMetrics.lines, lineWidths = textMetrics.lineWidths, lineHeight = textMetrics.lineHeight, lineMaxSizes = textMetrics.lineMaxSizes;
18394
18642
  var charRenderDataPool = TextRenderer._charRenderDataPool;
@@ -18456,7 +18704,7 @@ var /**
18456
18704
  var left = startX * pixelsPerUnitReciprocal;
18457
18705
  var right = (startX + w) * pixelsPerUnitReciprocal;
18458
18706
  var top = (startY + ascent) * pixelsPerUnitReciprocal;
18459
- var bottom = (startY - descent + 1) * pixelsPerUnitReciprocal;
18707
+ var bottom = (startY - descent) * pixelsPerUnitReciprocal;
18460
18708
  localPositions.set(left, top, right, bottom);
18461
18709
  i === firstLine && (maxY = Math.max(maxY, top));
18462
18710
  minY = Math.min(minY, bottom);
@@ -18497,6 +18745,9 @@ var /**
18497
18745
  Renderer1.prototype._onTransformChanged.call(this, bit);
18498
18746
  this._setDirtyFlagTrue(0x4 | 0x8);
18499
18747
  };
18748
+ _proto._isTextNoVisible = function _isTextNoVisible() {
18749
+ return this._text === "" || this._fontSize === 0 || this.enableWrapping && this.width <= 0 || this.overflowMode === exports.OverflowMode.Truncate && this.height <= 0;
18750
+ };
18500
18751
  _create_class(TextRenderer, [
18501
18752
  {
18502
18753
  key: "color",
@@ -18699,6 +18950,16 @@ var /**
18699
18950
  get: /**
18700
18951
  * The bounding volume of the TextRenderer.
18701
18952
  */ function get() {
18953
+ if (this._isTextNoVisible()) {
18954
+ if (this._isContainDirtyFlag(0x8)) {
18955
+ var localBounds = this._localBounds;
18956
+ localBounds.min.set(0, 0, 0);
18957
+ localBounds.max.set(0, 0, 0);
18958
+ this._updateBounds(this._bounds);
18959
+ this._setDirtyFlagFalse(0x8);
18960
+ }
18961
+ return this._bounds;
18962
+ }
18702
18963
  this._isContainDirtyFlag(0x1) && this._resetSubFont();
18703
18964
  this._isContainDirtyFlag(0x2) && this._updateLocalData();
18704
18965
  this._isContainDirtyFlag(0x4) && this._updatePosition();
@@ -19025,7 +19286,6 @@ ShaderPool.init();
19025
19286
  shaderProgramPools.length = length;
19026
19287
  }
19027
19288
  shaderProgramPools[index] = pool = new ShaderProgramPool();
19028
- shaderPass._shaderProgramPools.push(pool);
19029
19289
  }
19030
19290
  return pool;
19031
19291
  };
@@ -21615,38 +21875,45 @@ var passNum = 0;
21615
21875
  var v0 = a[from];
21616
21876
  var v1 = a[to - 1];
21617
21877
  var v2 = a[third_index];
21878
+ var swapFlag = false;
21618
21879
  var c01 = compareFunc(v0, v1);
21619
21880
  if (c01 > 0) {
21620
21881
  // v1 < v0, so swap them.
21621
21882
  var tmp = v0;
21622
21883
  v0 = v1;
21623
21884
  v1 = tmp;
21885
+ swapFlag = true;
21624
21886
  } // v0 <= v1.
21625
21887
  var c02 = compareFunc(v0, v2);
21626
- if (c02 >= 0) {
21627
- // v2 <= v0 <= v1.
21888
+ if (c02 > 0) {
21889
+ // v2 < v0.
21628
21890
  var tmp1 = v0;
21629
21891
  v0 = v2;
21630
21892
  v2 = v1;
21631
21893
  v1 = tmp1;
21894
+ swapFlag = true;
21632
21895
  } else {
21633
- // v0 <= v1 && v0 < v2
21896
+ // v2 >= v0
21634
21897
  var c12 = compareFunc(v1, v2);
21635
21898
  if (c12 > 0) {
21636
21899
  // v0 <= v2 < v1
21637
21900
  var tmp2 = v1;
21638
21901
  v1 = v2;
21639
21902
  v2 = tmp2;
21903
+ swapFlag = true;
21640
21904
  }
21641
21905
  }
21642
21906
  // v0 <= v1 <= v2
21643
- a[from] = v0;
21644
- a[to - 1] = v2;
21645
- var pivot = v1;
21646
21907
  var low_end = from + 1; // Upper bound of elements lower than pivot.
21647
21908
  var high_start = to - 1; // Lower bound of elements greater than pivot.
21648
- a[third_index] = a[low_end];
21649
- a[low_end] = pivot;
21909
+ var pivot = v2;
21910
+ if (swapFlag) {
21911
+ a[from] = v0;
21912
+ a[to - 1] = v2;
21913
+ pivot = v1;
21914
+ a[third_index] = a[low_end];
21915
+ a[low_end] = pivot;
21916
+ }
21650
21917
  // From low_end to i are elements equal to pivot.
21651
21918
  // From i to high_start are elements that haven't been compared yet.
21652
21919
  partition: for(var i = low_end + 1; i < high_start; i++){
@@ -21701,12 +21968,38 @@ var passNum = 0;
21701
21968
  /**
21702
21969
  * @internal
21703
21970
  */ RenderQueue._compareFromNearToFar = function _compareFromNearToFar(a, b) {
21704
- return a.data.component.priority - b.data.component.priority || a.data.material._priority - b.data.material._priority || a.data.component._distanceForSort - b.data.component._distanceForSort;
21971
+ var dataA = a.data;
21972
+ var dataB = b.data;
21973
+ var componentA = dataA.component;
21974
+ var componentB = dataB.component;
21975
+ var priorityOrder = componentA.priority - componentB.priority;
21976
+ if (priorityOrder !== 0) {
21977
+ return priorityOrder;
21978
+ }
21979
+ // make suer from the same renderer.
21980
+ if (componentA.instanceId === componentB.instanceId) {
21981
+ return dataA.material._priority - dataB.material._priority || componentA._distanceForSort - componentB._distanceForSort;
21982
+ } else {
21983
+ return componentA._distanceForSort - componentB._distanceForSort;
21984
+ }
21705
21985
  };
21706
21986
  /**
21707
21987
  * @internal
21708
21988
  */ RenderQueue._compareFromFarToNear = function _compareFromFarToNear(a, b) {
21709
- return a.data.component.priority - b.data.component.priority || a.data.material._priority - b.data.material._priority || b.data.component._distanceForSort - a.data.component._distanceForSort;
21989
+ var dataA = a.data;
21990
+ var dataB = b.data;
21991
+ var componentA = dataA.component;
21992
+ var componentB = dataB.component;
21993
+ var priorityOrder = componentA.priority - componentB.priority;
21994
+ if (priorityOrder !== 0) {
21995
+ return priorityOrder;
21996
+ }
21997
+ // make suer from the same renderer.
21998
+ if (componentA.instanceId === componentB.instanceId) {
21999
+ return dataA.material._priority - dataB.material._priority || componentB._distanceForSort - componentA._distanceForSort;
22000
+ } else {
22001
+ return componentB._distanceForSort - componentA._distanceForSort;
22002
+ }
21710
22003
  };
21711
22004
  return RenderQueue;
21712
22005
  }();
@@ -23747,12 +24040,6 @@ var BaseMaterial = /*#__PURE__*/ function(Material1) {
23747
24040
  return this._shader;
23748
24041
  },
23749
24042
  set: function set(value) {
23750
- var refCount = this._getReferCount();
23751
- if (refCount > 0) {
23752
- var _this__shader;
23753
- (_this__shader = this._shader) == null ? void 0 : _this__shader._addReferCount(-refCount);
23754
- value._addReferCount(refCount);
23755
- }
23756
24043
  this._shader = value;
23757
24044
  var renderStates = this._renderStates;
23758
24045
  var lastStatesCount = renderStates.length;
@@ -27612,7 +27899,7 @@ exports.ParticleStopMode = void 0;
27612
27899
  if (!material) {
27613
27900
  return;
27614
27901
  }
27615
- if (material.destroyed || material.shader.destroyed) {
27902
+ if (material.destroyed) {
27616
27903
  material = this.engine._particleMagentaMaterial;
27617
27904
  }
27618
27905
  var renderData = this._engine._renderDataPool.getFromPool();