@galacean/engine 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.
package/dist/browser.js CHANGED
@@ -6995,7 +6995,8 @@
6995
6995
  _proto._createFontAtlas = function _createFontAtlas() {
6996
6996
  var _this = this, engine = _this._engine;
6997
6997
  var fontAtlas = new FontAtlas(engine);
6998
- var texture = new Texture2D(engine, 256, 256);
6998
+ var texture = new Texture2D(engine, 256, 256, exports.TextureFormat.R8G8B8A8, false);
6999
+ texture.filterMode = exports.TextureFilterMode.Point;
6999
7000
  fontAtlas.texture = texture;
7000
7001
  fontAtlas.isGCIgnored = texture.isGCIgnored = true;
7001
7002
  this._fontAtlases.push(fontAtlas);
@@ -10824,7 +10825,6 @@
10824
10825
  _this = ShaderPart1.call(this) || this;
10825
10826
  /** @internal */ _this._shaderPassId = 0;
10826
10827
  /** @internal */ _this._renderStateDataMap = {};
10827
- /** @internal */ _this._shaderProgramPools = [];
10828
10828
  _this._shaderPassId = ShaderPass._shaderPassCounter++;
10829
10829
  if (typeof fragmentSourceOrTags === "string") {
10830
10830
  _this._name = nameOrVertexSource;
@@ -10878,15 +10878,6 @@
10878
10878
  shaderProgramPool.cache(shaderProgram);
10879
10879
  return shaderProgram;
10880
10880
  };
10881
- /**
10882
- * @internal
10883
- */ _proto._destroy = function _destroy() {
10884
- var shaderProgramPools = this._shaderProgramPools;
10885
- for(var i = 0, n = shaderProgramPools.length; i < n; i++){
10886
- shaderProgramPools[i]._destroy();
10887
- }
10888
- shaderProgramPools.length = 0;
10889
- };
10890
10881
  return ShaderPass;
10891
10882
  }(ShaderPart);
10892
10883
  (function() {
@@ -11509,8 +11500,6 @@
11509
11500
  */ var Shader = /*#__PURE__*/ function() {
11510
11501
  var Shader = function Shader(name1, subShaders) {
11511
11502
  this.name = name1;
11512
- this._refCount = 0;
11513
- this._destroyed = false;
11514
11503
  this.name = name1;
11515
11504
  this._subShaders = subShaders;
11516
11505
  };
@@ -11530,46 +11519,20 @@
11530
11519
  for(var i = 0, n = macros.length; i < n; i++){
11531
11520
  compileMacros.enable(ShaderMacro.getByName(macros[i]));
11532
11521
  }
11533
- var isValid = false;
11534
11522
  var subShaders = this._subShaders;
11535
11523
  for(var i1 = 0, n1 = subShaders.length; i1 < n1; i1++){
11524
+ var isValid = void 0;
11536
11525
  var passes = subShaders[i1].passes;
11537
11526
  for(var j = 0, m = passes.length; j < m; j++){
11538
- var shaderProgram = passes[j]._getShaderProgram(engine, compileMacros);
11539
- isValid = j === 0 ? shaderProgram.isValid : isValid && shaderProgram.isValid;
11540
- }
11541
- }
11542
- return isValid;
11543
- };
11544
- /**
11545
- * Destroy the shader.
11546
- * @param force - Whether to force the destruction, if it is false, refCount = 0 can be released successfully.
11547
- * @returns Whether the release was successful.
11548
- */ _proto.destroy = function destroy(force) {
11549
- if (force === void 0) force = false;
11550
- if (!force && this._refCount !== 0) {
11551
- return false;
11552
- }
11553
- var subShaders = this._subShaders;
11554
- for(var i = 0, n = subShaders.length; i < n; i++){
11555
- var passes = subShaders[i].passes;
11556
- for(var j = 0, m = passes.length; j < m; j++){
11557
- passes[j]._destroy();
11527
+ if (isValid === undefined) {
11528
+ isValid = passes[j]._getShaderProgram(engine, compileMacros).isValid;
11529
+ } else {
11530
+ isValid && (isValid = passes[j]._getShaderProgram(engine, compileMacros).isValid);
11531
+ }
11558
11532
  }
11533
+ if (isValid) return true;
11559
11534
  }
11560
- delete Shader._shaderMap[this.name];
11561
- this._destroyed = true;
11562
- return true;
11563
- };
11564
- /**
11565
- * @internal
11566
- */ _proto._getReferCount = function _getReferCount() {
11567
- return this._refCount;
11568
- };
11569
- /**
11570
- * @internal
11571
- */ _proto._addReferCount = function _addReferCount(value) {
11572
- this._refCount += value;
11535
+ return false;
11573
11536
  };
11574
11537
  Shader.create = function create(nameOrShaderSource, vertexSourceOrShaderPassesOrSubShaders, fragmentSource) {
11575
11538
  var shader;
@@ -11756,14 +11719,6 @@
11756
11719
  */ function get() {
11757
11720
  return this._subShaders;
11758
11721
  }
11759
- },
11760
- {
11761
- key: "destroyed",
11762
- get: /**
11763
- * Whether it has been destroyed.
11764
- */ function get() {
11765
- return this._destroyed;
11766
- }
11767
11722
  }
11768
11723
  ]);
