@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.
- package/dist/main.js +328 -91
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +328 -91
- package/dist/module.js +328 -91
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/mesh/PrimitiveMesh.d.ts +22 -0
- package/types/physics/PhysicsManager.d.ts +2 -4
- package/types/shader/Shader.d.ts +2 -15
- package/types/2d/data/RenderData2D.d.ts +0 -1
- package/types/RenderPipeline/MeshRenderElement.d.ts +0 -19
- package/types/RenderPipeline/SpriteElement.d.ts +0 -15
- package/types/RenderPipeline/SpriteMaskElement.d.ts +0 -12
- package/types/RenderPipeline/TextRenderElement.d.ts +0 -8
- package/types/animation/AnimatorLayerMask.d.ts +0 -45
- package/types/animation/LayerPathMask.d.ts +0 -16
- package/types/animation/animationCurve/AnimationStringCurve.d.ts +0 -7
- package/types/asset/IRefObject.d.ts +0 -2
- package/types/asset/RefObject.d.ts +0 -27
- package/types/base/Event.d.ts +0 -24
- package/types/base/Util.d.ts +0 -14
- package/types/enums/CameraType.d.ts +0 -1
- package/types/xr/XRManager.d.ts +0 -5
- /package/types/RenderPipeline/{index.d.ts → Index.d.ts} +0 -0
package/dist/module.js
CHANGED
|
@@ -2032,7 +2032,8 @@ var Logger = {
|
|
|
2032
2032
|
_proto._createFontAtlas = function _createFontAtlas() {
|
|
2033
2033
|
var _this = this, engine = _this._engine;
|
|
2034
2034
|
var fontAtlas = new FontAtlas(engine);
|
|
2035
|
-
var texture = new Texture2D(engine, 256, 256);
|
|
2035
|
+
var texture = new Texture2D(engine, 256, 256, TextureFormat.R8G8B8A8, false);
|
|
2036
|
+
texture.filterMode = TextureFilterMode.Point;
|
|
2036
2037
|
fontAtlas.texture = texture;
|
|
2037
2038
|
fontAtlas.isGCIgnored = texture.isGCIgnored = true;
|
|
2038
2039
|
this._fontAtlases.push(fontAtlas);
|
|
@@ -5975,7 +5976,6 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
5975
5976
|
_this = ShaderPart1.call(this) || this;
|
|
5976
5977
|
/** @internal */ _this._shaderPassId = 0;
|
|
5977
5978
|
/** @internal */ _this._renderStateDataMap = {};
|
|
5978
|
-
/** @internal */ _this._shaderProgramPools = [];
|
|
5979
5979
|
_this._shaderPassId = ShaderPass._shaderPassCounter++;
|
|
5980
5980
|
if (typeof fragmentSourceOrTags === "string") {
|
|
5981
5981
|
_this._name = nameOrVertexSource;
|
|
@@ -6029,15 +6029,6 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
6029
6029
|
shaderProgramPool.cache(shaderProgram);
|
|
6030
6030
|
return shaderProgram;
|
|
6031
6031
|
};
|
|
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
6032
|
return ShaderPass;
|
|
6042
6033
|
}(ShaderPart);
|
|
6043
6034
|
(function() {
|
|
@@ -6668,8 +6659,6 @@ __decorate([
|
|
|
6668
6659
|
*/ var Shader = /*#__PURE__*/ function() {
|
|
6669
6660
|
function Shader(name, subShaders) {
|
|
6670
6661
|
this.name = name;
|
|
6671
|
-
this._refCount = 0;
|
|
6672
|
-
this._destroyed = false;
|
|
6673
6662
|
this.name = name;
|
|
6674
6663
|
this._subShaders = subShaders;
|
|
6675
6664
|
}
|
|
@@ -6689,46 +6678,20 @@ __decorate([
|
|
|
6689
6678
|
for(var i = 0, n = macros.length; i < n; i++){
|
|
6690
6679
|
compileMacros.enable(ShaderMacro.getByName(macros[i]));
|
|
6691
6680
|
}
|
|
6692
|
-
var isValid = false;
|
|
6693
6681
|
var subShaders = this._subShaders;
|
|
6694
6682
|
for(var i1 = 0, n1 = subShaders.length; i1 < n1; i1++){
|
|
6683
|
+
var isValid = void 0;
|
|
6695
6684
|
var passes = subShaders[i1].passes;
|
|
6696
6685
|
for(var j = 0, m = passes.length; j < m; j++){
|
|
6697
|
-
|
|
6698
|
-
|
|
6699
|
-
|
|
6700
|
-
|
|
6701
|
-
|
|
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();
|
|
6686
|
+
if (isValid === undefined) {
|
|
6687
|
+
isValid = passes[j]._getShaderProgram(engine, compileMacros).isValid;
|
|
6688
|
+
} else {
|
|
6689
|
+
isValid && (isValid = passes[j]._getShaderProgram(engine, compileMacros).isValid);
|
|
6690
|
+
}
|
|
6717
6691
|
}
|
|
6692
|
+
if (isValid) return true;
|
|
6718
6693
|
}
|
|
6719
|
-
|
|
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;
|
|
6694
|
+
return false;
|
|
6732
6695
|
};
|
|
6733
6696
|
Shader.create = function create(nameOrShaderSource, vertexSourceOrShaderPassesOrSubShaders, fragmentSource) {
|
|
6734
6697
|
var shader;
|
|
@@ -6915,14 +6878,6 @@ __decorate([
|
|
|
6915
6878
|
*/ function get() {
|
|
6916
6879
|
return this._subShaders;
|
|
6917
6880
|
}
|
|
6918
|
-
},
|
|
6919
|
-
{
|
|
6920
|
-
key: "destroyed",
|
|
6921
|
-
get: /**
|
|
6922
|
-
* Whether it has been destroyed.
|
|
6923
|
-
*/ function get() {
|
|
6924
|
-
return this._destroyed;
|
|
6925
|
-
}
|
|
6926
6881
|
}
|
|
6927
6882
|
]);
|
|
6928
6883
|
return Shader;
|
|
@@ -8051,6 +8006,9 @@ SimpleSpriteAssembler = __decorate([
|
|
|
8051
8006
|
__decorate([
|
|
8052
8007
|
assignmentClone
|
|
8053
8008
|
], SpriteMask.prototype, "influenceLayers", void 0);
|
|
8009
|
+
__decorate([
|
|
8010
|
+
ignoreClone
|
|
8011
|
+
], SpriteMask.prototype, "_verticesData", void 0);
|
|
8054
8012
|
__decorate([
|
|
8055
8013
|
ignoreClone
|
|
8056
8014
|
], SpriteMask.prototype, "_sprite", void 0);
|
|
@@ -9183,7 +9141,7 @@ var BlendShapeFrameDirty;
|
|
|
9183
9141
|
if (!material) {
|
|
9184
9142
|
continue;
|
|
9185
9143
|
}
|
|
9186
|
-
if (material.destroyed
|
|
9144
|
+
if (material.destroyed) {
|
|
9187
9145
|
material = this.engine._meshMagentaMaterial;
|
|
9188
9146
|
}
|
|
9189
9147
|
var renderData = meshRenderDataPool.getFromPool();
|
|
@@ -10838,6 +10796,10 @@ var VertexElementIndex;
|
|
|
10838
10796
|
var sphereInfo = primitiveInfo;
|
|
10839
10797
|
PrimitiveMesh._setSphereData(this.resource, sphereInfo.radius, sphereInfo.segments, sphereInfo.noLongerAccessible, true, sphereInfo.vertexBuffer);
|
|
10840
10798
|
break;
|
|
10799
|
+
case 7:
|
|
10800
|
+
var CCSphereInfo = primitiveInfo;
|
|
10801
|
+
PrimitiveMesh._setSubdivisionSurfaceSphereData(this.resource, CCSphereInfo.radius, CCSphereInfo.step, CCSphereInfo.noLongerAccessible, true, CCSphereInfo.vertexBuffer);
|
|
10802
|
+
break;
|
|
10841
10803
|
case 1:
|
|
10842
10804
|
var cuboidInfo = primitiveInfo;
|
|
10843
10805
|
PrimitiveMesh._setCuboidData(this.resource, cuboidInfo.width, cuboidInfo.height, cuboidInfo.depth, cuboidInfo.noLongerAccessible, true, cuboidInfo.vertexBuffer);
|
|
@@ -10875,6 +10837,7 @@ var PrimitiveType;
|
|
|
10875
10837
|
PrimitiveType[PrimitiveType["Torus"] = 4] = "Torus";
|
|
10876
10838
|
PrimitiveType[PrimitiveType["Cone"] = 5] = "Cone";
|
|
10877
10839
|
PrimitiveType[PrimitiveType["Capsule"] = 6] = "Capsule";
|
|
10840
|
+
PrimitiveType[PrimitiveType["CCSphere"] = 7] = "CCSphere";
|
|
10878
10841
|
})(PrimitiveType || (PrimitiveType = {}));
|
|
10879
10842
|
/**
|
|
10880
10843
|
* @internal
|
|
@@ -10896,6 +10859,19 @@ var PrimitiveType;
|
|
|
10896
10859
|
}
|
|
10897
10860
|
return SphereRestoreInfo;
|
|
10898
10861
|
}(PrimitiveRestoreInfo);
|
|
10862
|
+
/**
|
|
10863
|
+
* @internal
|
|
10864
|
+
*/ var SubdivisionSurfaceSphereRestoreInfo = /*#__PURE__*/ function(PrimitiveRestoreInfo) {
|
|
10865
|
+
_inherits(SubdivisionSurfaceSphereRestoreInfo, PrimitiveRestoreInfo);
|
|
10866
|
+
function SubdivisionSurfaceSphereRestoreInfo(radius, step, vertexBuffer, noLongerAccessible) {
|
|
10867
|
+
var _this;
|
|
10868
|
+
_this = PrimitiveRestoreInfo.call(this, 7, vertexBuffer, noLongerAccessible) || this;
|
|
10869
|
+
_this.radius = radius;
|
|
10870
|
+
_this.step = step;
|
|
10871
|
+
return _this;
|
|
10872
|
+
}
|
|
10873
|
+
return SubdivisionSurfaceSphereRestoreInfo;
|
|
10874
|
+
}(PrimitiveRestoreInfo);
|
|
10899
10875
|
/**
|
|
10900
10876
|
* @internal
|
|
10901
10877
|
*/ var CuboidRestoreInfo = /*#__PURE__*/ function(PrimitiveRestoreInfo) {
|
|
@@ -11010,6 +10986,24 @@ var PrimitiveType;
|
|
|
11010
10986
|
return sphereMesh;
|
|
11011
10987
|
};
|
|
11012
10988
|
/**
|
|
10989
|
+
* Create a sphere mesh by implementing Catmull-Clark Surface Subdivision Algorithm.
|
|
10990
|
+
* Max step is limited to 6.
|
|
10991
|
+
* @param engine - Engine
|
|
10992
|
+
* @param radius - Sphere radius
|
|
10993
|
+
* @param step - Number of subdiv steps
|
|
10994
|
+
* @param noLongerAccessible - No longer access the vertices of the mesh after creation
|
|
10995
|
+
* @returns Sphere model mesh
|
|
10996
|
+
*/ PrimitiveMesh.createSubdivisionSurfaceSphere = function createSubdivisionSurfaceSphere(engine, radius, step, noLongerAccessible) {
|
|
10997
|
+
if (radius === void 0) radius = 0.5;
|
|
10998
|
+
if (step === void 0) step = 3;
|
|
10999
|
+
if (noLongerAccessible === void 0) noLongerAccessible = true;
|
|
11000
|
+
var sphereMesh = new ModelMesh(engine);
|
|
11001
|
+
PrimitiveMesh._setSubdivisionSurfaceSphereData(sphereMesh, radius, step, noLongerAccessible, false);
|
|
11002
|
+
var vertexBuffer = sphereMesh.vertexBufferBindings[0].buffer;
|
|
11003
|
+
engine.resourceManager.addContentRestorer(new PrimitiveMeshRestorer(sphereMesh, new SubdivisionSurfaceSphereRestoreInfo(radius, step, vertexBuffer, noLongerAccessible)));
|
|
11004
|
+
return sphereMesh;
|
|
11005
|
+
};
|
|
11006
|
+
/**
|
|
11013
11007
|
* Create a cuboid mesh.
|
|
11014
11008
|
* @param engine - Engine
|
|
11015
11009
|
* @param width - Cuboid width
|
|
@@ -11139,6 +11133,90 @@ var PrimitiveType;
|
|
|
11139
11133
|
};
|
|
11140
11134
|
/**
|
|
11141
11135
|
* @internal
|
|
11136
|
+
*/ PrimitiveMesh._setSubdivisionSurfaceSphereData = function _setSubdivisionSurfaceSphereData(sphereMesh, radius, step, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
|
|
11137
|
+
// Max step is limited to 6. Because 7 step will generate a single mesh with over 98306 vertices
|
|
11138
|
+
step = MathUtil$1.clamp(Math.floor(step), 1, 6);
|
|
11139
|
+
var positions = new Float32Array(3 * (6 * Math.pow(4, step) + 2));
|
|
11140
|
+
var cells = new Float32Array(24 * Math.pow(4, step));
|
|
11141
|
+
PrimitiveMesh._subdiveCatmullClark(step, positions, cells);
|
|
11142
|
+
var positionCount = positions.length / 3;
|
|
11143
|
+
var cellsCount = cells.length / 4;
|
|
11144
|
+
var poleOffset = positionCount + Math.pow(2, step + 1) - 1;
|
|
11145
|
+
// 16 extra vertices for pole uv
|
|
11146
|
+
// 2 vertices at each pole are idle
|
|
11147
|
+
var vertexCount = poleOffset + 16;
|
|
11148
|
+
var vertices = new Float32Array(vertexCount * 8);
|
|
11149
|
+
var indices = PrimitiveMesh._generateIndices(sphereMesh.engine, positionCount, cellsCount * 6);
|
|
11150
|
+
var seamCount = 0;
|
|
11151
|
+
var seamVertices = {};
|
|
11152
|
+
// Get normals, uvs, and scale to radius
|
|
11153
|
+
for(var i = 0; i < positionCount; i++){
|
|
11154
|
+
var offset = 3 * i;
|
|
11155
|
+
var x = positions[offset];
|
|
11156
|
+
var y = positions[offset + 1];
|
|
11157
|
+
var z = positions[offset + 2];
|
|
11158
|
+
var reciprocalLength = 1 / Math.sqrt(x * x + y * y + z * z);
|
|
11159
|
+
x *= reciprocalLength;
|
|
11160
|
+
y *= reciprocalLength;
|
|
11161
|
+
z *= reciprocalLength;
|
|
11162
|
+
offset = 8 * i;
|
|
11163
|
+
vertices[offset] = x * radius;
|
|
11164
|
+
vertices[offset + 1] = y * radius;
|
|
11165
|
+
vertices[offset + 2] = z * radius;
|
|
11166
|
+
vertices[offset + 3] = x;
|
|
11167
|
+
vertices[offset + 4] = y;
|
|
11168
|
+
vertices[offset + 5] = z;
|
|
11169
|
+
vertices[offset + 6] = (Math.PI - Math.atan2(z, x)) / (2 * Math.PI);
|
|
11170
|
+
vertices[offset + 7] = Math.acos(y) / Math.PI;
|
|
11171
|
+
if (vertices[offset + 6] === 0) {
|
|
11172
|
+
// Generate seam vertex
|
|
11173
|
+
var seamOffset = 8 * (positionCount + seamCount++);
|
|
11174
|
+
vertices.set(vertices.subarray(offset, offset + 8), seamOffset);
|
|
11175
|
+
vertices[seamOffset + 6] = 1.0;
|
|
11176
|
+
// Cache seam vertex
|
|
11177
|
+
seamVertices[offset / 8] = seamOffset / 8;
|
|
11178
|
+
}
|
|
11179
|
+
}
|
|
11180
|
+
// Get indices
|
|
11181
|
+
var offset1 = 0;
|
|
11182
|
+
this._spherePoleIdx = 0;
|
|
11183
|
+
for(var i1 = 0; i1 < cellsCount; i1++){
|
|
11184
|
+
var idx = 4 * i1;
|
|
11185
|
+
var indexA = cells[idx];
|
|
11186
|
+
var indexB = cells[idx + 1];
|
|
11187
|
+
var indexC = cells[idx + 2];
|
|
11188
|
+
var indexD = cells[idx + 3];
|
|
11189
|
+
// Handle seam by replacing vertex index to seam vertex index if necessary
|
|
11190
|
+
var floatIndexA = 8 * indexA;
|
|
11191
|
+
var floatIndexB = 8 * indexB;
|
|
11192
|
+
var floatIndexC = 8 * indexC;
|
|
11193
|
+
var floatIndexD = 8 * indexD;
|
|
11194
|
+
// If center Z is negative
|
|
11195
|
+
if (vertices[floatIndexA + 2] + vertices[floatIndexB + 2] + vertices[floatIndexC + 2] < 0) {
|
|
11196
|
+
vertices[floatIndexA + 6] === 0 && (indexA = seamVertices[indexA]);
|
|
11197
|
+
vertices[floatIndexB + 6] === 0 && (indexB = seamVertices[indexB]);
|
|
11198
|
+
vertices[floatIndexC + 6] === 0 && (indexC = seamVertices[indexC]);
|
|
11199
|
+
vertices[floatIndexD + 6] === 0 && (indexD = seamVertices[indexD]);
|
|
11200
|
+
}
|
|
11201
|
+
indices[offset1] = indexA;
|
|
11202
|
+
indices[offset1 + 1] = indexB;
|
|
11203
|
+
indices[offset1 + 2] = indexC;
|
|
11204
|
+
this._generateAndReplacePoleUV(indices, vertices, offset1, poleOffset);
|
|
11205
|
+
indices[offset1 + 3] = indexA;
|
|
11206
|
+
indices[offset1 + 4] = indexC;
|
|
11207
|
+
indices[offset1 + 5] = indexD;
|
|
11208
|
+
this._generateAndReplacePoleUV(indices, vertices, offset1 + 3, poleOffset);
|
|
11209
|
+
offset1 += 6;
|
|
11210
|
+
}
|
|
11211
|
+
if (!isRestoreMode) {
|
|
11212
|
+
var bounds = sphereMesh.bounds;
|
|
11213
|
+
bounds.min.set(-radius, -radius, -radius);
|
|
11214
|
+
bounds.max.set(radius, radius, radius);
|
|
11215
|
+
}
|
|
11216
|
+
PrimitiveMesh._initialize(sphereMesh, vertices, indices, noLongerAccessible, isRestoreMode, restoreVertexBuffer);
|
|
11217
|
+
};
|
|
11218
|
+
/**
|
|
11219
|
+
* @internal
|
|
11142
11220
|
*/ PrimitiveMesh._setSphereData = function _setSphereData(sphereMesh, radius, segments, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
|
|
11143
11221
|
segments = Math.max(2, Math.floor(segments));
|
|
11144
11222
|
var count = segments + 1;
|
|
@@ -11199,6 +11277,135 @@ var PrimitiveType;
|
|
|
11199
11277
|
};
|
|
11200
11278
|
/**
|
|
11201
11279
|
* @internal
|
|
11280
|
+
*/ PrimitiveMesh._subdiveCatmullClark = function _subdiveCatmullClark(step, positions, cells) {
|
|
11281
|
+
var edges = new Map();
|
|
11282
|
+
var faces = new Array();
|
|
11283
|
+
positions.set(PrimitiveMesh._sphereSeedPositions);
|
|
11284
|
+
cells.set(PrimitiveMesh._sphereSeedCells);
|
|
11285
|
+
for(var i = 0; i < step; i++){
|
|
11286
|
+
var cellCount = 6 * Math.pow(4, i);
|
|
11287
|
+
var positionCount = 4 * cellCount + 2;
|
|
11288
|
+
edges.clear();
|
|
11289
|
+
faces.length = 0;
|
|
11290
|
+
// Get cell face's facePoint
|
|
11291
|
+
for(var j = 0; j < cellCount; j++){
|
|
11292
|
+
var face = faces[j] = {
|
|
11293
|
+
facePoint: new Vector3(),
|
|
11294
|
+
adjacentEdges: new Array(4)
|
|
11295
|
+
};
|
|
11296
|
+
// Get cell's edgePoint
|
|
11297
|
+
for(var k = 0; k < 4; k++){
|
|
11298
|
+
var offset = 3 * cells[4 * j + k];
|
|
11299
|
+
face.facePoint.x += 0.25 * positions[offset];
|
|
11300
|
+
face.facePoint.y += 0.25 * positions[offset + 1];
|
|
11301
|
+
face.facePoint.z += 0.25 * positions[offset + 2];
|
|
11302
|
+
}
|
|
11303
|
+
// Get cell edges
|
|
11304
|
+
for(var k1 = 0; k1 < 4; k1++){
|
|
11305
|
+
var vertexIdxA = cells[4 * j + k1];
|
|
11306
|
+
var vertexIdxB = cells[4 * j + (k1 + 1) % 4];
|
|
11307
|
+
var edgeIdxKey = Math.min(vertexIdxA, vertexIdxB) * positionCount + Math.max(vertexIdxA, vertexIdxB);
|
|
11308
|
+
if (!edges.has(edgeIdxKey)) {
|
|
11309
|
+
var edge = {
|
|
11310
|
+
edgePoint: new Vector3(),
|
|
11311
|
+
edgePointIndex: undefined
|
|
11312
|
+
};
|
|
11313
|
+
var offsetA = 3 * vertexIdxA;
|
|
11314
|
+
var offsetB = 3 * vertexIdxB;
|
|
11315
|
+
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]));
|
|
11316
|
+
edges.set(edgeIdxKey, edge);
|
|
11317
|
+
}
|
|
11318
|
+
var edge1 = edges.get(edgeIdxKey);
|
|
11319
|
+
face.adjacentEdges[k1] = edge1;
|
|
11320
|
+
var edgePoint = edge1.edgePoint;
|
|
11321
|
+
var facePoint = face.facePoint;
|
|
11322
|
+
edgePoint.x += 0.25 * facePoint.x;
|
|
11323
|
+
edgePoint.y += 0.25 * facePoint.y;
|
|
11324
|
+
edgePoint.z += 0.25 * facePoint.z;
|
|
11325
|
+
}
|
|
11326
|
+
}
|
|
11327
|
+
var prePointCount = cellCount + 2;
|
|
11328
|
+
var edgePointOffset = prePointCount + cellCount;
|
|
11329
|
+
var pointIdx = 0;
|
|
11330
|
+
this._sphereEdgeIdx = 0;
|
|
11331
|
+
var preCells = cells.slice(0, 4 * cellCount);
|
|
11332
|
+
// Get New positions, which consists of updated positions of existing points, face points and edge points
|
|
11333
|
+
for(var j1 = 0; j1 < cellCount; j1++){
|
|
11334
|
+
// Add face point to new positions
|
|
11335
|
+
var face1 = faces[j1];
|
|
11336
|
+
face1.facePoint.copyToArray(positions, 3 * (prePointCount + j1));
|
|
11337
|
+
// Get the face point index
|
|
11338
|
+
var ic = prePointCount + j1;
|
|
11339
|
+
var id = void 0, ib = void 0, temp = void 0;
|
|
11340
|
+
// ia -- id -- ia
|
|
11341
|
+
// | | |
|
|
11342
|
+
// ib -- ic -- ib
|
|
11343
|
+
// | | |
|
|
11344
|
+
// ia -- id -- ia
|
|
11345
|
+
for(var k2 = 0; k2 < 4; k2++){
|
|
11346
|
+
// Get the updated existing point index
|
|
11347
|
+
var ia = preCells[pointIdx++];
|
|
11348
|
+
// ib and id share four edge points in one cell
|
|
11349
|
+
switch(k2){
|
|
11350
|
+
case 0:
|
|
11351
|
+
{
|
|
11352
|
+
var edgeB = face1.adjacentEdges[k2 % 4];
|
|
11353
|
+
var edgeD = face1.adjacentEdges[(k2 + 3) % 4];
|
|
11354
|
+
ib = this._calculateEdgeIndex(positions, edgeB, edgePointOffset);
|
|
11355
|
+
id = this._calculateEdgeIndex(positions, edgeD, edgePointOffset);
|
|
11356
|
+
temp = id;
|
|
11357
|
+
break;
|
|
11358
|
+
}
|
|
11359
|
+
case 1:
|
|
11360
|
+
case 2:
|
|
11361
|
+
{
|
|
11362
|
+
var edgeB1 = face1.adjacentEdges[k2 % 4];
|
|
11363
|
+
id = ib;
|
|
11364
|
+
ib = this._calculateEdgeIndex(positions, edgeB1, edgePointOffset);
|
|
11365
|
+
break;
|
|
11366
|
+
}
|
|
11367
|
+
case 3:
|
|
11368
|
+
{
|
|
11369
|
+
id = ib;
|
|
11370
|
+
ib = temp;
|
|
11371
|
+
break;
|
|
11372
|
+
}
|
|
11373
|
+
}
|
|
11374
|
+
var idx = 4 * (4 * j1 + k2);
|
|
11375
|
+
cells[idx] = ia;
|
|
11376
|
+
cells[idx + 1] = ib;
|
|
11377
|
+
cells[idx + 2] = ic;
|
|
11378
|
+
cells[idx + 3] = id;
|
|
11379
|
+
}
|
|
11380
|
+
}
|
|
11381
|
+
}
|
|
11382
|
+
};
|
|
11383
|
+
/**
|
|
11384
|
+
* Duplicate vertices at the poles and adjust their UV coordinates.
|
|
11385
|
+
*/ PrimitiveMesh._generateAndReplacePoleUV = function _generateAndReplacePoleUV(indices, vertices, idx, poleOffset) {
|
|
11386
|
+
var v = vertices[8 * indices[idx] + 7];
|
|
11387
|
+
if (v === 0 || v === 1) {
|
|
11388
|
+
var offset = 8 * indices[idx];
|
|
11389
|
+
var addedOffset = 8 * (poleOffset + this._spherePoleIdx);
|
|
11390
|
+
vertices.set(vertices.subarray(offset, offset + 8), addedOffset);
|
|
11391
|
+
vertices[addedOffset + 6] = 0.5 * (vertices[offset + 6] + vertices[8 * indices[idx + 1] + 6] + vertices[8 * indices[idx + 2] + 6] - 0.5);
|
|
11392
|
+
indices[idx] = poleOffset + this._spherePoleIdx++;
|
|
11393
|
+
}
|
|
11394
|
+
};
|
|
11395
|
+
/**
|
|
11396
|
+
* Get edge point index for subdivision surface sphere.
|
|
11397
|
+
*/ PrimitiveMesh._calculateEdgeIndex = function _calculateEdgeIndex(positions, edge, offset) {
|
|
11398
|
+
if (edge.edgePointIndex !== undefined) {
|
|
11399
|
+
return edge.edgePointIndex;
|
|
11400
|
+
} else {
|
|
11401
|
+
edge.edgePoint.copyToArray(positions, 3 * (offset + PrimitiveMesh._sphereEdgeIdx));
|
|
11402
|
+
var index = offset + PrimitiveMesh._sphereEdgeIdx++;
|
|
11403
|
+
edge.edgePointIndex = index;
|
|
11404
|
+
return index;
|
|
11405
|
+
}
|
|
11406
|
+
};
|
|
11407
|
+
/**
|
|
11408
|
+
* @internal
|
|
11202
11409
|
*/ PrimitiveMesh._setCuboidData = function _setCuboidData(cuboidMesh, width, height, depth, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
|
|
11203
11410
|
var halfWidth = width / 2;
|
|
11204
11411
|
var halfHeight = height / 2;
|
|
@@ -11828,6 +12035,68 @@ var PrimitiveType;
|
|
|
11828
12035
|
(function() {
|
|
11829
12036
|
PrimitiveMesh._tempVec30 = new Vector3();
|
|
11830
12037
|
})();
|
|
12038
|
+
(function() {
|
|
12039
|
+
PrimitiveMesh._sphereSeedPositions = new Float32Array([
|
|
12040
|
+
-1,
|
|
12041
|
+
1,
|
|
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
|
+
]);
|
|
12065
|
+
})();
|
|
12066
|
+
(function() {
|
|
12067
|
+
PrimitiveMesh._sphereSeedCells = new Float32Array([
|
|
12068
|
+
0,
|
|
12069
|
+
1,
|
|
12070
|
+
2,
|
|
12071
|
+
3,
|
|
12072
|
+
3,
|
|
12073
|
+
2,
|
|
12074
|
+
4,
|
|
12075
|
+
5,
|
|
12076
|
+
5,
|
|
12077
|
+
4,
|
|
12078
|
+
6,
|
|
12079
|
+
7,
|
|
12080
|
+
7,
|
|
12081
|
+
0,
|
|
12082
|
+
3,
|
|
12083
|
+
5,
|
|
12084
|
+
7,
|
|
12085
|
+
6,
|
|
12086
|
+
1,
|
|
12087
|
+
0,
|
|
12088
|
+
6,
|
|
12089
|
+
4,
|
|
12090
|
+
2,
|
|
12091
|
+
1
|
|
12092
|
+
]);
|
|
12093
|
+
})();
|
|
12094
|
+
(function() {
|
|
12095
|
+
PrimitiveMesh._sphereEdgeIdx = 0;
|
|
12096
|
+
})();
|
|
12097
|
+
(function() {
|
|
12098
|
+
PrimitiveMesh._spherePoleIdx = 0;
|
|
12099
|
+
})();
|
|
11831
12100
|
|
|
11832
12101
|
/**
|
|
11833
12102
|
* Mesh skin data, equal glTF skins define
|
|
@@ -12336,8 +12605,8 @@ var Basic2DBatcher = /*#__PURE__*/ function() {
|
|
|
12336
12605
|
}
|
|
12337
12606
|
mesh.addSubMesh(this._getSubMeshFromPool(vertexStartIndex, vertexCount));
|
|
12338
12607
|
batchedQueue[curMeshIndex] = preElement;
|
|
12339
|
-
this._vertexBuffers[_flushId].setData(vertices, 0, 0, vertexIndex);
|
|
12340
|
-
this._indiceBuffers[_flushId].setData(indices, 0, 0, indiceIndex);
|
|
12608
|
+
this._vertexBuffers[_flushId].setData(vertices, 0, 0, vertexIndex, SetDataOptions.Discard);
|
|
12609
|
+
this._indiceBuffers[_flushId].setData(indices, 0, 0, indiceIndex, SetDataOptions.Discard);
|
|
12341
12610
|
};
|
|
12342
12611
|
_proto._getSubMeshFromPool = function _getSubMeshFromPool(start, count) {
|
|
12343
12612
|
var subMesh = this._subMeshPool.getFromPool();
|
|
@@ -16399,7 +16668,6 @@ __decorate([
|
|
|
16399
16668
|
if (this._destroyed) return;
|
|
16400
16669
|
ReferResource1.prototype._addReferCount.call(this, value);
|
|
16401
16670
|
this.shaderData._addReferCount(value);
|
|
16402
|
-
this._shader._addReferCount(value);
|
|
16403
16671
|
};
|
|
16404
16672
|
/**
|
|
16405
16673
|
* @override
|
|
@@ -16427,12 +16695,6 @@ __decorate([
|
|
|
16427
16695
|
return this._shader;
|
|
16428
16696
|
},
|
|
16429
16697
|
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
16698
|
this._shader = value;
|
|
16437
16699
|
var renderStates = this._renderStates;
|
|
16438
16700
|
var lastStatesCount = renderStates.length;
|
|
@@ -16696,24 +16958,6 @@ var unlitVs = "#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#in
|
|
|
16696
16958
|
*/ _proto.cache = function cache(shaderProgram) {
|
|
16697
16959
|
this._lastQueryMap[this._lastQueryKey] = shaderProgram;
|
|
16698
16960
|
};
|
|
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
16961
|
_proto._resizeCacheMapHierarchy = function _resizeCacheMapHierarchy(cacheMap, hierarchy, currentHierarchy, increaseHierarchy) {
|
|
16718
16962
|
// Only expand but not shrink
|
|
16719
16963
|
if (hierarchy == currentHierarchy - 1) {
|
|
@@ -19021,7 +19265,6 @@ ShaderPool.init();
|
|
|
19021
19265
|
shaderProgramPools.length = length;
|
|
19022
19266
|
}
|
|
19023
19267
|
shaderProgramPools[index] = pool = new ShaderProgramPool();
|
|
19024
|
-
shaderPass._shaderProgramPools.push(pool);
|
|
19025
19268
|
}
|
|
19026
19269
|
return pool;
|
|
19027
19270
|
};
|
|
@@ -23743,12 +23986,6 @@ var BaseMaterial = /*#__PURE__*/ function(Material1) {
|
|
|
23743
23986
|
return this._shader;
|
|
23744
23987
|
},
|
|
23745
23988
|
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
23989
|
this._shader = value;
|
|
23753
23990
|
var renderStates = this._renderStates;
|
|
23754
23991
|
var lastStatesCount = renderStates.length;
|
|
@@ -27608,7 +27845,7 @@ var ParticleStopMode;
|
|
|
27608
27845
|
if (!material) {
|
|
27609
27846
|
return;
|
|
27610
27847
|
}
|
|
27611
|
-
if (material.destroyed
|
|
27848
|
+
if (material.destroyed) {
|
|
27612
27849
|
material = this.engine._particleMagentaMaterial;
|
|
27613
27850
|
}
|
|
27614
27851
|
var renderData = this._engine._renderDataPool.getFromPool();
|