@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/module.js CHANGED
@@ -1943,13 +1943,15 @@ var Logger = {
1943
1943
  ];
1944
1944
  })();
1945
1945
  (function() {
1946
- /** These characters are all tall to help calculate the height required for text. */ TextUtils._measureString = "|\xc9q\xc5";
1946
+ // _heightMultiplier used to measure the height of text, but in miniprogram performance is different from h5.
1947
+ // so can set _heightMultiplier to adapt miniprogram, the larger the value, the worse the performance.
1948
+ /** @internal */ TextUtils._heightMultiplier = 2;
1947
1949
  })();
1948
1950
  (function() {
1949
- TextUtils._measureBaseline = "M";
1951
+ /** These characters are all tall to help calculate the height required for text. */ TextUtils._measureString = "|\xc9q\xc5";
1950
1952
  })();
1951
1953
  (function() {
1952
- TextUtils._heightMultiplier = 2;
1954
+ TextUtils._measureBaseline = "M";
1953
1955
  })();
1954
1956
  (function() {
1955
1957
  TextUtils._baselineMultiplier = 1.4;
@@ -2032,7 +2034,8 @@ var Logger = {
2032
2034
  _proto._createFontAtlas = function _createFontAtlas() {
2033
2035
  var _this = this, engine = _this._engine;
2034
2036
  var fontAtlas = new FontAtlas(engine);
2035
- var texture = new Texture2D(engine, 256, 256);
2037
+ var texture = new Texture2D(engine, 256, 256, TextureFormat.R8G8B8A8, false);
2038
+ texture.filterMode = TextureFilterMode.Bilinear;
2036
2039
  fontAtlas.texture = texture;
2037
2040
  fontAtlas.isGCIgnored = texture.isGCIgnored = true;
2038
2041
  this._fontAtlases.push(fontAtlas);
@@ -5975,7 +5978,6 @@ var ShaderFactory = /*#__PURE__*/ function() {
5975
5978
  _this = ShaderPart1.call(this) || this;
5976
5979
  /** @internal */ _this._shaderPassId = 0;
5977
5980
  /** @internal */ _this._renderStateDataMap = {};
5978
- /** @internal */ _this._shaderProgramPools = [];
5979
5981
  _this._shaderPassId = ShaderPass._shaderPassCounter++;
5980
5982
  if (typeof fragmentSourceOrTags === "string") {
5981
5983
  _this._name = nameOrVertexSource;
@@ -6029,15 +6031,6 @@ var ShaderFactory = /*#__PURE__*/ function() {
6029
6031
  shaderProgramPool.cache(shaderProgram);
6030
6032
  return shaderProgram;
6031
6033
  };
6032
- /**
6033
- * @internal
6034
- */ _proto._destroy = function _destroy() {
6035
- var shaderProgramPools = this._shaderProgramPools;
6036
- for(var i = 0, n = shaderProgramPools.length; i < n; i++){
6037
- shaderProgramPools[i]._destroy();
6038
- }
6039
- shaderProgramPools.length = 0;
6040
- };
6041
6034
  return ShaderPass;
6042
6035
  }(ShaderPart);
6043
6036
  (function() {
@@ -6668,8 +6661,6 @@ __decorate([
6668
6661
  */ var Shader = /*#__PURE__*/ function() {
6669
6662
  function Shader(name, subShaders) {
6670
6663
  this.name = name;
6671
- this._refCount = 0;
6672
- this._destroyed = false;
6673
6664
  this.name = name;
6674
6665
  this._subShaders = subShaders;
6675
6666
  }
@@ -6689,46 +6680,20 @@ __decorate([
6689
6680
  for(var i = 0, n = macros.length; i < n; i++){
6690
6681
  compileMacros.enable(ShaderMacro.getByName(macros[i]));
6691
6682
  }
6692
- var isValid = false;
6693
6683
  var subShaders = this._subShaders;
6694
6684
  for(var i1 = 0, n1 = subShaders.length; i1 < n1; i1++){
6685
+ var isValid = void 0;
6695
6686
  var passes = subShaders[i1].passes;
6696
6687
  for(var j = 0, m = passes.length; j < m; j++){
6697
- var shaderProgram = passes[j]._getShaderProgram(engine, compileMacros);
6698
- isValid = j === 0 ? shaderProgram.isValid : isValid && shaderProgram.isValid;
6699
- }
6700
- }
6701
- return isValid;
6702
- };
6703
- /**
6704
- * Destroy the shader.
6705
- * @param force - Whether to force the destruction, if it is false, refCount = 0 can be released successfully.
6706
- * @returns Whether the release was successful.
6707
- */ _proto.destroy = function destroy(force) {
6708
- if (force === void 0) force = false;
6709
- if (!force && this._refCount !== 0) {
6710
- return false;
6711
- }
6712
- var subShaders = this._subShaders;
6713
- for(var i = 0, n = subShaders.length; i < n; i++){
6714
- var passes = subShaders[i].passes;
6715
- for(var j = 0, m = passes.length; j < m; j++){
6716
- passes[j]._destroy();
6688
+ if (isValid === undefined) {
6689
+ isValid = passes[j]._getShaderProgram(engine, compileMacros).isValid;
6690
+ } else {
6691
+ isValid && (isValid = passes[j]._getShaderProgram(engine, compileMacros).isValid);
6692
+ }
6717
6693
  }
6694
+ if (isValid) return true;
6718
6695
  }
6719
- delete Shader._shaderMap[this.name];
6720
- this._destroyed = true;
6721
- return true;
6722
- };
6723
- /**
6724
- * @internal
6725
- */ _proto._getReferCount = function _getReferCount() {
6726
- return this._refCount;
6727
- };
6728
- /**
6729
- * @internal
6730
- */ _proto._addReferCount = function _addReferCount(value) {
6731
- this._refCount += value;
6696
+ return false;
6732
6697
  };
6733
6698
  Shader.create = function create(nameOrShaderSource, vertexSourceOrShaderPassesOrSubShaders, fragmentSource) {
6734
6699
  var shader;
@@ -6915,14 +6880,6 @@ __decorate([
6915
6880
  */ function get() {
6916
6881
  return this._subShaders;
6917
6882
  }
6918
- },
6919
- {
6920
- key: "destroyed",
6921
- get: /**
6922
- * Whether it has been destroyed.
6923
- */ function get() {
6924
- return this._destroyed;
6925
- }
6926
6883
  }
6927
6884
  ]);
6928
6885
  return Shader;
@@ -8051,6 +8008,9 @@ SimpleSpriteAssembler = __decorate([
8051
8008
  __decorate([
8052
8009
  assignmentClone
8053
8010
  ], SpriteMask.prototype, "influenceLayers", void 0);
8011
+ __decorate([
8012
+ ignoreClone
8013
+ ], SpriteMask.prototype, "_verticesData", void 0);
8054
8014
  __decorate([
8055
8015
  ignoreClone
8056
8016
  ], SpriteMask.prototype, "_sprite", void 0);
@@ -9183,7 +9143,7 @@ var BlendShapeFrameDirty;
9183
9143
  if (!material) {
9184
9144
  continue;
9185
9145
  }
9186
- if (material.destroyed || material.shader.destroyed) {
9146
+ if (material.destroyed) {
9187
9147
  material = this.engine._meshMagentaMaterial;
9188
9148
  }
9189
9149
  var renderData = meshRenderDataPool.getFromPool();
@@ -10838,6 +10798,10 @@ var VertexElementIndex;
10838
10798
  var sphereInfo = primitiveInfo;
10839
10799
  PrimitiveMesh._setSphereData(this.resource, sphereInfo.radius, sphereInfo.segments, sphereInfo.noLongerAccessible, true, sphereInfo.vertexBuffer);
10840
10800
  break;
10801
+ case 7:
10802
+ var CCSphereInfo = primitiveInfo;
10803
+ PrimitiveMesh._setSubdivisionSurfaceSphereData(this.resource, CCSphereInfo.radius, CCSphereInfo.step, CCSphereInfo.noLongerAccessible, true, CCSphereInfo.vertexBuffer);
10804
+ break;
10841
10805
  case 1:
10842
10806
  var cuboidInfo = primitiveInfo;
10843
10807
  PrimitiveMesh._setCuboidData(this.resource, cuboidInfo.width, cuboidInfo.height, cuboidInfo.depth, cuboidInfo.noLongerAccessible, true, cuboidInfo.vertexBuffer);
@@ -10875,6 +10839,7 @@ var PrimitiveType;
10875
10839
  PrimitiveType[PrimitiveType["Torus"] = 4] = "Torus";
10876
10840
  PrimitiveType[PrimitiveType["Cone"] = 5] = "Cone";
10877
10841
  PrimitiveType[PrimitiveType["Capsule"] = 6] = "Capsule";
10842
+ PrimitiveType[PrimitiveType["CCSphere"] = 7] = "CCSphere";
10878
10843
  })(PrimitiveType || (PrimitiveType = {}));
10879
10844
  /**
10880
10845
  * @internal
@@ -10896,6 +10861,19 @@ var PrimitiveType;
10896
10861
  }
10897
10862
  return SphereRestoreInfo;
10898
10863
  }(PrimitiveRestoreInfo);
10864
+ /**
10865
+ * @internal
10866
+ */ var SubdivisionSurfaceSphereRestoreInfo = /*#__PURE__*/ function(PrimitiveRestoreInfo) {
10867
+ _inherits(SubdivisionSurfaceSphereRestoreInfo, PrimitiveRestoreInfo);
10868
+ function SubdivisionSurfaceSphereRestoreInfo(radius, step, vertexBuffer, noLongerAccessible) {
10869
+ var _this;
10870
+ _this = PrimitiveRestoreInfo.call(this, 7, vertexBuffer, noLongerAccessible) || this;
10871
+ _this.radius = radius;
10872
+ _this.step = step;
10873
+ return _this;
10874
+ }
10875
+ return SubdivisionSurfaceSphereRestoreInfo;
10876
+ }(PrimitiveRestoreInfo);
10899
10877
  /**
10900
10878
  * @internal
10901
10879
  */ var CuboidRestoreInfo = /*#__PURE__*/ function(PrimitiveRestoreInfo) {
@@ -11010,6 +10988,24 @@ var PrimitiveType;
11010
10988
  return sphereMesh;
11011
10989
  };
11012
10990
  /**
10991
+ * Create a sphere mesh by implementing Catmull-Clark Surface Subdivision Algorithm.
10992
+ * Max step is limited to 6.
10993
+ * @param engine - Engine
10994
+ * @param radius - Sphere radius
10995
+ * @param step - Number of subdiv steps
10996
+ * @param noLongerAccessible - No longer access the vertices of the mesh after creation
10997
+ * @returns Sphere model mesh
10998
+ */ PrimitiveMesh.createSubdivisionSurfaceSphere = function createSubdivisionSurfaceSphere(engine, radius, step, noLongerAccessible) {
10999
+ if (radius === void 0) radius = 0.5;
11000
+ if (step === void 0) step = 3;
11001
+ if (noLongerAccessible === void 0) noLongerAccessible = true;
11002
+ var sphereMesh = new ModelMesh(engine);
11003
+ PrimitiveMesh._setSubdivisionSurfaceSphereData(sphereMesh, radius, step, noLongerAccessible, false);
11004
+ var vertexBuffer = sphereMesh.vertexBufferBindings[0].buffer;
11005
+ engine.resourceManager.addContentRestorer(new PrimitiveMeshRestorer(sphereMesh, new SubdivisionSurfaceSphereRestoreInfo(radius, step, vertexBuffer, noLongerAccessible)));
11006
+ return sphereMesh;
11007
+ };
11008
+ /**
11013
11009
  * Create a cuboid mesh.
11014
11010
  * @param engine - Engine
11015
11011
  * @param width - Cuboid width
@@ -11139,6 +11135,90 @@ var PrimitiveType;
11139
11135
  };
11140
11136
  /**
11141
11137
  * @internal
11138
+ */ PrimitiveMesh._setSubdivisionSurfaceSphereData = function _setSubdivisionSurfaceSphereData(sphereMesh, radius, step, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
11139
+ // Max step is limited to 6. Because 7 step will generate a single mesh with over 98306 vertices
11140
+ step = MathUtil$1.clamp(Math.floor(step), 1, 6);
11141
+ var positions = new Float32Array(3 * (6 * Math.pow(4, step) + 2));
11142
+ var cells = new Float32Array(24 * Math.pow(4, step));
11143
+ PrimitiveMesh._subdiveCatmullClark(step, positions, cells);
11144
+ var positionCount = positions.length / 3;
11145
+ var cellsCount = cells.length / 4;
11146
+ var poleOffset = positionCount + Math.pow(2, step + 1) - 1;
11147
+ // 16 extra vertices for pole uv
11148
+ // 2 vertices at each pole are idle
11149
+ var vertexCount = poleOffset + 16;
11150
+ var vertices = new Float32Array(vertexCount * 8);
11151
+ var indices = PrimitiveMesh._generateIndices(sphereMesh.engine, positionCount, cellsCount * 6);
11152
+ var seamCount = 0;
11153
+ var seamVertices = {};
11154
+ // Get normals, uvs, and scale to radius
11155
+ for(var i = 0; i < positionCount; i++){
11156
+ var offset = 3 * i;
11157
+ var x = positions[offset];
11158
+ var y = positions[offset + 1];
11159
+ var z = positions[offset + 2];
11160
+ var reciprocalLength = 1 / Math.sqrt(x * x + y * y + z * z);
11161
+ x *= reciprocalLength;
11162
+ y *= reciprocalLength;
11163
+ z *= reciprocalLength;
11164
+ offset = 8 * i;
11165
+ vertices[offset] = x * radius;
11166
+ vertices[offset + 1] = y * radius;
11167
+ vertices[offset + 2] = z * radius;
11168
+ vertices[offset + 3] = x;
11169
+ vertices[offset + 4] = y;
11170
+ vertices[offset + 5] = z;
11171
+ vertices[offset + 6] = (Math.PI - Math.atan2(z, x)) / (2 * Math.PI);
11172
+ vertices[offset + 7] = Math.acos(y) / Math.PI;
11173
+ if (vertices[offset + 6] === 0) {
11174
+ // Generate seam vertex
11175
+ var seamOffset = 8 * (positionCount + seamCount++);
11176
+ vertices.set(vertices.subarray(offset, offset + 8), seamOffset);
11177
+ vertices[seamOffset + 6] = 1.0;
11178
+ // Cache seam vertex
11179
+ seamVertices[offset / 8] = seamOffset / 8;
11180
+ }
11181
+ }
11182
+ // Get indices
11183
+ var offset1 = 0;
11184
+ this._spherePoleIdx = 0;
11185
+ for(var i1 = 0; i1 < cellsCount; i1++){
11186
+ var idx = 4 * i1;
11187
+ var indexA = cells[idx];
11188
+ var indexB = cells[idx + 1];
11189
+ var indexC = cells[idx + 2];
11190
+ var indexD = cells[idx + 3];
11191
+ // Handle seam by replacing vertex index to seam vertex index if necessary
11192
+ var floatIndexA = 8 * indexA;
11193
+ var floatIndexB = 8 * indexB;
11194
+ var floatIndexC = 8 * indexC;
11195
+ var floatIndexD = 8 * indexD;
11196
+ // If center Z is negative
11197
+ if (vertices[floatIndexA + 2] + vertices[floatIndexB + 2] + vertices[floatIndexC + 2] < 0) {
11198
+ vertices[floatIndexA + 6] === 0 && (indexA = seamVertices[indexA]);
11199
+ vertices[floatIndexB + 6] === 0 && (indexB = seamVertices[indexB]);
11200
+ vertices[floatIndexC + 6] === 0 && (indexC = seamVertices[indexC]);
11201
+ vertices[floatIndexD + 6] === 0 && (indexD = seamVertices[indexD]);
11202
+ }
11203
+ indices[offset1] = indexA;
11204
+ indices[offset1 + 1] = indexB;
11205
+ indices[offset1 + 2] = indexC;
11206
+ this._generateAndReplacePoleUV(indices, vertices, offset1, poleOffset);
11207
+ indices[offset1 + 3] = indexA;
11208
+ indices[offset1 + 4] = indexC;
11209
+ indices[offset1 + 5] = indexD;
11210
+ this._generateAndReplacePoleUV(indices, vertices, offset1 + 3, poleOffset);
11211
+ offset1 += 6;
11212
+ }
11213
+ if (!isRestoreMode) {
11214
+ var bounds = sphereMesh.bounds;
11215
+ bounds.min.set(-radius, -radius, -radius);
11216
+ bounds.max.set(radius, radius, radius);
11217
+ }
11218
+ PrimitiveMesh._initialize(sphereMesh, vertices, indices, noLongerAccessible, isRestoreMode, restoreVertexBuffer);
11219
+ };
11220
+ /**
11221
+ * @internal
11142
11222
  */ PrimitiveMesh._setSphereData = function _setSphereData(sphereMesh, radius, segments, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
11143
11223
  segments = Math.max(2, Math.floor(segments));
11144
11224
  var count = segments + 1;
@@ -11199,6 +11279,135 @@ var PrimitiveType;
11199
11279
  };
11200
11280
  /**
11201
11281
  * @internal
11282
+ */ PrimitiveMesh._subdiveCatmullClark = function _subdiveCatmullClark(step, positions, cells) {
11283
+ var edges = new Map();
11284
+ var faces = new Array();
11285
+ positions.set(PrimitiveMesh._sphereSeedPositions);
11286
+ cells.set(PrimitiveMesh._sphereSeedCells);
11287
+ for(var i = 0; i < step; i++){
11288
+ var cellCount = 6 * Math.pow(4, i);
11289
+ var positionCount = 4 * cellCount + 2;
11290
+ edges.clear();
11291
+ faces.length = 0;
11292
+ // Get cell face's facePoint
11293
+ for(var j = 0; j < cellCount; j++){
11294
+ var face = faces[j] = {
11295
+ facePoint: new Vector3(),
11296
+ adjacentEdges: new Array(4)
11297
+ };
11298
+ // Get cell's edgePoint
11299
+ for(var k = 0; k < 4; k++){
11300
+ var offset = 3 * cells[4 * j + k];
11301
+ face.facePoint.x += 0.25 * positions[offset];
11302
+ face.facePoint.y += 0.25 * positions[offset + 1];
11303
+ face.facePoint.z += 0.25 * positions[offset + 2];
11304
+ }
11305
+ // Get cell edges
11306
+ for(var k1 = 0; k1 < 4; k1++){
11307
+ var vertexIdxA = cells[4 * j + k1];
11308
+ var vertexIdxB = cells[4 * j + (k1 + 1) % 4];
11309
+ var edgeIdxKey = Math.min(vertexIdxA, vertexIdxB) * positionCount + Math.max(vertexIdxA, vertexIdxB);
11310
+ if (!edges.has(edgeIdxKey)) {
11311
+ var edge = {
11312
+ edgePoint: new Vector3(),
11313
+ edgePointIndex: undefined
11314
+ };
11315
+ var offsetA = 3 * vertexIdxA;
11316
+ var offsetB = 3 * vertexIdxB;
11317
+ 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]));
11318
+ edges.set(edgeIdxKey, edge);
11319
+ }
11320
+ var edge1 = edges.get(edgeIdxKey);
11321
+ face.adjacentEdges[k1] = edge1;
11322
+ var edgePoint = edge1.edgePoint;
11323
+ var facePoint = face.facePoint;
11324
+ edgePoint.x += 0.25 * facePoint.x;
11325
+ edgePoint.y += 0.25 * facePoint.y;
11326
+ edgePoint.z += 0.25 * facePoint.z;
11327
+ }
11328
+ }
11329
+ var prePointCount = cellCount + 2;
11330
+ var edgePointOffset = prePointCount + cellCount;
11331
+ var pointIdx = 0;
11332
+ this._sphereEdgeIdx = 0;
11333
+ var preCells = cells.slice(0, 4 * cellCount);
11334
+ // Get New positions, which consists of updated positions of existing points, face points and edge points
11335
+ for(var j1 = 0; j1 < cellCount; j1++){
11336
+ // Add face point to new positions
11337
+ var face1 = faces[j1];
11338
+ face1.facePoint.copyToArray(positions, 3 * (prePointCount + j1));
11339
+ // Get the face point index
11340
+ var ic = prePointCount + j1;
11341
+ var id = void 0, ib = void 0, temp = void 0;
11342
+ // ia -- id -- ia
11343
+ // | | |
11344
+ // ib -- ic -- ib
11345
+ // | | |
11346
+ // ia -- id -- ia
11347
+ for(var k2 = 0; k2 < 4; k2++){
11348
+ // Get the updated existing point index
11349
+ var ia = preCells[pointIdx++];
11350
+ // ib and id share four edge points in one cell
11351
+ switch(k2){
11352
+ case 0:
11353
+ {
11354
+ var edgeB = face1.adjacentEdges[k2 % 4];
11355
+ var edgeD = face1.adjacentEdges[(k2 + 3) % 4];
11356
+ ib = this._calculateEdgeIndex(positions, edgeB, edgePointOffset);
11357
+ id = this._calculateEdgeIndex(positions, edgeD, edgePointOffset);
11358
+ temp = id;
11359
+ break;
11360
+ }
11361
+ case 1:
11362
+ case 2:
11363
+ {
11364
+ var edgeB1 = face1.adjacentEdges[k2 % 4];
11365
+ id = ib;
11366
+ ib = this._calculateEdgeIndex(positions, edgeB1, edgePointOffset);
11367
+ break;
11368
+ }
11369
+ case 3:
11370
+ {
11371
+ id = ib;
11372
+ ib = temp;
11373
+ break;
11374
+ }
11375
+ }
11376
+ var idx = 4 * (4 * j1 + k2);
11377
+ cells[idx] = ia;
11378
+ cells[idx + 1] = ib;
11379
+ cells[idx + 2] = ic;
11380
+ cells[idx + 3] = id;
11381
+ }
11382
+ }
11383
+ }
11384
+ };
11385
+ /**
11386
+ * Duplicate vertices at the poles and adjust their UV coordinates.
11387
+ */ PrimitiveMesh._generateAndReplacePoleUV = function _generateAndReplacePoleUV(indices, vertices, idx, poleOffset) {
11388
+ var v = vertices[8 * indices[idx] + 7];
11389
+ if (v === 0 || v === 1) {
11390
+ var offset = 8 * indices[idx];
11391
+ var addedOffset = 8 * (poleOffset + this._spherePoleIdx);
11392
+ vertices.set(vertices.subarray(offset, offset + 8), addedOffset);
11393
+ vertices[addedOffset + 6] = 0.5 * (vertices[offset + 6] + vertices[8 * indices[idx + 1] + 6] + vertices[8 * indices[idx + 2] + 6] - 0.5);
11394
+ indices[idx] = poleOffset + this._spherePoleIdx++;
11395
+ }
11396
+ };
11397
+ /**
11398
+ * Get edge point index for subdivision surface sphere.
11399
+ */ PrimitiveMesh._calculateEdgeIndex = function _calculateEdgeIndex(positions, edge, offset) {
11400
+ if (edge.edgePointIndex !== undefined) {
11401
+ return edge.edgePointIndex;
11402
+ } else {
11403
+ edge.edgePoint.copyToArray(positions, 3 * (offset + PrimitiveMesh._sphereEdgeIdx));
11404
+ var index = offset + PrimitiveMesh._sphereEdgeIdx++;
11405
+ edge.edgePointIndex = index;
11406
+ return index;
11407
+ }
11408
+ };
11409
+ /**
11410
+ * @internal
11202
11411
  */ PrimitiveMesh._setCuboidData = function _setCuboidData(cuboidMesh, width, height, depth, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
11203
11412
  var halfWidth = width / 2;
11204
11413
  var halfHeight = height / 2;
@@ -11828,6 +12037,68 @@ var PrimitiveType;
11828
12037
  (function() {
11829
12038
  PrimitiveMesh._tempVec30 = new Vector3();
11830
12039
  })();
12040
+ (function() {
12041
+ PrimitiveMesh._sphereSeedPositions = new Float32Array([
12042
+ -1,
12043
+ 1,
12044
+ 1,
12045
+ -1,
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
+ ]);
12067
+ })();
12068
+ (function() {
12069
+ PrimitiveMesh._sphereSeedCells = new Float32Array([
12070
+ 0,
12071
+ 1,
12072
+ 2,
12073
+ 3,
12074
+ 3,
12075
+ 2,
12076
+ 4,
12077
+ 5,
12078
+ 5,
12079
+ 4,
12080
+ 6,
12081
+ 7,
12082
+ 7,
12083
+ 0,
12084
+ 3,
12085
+ 5,
12086
+ 7,
12087
+ 6,
12088
+ 1,
12089
+ 0,
12090
+ 6,
12091
+ 4,
12092
+ 2,
12093
+ 1
12094
+ ]);
12095
+ })();
12096
+ (function() {
12097
+ PrimitiveMesh._sphereEdgeIdx = 0;
12098
+ })();
12099
+ (function() {
12100
+ PrimitiveMesh._spherePoleIdx = 0;
12101
+ })();
11831
12102
 
11832
12103
  /**
11833
12104
  * Mesh skin data, equal glTF skins define
@@ -12336,8 +12607,10 @@ var Basic2DBatcher = /*#__PURE__*/ function() {
12336
12607
  }
12337
12608
  mesh.addSubMesh(this._getSubMeshFromPool(vertexStartIndex, vertexCount));
12338
12609
  batchedQueue[curMeshIndex] = preElement;
12339
- this._vertexBuffers[_flushId].setData(vertices, 0, 0, vertexIndex);
12340
- this._indiceBuffers[_flushId].setData(indices, 0, 0, indiceIndex);
12610
+ // Set data option use Discard, or will resulted in performance slowdown when open antialias and cross-rendering of 3D and 2D elements.
12611
+ // Device: iphone X(16.7.2)、iphone 15 pro max(17.1.1)、iphone XR(17.1.2) etc.
12612
+ this._vertexBuffers[_flushId].setData(vertices, 0, 0, vertexIndex, SetDataOptions.Discard);
12613
+ this._indiceBuffers[_flushId].setData(indices, 0, 0, indiceIndex, SetDataOptions.Discard);
12341
12614
  };
12342
12615
  _proto._getSubMeshFromPool = function _getSubMeshFromPool(start, count) {
12343
12616
  var subMesh = this._subMeshPool.getFromPool();
@@ -16399,7 +16672,6 @@ __decorate([
16399
16672
  if (this._destroyed) return;
16400
16673
  ReferResource1.prototype._addReferCount.call(this, value);
16401
16674
  this.shaderData._addReferCount(value);
16402
- this._shader._addReferCount(value);
16403
16675
  };
16404
16676
  /**
16405
16677
  * @override
@@ -16427,12 +16699,6 @@ __decorate([
16427
16699
  return this._shader;
16428
16700
  },
16429
16701
  set: function set(value) {
16430
- var refCount = this._getReferCount();
16431
- if (refCount > 0) {
16432
- var _this__shader;
16433
- (_this__shader = this._shader) == null ? void 0 : _this__shader._addReferCount(-refCount);
16434
- value._addReferCount(refCount);
16435
- }
16436
16702
  this._shader = value;
16437
16703
  var renderStates = this._renderStates;
16438
16704
  var lastStatesCount = renderStates.length;
@@ -16696,24 +16962,6 @@ var unlitVs = "#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#in
16696
16962
  */ _proto.cache = function cache(shaderProgram) {
16697
16963
  this._lastQueryMap[this._lastQueryKey] = shaderProgram;
16698
16964
  };
16699
- /**
16700
- * @internal
16701
- */ _proto._destroy = function _destroy() {
16702
- this._recursiveDestroy(0, this._cacheMap);
16703
- this._cacheMap = Object.create(null);
16704
- };
16705
- _proto._recursiveDestroy = function _recursiveDestroy(hierarchy, cacheMap) {
16706
- if (hierarchy === this._cacheHierarchyDepth - 1) {
16707
- for(var k in cacheMap){
16708
- cacheMap[k].destroy();
16709
- }
16710
- return;
16711
- }
16712
- ++hierarchy;
16713
- for(var k1 in cacheMap){
16714
- this._recursiveDestroy(hierarchy, cacheMap[k1]);
16715
- }
16716
- };
16717
16965
  _proto._resizeCacheMapHierarchy = function _resizeCacheMapHierarchy(cacheMap, hierarchy, currentHierarchy, increaseHierarchy) {
16718
16966
  // Only expand but not shrink
16719
16967
  if (hierarchy == currentHierarchy - 1) {
@@ -18291,7 +18539,7 @@ var /**
18291
18539
  /**
18292
18540
  * @internal
18293
18541
  */ _proto._render = function _render(context) {
18294
- if (this._text === "" || this.enableWrapping && this.width <= 0 || this.overflowMode === OverflowMode.Truncate && this.height <= 0) {
18542
+ if (this._isTextNoVisible()) {
18295
18543
  return;
18296
18544
  }
18297
18545
  if (this._isContainDirtyFlag(0x10)) {
@@ -18383,8 +18631,8 @@ var /**
18383
18631
  }
18384
18632
  };
18385
18633
  _proto._updateLocalData = function _updateLocalData() {
18386
- var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
18387
18634
  var _this__localBounds = this._localBounds, min = _this__localBounds.min, max = _this__localBounds.max;
18635
+ var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
18388
18636
  var textMetrics = this.enableWrapping ? TextUtils.measureTextWithWrap(this) : TextUtils.measureTextWithoutWrap(this);
18389
18637
  var height = textMetrics.height, lines = textMetrics.lines, lineWidths = textMetrics.lineWidths, lineHeight = textMetrics.lineHeight, lineMaxSizes = textMetrics.lineMaxSizes;
18390
18638
  var charRenderDataPool = TextRenderer._charRenderDataPool;
@@ -18452,7 +18700,7 @@ var /**
18452
18700
  var left = startX * pixelsPerUnitReciprocal;
18453
18701
  var right = (startX + w) * pixelsPerUnitReciprocal;
18454
18702
  var top = (startY + ascent) * pixelsPerUnitReciprocal;
18455
- var bottom = (startY - descent + 1) * pixelsPerUnitReciprocal;
18703
+ var bottom = (startY - descent) * pixelsPerUnitReciprocal;
18456
18704
  localPositions.set(left, top, right, bottom);
18457
18705
  i === firstLine && (maxY = Math.max(maxY, top));
18458
18706
  minY = Math.min(minY, bottom);
@@ -18493,6 +18741,9 @@ var /**
18493
18741
  Renderer1.prototype._onTransformChanged.call(this, bit);
18494
18742
  this._setDirtyFlagTrue(0x4 | 0x8);
18495
18743
  };
18744
+ _proto._isTextNoVisible = function _isTextNoVisible() {
18745
+ return this._text === "" || this._fontSize === 0 || this.enableWrapping && this.width <= 0 || this.overflowMode === OverflowMode.Truncate && this.height <= 0;
18746
+ };
18496
18747
  _create_class(TextRenderer, [
18497
18748
  {
18498
18749
  key: "color",
@@ -18695,6 +18946,16 @@ var /**
18695
18946
  get: /**
18696
18947
  * The bounding volume of the TextRenderer.
18697
18948
  */ function get() {
18949
+ if (this._isTextNoVisible()) {
18950
+ if (this._isContainDirtyFlag(0x8)) {
18951
+ var localBounds = this._localBounds;
18952
+ localBounds.min.set(0, 0, 0);
18953
+ localBounds.max.set(0, 0, 0);
18954
+ this._updateBounds(this._bounds);
18955
+ this._setDirtyFlagFalse(0x8);
18956
+ }
18957
+ return this._bounds;
18958
+ }
18698
18959
  this._isContainDirtyFlag(0x1) && this._resetSubFont();
18699
18960
  this._isContainDirtyFlag(0x2) && this._updateLocalData();
18700
18961
  this._isContainDirtyFlag(0x4) && this._updatePosition();
@@ -19021,7 +19282,6 @@ ShaderPool.init();
19021
19282
  shaderProgramPools.length = length;
19022
19283
  }
19023
19284
  shaderProgramPools[index] = pool = new ShaderProgramPool();
19024
- shaderPass._shaderProgramPools.push(pool);
19025
19285
  }
19026
19286
  return pool;
19027
19287
  };
@@ -21611,38 +21871,45 @@ var passNum = 0;
21611
21871
  var v0 = a[from];
21612
21872
  var v1 = a[to - 1];
21613
21873
  var v2 = a[third_index];
21874
+ var swapFlag = false;
21614
21875
  var c01 = compareFunc(v0, v1);
21615
21876
  if (c01 > 0) {
21616
21877
  // v1 < v0, so swap them.
21617
21878
  var tmp = v0;
21618
21879
  v0 = v1;
21619
21880
  v1 = tmp;
21881
+ swapFlag = true;
21620
21882
  } // v0 <= v1.
21621
21883
  var c02 = compareFunc(v0, v2);
21622
- if (c02 >= 0) {
21623
- // v2 <= v0 <= v1.
21884
+ if (c02 > 0) {
21885
+ // v2 < v0.
21624
21886
  var tmp1 = v0;
21625
21887
  v0 = v2;
21626
21888
  v2 = v1;
21627
21889
  v1 = tmp1;
21890
+ swapFlag = true;
21628
21891
  } else {
21629
- // v0 <= v1 && v0 < v2
21892
+ // v2 >= v0
21630
21893
  var c12 = compareFunc(v1, v2);
21631
21894
  if (c12 > 0) {
21632
21895
  // v0 <= v2 < v1
21633
21896
  var tmp2 = v1;
21634
21897
  v1 = v2;
21635
21898
  v2 = tmp2;
21899
+ swapFlag = true;
21636
21900
  }
21637
21901
  }
21638
21902
  // v0 <= v1 <= v2
21639
- a[from] = v0;
21640
- a[to - 1] = v2;
21641
- var pivot = v1;
21642
21903
  var low_end = from + 1; // Upper bound of elements lower than pivot.
21643
21904
  var high_start = to - 1; // Lower bound of elements greater than pivot.
21644
- a[third_index] = a[low_end];
21645
- a[low_end] = pivot;
21905
+ var pivot = v2;
21906
+ if (swapFlag) {
21907
+ a[from] = v0;
21908
+ a[to - 1] = v2;
21909
+ pivot = v1;
21910
+ a[third_index] = a[low_end];
21911
+ a[low_end] = pivot;
21912
+ }
21646
21913
  // From low_end to i are elements equal to pivot.
21647
21914
  // From i to high_start are elements that haven't been compared yet.
21648
21915
  partition: for(var i = low_end + 1; i < high_start; i++){
@@ -21697,12 +21964,38 @@ var passNum = 0;
21697
21964
  /**
21698
21965
  * @internal
21699
21966
  */ RenderQueue._compareFromNearToFar = function _compareFromNearToFar(a, b) {
21700
- 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;
21967
+ var dataA = a.data;
21968
+ var dataB = b.data;
21969
+ var componentA = dataA.component;
21970
+ var componentB = dataB.component;
21971
+ var priorityOrder = componentA.priority - componentB.priority;
21972
+ if (priorityOrder !== 0) {
21973
+ return priorityOrder;
21974
+ }
21975
+ // make suer from the same renderer.
21976
+ if (componentA.instanceId === componentB.instanceId) {
21977
+ return dataA.material._priority - dataB.material._priority || componentA._distanceForSort - componentB._distanceForSort;
21978
+ } else {
21979
+ return componentA._distanceForSort - componentB._distanceForSort;
21980
+ }
21701
21981
  };
21702
21982
  /**
21703
21983
  * @internal
21704
21984
  */ RenderQueue._compareFromFarToNear = function _compareFromFarToNear(a, b) {
21705
- 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;
21985
+ var dataA = a.data;
21986
+ var dataB = b.data;
21987
+ var componentA = dataA.component;
21988
+ var componentB = dataB.component;
21989
+ var priorityOrder = componentA.priority - componentB.priority;
21990
+ if (priorityOrder !== 0) {
21991
+ return priorityOrder;
21992
+ }
21993
+ // make suer from the same renderer.
21994
+ if (componentA.instanceId === componentB.instanceId) {
21995
+ return dataA.material._priority - dataB.material._priority || componentB._distanceForSort - componentA._distanceForSort;
21996
+ } else {
21997
+ return componentB._distanceForSort - componentA._distanceForSort;
21998
+ }
21706
21999
  };
21707
22000
  return RenderQueue;
21708
22001
  }();
@@ -23743,12 +24036,6 @@ var BaseMaterial = /*#__PURE__*/ function(Material1) {
23743
24036
  return this._shader;
23744
24037
  },
23745
24038
  set: function set(value) {
23746
- var refCount = this._getReferCount();
23747
- if (refCount > 0) {
23748
- var _this__shader;
23749
- (_this__shader = this._shader) == null ? void 0 : _this__shader._addReferCount(-refCount);
23750
- value._addReferCount(refCount);
23751
- }
23752
24039
  this._shader = value;
23753
24040
  var renderStates = this._renderStates;
23754
24041
  var lastStatesCount = renderStates.length;
@@ -27608,7 +27895,7 @@ var ParticleStopMode;
27608
27895
  if (!material) {
27609
27896
  return;
27610
27897
  }
27611
- if (material.destroyed || material.shader.destroyed) {
27898
+ if (material.destroyed) {
27612
27899
  material = this.engine._particleMagentaMaterial;
27613
27900
  }
27614
27901
  var renderData = this._engine._renderDataPool.getFromPool();