11769
11724
  return Shader;
@@ -12879,6 +12834,9 @@
12879
12834
  __decorate$1([
12880
12835
  assignmentClone
12881
12836
  ], SpriteMask.prototype, "influenceLayers", void 0);
12837
+ __decorate$1([
12838
+ ignoreClone
12839
+ ], SpriteMask.prototype, "_verticesData", void 0);
12882
12840
  __decorate$1([
12883
12841
  ignoreClone
12884
12842
  ], SpriteMask.prototype, "_sprite", void 0);
@@ -13993,7 +13951,7 @@
13993
13951
  if (!material) {
13994
13952
  continue;
13995
13953
  }
13996
- if (material.destroyed || material.shader.destroyed) {
13954
+ if (material.destroyed) {
13997
13955
  material = this.engine._meshMagentaMaterial;
13998
13956
  }
13999
13957
  var renderData = meshRenderDataPool.getFromPool();
@@ -15644,6 +15602,10 @@
15644
15602
  var sphereInfo = primitiveInfo;
15645
15603
  PrimitiveMesh._setSphereData(this.resource, sphereInfo.radius, sphereInfo.segments, sphereInfo.noLongerAccessible, true, sphereInfo.vertexBuffer);
15646
15604
  break;
15605
+ case 7:
15606
+ var CCSphereInfo = primitiveInfo;
15607
+ PrimitiveMesh._setSubdivisionSurfaceSphereData(this.resource, CCSphereInfo.radius, CCSphereInfo.step, CCSphereInfo.noLongerAccessible, true, CCSphereInfo.vertexBuffer);
15608
+ break;
15647
15609
  case 1:
15648
15610
  var cuboidInfo = primitiveInfo;
15649
15611
  PrimitiveMesh._setCuboidData(this.resource, cuboidInfo.width, cuboidInfo.height, cuboidInfo.depth, cuboidInfo.noLongerAccessible, true, cuboidInfo.vertexBuffer);
@@ -15681,6 +15643,7 @@
15681
15643
  PrimitiveType[PrimitiveType["Torus"] = 4] = "Torus";
15682
15644
  PrimitiveType[PrimitiveType["Cone"] = 5] = "Cone";
15683
15645
  PrimitiveType[PrimitiveType["Capsule"] = 6] = "Capsule";
15646
+ PrimitiveType[PrimitiveType["CCSphere"] = 7] = "CCSphere";
15684
15647
  })(PrimitiveType || (PrimitiveType = {}));
