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