@galacean/engine-core 0.0.0-experimental-shaderlab.0 → 0.0.0-experimental-uploadSameBuffer.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.
@@ -2037,7 +2037,8 @@ var Logger = {
2037
2037
  _proto._createFontAtlas = function _createFontAtlas() {
2038
2038
  var _this = this, engine = _this._engine;
2039
2039
  var fontAtlas = new FontAtlas(engine);
2040
- var texture = new Texture2D(engine, 256, 256);
2040
+ var texture = new Texture2D(engine, 256, 256, exports.TextureFormat.R8G8B8A8, false);
2041
+ texture.filterMode = exports.TextureFilterMode.Point;
2041
2042
  fontAtlas.texture = texture;
2042
2043
  fontAtlas.isGCIgnored = texture.isGCIgnored = true;
2043
2044
  this._fontAtlases.push(fontAtlas);
@@ -5980,7 +5981,6 @@ var ShaderFactory = /*#__PURE__*/ function() {
5980
5981
  _this = ShaderPart1.call(this) || this;
5981
5982
  /** @internal */ _this._shaderPassId = 0;
5982
5983
  /** @internal */ _this._renderStateDataMap = {};
5983
- /** @internal */ _this._shaderProgramPools = [];
5984
5984
  _this._shaderPassId = ShaderPass._shaderPassCounter++;
5985
5985
  if (typeof fragmentSourceOrTags === "string") {
5986
5986
  _this._name = nameOrVertexSource;
@@ -6034,15 +6034,6 @@ var ShaderFactory = /*#__PURE__*/ function() {
6034
6034
  shaderProgramPool.cache(shaderProgram);
6035
6035
  return shaderProgram;
6036
6036
  };
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
6037
  return ShaderPass;
6047
6038
  }(ShaderPart);
6048
6039
  (function() {
@@ -6673,8 +6664,6 @@ __decorate([
6673
6664
  */ var Shader = /*#__PURE__*/ function() {
6674
6665
  function Shader(name, subShaders) {
6675
6666
  this.name = name;
6676
- this._refCount = 0;
6677
- this._destroyed = false;
6678
6667
  this.name = name;
6679
6668
  this._subShaders = subShaders;
6680
6669
  }
@@ -6694,46 +6683,20 @@ __decorate([
6694
6683
  for(var i = 0, n = macros.length; i < n; i++){
6695
6684
  compileMacros.enable(ShaderMacro.getByName(macros[i]));
6696
6685
  }
6697
- var isValid = false;
6698
6686
  var subShaders = this._subShaders;
6699
6687
  for(var i1 = 0, n1 = subShaders.length; i1 < n1; i1++){
6688
+ var isValid = void 0;
6700
6689
  var passes = subShaders[i1].passes;
6701
6690
  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();
6691
+ if (isValid === undefined) {
6692
+ isValid = passes[j]._getShaderProgram(engine, compileMacros).isValid;
6693
+ } else {
6694
+ isValid && (isValid = passes[j]._getShaderProgram(engine, compileMacros).isValid);
6695
+ }
6722
6696
  }
6697
+ if (isValid) return true;
6723
6698
  }
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;
6699
+ return false;
6737
6700
  };
6738
6701
  Shader.create = function create(nameOrShaderSource, vertexSourceOrShaderPassesOrSubShaders, fragmentSource) {
6739
6702
  var shader;
@@ -6920,14 +6883,6 @@ __decorate([
6920
6883
  */ function get() {
6921
6884
  return this._subShaders;
6922
6885
  }
6923
- },
6924
- {
6925
- key: "destroyed",
6926
- get: /**
6927
- * Whether it has been destroyed.
6928
- */ function get() {
6929
- return this._destroyed;
6930
- }
6931
6886
  }
6932
6887
  ]);
6933
6888
  return Shader;
@@ -8056,6 +8011,9 @@ SimpleSpriteAssembler = __decorate([
8056
8011
  __decorate([
8057
8012
  assignmentClone
8058
8013
  ], SpriteMask.prototype, "influenceLayers", void 0);
8014
+ __decorate([
8015
+ ignoreClone
8016
+ ], SpriteMask.prototype, "_verticesData", void 0);
8059
8017
  __decorate([
8060
8018
  ignoreClone
8061
8019
  ], SpriteMask.prototype, "_sprite", void 0);
@@ -9188,7 +9146,7 @@ var BlendShapeFrameDirty;
9188
9146
  if (!material) {
9189
9147
  continue;
9190
9148
  }
9191
- if (material.destroyed || material.shader.destroyed) {
9149
+ if (material.destroyed) {
9192
9150
  material = this.engine._meshMagentaMaterial;
9193
9151
  }
9194
9152
  var renderData = meshRenderDataPool.getFromPool();
@@ -10843,6 +10801,10 @@ var VertexElementIndex;
10843
10801
  var sphereInfo = primitiveInfo;
10844
10802
  PrimitiveMesh._setSphereData(this.resource, sphereInfo.radius, sphereInfo.segments, sphereInfo.noLongerAccessible, true, sphereInfo.vertexBuffer);
10845
10803
  break;
10804
+ case 7:
10805
+ var CCSphereInfo = primitiveInfo;
10806
+ PrimitiveMesh._setSubdivisionSurfaceSphereData(this.resource, CCSphereInfo.radius, CCSphereInfo.step, CCSphereInfo.noLongerAccessible, true, CCSphereInfo.vertexBuffer);
10807
+ break;
10846
10808
  case 1:
10847
10809
  var cuboidInfo = primitiveInfo;
10848
10810
  PrimitiveMesh._setCuboidData(this.resource, cuboidInfo.width, cuboidInfo.height, cuboidInfo.depth, cuboidInfo.noLongerAccessible, true, cuboidInfo.vertexBuffer);
@@ -10880,6 +10842,7 @@ var PrimitiveType;
10880
10842
  PrimitiveType[PrimitiveType["Torus"] = 4] = "Torus";
10881
10843
  PrimitiveType[PrimitiveType["Cone"] = 5] = "Cone";
10882
10844
  PrimitiveType[PrimitiveType["Capsule"] = 6] = "Capsule";
10845
+ PrimitiveType[PrimitiveType["CCSphere"] = 7] = "CCSphere";
10883
10846
  })(PrimitiveType || (PrimitiveType = {}));
10884
10847
  /**
10885
10848
  * @internal
@@ -10901,6 +10864,19 @@ var PrimitiveType;
10901
10864
  }
10902
10865
  return SphereRestoreInfo;
10903
10866
  }(PrimitiveRestoreInfo);
10867
+ /**
10868
+ * @internal
10869
+ */ var SubdivisionSurfaceSphereRestoreInfo = /*#__PURE__*/ function(PrimitiveRestoreInfo) {
10870
+ _inherits(SubdivisionSurfaceSphereRestoreInfo, PrimitiveRestoreInfo);
10871
+ function SubdivisionSurfaceSphereRestoreInfo(radius, step, vertexBuffer, noLongerAccessible) {
10872
+ var _this;
10873
+ _this = PrimitiveRestoreInfo.call(this, 7, vertexBuffer, noLongerAccessible) || this;
10874
+ _this.radius = radius;
10875
+ _this.step = step;
10876
+ return _this;
10877
+ }
10878
+ return SubdivisionSurfaceSphereRestoreInfo;
10879
+ }(PrimitiveRestoreInfo);
10904
10880
  /**
10905
10881
  * @internal
10906
10882
  */ var CuboidRestoreInfo = /*#__PURE__*/ function(PrimitiveRestoreInfo) {
@@ -11015,6 +10991,24 @@ var PrimitiveType;
11015
10991
  return sphereMesh;
11016
10992
  };
11017
10993
  /**
10994
+ * Create a sphere mesh by implementing Catmull-Clark Surface Subdivision Algorithm.
10995
+ * Max step is limited to 6.
10996
+ * @param engine - Engine
10997
+ * @param radius - Sphere radius
10998
+ * @param step - Number of subdiv steps
10999
+ * @param noLongerAccessible - No longer access the vertices of the mesh after creation
11000
+ * @returns Sphere model mesh
11001
+ */ PrimitiveMesh.createSubdivisionSurfaceSphere = function createSubdivisionSurfaceSphere(engine, radius, step, noLongerAccessible) {
11002
+ if (radius === void 0) radius = 0.5;
11003
+ if (step === void 0) step = 3;
11004
+ if (noLongerAccessible === void 0) noLongerAccessible = true;
11005
+ var sphereMesh = new ModelMesh(engine);
11006
+ PrimitiveMesh._setSubdivisionSurfaceSphereData(sphereMesh, radius, step, noLongerAccessible, false);
11007
+ var vertexBuffer = sphereMesh.vertexBufferBindings[0].buffer;
11008
+ engine.resourceManager.addContentRestorer(new PrimitiveMeshRestorer(sphereMesh, new SubdivisionSurfaceSphereRestoreInfo(radius, step, vertexBuffer, noLongerAccessible)));
11009
+ return sphereMesh;
11010
+ };
11011
+ /**
11018
11012
  * Create a cuboid mesh.
11019
11013
  * @param engine - Engine
11020
11014
  * @param width - Cuboid width
@@ -11144,6 +11138,90 @@ var PrimitiveType;
11144
11138
  };
11145
11139
  /**
11146
11140
  * @internal
11141
+ */ PrimitiveMesh._setSubdivisionSurfaceSphereData = function _setSubdivisionSurfaceSphereData(sphereMesh, radius, step, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
11142
+ // Max step is limited to 6. Because 7 step will generate a single mesh with over 98306 vertices
11143
+ step = miniprogram.MathUtil.clamp(Math.floor(step), 1, 6);
11144
+ var positions = new Float32Array(3 * (6 * Math.pow(4, step) + 2));
11145
+ var cells = new Float32Array(24 * Math.pow(4, step));
11146
+ PrimitiveMesh._subdiveCatmullClark(step, positions, cells);
11147
+ var positionCount = positions.length / 3;
11148
+ var cellsCount = cells.length / 4;
11149
+ var poleOffset = positionCount + Math.pow(2, step + 1) - 1;
11150
+ // 16 extra vertices for pole uv
11151
+ // 2 vertices at each pole are idle
11152
+ var vertexCount = poleOffset + 16;
11153
+ var vertices = new Float32Array(vertexCount * 8);
11154
+ var indices = PrimitiveMesh._generateIndices(sphereMesh.engine, positionCount, cellsCount * 6);
11155
+ var seamCount = 0;
11156
+ var seamVertices = {};
11157
+ // Get normals, uvs, and scale to radius
11158
+ for(var i = 0; i < positionCount; i++){
11159
+ var offset = 3 * i;
11160
+ var x = positions[offset];
11161
+ var y = positions[offset + 1];
11162
+ var z = positions[offset + 2];
11163
+ var reciprocalLength = 1 / Math.sqrt(x * x + y * y + z * z);
11164
+ x *= reciprocalLength;
11165
+ y *= reciprocalLength;
11166
+ z *= reciprocalLength;
11167
+ offset = 8 * i;
11168
+ vertices[offset] = x * radius;
11169
+ vertices[offset + 1] = y * radius;
11170
+ vertices[offset + 2] = z * radius;
11171
+ vertices[offset + 3] = x;
11172
+ vertices[offset + 4] = y;
11173
+ vertices[offset + 5] = z;
11174
+ vertices[offset + 6] = (Math.PI - Math.atan2(z, x)) / (2 * Math.PI);
11175
+ vertices[offset + 7] = Math.acos(y) / Math.PI;
11176
+ if (vertices[offset + 6] === 0) {
11177
+ // Generate seam vertex
11178
+ var seamOffset = 8 * (positionCount + seamCount++);
11179
+ vertices.set(vertices.subarray(offset, offset + 8), seamOffset);
11180
+ vertices[seamOffset + 6] = 1.0;
11181
+ // Cache seam vertex
11182
+ seamVertices[offset / 8] = seamOffset / 8;
11183
+ }
11184
+ }
11185
+ // Get indices
11186
+ var offset1 = 0;
11187
+ this._spherePoleIdx = 0;
11188
+ for(var i1 = 0; i1 < cellsCount; i1++){
11189
+ var idx = 4 * i1;
11190
+ var indexA = cells[idx];
11191
+ var indexB = cells[idx + 1];
11192
+ var indexC = cells[idx + 2];
11193
+ var indexD = cells[idx + 3];
11194
+ // Handle seam by replacing vertex index to seam vertex index if necessary
11195
+ var floatIndexA = 8 * indexA;
11196
+ var floatIndexB = 8 * indexB;
11197
+ var floatIndexC = 8 * indexC;
11198
+ var floatIndexD = 8 * indexD;
11199
+ // If center Z is negative
11200
+ if (vertices[floatIndexA + 2] + vertices[floatIndexB + 2] + vertices[floatIndexC + 2] < 0) {
11201
+ vertices[floatIndexA + 6] === 0 && (indexA = seamVertices[indexA]);
11202
+ vertices[floatIndexB + 6] === 0 && (indexB = seamVertices[indexB]);
11203
+ vertices[floatIndexC + 6] === 0 && (indexC = seamVertices[indexC]);
11204
+ vertices[floatIndexD + 6] === 0 && (indexD = seamVertices[indexD]);
11205
+ }
11206
+ indices[offset1] = indexA;
11207
+ indices[offset1 + 1] = indexB;
11208
+ indices[offset1 + 2] = indexC;
11209
+ this._generateAndReplacePoleUV(indices, vertices, offset1, poleOffset);
11210
+ indices[offset1 + 3] = indexA;
11211
+ indices[offset1 + 4] = indexC;
11212
+ indices[offset1 + 5] = indexD;
11213
+ this._generateAndReplacePoleUV(indices, vertices, offset1 + 3, poleOffset);
11214
+ offset1 += 6;
11215
+ }
11216
+ if (!isRestoreMode) {
11217
+ var bounds = sphereMesh.bounds;
11218
+ bounds.min.set(-radius, -radius, -radius);
11219
+ bounds.max.set(radius, radius, radius);
11220
+ }
11221
+ PrimitiveMesh._initialize(sphereMesh, vertices, indices, noLongerAccessible, isRestoreMode, restoreVertexBuffer);
11222
+ };
11223
+ /**
11224
+ * @internal
11147
11225
  */ PrimitiveMesh._setSphereData = function _setSphereData(sphereMesh, radius, segments, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
11148
11226
  segments = Math.max(2, Math.floor(segments));
11149
11227
  var count = segments + 1;
@@ -11204,6 +11282,135 @@ var PrimitiveType;
11204
11282
  };
11205
11283
  /**
11206
11284
  * @internal
11285
+ */ PrimitiveMesh._subdiveCatmullClark = function _subdiveCatmullClark(step, positions, cells) {
11286
+ var edges = new Map();
11287
+ var faces = new Array();
11288
+ positions.set(PrimitiveMesh._sphereSeedPositions);
11289
+ cells.set(PrimitiveMesh._sphereSeedCells);
11290
+ for(var i = 0; i < step; i++){
11291
+ var cellCount = 6 * Math.pow(4, i);
11292
+ var positionCount = 4 * cellCount + 2;
11293
+ edges.clear();
11294
+ faces.length = 0;
11295
+ // Get cell face's facePoint
11296
+ for(var j = 0; j < cellCount; j++){
11297
+ var face = faces[j] = {
11298
+ facePoint: new miniprogram.Vector3(),
11299
+ adjacentEdges: new Array(4)
11300
+ };
11301
+ // Get cell's edgePoint
11302
+ for(var k = 0; k < 4; k++){
11303
+ var offset = 3 * cells[4 * j + k];
11304
+ face.facePoint.x += 0.25 * positions[offset];
11305
+ face.facePoint.y += 0.25 * positions[offset + 1];
11306
+ face.facePoint.z += 0.25 * positions[offset + 2];
11307
+ }
11308
+ // Get cell edges
11309
+ for(var k1 = 0; k1 < 4; k1++){
11310
+ var vertexIdxA = cells[4 * j + k1];
11311
+ var vertexIdxB = cells[4 * j + (k1 + 1) % 4];
11312
+ var edgeIdxKey = Math.min(vertexIdxA, vertexIdxB) * positionCount + Math.max(vertexIdxA, vertexIdxB);
11313
+ if (!edges.has(edgeIdxKey)) {
11314
+ var edge = {
11315
+ edgePoint: new miniprogram.Vector3(),
11316
+ edgePointIndex: undefined
11317
+ };
11318
+ var offsetA = 3 * vertexIdxA;
11319
+ var offsetB = 3 * vertexIdxB;
11320
+ 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]));
11321
+ edges.set(edgeIdxKey, edge);
11322
+ }
11323
+ var edge1 = edges.get(edgeIdxKey);
11324
+ face.adjacentEdges[k1] = edge1;
11325
+ var edgePoint = edge1.edgePoint;
11326
+ var facePoint = face.facePoint;
11327
+ edgePoint.x += 0.25 * facePoint.x;
11328
+ edgePoint.y += 0.25 * facePoint.y;
11329
+ edgePoint.z += 0.25 * facePoint.z;
11330
+ }
11331
+ }
11332
+ var prePointCount = cellCount + 2;
11333
+ var edgePointOffset = prePointCount + cellCount;
11334
+ var pointIdx = 0;
11335
+ this._sphereEdgeIdx = 0;
11336
+ var preCells = cells.slice(0, 4 * cellCount);
11337
+ // Get New positions, which consists of updated positions of existing points, face points and edge points
11338
+ for(var j1 = 0; j1 < cellCount; j1++){
11339
+ // Add face point to new positions
11340
+ var face1 = faces[j1];
11341
+ face1.facePoint.copyToArray(positions, 3 * (prePointCount + j1));
11342
+ // Get the face point index
11343
+ var ic = prePointCount + j1;
11344
+ var id = void 0, ib = void 0, temp = void 0;
11345
+ // ia -- id -- ia
11346
+ // | | |
11347
+ // ib -- ic -- ib
11348
+ // | | |
11349
+ // ia -- id -- ia
11350
+ for(var k2 = 0; k2 < 4; k2++){
11351
+ // Get the updated existing point index
11352
+ var ia = preCells[pointIdx++];
11353
+ // ib and id share four edge points in one cell
11354
+ switch(k2){
11355
+ case 0:
11356
+ {
11357
+ var edgeB = face1.adjacentEdges[k2 % 4];
11358
+ var edgeD = face1.adjacentEdges[(k2 + 3) % 4];
11359
+ ib = this._calculateEdgeIndex(positions, edgeB, edgePointOffset);
11360
+ id = this._calculateEdgeIndex(positions, edgeD, edgePointOffset);
11361
+ temp = id;
11362
+ break;
11363
+ }
11364
+ case 1:
11365
+ case 2:
11366
+ {
11367
+ var edgeB1 = face1.adjacentEdges[k2 % 4];
11368
+ id = ib;
11369
+ ib = this._calculateEdgeIndex(positions, edgeB1, edgePointOffset);
11370
+ break;
11371
+ }
11372
+ case 3:
11373
+ {
11374
+ id = ib;
11375
+ ib = temp;
11376
+ break;
11377
+ }
11378
+ }
11379
+ var idx = 4 * (4 * j1 + k2);
11380
+ cells[idx] = ia;
11381
+ cells[idx + 1] = ib;
11382
+ cells[idx + 2] = ic;
11383
+ cells[idx + 3] = id;
11384
+ }
11385
+ }
11386
+ }
11387
+ };
11388
+ /**
11389
+ * Duplicate vertices at the poles and adjust their UV coordinates.
11390
+ */ PrimitiveMesh._generateAndReplacePoleUV = function _generateAndReplacePoleUV(indices, vertices, idx, poleOffset) {
11391
+ var v = vertices[8 * indices[idx] + 7];
11392
+ if (v === 0 || v === 1) {
11393
+ var offset = 8 * indices[idx];
11394
+ var addedOffset = 8 * (poleOffset + this._spherePoleIdx);
11395
+ vertices.set(vertices.subarray(offset, offset + 8), addedOffset);
11396
+ vertices[addedOffset + 6] = 0.5 * (vertices[offset + 6] + vertices[8 * indices[idx + 1] + 6] + vertices[8 * indices[idx + 2] + 6] - 0.5);
11397
+ indices[idx] = poleOffset + this._spherePoleIdx++;
11398
+ }
11399
+ };
11400
+ /**
11401
+ * Get edge point index for subdivision surface sphere.
11402
+ */ PrimitiveMesh._calculateEdgeIndex = function _calculateEdgeIndex(positions, edge, offset) {
11403
+ if (edge.edgePointIndex !== undefined) {
11404
+ return edge.edgePointIndex;
11405
+ } else {
11406
+ edge.edgePoint.copyToArray(positions, 3 * (offset + PrimitiveMesh._sphereEdgeIdx));
11407
+ var index = offset + PrimitiveMesh._sphereEdgeIdx++;
11408
+ edge.edgePointIndex = index;
11409
+ return index;
11410
+ }
11411
+ };
11412
+ /**
11413
+ * @internal
11207
11414
  */ PrimitiveMesh._setCuboidData = function _setCuboidData(cuboidMesh, width, height, depth, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
11208
11415
  var halfWidth = width / 2;
11209
11416
  var halfHeight = height / 2;
@@ -11833,6 +12040,68 @@ var PrimitiveType;
11833
12040
  (function() {
11834
12041
  PrimitiveMesh._tempVec30 = new miniprogram.Vector3();
11835
12042
  })();
12043
+ (function() {
12044
+ PrimitiveMesh._sphereSeedPositions = new Float32Array([
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
+ -1,
12067
+ 1,
12068
+ -1
12069
+ ]);
12070
+ })();
12071
+ (function() {
12072
+ PrimitiveMesh._sphereSeedCells = new Float32Array([
12073
+ 0,
12074
+ 1,
12075
+ 2,
12076
+ 3,
12077
+ 3,
12078
+ 2,
12079
+ 4,
12080
+ 5,
12081
+ 5,
12082
+ 4,
12083
+ 6,
12084
+ 7,
12085
+ 7,
12086
+ 0,
12087
+ 3,
12088
+ 5,
12089
+ 7,
12090
+ 6,
12091
+ 1,
12092
+ 0,
12093
+ 6,
12094
+ 4,
12095
+ 2,
12096
+ 1
12097
+ ]);
12098
+ })();
12099
+ (function() {
12100
+ PrimitiveMesh._sphereEdgeIdx = 0;
12101
+ })();
12102
+ (function() {
12103
+ PrimitiveMesh._spherePoleIdx = 0;
12104
+ })();
11836
12105
 
11837
12106
  /**
11838
12107
  * Mesh skin data, equal glTF skins define
@@ -12341,8 +12610,8 @@ var Basic2DBatcher = /*#__PURE__*/ function() {
12341
12610
  }
12342
12611
  mesh.addSubMesh(this._getSubMeshFromPool(vertexStartIndex, vertexCount));
12343
12612
  batchedQueue[curMeshIndex] = preElement;
12344
- this._vertexBuffers[_flushId].setData(vertices, 0, 0, vertexIndex);
12345
- this._indiceBuffers[_flushId].setData(indices, 0, 0, indiceIndex);
12613
+ this._vertexBuffers[_flushId].setData(vertices, 0, 0, vertexIndex, exports.SetDataOptions.Discard);
12614
+ this._indiceBuffers[_flushId].setData(indices, 0, 0, indiceIndex, exports.SetDataOptions.Discard);
12346
12615
  };
12347
12616
  _proto._getSubMeshFromPool = function _getSubMeshFromPool(start, count) {
12348
12617
  var subMesh = this._subMeshPool.getFromPool();
@@ -16404,7 +16673,6 @@ __decorate([
16404
16673
  if (this._destroyed) return;
16405
16674
  ReferResource1.prototype._addReferCount.call(this, value);
16406
16675
  this.shaderData._addReferCount(value);
16407
- this._shader._addReferCount(value);
16408
16676
  };
16409
16677
  /**
16410
16678
  * @override
@@ -16432,12 +16700,6 @@ __decorate([
16432
16700
  return this._shader;
16433
16701
  },
16434
16702
  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
16703
  this._shader = value;
16442
16704
  var renderStates = this._renderStates;
16443
16705
  var lastStatesCount = renderStates.length;
@@ -16701,24 +16963,6 @@ var unlitVs = "#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#in
16701
16963
  */ _proto.cache = function cache(shaderProgram) {
16702
16964
  this._lastQueryMap[this._lastQueryKey] = shaderProgram;
16703
16965
  };
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
16966
  _proto._resizeCacheMapHierarchy = function _resizeCacheMapHierarchy(cacheMap, hierarchy, currentHierarchy, increaseHierarchy) {
16723
16967
  // Only expand but not shrink
16724
16968
  if (hierarchy == currentHierarchy - 1) {
@@ -19026,7 +19270,6 @@ ShaderPool.init();
19026
19270
  shaderProgramPools.length = length;
19027
19271
  }
19028
19272
  shaderProgramPools[index] = pool = new ShaderProgramPool();
19029
- shaderPass._shaderProgramPools.push(pool);
19030
19273
  }
19031
19274
  return pool;
19032
19275
  };
@@ -23748,12 +23991,6 @@ var BaseMaterial = /*#__PURE__*/ function(Material1) {
23748
23991
  return this._shader;
23749
23992
  },
23750
23993
  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
23994
  this._shader = value;
23758
23995
  var renderStates = this._renderStates;
23759
23996
  var lastStatesCount = renderStates.length;
@@ -27613,7 +27850,7 @@ exports.ParticleStopMode = void 0;
27613
27850
  if (!material) {
27614
27851
  return;
27615
27852
  }
27616
- if (material.destroyed || material.shader.destroyed) {
27853
+ if (material.destroyed) {
27617
27854
  material = this.engine._particleMagentaMaterial;
27618
27855
  }
27619
27856
  var renderData = this._engine._renderDataPool.getFromPool();