15685
15648
  /**
15686
15649
  * @internal
@@ -15702,6 +15665,19 @@
15702
15665
  _inherits$2(SphereRestoreInfo, PrimitiveRestoreInfo);
15703
15666
  return SphereRestoreInfo;
15704
15667
  }(PrimitiveRestoreInfo);
15668
+ /**
15669
+ * @internal
15670
+ */ var SubdivisionSurfaceSphereRestoreInfo = /*#__PURE__*/ function(PrimitiveRestoreInfo) {
15671
+ var SubdivisionSurfaceSphereRestoreInfo = function SubdivisionSurfaceSphereRestoreInfo(radius, step, vertexBuffer, noLongerAccessible) {
15672
+ var _this;
15673
+ _this = PrimitiveRestoreInfo.call(this, 7, vertexBuffer, noLongerAccessible) || this;
15674
+ _this.radius = radius;
15675
+ _this.step = step;
15676
+ return _this;
15677
+ };
15678
+ _inherits$2(SubdivisionSurfaceSphereRestoreInfo, PrimitiveRestoreInfo);
15679
+ return SubdivisionSurfaceSphereRestoreInfo;
15680
+ }(PrimitiveRestoreInfo);
15705
15681
  /**
15706
15682
  * @internal
15707
15683
  */ var CuboidRestoreInfo = /*#__PURE__*/ function(PrimitiveRestoreInfo) {
@@ -15815,6 +15791,24 @@
15815
15791
  return sphereMesh;
15816
15792
  };
15817
15793
  /**
15794
+ * Create a sphere mesh by implementing Catmull-Clark Surface Subdivision Algorithm.
15795
+ * Max step is limited to 6.
15796
+ * @param engine - Engine
15797
+ * @param radius - Sphere radius
15798
+ * @param step - Number of subdiv steps
15799
+ * @param noLongerAccessible - No longer access the vertices of the mesh after creation
15800
+ * @returns Sphere model mesh
15801
+ */ PrimitiveMesh.createSubdivisionSurfaceSphere = function createSubdivisionSurfaceSphere(engine, radius, step, noLongerAccessible) {
15802
+ if (radius === void 0) radius = 0.5;
15803
+ if (step === void 0) step = 3;
15804
+ if (noLongerAccessible === void 0) noLongerAccessible = true;
15805
+ var sphereMesh = new ModelMesh(engine);
15806
+ PrimitiveMesh._setSubdivisionSurfaceSphereData(sphereMesh, radius, step, noLongerAccessible, false);
15807
+ var vertexBuffer = sphereMesh.vertexBufferBindings[0].buffer;
15808
+ engine.resourceManager.addContentRestorer(new PrimitiveMeshRestorer(sphereMesh, new SubdivisionSurfaceSphereRestoreInfo(radius, step, vertexBuffer, noLongerAccessible)));
15809
+ return sphereMesh;
15810
+ };
15811
+ /**
15818
15812
  * Create a cuboid mesh.
15819
15813
  * @param engine - Engine
15820
15814
  * @param width - Cuboid width
@@ -15944,6 +15938,90 @@
15944
15938
  };
15945
15939
  /**
15946
15940
  * @internal
15941
+ */ PrimitiveMesh._setSubdivisionSurfaceSphereData = function _setSubdivisionSurfaceSphereData(sphereMesh, radius, step, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
15942
+ // Max step is limited to 6. Because 7 step will generate a single mesh with over 98306 vertices
15943
+ step = MathUtil$1.clamp(Math.floor(step), 1, 6);
15944
+ var positions = new Float32Array(3 * (6 * Math.pow(4, step) + 2));
15945
+ var cells = new Float32Array(24 * Math.pow(4, step));
15946
+ PrimitiveMesh._subdiveCatmullClark(step, positions, cells);
15947
+ var positionCount = positions.length / 3;
15948
+ var cellsCount = cells.length / 4;
15949
+ var poleOffset = positionCount + Math.pow(2, step + 1) - 1;
15950
+ // 16 extra vertices for pole uv
15951
+ // 2 vertices at each pole are idle
15952
+ var vertexCount = poleOffset + 16;
15953
+ var vertices = new Float32Array(vertexCount * 8);
15954
+ var indices = PrimitiveMesh._generateIndices(sphereMesh.engine, positionCount, cellsCount * 6);
15955
+ var seamCount = 0;
15956
+ var seamVertices = {};
15957
+ // Get normals, uvs, and scale to radius
15958
+ for(var i = 0; i < positionCount; i++){
15959
+ var offset = 3 * i;
15960
+ var x = positions[offset];
15961
+ var y = positions[offset + 1];
15962
+ var z = positions[offset + 2];
15963
+ var reciprocalLength = 1 / Math.sqrt(x * x + y * y + z * z);
15964
+ x *= reciprocalLength;
15965
+ y *= reciprocalLength;
15966
+ z *= reciprocalLength;
15967
+ offset = 8 * i;
15968
+ vertices[offset] = x * radius;
15969
+ vertices[offset + 1] = y * radius;
15970
+ vertices[offset + 2] = z * radius;
15971
+ vertices[offset + 3] = x;
15972
+ vertices[offset + 4] = y;
15973
+ vertices[offset + 5] = z;
15974
+ vertices[offset + 6] = (Math.PI - Math.atan2(z, x)) / (2 * Math.PI);
15975
+ vertices[offset + 7] = Math.acos(y) / Math.PI;
15976
+ if (vertices[offset + 6] === 0) {
15977
+ // Generate seam vertex
15978
+ var seamOffset = 8 * (positionCount + seamCount++);
15979
+ vertices.set(vertices.subarray(offset, offset + 8), seamOffset);
15980
+ vertices[seamOffset + 6] = 1.0;
15981
+ // Cache seam vertex
15982
+ seamVertices[offset / 8] = seamOffset / 8;
15983
+ }
15984
+ }
15985
+ // Get indices
15986
+ var offset1 = 0;
15987
+ this._spherePoleIdx = 0;
15988
+ for(var i1 = 0; i1 < cellsCount; i1++){
15989
+ var idx = 4 * i1;
15990
+ var indexA = cells[idx];
15991
+ var indexB = cells[idx + 1];
15992
+ var indexC = cells[idx + 2];
15993
+ var indexD = cells[idx + 3];
15994
+ // Handle seam by replacing vertex index to seam vertex index if necessary
15995
+ var floatIndexA = 8 * indexA;
15996
+ var floatIndexB = 8 * indexB;
15997
+ var floatIndexC = 8 * indexC;
15998
+ var floatIndexD = 8 * indexD;
15999
+ // If center Z is negative
16000
+ if (vertices[floatIndexA + 2] + vertices[floatIndexB + 2] + vertices[floatIndexC + 2] < 0) {
16001
+ vertices[floatIndexA + 6] === 0 && (indexA = seamVertices[indexA]);
16002
+ vertices[floatIndexB + 6] === 0 && (indexB = seamVertices[indexB]);
16003
+ vertices[floatIndexC + 6] === 0 && (indexC = seamVertices[indexC]);
16004
+ vertices[floatIndexD + 6] === 0 && (indexD = seamVertices[indexD]);
16005
+ }
16006
+ indices[offset1] = indexA;
16007
+ indices[offset1 + 1] = indexB;
16008
+ indices[offset1 + 2] = indexC;
16009
+ this._generateAndReplacePoleUV(indices, vertices, offset1, poleOffset);
16010
+ indices[offset1 + 3] = indexA;
16011
+ indices[offset1 + 4] = indexC;
16012
+ indices[offset1 + 5] = indexD;
16013
+ this._generateAndReplacePoleUV(indices, vertices, offset1 + 3, poleOffset);
16014
+ offset1 += 6;
16015
+ }
16016
+ if (!isRestoreMode) {
16017
+ var bounds = sphereMesh.bounds;
16018
+ bounds.min.set(-radius, -radius, -radius);
16019
+ bounds.max.set(radius, radius, radius);
16020
+ }
16021
+ PrimitiveMesh._initialize(sphereMesh, vertices, indices, noLongerAccessible, isRestoreMode, restoreVertexBuffer);
16022
+ };
16023
+ /**
16024
+ * @internal
15947
16025
  */ PrimitiveMesh._setSphereData = function _setSphereData(sphereMesh, radius, segments, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
15948
16026
  segments = Math.max(2, Math.floor(segments));
15949
16027
  var count = segments + 1;
@@ -16004,6 +16082,135 @@
16004
16082
  };
16005
16083
  /**
16006
16084
  * @internal
16085
+ */ PrimitiveMesh._subdiveCatmullClark = function _subdiveCatmullClark(step, positions, cells) {
16086
+ var edges = new Map();
16087
+ var faces = new Array();
16088
+ positions.set(PrimitiveMesh._sphereSeedPositions);
16089
+ cells.set(PrimitiveMesh._sphereSeedCells);
16090
+ for(var i = 0; i < step; i++){
16091
+ var cellCount = 6 * Math.pow(4, i);
16092
+ var positionCount = 4 * cellCount + 2;
16093
+ edges.clear();
16094
+ faces.length = 0;
16095
+ // Get cell face's facePoint
16096
+ for(var j = 0; j < cellCount; j++){
16097
+ var face = faces[j] = {
16098
+ facePoint: new Vector3(),
16099
+ adjacentEdges: new Array(4)
16100
+ };
16101
+ // Get cell's edgePoint
16102
+ for(var k = 0; k < 4; k++){
16103
+ var offset = 3 * cells[4 * j + k];
16104
+ face.facePoint.x += 0.25 * positions[offset];
16105
+ face.facePoint.y += 0.25 * positions[offset + 1];
16106
+ face.facePoint.z += 0.25 * positions[offset + 2];
16107
+ }
16108
+ // Get cell edges
16109
+ for(var k1 = 0; k1 < 4; k1++){
16110
+ var vertexIdxA = cells[4 * j + k1];
16111
+ var vertexIdxB = cells[4 * j + (k1 + 1) % 4];
16112
+ var edgeIdxKey = Math.min(vertexIdxA, vertexIdxB) * positionCount + Math.max(vertexIdxA, vertexIdxB);
16113
+ if (!edges.has(edgeIdxKey)) {
16114
+ var edge = {
16115
+ edgePoint: new Vector3(),
16116
+ edgePointIndex: undefined
16117
+ };
16118
+ var offsetA = 3 * vertexIdxA;
16119
+ var offsetB = 3 * vertexIdxB;
16120
+ 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]));
16121
+ edges.set(edgeIdxKey, edge);
16122
+ }
16123
+ var edge1 = edges.get(edgeIdxKey);
16124
+ face.adjacentEdges[k1] = edge1;
16125
+ var edgePoint = edge1.edgePoint;
16126
+ var facePoint = face.facePoint;
16127
+ edgePoint.x += 0.25 * facePoint.x;
16128
+ edgePoint.y += 0.25 * facePoint.y;
16129
+ edgePoint.z += 0.25 * facePoint.z;
16130
+ }
16131
+ }
16132
+ var prePointCount = cellCount + 2;
16133
+ var edgePointOffset = prePointCount + cellCount;
16134
+ var pointIdx = 0;
16135
+ this._sphereEdgeIdx = 0;
16136
+ var preCells = cells.slice(0, 4 * cellCount);
16137
+ // Get New positions, which consists of updated positions of existing points, face points and edge points
16138
+ for(var j1 = 0; j1 < cellCount; j1++){
16139
+ // Add face point to new positions
16140
+ var face1 = faces[j1];
16141
+ face1.facePoint.copyToArray(positions, 3 * (prePointCount + j1));
16142
+ // Get the face point index
16143
+ var ic = prePointCount + j1;
16144
+ var id = void 0, ib = void 0, temp = void 0;
16145
+ // ia -- id -- ia
16146
+ // | | |
16147
+ // ib -- ic -- ib
16148
+ // | | |
16149
+ // ia -- id -- ia
16150
+ for(var k2 = 0; k2 < 4; k2++){
16151
+ // Get the updated existing point index
16152
+ var ia = preCells[pointIdx++];
16153
+ // ib and id share four edge points in one cell
16154
+ switch(k2){
16155
+ case 0:
16156
+ {
16157
+ var edgeB = face1.adjacentEdges[k2 % 4];
16158
+ var edgeD = face1.adjacentEdges[(k2 + 3) % 4];
16159
+ ib = this._calculateEdgeIndex(positions, edgeB, edgePointOffset);
16160
+ id = this._calculateEdgeIndex(positions, edgeD, edgePointOffset);
16161
+ temp = id;
16162
+ break;
16163
+ }
16164
+ case 1:
16165
+ case 2:
16166
+ {
16167
+ var edgeB1 = face1.adjacentEdges[k2 % 4];
16168
+ id = ib;
16169
+ ib = this._calculateEdgeIndex(positions, edgeB1, edgePointOffset);
16170
+ break;
16171
+ }
16172
+ case 3:
16173
+ {
16174
+ id = ib;
16175
+ ib = temp;
16176
+ break;
16177
+ }
16178
+ }
16179
+ var idx = 4 * (4 * j1 + k2);
16180
+ cells[idx] = ia;
16181
+ cells[idx + 1] = ib;
16182
+ cells[idx + 2] = ic;
16183
+ cells[idx + 3] = id;
16184
+ }
16185
+ }
16186
+ }
16187
+ };
16188
+ /**
16189
+ * Duplicate vertices at the poles and adjust their UV coordinates.
16190
+ */ PrimitiveMesh._generateAndReplacePoleUV = function _generateAndReplacePoleUV(indices, vertices, idx, poleOffset) {
16191
+ var v = vertices[8 * indices[idx] + 7];
16192
+ if (v === 0 || v === 1) {
16193
+ var offset = 8 * indices[idx];
16194
+ var addedOffset = 8 * (poleOffset + this._spherePoleIdx);
16195
+ vertices.set(vertices.subarray(offset, offset + 8), addedOffset);
16196
+ vertices[addedOffset + 6] = 0.5 * (vertices[offset + 6] + vertices[8 * indices[idx + 1] + 6] + vertices[8 * indices[idx + 2] + 6] - 0.5);
16197
+ indices[idx] = poleOffset + this._spherePoleIdx++;
16198
+ }
16199
+ };
16200
+ /**
16201
+ * Get edge point index for subdivision surface sphere.
16202
+ */ PrimitiveMesh._calculateEdgeIndex = function _calculateEdgeIndex(positions, edge, offset) {
16203
+ if (edge.edgePointIndex !== undefined) {
16204
+ return edge.edgePointIndex;
16205
+ } else {
16206
+ edge.edgePoint.copyToArray(positions, 3 * (offset + PrimitiveMesh._sphereEdgeIdx));
16207
+ var index = offset + PrimitiveMesh._sphereEdgeIdx++;
16208
+ edge.edgePointIndex = index;
16209
+ return index;
16210
+ }
16211
+ };
16212
+ /**
16213
+ * @internal
16007
16214
  */ PrimitiveMesh._setCuboidData = function _setCuboidData(cuboidMesh, width, height, depth, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
16008
16215
  var halfWidth = width / 2;
16009
16216
  var halfHeight = height / 2;
@@ -16628,6 +16835,68 @@
16628
16835
  (function() {
16629
16836
  PrimitiveMesh._tempVec30 = new Vector3();
16630
16837
  })();
16838
+ (function() {
16839
+ PrimitiveMesh._sphereSeedPositions = new Float32Array([
16840
+ -1,
16841
+ 1,
16842
+ 1,
16843
+ -1,
16844
+ -1,
16845
+ 1,
16846
+ 1,
16847
+ -1,
16848
+ 1,
16849
+ 1,
16850
+ 1,
16851
+ 1,
16852
+ 1,
16853
+ -1,
16854
+ -1,
16855
+ 1,
16856
+ 1,
16857
+ -1,
16858
+ -1,
16859
+ -1,
16860
+ -1,
16861
+ -1,
16862
+ 1,
16863
+ -1
16864
+ ]);
16865
+ })();
16866
+ (function() {
16867
+ PrimitiveMesh._sphereSeedCells = new Float32Array([
16868
+ 0,
16869
+ 1,
16870
+ 2,
16871
+ 3,
16872
+ 3,
16873
+ 2,
16874
+ 4,
16875
+ 5,
16876
+ 5,
16877
+ 4,
16878
+ 6,
16879
+ 7,
16880
+ 7,
16881
+ 0,
16882
+ 3,
16883
+ 5,
16884
+ 7,
16885
+ 6,
16886
+ 1,
16887
+ 0,
16888
+ 6,
16889
+ 4,
16890
+ 2,
16891
+ 1
16892
+ ]);
16893
+ })();
16894
+ (function() {
16895
+ PrimitiveMesh._sphereEdgeIdx = 0;
16896
+ })();
16897
+ (function() {
16898
+ PrimitiveMesh._spherePoleIdx = 0;
16899
+ })();
16631
16900
  /**
16632
16901
  * Mesh skin data, equal glTF skins define
16633
16902
  */ var Skin = /*#__PURE__*/ function(EngineObject1) {
@@ -17133,8 +17402,8 @@
17133
17402
  }
17134
17403
  mesh.addSubMesh(this._getSubMeshFromPool(vertexStartIndex, vertexCount));
17135
17404
  batchedQueue[curMeshIndex] = preElement;
17136
- this._vertexBuffers[_flushId].setData(vertices, 0, 0, vertexIndex);
17137
- this._indiceBuffers[_flushId].setData(indices, 0, 0, indiceIndex);
17405
+ this._vertexBuffers[_flushId].setData(vertices, 0, 0, vertexIndex, exports.SetDataOptions.Discard);
17406
+ this._indiceBuffers[_flushId].setData(indices, 0, 0, indiceIndex, exports.SetDataOptions.Discard);
17138
17407
  };
17139
17408
  _proto._getSubMeshFromPool = function _getSubMeshFromPool(start, count) {
17140
17409
  var subMesh = this._subMeshPool.getFromPool();
@@ -21148,7 +21417,6 @@
21148
21417
  if (this._destroyed) return;
21149
21418
  ReferResource1.prototype._addReferCount.call(this, value);
21150
21419
  this.shaderData._addReferCount(value);
21151
- this._shader._addReferCount(value);
21152
21420
  };
21153
21421
  /**
21154
21422
  * @override
@@ -21176,12 +21444,6 @@
21176
21444
  return this._shader;
21177
21445
  },
21178
21446
  set: function set(value) {
21179
- var refCount = this._getReferCount();
21180
- if (refCount > 0) {
21181
- var _this__shader;
21182
- (_this__shader = this._shader) == null ? void 0 : _this__shader._addReferCount(-refCount);
21183
- value._addReferCount(refCount);
21184
- }
21185
21447
  this._shader = value;
21186
21448
  var renderStates = this._renderStates;
21187
21449
  var lastStatesCount = renderStates.length;
@@ -21417,24 +21679,6 @@
21417
21679
  */ _proto.cache = function cache(shaderProgram) {
21418
21680
  this._lastQueryMap[this._lastQueryKey] = shaderProgram;
21419
21681
  };
21420
- /**
21421
- * @internal
21422
- */ _proto._destroy = function _destroy() {
21423
- this._recursiveDestroy(0, this._cacheMap);
21424
- this._cacheMap = Object.create(null);
21425
- };
21426
- _proto._recursiveDestroy = function _recursiveDestroy(hierarchy, cacheMap) {
21427
- if (hierarchy === this._cacheHierarchyDepth - 1) {
21428
- for(var k in cacheMap){
21429
- cacheMap[k].destroy();
21430
- }
21431
- return;
21432
- }
21433
- ++hierarchy;
21434
- for(var k1 in cacheMap){
21435
- this._recursiveDestroy(hierarchy, cacheMap[k1]);
21436
- }
21437
- };
21438
21682
  _proto._resizeCacheMapHierarchy = function _resizeCacheMapHierarchy(cacheMap, hierarchy, currentHierarchy, increaseHierarchy) {
21439
21683
  // Only expand but not shrink
21440
21684
  if (hierarchy == currentHierarchy - 1) {
@@ -23730,7 +23974,6 @@
23730
23974
  shaderProgramPools.length = length;
23731
23975
  }
23732
23976
  shaderProgramPools[index] = pool = new ShaderProgramPool();
23733
- shaderPass._shaderProgramPools.push(pool);
23734
23977
  }
23735
23978
  return pool;
23736
23979
  };
@@ -28414,12 +28657,6 @@
28414
28657
  return this._shader;
28415
28658
  },
28416
28659
  set: function set(value) {
28417
- var refCount = this._getReferCount();
28418
- if (refCount > 0) {
28419
- var _this__shader;
28420
- (_this__shader = this._shader) == null ? void 0 : _this__shader._addReferCount(-refCount);
28421
- value._addReferCount(refCount);
28422
- }
28423
28660
  this._shader = value;
28424
28661
  var renderStates = this._renderStates;
28425
28662
  var lastStatesCount = renderStates.length;
@@ -32223,7 +32460,7 @@
32223
32460
  if (!material) {
32224
32461
  return;
32225
32462
  }
32226
- if (material.destroyed || material.shader.destroyed) {
32463
+ if (material.destroyed) {
32227
32464
  material = this.engine._particleMagentaMaterial;
32228
32465
  }
32229
32466
  var renderData = this._engine._renderDataPool.getFromPool();
@@ -42938,26 +43175,31 @@
42938
43175
  var _proto = SpriteLoader.prototype;
42939
43176
  _proto.load = function load(item, resourceManager) {
42940
43177
  var _this = this;
42941
- return new AssetPromise(function(resolve, reject) {
42942
- _this.request(item.url, _extends({}, item, {
42943
- type: "json"
42944
- })).then(function(data) {
42945
- if (data.belongToAtlas) {
42946
- resourceManager // @ts-ignore
42947
- .getResourceByRef(data.belongToAtlas).then(function(atlas) {
42948
- resolve(atlas.getSprite(data.fullPath));
42949
- }).catch(reject);
42950
- } else if (data.texture) {
42951
- resourceManager // @ts-ignore
42952
- .getResourceByRef(data.texture).then(function(texture) {
42953
- resolve(new Sprite(resourceManager.engine, texture, data.region, data.pivot, data.border));
42954
- }).catch(reject);
42955
- } else {
42956
- resolve(new Sprite(resourceManager.engine, null, data.region, data.pivot, data.border));
42957
- }
42958
- }).catch(reject);
43178
+ return this.request(item.url, _extends({}, item, {
43179
+ type: "json"
43180
+ })).then(function(data) {
43181
+ return data.belongToAtlas ? _this._loadFromAtlas(resourceManager, data) : _this._loadFromTexture(resourceManager, data);
42959
43182
  });
42960
43183
  };
43184
+ _proto._loadFromAtlas = function _loadFromAtlas(resourceManager, data) {
43185
+ var _this = this;
43186
+ return resourceManager // @ts-ignore
43187
+ .getResourceByRef(data.belongToAtlas).then(function(atlas) {
43188
+ return atlas.getSprite(data.fullPath) || _this._loadFromTexture(resourceManager, data);
43189
+ });
43190
+ };
43191
+ _proto._loadFromTexture = function _loadFromTexture(resourceManager, data) {
43192
+ if (data.texture) {
43193
+ return resourceManager // @ts-ignore
43194
+ .getResourceByRef(data.texture).then(function(texture) {
43195
+ return new Sprite(resourceManager.engine, texture, data.region, data.pivot, data.border);
43196
+ });
43197
+ } else {
43198
+ return new AssetPromise(function(resolve) {
43199
+ resolve(new Sprite(resourceManager.engine, null, data.region, data.pivot, data.border));
43200
+ });
43201
+ }
43202
+ };
42961
43203
  return SpriteLoader;
42962
43204
  }(Loader);
42963
43205
  SpriteLoader = __decorate([
@@ -43733,7 +43975,7 @@
43733
43975
  ], GALACEAN_animation_event);
43734
43976
 
43735
43977
  //@ts-ignore
43736
- var version = "0.0.0-experimental-shaderlab.0";
43978
+ var version = "0.0.0-experimental-uploadSameBuffer.0";
43737
43979
  console.log("Galacean engine version: " + version);
43738
43980
  for(var key in CoreObjects){
43739
43981
  Loader.registerClass(key, CoreObjects[key]);