@galacean/engine-core 2.0.0-alpha.55 → 2.0.0-alpha.57
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 +3007 -1280
- package/dist/main.js.map +1 -1
- package/dist/module.js +3007 -1281
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/BasicResources.d.ts +2 -2
- package/types/Engine.d.ts +3 -0
- package/types/lighting/ambientOcclusion/ScalableAmbientObscurancePass.d.ts +2 -2
- package/types/material/Material.d.ts +1 -0
- package/types/mesh/MeshTangentUtils.d.ts +9 -0
- package/types/mesh/ModelMesh.d.ts +5 -8
- package/types/mesh/PrimitiveMesh.d.ts +229 -101
- package/types/mesh/PrimitiveMeshOptions.d.ts +415 -0
- package/types/mesh/enums/PrimitiveMeshCapMode.d.ts +21 -0
- package/types/mesh/index.d.ts +2 -0
- package/types/mesh/primitive/MeshPathUtils.d.ts +13 -0
- package/types/mesh/primitive/PolygonUtils.d.ts +44 -0
- package/types/mesh/primitive/PrimitiveMeshBuilder.d.ts +25 -0
- package/types/mesh/primitive/PrimitiveMeshRestorer.d.ts +15 -0
- package/types/mesh/primitive/SubdivisionUtils.d.ts +9 -0
- package/types/particle/ParticleSubEmitterSpawnState.d.ts +2 -1
- package/types/particle/ParticleTransformFeedbackSimulator.d.ts +2 -6
- package/types/postProcess/FinalPass.d.ts +2 -1
- package/types/shader/BuiltinShaders.d.ts +27 -0
- package/types/shader/Shader.d.ts +0 -2
- package/types/shader/ShaderPass.d.ts +3 -1
- package/types/shader/index.d.ts +1 -0
- package/types/mesh/PrimitiveMeshRestorer.d.ts +0 -108
package/dist/module.js
CHANGED
|
@@ -7162,10 +7162,8 @@ ShaderBlockProperty._nameMap = Object.create(null);
|
|
|
7162
7162
|
mrtIndexSet.forEach(function(index) {
|
|
7163
7163
|
declaration += "layout(location=" + index + ") out vec4 fragOutColor" + index + ";\n";
|
|
7164
7164
|
});
|
|
7165
|
-
declaration += "void main(";
|
|
7166
7165
|
shader = shader.replace(/\bgl_FragData\[(.+?)\]/g, "fragOutColor$1");
|
|
7167
|
-
|
|
7168
|
-
return shader;
|
|
7166
|
+
return declaration + shader;
|
|
7169
7167
|
};
|
|
7170
7168
|
return ShaderFactory;
|
|
7171
7169
|
}();
|
|
@@ -9015,7 +9013,7 @@ var precisionStr = "\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision hig
|
|
|
9015
9013
|
* Shader pass containing vertex and fragment source.
|
|
9016
9014
|
*/ var ShaderPass = /*#__PURE__*/ function(ShaderPart) {
|
|
9017
9015
|
_inherits(ShaderPass, ShaderPart);
|
|
9018
|
-
function ShaderPass(name, vertexShaderInstructions, fragmentShaderInstructions, platformTarget, tags) {
|
|
9016
|
+
function ShaderPass(name, vertexShaderInstructions, fragmentShaderInstructions, platformTarget, tags, vertexOutputNames) {
|
|
9019
9017
|
var _this;
|
|
9020
9018
|
_this = ShaderPart.call(this) || this, /** @internal */ _this._shaderPassId = 0, /** @internal Pass-level render state — always present, populated from ShaderLab declarations. */ _this._renderState = new RenderState(), /** @internal */ _this._renderStateDataMap = {}, /** @internal */ _this._shaderProgramMaps = [];
|
|
9021
9019
|
_this._shaderPassId = ShaderPass._shaderPassCounter++;
|
|
@@ -9023,6 +9021,7 @@ var precisionStr = "\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision hig
|
|
|
9023
9021
|
_this._vertexShaderInstructions = vertexShaderInstructions;
|
|
9024
9022
|
_this._fragmentShaderInstructions = fragmentShaderInstructions;
|
|
9025
9023
|
_this._platformTarget = platformTarget;
|
|
9024
|
+
_this._vertexOutputNames = vertexOutputNames;
|
|
9026
9025
|
var mergedTags = _extends({
|
|
9027
9026
|
pipelineStage: PipelineStage.Forward
|
|
9028
9027
|
}, tags);
|
|
@@ -9058,6 +9057,12 @@ var precisionStr = "\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision hig
|
|
|
9058
9057
|
/**
|
|
9059
9058
|
* @internal
|
|
9060
9059
|
*/ _proto._compileShaderProgram = function _compileShaderProgram(engine, macroCollection, feedbackVaryings) {
|
|
9060
|
+
var names = this._vertexOutputNames;
|
|
9061
|
+
if (names && (feedbackVaryings == null ? void 0 : feedbackVaryings.length)) {
|
|
9062
|
+
feedbackVaryings = feedbackVaryings.map(function(name) {
|
|
9063
|
+
return Object.prototype.hasOwnProperty.call(names, name) ? names[name] : name;
|
|
9064
|
+
});
|
|
9065
|
+
}
|
|
9061
9066
|
var isGPUInstance = macroCollection.isEnable(InstanceBuffer.gpuInstanceMacro);
|
|
9062
9067
|
var _this__compileShaderSource = this._compileShaderSource(engine, macroCollection, isGPUInstance), vertexSource = _this__compileShaderSource.vertexSource, fragmentSource = _this__compileShaderSource.fragmentSource, instanceLayout = _this__compileShaderSource.instanceLayout;
|
|
9063
9068
|
var program = new ShaderProgram(engine, vertexSource, fragmentSource, feedbackVaryings);
|
|
@@ -9258,7 +9263,7 @@ ShaderPass._macroMap = new Map();
|
|
|
9258
9263
|
if (!shaderPassSource) {
|
|
9259
9264
|
throw 'Shader pass "' + parsedSource.name + "." + subShaderSource.name + "." + passSource.name + '" parse failed, please check the shader source code.';
|
|
9260
9265
|
}
|
|
9261
|
-
var shaderPass = new ShaderPass(passSource.name, shaderPassSource.vertexShaderInstructions, shaderPassSource.fragmentShaderInstructions, platformTarget, passSource.tags);
|
|
9266
|
+
var shaderPass = new ShaderPass(passSource.name, shaderPassSource.vertexShaderInstructions, shaderPassSource.fragmentShaderInstructions, platformTarget, passSource.tags, shaderPassSource.vertexOutputNames);
|
|
9262
9267
|
Shader._applyRenderStates(shaderPass, passSource.renderStates.constantMap, passSource.renderStates.variableMap, false);
|
|
9263
9268
|
return shaderPass;
|
|
9264
9269
|
});
|
|
@@ -9276,8 +9281,6 @@ ShaderPass._macroMap = new Map();
|
|
|
9276
9281
|
return shaders == null ? void 0 : shaders[shaders.length - 1];
|
|
9277
9282
|
};
|
|
9278
9283
|
/**
|
|
9279
|
-
* Create a shader from precompiled instructions.
|
|
9280
|
-
* @param data - Precompiled shader data
|
|
9281
9284
|
* @internal
|
|
9282
9285
|
*/ Shader._createFromPrecompiled = function _createFromPrecompiled(data) {
|
|
9283
9286
|
var subShaderList = data.subShaders.map(function(subData) {
|
|
@@ -9285,7 +9288,7 @@ ShaderPass._macroMap = new Map();
|
|
|
9285
9288
|
if (passData.isUsePass) {
|
|
9286
9289
|
return Shader._resolveUsePass(passData.name);
|
|
9287
9290
|
}
|
|
9288
|
-
var shaderPass = new ShaderPass(passData.name, passData.vertexShaderInstructions, passData.fragmentShaderInstructions, data.platformTarget, passData.tags);
|
|
9291
|
+
var shaderPass = new ShaderPass(passData.name, passData.vertexShaderInstructions, passData.fragmentShaderInstructions, data.platformTarget, passData.tags, passData.vertexOutputNames);
|
|
9289
9292
|
Shader._applyRenderStates(shaderPass, passData.renderStates.constantMap, passData.renderStates.variableMap, true);
|
|
9290
9293
|
return shaderPass;
|
|
9291
9294
|
});
|
|
@@ -11147,6 +11150,9 @@ var TextChunk = function TextChunk() {
|
|
|
11147
11150
|
_inherits(Material, ReferResource);
|
|
11148
11151
|
function Material(engine, shader) {
|
|
11149
11152
|
var _this;
|
|
11153
|
+
if (shader.destroyed) {
|
|
11154
|
+
throw new Error("Cannot create a material with a destroyed shader.");
|
|
11155
|
+
}
|
|
11150
11156
|
_this = ReferResource.call(this, engine) || this, _this._shaderData = new ShaderData(ShaderDataGroup.Material);
|
|
11151
11157
|
_this.shader = shader;
|
|
11152
11158
|
_this.name = shader.name;
|
|
@@ -11437,7 +11443,7 @@ BaseMaterial._rasterStateCullModeProp = ShaderProperty.getByName("rasterStateCul
|
|
|
11437
11443
|
_inherits(BlinnPhongMaterial, BaseMaterial);
|
|
11438
11444
|
function BlinnPhongMaterial(engine) {
|
|
11439
11445
|
var _this;
|
|
11440
|
-
_this = BaseMaterial.call(this, engine,
|
|
11446
|
+
_this = BaseMaterial.call(this, engine, Engine._builtinShaders.blinnPhong) || this;
|
|
11441
11447
|
var shaderData = _this.shaderData;
|
|
11442
11448
|
shaderData.enableMacro("MATERIAL_NEED_WORLD_POS");
|
|
11443
11449
|
shaderData.enableMacro("MATERIAL_NEED_TILING_OFFSET");
|
|
@@ -11633,7 +11639,7 @@ BlinnPhongMaterial._specularTextureProp = ShaderProperty.getByName("material_Spe
|
|
|
11633
11639
|
_inherits(PBRMaterial, BaseMaterial1);
|
|
11634
11640
|
function PBRMaterial(engine) {
|
|
11635
11641
|
var _this;
|
|
11636
|
-
_this = BaseMaterial1.call(this, engine,
|
|
11642
|
+
_this = BaseMaterial1.call(this, engine, Engine._builtinShaders.pbr) || this, _this._anisotropyRotation = 0, _this._iridescenceRange = new Vector2(100, 400), _this._sheenEnabled = false;
|
|
11637
11643
|
var shaderData = _this.shaderData;
|
|
11638
11644
|
shaderData.enableMacro("MATERIAL_NEED_WORLD_POS");
|
|
11639
11645
|
shaderData.enableMacro("MATERIAL_NEED_TILING_OFFSET");
|
|
@@ -12429,7 +12435,7 @@ PBRMaterial._specularColorTextureProp = ShaderProperty.getByName("material_Specu
|
|
|
12429
12435
|
_inherits(UnlitMaterial, BaseMaterial);
|
|
12430
12436
|
function UnlitMaterial(engine) {
|
|
12431
12437
|
var _this;
|
|
12432
|
-
_this = BaseMaterial.call(this, engine,
|
|
12438
|
+
_this = BaseMaterial.call(this, engine, Engine._builtinShaders.unlit) || this;
|
|
12433
12439
|
var shaderData = _this.shaderData;
|
|
12434
12440
|
shaderData.enableMacro("MATERIAL_OMIT_NORMAL");
|
|
12435
12441
|
shaderData.enableMacro("MATERIAL_NEED_TILING_OFFSET");
|
|
@@ -13771,6 +13777,134 @@ BlendShapeManager._blendShapeWeightsProperty = ShaderProperty.getByName("rendere
|
|
|
13771
13777
|
BlendShapeManager._blendShapeTextureProperty = ShaderProperty.getByName("renderer_BlendShapeTexture");
|
|
13772
13778
|
BlendShapeManager._blendShapeTextureInfoProperty = ShaderProperty.getByName("renderer_BlendShapeTextureInfo");
|
|
13773
13779
|
|
|
13780
|
+
/**
|
|
13781
|
+
* @internal
|
|
13782
|
+
*/ var MeshTangentUtils = /*#__PURE__*/ function() {
|
|
13783
|
+
function MeshTangentUtils() {}
|
|
13784
|
+
MeshTangentUtils.calculateTangents = function calculateTangents(positions, normals, uvs, indices) {
|
|
13785
|
+
return MeshTangentUtils._calculateTangents(positions, normals, uvs, indices, null);
|
|
13786
|
+
};
|
|
13787
|
+
MeshTangentUtils.calculateTangentsFromBuffer = function calculateTangentsFromBuffer(vertices, indices) {
|
|
13788
|
+
return MeshTangentUtils._calculateTangents(null, null, null, indices, vertices);
|
|
13789
|
+
};
|
|
13790
|
+
MeshTangentUtils._calculateTangents = function _calculateTangents(positions, normals, uvs, indices, vertices) {
|
|
13791
|
+
var vertexCount = vertices ? vertices.length / 8 : positions.length;
|
|
13792
|
+
var indexCount = indices ? indices.length : vertexCount;
|
|
13793
|
+
// Accumulate the tangent basis in double precision
|
|
13794
|
+
var basis = new Float64Array(vertexCount * 6);
|
|
13795
|
+
for(var i = 0; i + 2 < indexCount; i += 3){
|
|
13796
|
+
var a = indices ? indices[i] : i;
|
|
13797
|
+
var b = indices ? indices[i + 1] : i + 1;
|
|
13798
|
+
var c = indices ? indices[i + 2] : i + 2;
|
|
13799
|
+
var e1x = void 0, e1y = void 0, e1z = void 0, e2x = void 0, e2y = void 0, e2z = void 0;
|
|
13800
|
+
var x1 = void 0, x2 = void 0, y1 = void 0, y2 = void 0;
|
|
13801
|
+
if (vertices) {
|
|
13802
|
+
var offsetA = a * 8;
|
|
13803
|
+
var offsetB = b * 8;
|
|
13804
|
+
var offsetC = c * 8;
|
|
13805
|
+
e1x = vertices[offsetB] - vertices[offsetA];
|
|
13806
|
+
e1y = vertices[offsetB + 1] - vertices[offsetA + 1];
|
|
13807
|
+
e1z = vertices[offsetB + 2] - vertices[offsetA + 2];
|
|
13808
|
+
e2x = vertices[offsetC] - vertices[offsetA];
|
|
13809
|
+
e2y = vertices[offsetC + 1] - vertices[offsetA + 1];
|
|
13810
|
+
e2z = vertices[offsetC + 2] - vertices[offsetA + 2];
|
|
13811
|
+
x1 = vertices[offsetB + 6] - vertices[offsetA + 6];
|
|
13812
|
+
x2 = vertices[offsetC + 6] - vertices[offsetA + 6];
|
|
13813
|
+
y1 = vertices[offsetB + 7] - vertices[offsetA + 7];
|
|
13814
|
+
y2 = vertices[offsetC + 7] - vertices[offsetA + 7];
|
|
13815
|
+
} else {
|
|
13816
|
+
var p0 = positions[a];
|
|
13817
|
+
var p1 = positions[b];
|
|
13818
|
+
var p2 = positions[c];
|
|
13819
|
+
var uv0 = uvs[a];
|
|
13820
|
+
var uv1 = uvs[b];
|
|
13821
|
+
var uv2 = uvs[c];
|
|
13822
|
+
e1x = p1.x - p0.x;
|
|
13823
|
+
e1y = p1.y - p0.y;
|
|
13824
|
+
e1z = p1.z - p0.z;
|
|
13825
|
+
e2x = p2.x - p0.x;
|
|
13826
|
+
e2y = p2.y - p0.y;
|
|
13827
|
+
e2z = p2.z - p0.z;
|
|
13828
|
+
x1 = uv1.x - uv0.x;
|
|
13829
|
+
x2 = uv2.x - uv0.x;
|
|
13830
|
+
y1 = uv1.y - uv0.y;
|
|
13831
|
+
y2 = uv2.y - uv0.y;
|
|
13832
|
+
}
|
|
13833
|
+
var determinant = x1 * y2 - x2 * y1;
|
|
13834
|
+
if (determinant === 0) {
|
|
13835
|
+
continue;
|
|
13836
|
+
}
|
|
13837
|
+
var inverse = 1 / determinant;
|
|
13838
|
+
var ty1 = y1 * inverse;
|
|
13839
|
+
var ty2 = y2 * inverse;
|
|
13840
|
+
var bx1 = x1 * inverse;
|
|
13841
|
+
var bx2 = x2 * inverse;
|
|
13842
|
+
var tx = e1x * ty2 - e2x * ty1;
|
|
13843
|
+
var ty = e1y * ty2 - e2y * ty1;
|
|
13844
|
+
var tz = e1z * ty2 - e2z * ty1;
|
|
13845
|
+
var bx = e2x * bx1 - e1x * bx2;
|
|
13846
|
+
var by = e2y * bx1 - e1y * bx2;
|
|
13847
|
+
var bz = e2z * bx1 - e1z * bx2;
|
|
13848
|
+
for(var corner = 0; corner < 3; corner++){
|
|
13849
|
+
var offset = (corner === 0 ? a : corner === 1 ? b : c) * 6;
|
|
13850
|
+
basis[offset] += tx;
|
|
13851
|
+
basis[offset + 1] += ty;
|
|
13852
|
+
basis[offset + 2] += tz;
|
|
13853
|
+
basis[offset + 3] += bx;
|
|
13854
|
+
basis[offset + 4] += by;
|
|
13855
|
+
basis[offset + 5] += bz;
|
|
13856
|
+
}
|
|
13857
|
+
}
|
|
13858
|
+
var tangents = vertices ? new Float32Array(vertexCount * 4) : new Array(vertexCount);
|
|
13859
|
+
for(var i1 = 0; i1 < vertexCount; i1++){
|
|
13860
|
+
var nx = void 0, ny = void 0, nz = void 0;
|
|
13861
|
+
if (vertices) {
|
|
13862
|
+
var offset1 = i1 * 8;
|
|
13863
|
+
nx = vertices[offset1 + 3];
|
|
13864
|
+
ny = vertices[offset1 + 4];
|
|
13865
|
+
nz = vertices[offset1 + 5];
|
|
13866
|
+
} else {
|
|
13867
|
+
var normal = normals[i1];
|
|
13868
|
+
nx = normal.x;
|
|
13869
|
+
ny = normal.y;
|
|
13870
|
+
nz = normal.z;
|
|
13871
|
+
}
|
|
13872
|
+
var offset2 = i1 * 6;
|
|
13873
|
+
var tx1 = basis[offset2];
|
|
13874
|
+
var ty3 = basis[offset2 + 1];
|
|
13875
|
+
var tz1 = basis[offset2 + 2];
|
|
13876
|
+
var bx3 = basis[offset2 + 3];
|
|
13877
|
+
var by1 = basis[offset2 + 4];
|
|
13878
|
+
var bz1 = basis[offset2 + 5];
|
|
13879
|
+
var handedness = (ty3 * bz1 - tz1 * by1) * nx + (tz1 * bx3 - tx1 * bz1) * ny + (tx1 * by1 - ty3 * bx3) * nz > 0 ? 1 : -1;
|
|
13880
|
+
// Custom normals need not have unit length
|
|
13881
|
+
var normalLengthSquared = nx * nx + ny * ny + nz * nz;
|
|
13882
|
+
var projection = normalLengthSquared > 0 ? (tx1 * nx + ty3 * ny + tz1 * nz) / normalLengthSquared : 0;
|
|
13883
|
+
tx1 -= nx * projection;
|
|
13884
|
+
ty3 -= ny * projection;
|
|
13885
|
+
tz1 -= nz * projection;
|
|
13886
|
+
var length = Math.hypot(tx1, ty3, tz1);
|
|
13887
|
+
if (length > 0) {
|
|
13888
|
+
var inverse1 = 1 / length;
|
|
13889
|
+
tx1 *= inverse1;
|
|
13890
|
+
ty3 *= inverse1;
|
|
13891
|
+
tz1 *= inverse1;
|
|
13892
|
+
}
|
|
13893
|
+
if (vertices) {
|
|
13894
|
+
var result = tangents;
|
|
13895
|
+
result[i1 * 4] = tx1;
|
|
13896
|
+
result[i1 * 4 + 1] = ty3;
|
|
13897
|
+
result[i1 * 4 + 2] = tz1;
|
|
13898
|
+
result[i1 * 4 + 3] = handedness;
|
|
13899
|
+
} else {
|
|
13900
|
+
tangents[i1] = new Vector4(tx1, ty3, tz1, handedness);
|
|
13901
|
+
}
|
|
13902
|
+
}
|
|
13903
|
+
return tangents;
|
|
13904
|
+
};
|
|
13905
|
+
return MeshTangentUtils;
|
|
13906
|
+
}();
|
|
13907
|
+
|
|
13774
13908
|
/**
|
|
13775
13909
|
* Vertex attribute types of a vertex in a ModelMesh.
|
|
13776
13910
|
*/ var VertexAttribute = /*#__PURE__*/ function(VertexAttribute) {
|
|
@@ -14183,9 +14317,11 @@ BlendShapeManager._blendShapeTextureInfoProperty = ShaderProperty.getByName("ren
|
|
|
14183
14317
|
}
|
|
14184
14318
|
};
|
|
14185
14319
|
/**
|
|
14186
|
-
* Calculate
|
|
14187
|
-
* @
|
|
14188
|
-
*
|
|
14320
|
+
* Calculate tangents from readable positions, normals and UVs.
|
|
14321
|
+
* @remarks
|
|
14322
|
+
* Without indices, every three consecutive vertices form a triangle.
|
|
14323
|
+
* Incomplete trailing triangles and triangles with zero UV area are ignored.
|
|
14324
|
+
* @see http://foundationsofgameenginedev.com/FGED2-sample.pdf
|
|
14189
14325
|
*/ _proto.calculateTangents = function calculateTangents() {
|
|
14190
14326
|
var positions = this.getPositions();
|
|
14191
14327
|
var normals = this.getNormals();
|
|
@@ -14193,68 +14329,7 @@ BlendShapeManager._blendShapeTextureInfoProperty = ShaderProperty.getByName("ren
|
|
|
14193
14329
|
if (!normals || !uvs) {
|
|
14194
14330
|
throw "Set normal and uv before calculation.";
|
|
14195
14331
|
}
|
|
14196
|
-
|
|
14197
|
-
var e1 = ModelMesh._tempVec0, e2 = ModelMesh._tempVec1, t = ModelMesh._tempVec2, b = ModelMesh._tempVec3, temp = ModelMesh._tempVec4;
|
|
14198
|
-
var triangleCount = indices ? indices.length / 3 : positions.length / 3;
|
|
14199
|
-
var tangents = new Array(vertexCount);
|
|
14200
|
-
var biTangents = new Array(vertexCount);
|
|
14201
|
-
for(var i = 0; i < vertexCount; i++){
|
|
14202
|
-
tangents[i] = new Vector4();
|
|
14203
|
-
biTangents[i] = new Vector3();
|
|
14204
|
-
}
|
|
14205
|
-
// Calculate tangent and bi-tangent for each triangle and add to all three vertices.
|
|
14206
|
-
for(var k = 0; k < triangleCount; k++){
|
|
14207
|
-
var i0 = 3 * k;
|
|
14208
|
-
var i1 = 3 * k + 1;
|
|
14209
|
-
var i2 = 3 * k + 2;
|
|
14210
|
-
if (indices) {
|
|
14211
|
-
i0 = indices[i0];
|
|
14212
|
-
i1 = indices[i1];
|
|
14213
|
-
i2 = indices[i2];
|
|
14214
|
-
}
|
|
14215
|
-
var p0 = positions[i0];
|
|
14216
|
-
var p1 = positions[i1];
|
|
14217
|
-
var p2 = positions[i2];
|
|
14218
|
-
var w0 = uvs[i0];
|
|
14219
|
-
var w1 = uvs[i1];
|
|
14220
|
-
var w2 = uvs[i2];
|
|
14221
|
-
Vector3.subtract(p1, p0, e1);
|
|
14222
|
-
Vector3.subtract(p2, p0, e2);
|
|
14223
|
-
var x1 = w1.x - w0.x;
|
|
14224
|
-
var x2 = w2.x - w0.x;
|
|
14225
|
-
var y1 = w1.y - w0.y;
|
|
14226
|
-
var y2 = w2.y - w0.y;
|
|
14227
|
-
var r = 1.0 / (x1 * y2 - x2 * y1);
|
|
14228
|
-
Vector3.scale(e1, y2 * r, t);
|
|
14229
|
-
Vector3.scale(e2, y1 * r, temp);
|
|
14230
|
-
Vector3.subtract(t, temp, t);
|
|
14231
|
-
Vector3.scale(e2, x1 * r, b);
|
|
14232
|
-
Vector3.scale(e1, x2 * r, temp);
|
|
14233
|
-
Vector3.subtract(b, temp, b);
|
|
14234
|
-
var tangent = tangents[i0];
|
|
14235
|
-
tangent.set(tangent.x + t.x, tangent.y + t.y, tangent.z + t.z, 1.0);
|
|
14236
|
-
tangent = tangents[i1];
|
|
14237
|
-
tangent.set(tangent.x + t.x, tangent.y + t.y, tangent.z + t.z, 1.0);
|
|
14238
|
-
tangent = tangents[i2];
|
|
14239
|
-
tangent.set(tangent.x + t.x, tangent.y + t.y, tangent.z + t.z, 1.0);
|
|
14240
|
-
biTangents[i0].add(b);
|
|
14241
|
-
biTangents[i1].add(b);
|
|
14242
|
-
biTangents[i2].add(b);
|
|
14243
|
-
}
|
|
14244
|
-
// Orthonormalize each tangent and calculate the handedness.
|
|
14245
|
-
for(var i3 = 0; i3 < vertexCount; i3++){
|
|
14246
|
-
var n = normals[i3];
|
|
14247
|
-
var b1 = biTangents[i3];
|
|
14248
|
-
var tangent1 = tangents[i3];
|
|
14249
|
-
t.set(tangent1.x, tangent1.y, tangent1.z);
|
|
14250
|
-
Vector3.cross(t, b1, temp);
|
|
14251
|
-
var w = Vector3.dot(temp, n) > 0.0 ? 1 : -1;
|
|
14252
|
-
Vector3.scale(n, Vector3.dot(t, n), temp);
|
|
14253
|
-
Vector3.subtract(t, temp, t);
|
|
14254
|
-
t.normalize();
|
|
14255
|
-
tangent1.set(t.x, t.y, t.z, w);
|
|
14256
|
-
}
|
|
14257
|
-
this.setTangents(tangents);
|
|
14332
|
+
this.setTangents(MeshTangentUtils.calculateTangents(positions, normals, uvs, this._indices));
|
|
14258
14333
|
};
|
|
14259
14334
|
/**
|
|
14260
14335
|
* @internal
|
|
@@ -14262,25 +14337,25 @@ BlendShapeManager._blendShapeTextureInfoProperty = ShaderProperty.getByName("ren
|
|
|
14262
14337
|
var _this = this;
|
|
14263
14338
|
var vertexBufferBindings = this._primitive.vertexBufferBindings;
|
|
14264
14339
|
var updateInfos = this._vertexBufferInfos;
|
|
14265
|
-
var
|
|
14266
|
-
if (!_this._advancedDataSyncToBuffer) {
|
|
14267
|
-
updateInfos[index].dataVersion = _this._dataVersionCounter++;
|
|
14268
|
-
}
|
|
14269
|
-
};
|
|
14270
|
-
// Remove listener from previous binding
|
|
14340
|
+
var updateInfo = updateInfos[index];
|
|
14271
14341
|
var previousBinding = vertexBufferBindings[index];
|
|
14272
|
-
|
|
14342
|
+
if (previousBinding) {
|
|
14343
|
+
previousBinding.buffer._dataUpdateManager.removeListener(updateInfo.onBufferChanged);
|
|
14344
|
+
}
|
|
14273
14345
|
Mesh.prototype._setVertexBufferBinding.call(this, index, binding);
|
|
14274
|
-
// Add listener to new binding and trigger update
|
|
14275
14346
|
if (binding) {
|
|
14276
|
-
|
|
14277
|
-
|
|
14278
|
-
|
|
14279
|
-
|
|
14280
|
-
|
|
14281
|
-
|
|
14282
|
-
vertexBufferBindings.length--;
|
|
14347
|
+
if (!updateInfo) {
|
|
14348
|
+
updateInfo = updateInfos[index] = new BufferUpdateInfo(function() {
|
|
14349
|
+
if (!_this._advancedDataSyncToBuffer) {
|
|
14350
|
+
updateInfos[index].dataVersion = _this._dataVersionCounter++;
|
|
14351
|
+
}
|
|
14352
|
+
});
|
|
14283
14353
|
}
|
|
14354
|
+
binding.buffer._dataUpdateManager.addListener(updateInfo.onBufferChanged);
|
|
14355
|
+
updateInfo.reset();
|
|
14356
|
+
updateInfo.onBufferChanged();
|
|
14357
|
+
} else if (index + 1 == vertexBufferBindings.length) {
|
|
14358
|
+
vertexBufferBindings.length--;
|
|
14284
14359
|
}
|
|
14285
14360
|
};
|
|
14286
14361
|
/**
|
|
@@ -14302,6 +14377,11 @@ BlendShapeManager._blendShapeTextureInfoProperty = ShaderProperty.getByName("ren
|
|
|
14302
14377
|
/**
|
|
14303
14378
|
* @internal
|
|
14304
14379
|
*/ _proto._onDestroy = function _onDestroy() {
|
|
14380
|
+
var bindings = this._primitive.vertexBufferBindings;
|
|
14381
|
+
for(var i = 0; i < bindings.length; i++){
|
|
14382
|
+
var _bindings_i;
|
|
14383
|
+
(_bindings_i = bindings[i]) == null ? void 0 : _bindings_i.buffer._dataUpdateManager.removeListener(this._vertexBufferInfos[i].onBufferChanged);
|
|
14384
|
+
}
|
|
14305
14385
|
Mesh.prototype._onDestroy.call(this);
|
|
14306
14386
|
this._releaseCache(true);
|
|
14307
14387
|
};
|
|
@@ -14773,13 +14853,9 @@ BlendShapeManager._blendShapeTextureInfoProperty = ShaderProperty.getByName("ren
|
|
|
14773
14853
|
]);
|
|
14774
14854
|
return ModelMesh;
|
|
14775
14855
|
}(Mesh);
|
|
14776
|
-
ModelMesh._tempVec0 = new Vector3();
|
|
14777
|
-
ModelMesh._tempVec1 = new Vector3();
|
|
14778
|
-
ModelMesh._tempVec2 = new Vector3();
|
|
14779
|
-
ModelMesh._tempVec3 = new Vector3();
|
|
14780
|
-
ModelMesh._tempVec4 = new Vector3();
|
|
14781
14856
|
var BufferUpdateInfo = /*#__PURE__*/ function() {
|
|
14782
|
-
function BufferUpdateInfo() {
|
|
14857
|
+
function BufferUpdateInfo(onBufferChanged) {
|
|
14858
|
+
this.onBufferChanged = onBufferChanged;
|
|
14783
14859
|
this.dataVersion = -1;
|
|
14784
14860
|
this.uploadAdvancedData = false;
|
|
14785
14861
|
}
|
|
@@ -14790,337 +14866,2339 @@ var BufferUpdateInfo = /*#__PURE__*/ function() {
|
|
|
14790
14866
|
return BufferUpdateInfo;
|
|
14791
14867
|
}();
|
|
14792
14868
|
|
|
14869
|
+
function _type_of(obj) {
|
|
14870
|
+
"@swc/helpers - typeof";
|
|
14871
|
+
|
|
14872
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
14873
|
+
}
|
|
14874
|
+
|
|
14875
|
+
/**
|
|
14876
|
+
* End caps generated for cylinders and truncated cones.
|
|
14877
|
+
*/ var PrimitiveMeshCapMode = /*#__PURE__*/ function(PrimitiveMeshCapMode) {
|
|
14878
|
+
/**
|
|
14879
|
+
* Generate both the top and bottom caps.
|
|
14880
|
+
*/ PrimitiveMeshCapMode["Both"] = "both";
|
|
14881
|
+
/**
|
|
14882
|
+
* Generate only the top cap, facing +Y.
|
|
14883
|
+
*/ PrimitiveMeshCapMode["Top"] = "top";
|
|
14884
|
+
/**
|
|
14885
|
+
* Generate only the bottom cap, facing -Y.
|
|
14886
|
+
*/ PrimitiveMeshCapMode["Bottom"] = "bottom";
|
|
14887
|
+
/**
|
|
14888
|
+
* Leave both ends open.
|
|
14889
|
+
*/ PrimitiveMeshCapMode["None"] = "none";
|
|
14890
|
+
return PrimitiveMeshCapMode;
|
|
14891
|
+
}({});
|
|
14892
|
+
|
|
14893
|
+
/**
|
|
14894
|
+
* @internal
|
|
14895
|
+
*/ var PrimitiveMeshBuilder = /*#__PURE__*/ function() {
|
|
14896
|
+
function PrimitiveMeshBuilder(vertexCapacity, indexCapacity) {
|
|
14897
|
+
if (vertexCapacity === void 0) vertexCapacity = 0;
|
|
14898
|
+
if (indexCapacity === void 0) indexCapacity = 0;
|
|
14899
|
+
this.vertexCount = 0;
|
|
14900
|
+
this.indexCount = 0;
|
|
14901
|
+
this.groups = [];
|
|
14902
|
+
this.vertices = new Float32Array(vertexCapacity * 8);
|
|
14903
|
+
this.indices = vertexCapacity > 65535 ? new Uint32Array(indexCapacity) : new Uint16Array(indexCapacity);
|
|
14904
|
+
}
|
|
14905
|
+
var _proto = PrimitiveMeshBuilder.prototype;
|
|
14906
|
+
_proto.addVertex = function addVertex(x, y, z, nx, ny, nz, u, v) {
|
|
14907
|
+
var index = this.vertexCount++;
|
|
14908
|
+
this._ensureVertexCapacity(this.vertexCount);
|
|
14909
|
+
var length = Math.hypot(nx, ny, nz);
|
|
14910
|
+
var inverse = length > 0 ? 1 / length : 0;
|
|
14911
|
+
var vertices = this.vertices;
|
|
14912
|
+
var offset = index * 8;
|
|
14913
|
+
vertices[offset] = x;
|
|
14914
|
+
vertices[offset + 1] = y;
|
|
14915
|
+
vertices[offset + 2] = z;
|
|
14916
|
+
vertices[offset + 3] = nx * inverse;
|
|
14917
|
+
vertices[offset + 4] = ny * inverse;
|
|
14918
|
+
vertices[offset + 5] = nz * inverse;
|
|
14919
|
+
vertices[offset + 6] = u;
|
|
14920
|
+
vertices[offset + 7] = v;
|
|
14921
|
+
return index;
|
|
14922
|
+
};
|
|
14923
|
+
_proto.addTriangle = function addTriangle(a, b, c) {
|
|
14924
|
+
this._ensureIndexCapacity(this.indexCount + 3);
|
|
14925
|
+
this.indices[this.indexCount++] = a;
|
|
14926
|
+
this.indices[this.indexCount++] = b;
|
|
14927
|
+
this.indices[this.indexCount++] = c;
|
|
14928
|
+
};
|
|
14929
|
+
_proto.addIndex = function addIndex(index) {
|
|
14930
|
+
this._ensureIndexCapacity(this.indexCount + 1);
|
|
14931
|
+
this.indices[this.indexCount++] = index;
|
|
14932
|
+
};
|
|
14933
|
+
_proto.addGroup = function addGroup(start) {
|
|
14934
|
+
var count = this.indexCount - start;
|
|
14935
|
+
if (count > 0) {
|
|
14936
|
+
this.groups.push({
|
|
14937
|
+
start: start,
|
|
14938
|
+
count: count
|
|
14939
|
+
});
|
|
14940
|
+
}
|
|
14941
|
+
};
|
|
14942
|
+
_proto.addFace = function addFace(a, b, c, uvA, uvB, uvC) {
|
|
14943
|
+
var abX = b.x - a.x;
|
|
14944
|
+
var abY = b.y - a.y;
|
|
14945
|
+
var abZ = b.z - a.z;
|
|
14946
|
+
var acX = c.x - a.x;
|
|
14947
|
+
var acY = c.y - a.y;
|
|
14948
|
+
var acZ = c.z - a.z;
|
|
14949
|
+
var nx = abY * acZ - abZ * acY;
|
|
14950
|
+
var ny = abZ * acX - abX * acZ;
|
|
14951
|
+
var nz = abX * acY - abY * acX;
|
|
14952
|
+
var start = this.vertexCount;
|
|
14953
|
+
this.addVertex(a.x, a.y, a.z, nx, ny, nz, uvA.x, uvA.y);
|
|
14954
|
+
this.addVertex(b.x, b.y, b.z, nx, ny, nz, uvB.x, uvB.y);
|
|
14955
|
+
this.addVertex(c.x, c.y, c.z, nx, ny, nz, uvC.x, uvC.y);
|
|
14956
|
+
this.addTriangle(start, start + 1, start + 2);
|
|
14957
|
+
};
|
|
14958
|
+
_proto.setData = function setData(vertices, indices) {
|
|
14959
|
+
this.vertices = vertices;
|
|
14960
|
+
this.indices = indices;
|
|
14961
|
+
this.vertexCount = vertices.length / 8;
|
|
14962
|
+
this.indexCount = indices.length;
|
|
14963
|
+
};
|
|
14964
|
+
_proto.trim = function trim() {
|
|
14965
|
+
if (this.vertices.length !== this.vertexCount * 8) {
|
|
14966
|
+
this.vertices = this.vertices.subarray(0, this.vertexCount * 8);
|
|
14967
|
+
}
|
|
14968
|
+
if (this.indices.length !== this.indexCount) {
|
|
14969
|
+
this.indices = this.indices.subarray(0, this.indexCount);
|
|
14970
|
+
}
|
|
14971
|
+
var IndexArray = this.vertexCount > 65535 ? Uint32Array : Uint16Array;
|
|
14972
|
+
if (!_instanceof(this.indices, IndexArray)) {
|
|
14973
|
+
this.indices = new IndexArray(this.indices);
|
|
14974
|
+
}
|
|
14975
|
+
};
|
|
14976
|
+
_proto._ensureVertexCapacity = function _ensureVertexCapacity(count) {
|
|
14977
|
+
if (count * 8 > this.vertices.length) {
|
|
14978
|
+
var vertices = new Float32Array(Math.max(count * 8, this.vertices.length * 2, 64));
|
|
14979
|
+
vertices.set(this.vertices);
|
|
14980
|
+
this.vertices = vertices;
|
|
14981
|
+
}
|
|
14982
|
+
};
|
|
14983
|
+
_proto._ensureIndexCapacity = function _ensureIndexCapacity(count) {
|
|
14984
|
+
var previous = this.indices;
|
|
14985
|
+
var useUint32 = this.vertexCount > 65535;
|
|
14986
|
+
if (count > previous.length || useUint32 && _instanceof(previous, Uint16Array)) {
|
|
14987
|
+
var capacity = count > previous.length ? Math.max(count, previous.length * 2, 24) : previous.length;
|
|
14988
|
+
var IndexArray = useUint32 || _instanceof(previous, Uint32Array) ? Uint32Array : Uint16Array;
|
|
14989
|
+
var indices = new IndexArray(capacity);
|
|
14990
|
+
indices.set(previous);
|
|
14991
|
+
this.indices = indices;
|
|
14992
|
+
}
|
|
14993
|
+
};
|
|
14994
|
+
return PrimitiveMeshBuilder;
|
|
14995
|
+
}();
|
|
14996
|
+
|
|
14793
14997
|
/**
|
|
14794
14998
|
* @internal
|
|
14795
14999
|
*/ var PrimitiveMeshRestorer = /*#__PURE__*/ function(ContentRestorer) {
|
|
14796
15000
|
_inherits(PrimitiveMeshRestorer, ContentRestorer);
|
|
14797
|
-
function PrimitiveMeshRestorer(
|
|
15001
|
+
function PrimitiveMeshRestorer(mesh, _generate, _args) {
|
|
14798
15002
|
var _this;
|
|
14799
|
-
|
|
15003
|
+
var _mesh_vertexBufferBindings_;
|
|
15004
|
+
_this = ContentRestorer.call(this, mesh) || this, _this._generate = _generate, _this._args = _args;
|
|
15005
|
+
_this._vertexBuffer = mesh.vertexBufferBindings[0].buffer;
|
|
15006
|
+
_this._tangentBuffer = (_mesh_vertexBufferBindings_ = mesh.vertexBufferBindings[1]) == null ? void 0 : _mesh_vertexBufferBindings_.buffer;
|
|
15007
|
+
_this._indexBuffer = mesh._primitive.indexBufferBinding._buffer;
|
|
14800
15008
|
return _this;
|
|
14801
15009
|
}
|
|
14802
15010
|
var _proto = PrimitiveMeshRestorer.prototype;
|
|
14803
15011
|
_proto.restoreContent = function restoreContent() {
|
|
14804
|
-
var
|
|
14805
|
-
|
|
14806
|
-
|
|
14807
|
-
|
|
14808
|
-
|
|
14809
|
-
|
|
14810
|
-
|
|
14811
|
-
|
|
14812
|
-
|
|
14813
|
-
|
|
14814
|
-
|
|
14815
|
-
|
|
14816
|
-
|
|
14817
|
-
|
|
14818
|
-
|
|
14819
|
-
|
|
14820
|
-
|
|
14821
|
-
|
|
14822
|
-
|
|
14823
|
-
var cylinderInfo = primitiveInfo;
|
|
14824
|
-
PrimitiveMesh._setCylinderData(this.resource, cylinderInfo.radiusTop, cylinderInfo.radiusBottom, cylinderInfo.height, cylinderInfo.radialSegments, cylinderInfo.heightSegments, cylinderInfo.noLongerAccessible, true, cylinderInfo.vertexBuffer);
|
|
14825
|
-
break;
|
|
14826
|
-
case 4:
|
|
14827
|
-
var torusInfo = primitiveInfo;
|
|
14828
|
-
PrimitiveMesh._setTorusData(this.resource, torusInfo.radius, torusInfo.tubeRadius, torusInfo.radialSegments, torusInfo.tubularSegments, torusInfo.arc, torusInfo.noLongerAccessible, true, torusInfo.vertexBuffer);
|
|
14829
|
-
break;
|
|
14830
|
-
case 5:
|
|
14831
|
-
var coneInfo = primitiveInfo;
|
|
14832
|
-
PrimitiveMesh._setConeData(this.resource, coneInfo.radius, coneInfo.height, coneInfo.radialSegments, coneInfo.heightSegments, coneInfo.noLongerAccessible, true, coneInfo.vertexBuffer);
|
|
14833
|
-
break;
|
|
14834
|
-
case 6:
|
|
14835
|
-
var capsuleInfo = primitiveInfo;
|
|
14836
|
-
PrimitiveMesh._setCapsuleData(this.resource, capsuleInfo.radius, capsuleInfo.height, capsuleInfo.radialSegments, capsuleInfo.heightSegments, capsuleInfo.noLongerAccessible, true, capsuleInfo.vertexBuffer);
|
|
14837
|
-
break;
|
|
15012
|
+
var _mesh__primitive_indexBufferBinding;
|
|
15013
|
+
var mesh = this.resource;
|
|
15014
|
+
var data = this._generate.apply(this, [].concat(this._args));
|
|
15015
|
+
data.trim();
|
|
15016
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(mesh.vertexBufferBindings), _step; !(_step = _iterator()).done;){
|
|
15017
|
+
var binding = _step.value;
|
|
15018
|
+
var buffer = binding == null ? void 0 : binding.buffer;
|
|
15019
|
+
if (!buffer) {
|
|
15020
|
+
continue;
|
|
15021
|
+
}
|
|
15022
|
+
if (buffer === this._vertexBuffer) {
|
|
15023
|
+
buffer.setData(data.vertices);
|
|
15024
|
+
} else if (buffer === this._tangentBuffer) {
|
|
15025
|
+
buffer.setData(MeshTangentUtils.calculateTangentsFromBuffer(data.vertices, data.indices));
|
|
15026
|
+
}
|
|
15027
|
+
}
|
|
15028
|
+
var indexBuffer = (_mesh__primitive_indexBufferBinding = mesh._primitive.indexBufferBinding) == null ? void 0 : _mesh__primitive_indexBufferBinding._buffer;
|
|
15029
|
+
if (indexBuffer === this._indexBuffer) {
|
|
15030
|
+
indexBuffer.setData(data.indices);
|
|
14838
15031
|
}
|
|
14839
15032
|
};
|
|
14840
15033
|
return PrimitiveMeshRestorer;
|
|
14841
15034
|
}(ContentRestorer);
|
|
15035
|
+
|
|
14842
15036
|
/**
|
|
14843
15037
|
* @internal
|
|
14844
|
-
*/ var
|
|
14845
|
-
|
|
14846
|
-
|
|
14847
|
-
|
|
14848
|
-
|
|
14849
|
-
|
|
14850
|
-
|
|
14851
|
-
|
|
14852
|
-
|
|
14853
|
-
|
|
14854
|
-
|
|
14855
|
-
|
|
14856
|
-
|
|
14857
|
-
|
|
14858
|
-
|
|
14859
|
-
|
|
14860
|
-
|
|
14861
|
-
|
|
14862
|
-
|
|
14863
|
-
|
|
14864
|
-
|
|
14865
|
-
var
|
|
14866
|
-
|
|
14867
|
-
|
|
14868
|
-
|
|
14869
|
-
|
|
14870
|
-
|
|
14871
|
-
|
|
14872
|
-
|
|
14873
|
-
|
|
14874
|
-
|
|
14875
|
-
|
|
14876
|
-
var
|
|
14877
|
-
|
|
14878
|
-
|
|
14879
|
-
|
|
14880
|
-
|
|
14881
|
-
}
|
|
14882
|
-
|
|
14883
|
-
|
|
14884
|
-
|
|
14885
|
-
|
|
14886
|
-
|
|
14887
|
-
|
|
14888
|
-
|
|
14889
|
-
|
|
14890
|
-
|
|
14891
|
-
|
|
14892
|
-
|
|
14893
|
-
|
|
14894
|
-
|
|
14895
|
-
|
|
14896
|
-
|
|
14897
|
-
|
|
14898
|
-
|
|
14899
|
-
|
|
14900
|
-
|
|
14901
|
-
|
|
14902
|
-
|
|
14903
|
-
}
|
|
14904
|
-
|
|
14905
|
-
|
|
14906
|
-
|
|
14907
|
-
|
|
14908
|
-
|
|
14909
|
-
|
|
14910
|
-
|
|
14911
|
-
|
|
14912
|
-
|
|
14913
|
-
|
|
14914
|
-
|
|
15038
|
+
*/ var MeshPathUtils = /*#__PURE__*/ function() {
|
|
15039
|
+
function MeshPathUtils() {}
|
|
15040
|
+
MeshPathUtils.sample = function sample(path, divisions, closed, tangents) {
|
|
15041
|
+
var result = new Array(divisions + 1);
|
|
15042
|
+
if (path.length < 2) {
|
|
15043
|
+
throw new Error("A mesh path needs at least two points.");
|
|
15044
|
+
}
|
|
15045
|
+
var points = [];
|
|
15046
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(path), _step; !(_step = _iterator()).done;){
|
|
15047
|
+
var point = _step.value;
|
|
15048
|
+
if (points.length === 0 || Vector3.distance(points[points.length - 1], point) > 0) {
|
|
15049
|
+
points.push(point);
|
|
15050
|
+
}
|
|
15051
|
+
}
|
|
15052
|
+
if (closed && Vector3.distance(points[0], points[points.length - 1]) > 0) {
|
|
15053
|
+
points.push(points[0]);
|
|
15054
|
+
}
|
|
15055
|
+
var lengths = new Float64Array(points.length);
|
|
15056
|
+
for(var i = 1; i < points.length; i++){
|
|
15057
|
+
lengths[i] = lengths[i - 1] + Vector3.distance(points[i], points[i - 1]);
|
|
15058
|
+
}
|
|
15059
|
+
var length = lengths[lengths.length - 1];
|
|
15060
|
+
if (length === 0) {
|
|
15061
|
+
throw new Error("A mesh path must have nonzero length.");
|
|
15062
|
+
}
|
|
15063
|
+
if (tangents) {
|
|
15064
|
+
tangents.length = divisions + 1;
|
|
15065
|
+
}
|
|
15066
|
+
var adjacent = new Vector3();
|
|
15067
|
+
var direction = new Vector3();
|
|
15068
|
+
var tangent;
|
|
15069
|
+
var tangentEdge = 0;
|
|
15070
|
+
var edge = 1;
|
|
15071
|
+
for(var i1 = 0; i1 <= divisions; i1++){
|
|
15072
|
+
var distance = i1 / divisions * length;
|
|
15073
|
+
while(edge < lengths.length - 1 && lengths[edge] < distance){
|
|
15074
|
+
edge++;
|
|
15075
|
+
}
|
|
15076
|
+
var edgeLength = lengths[edge] - lengths[edge - 1];
|
|
15077
|
+
var t = edgeLength > 0 ? (distance - lengths[edge - 1]) / edgeLength : 0;
|
|
15078
|
+
var point1 = new Vector3();
|
|
15079
|
+
Vector3.lerp(points[edge - 1], points[edge], t, point1);
|
|
15080
|
+
result[i1] = point1;
|
|
15081
|
+
if (tangents) {
|
|
15082
|
+
if (tangentEdge !== edge) {
|
|
15083
|
+
Vector3.subtract(points[edge], points[edge - 1], direction);
|
|
15084
|
+
MeshPathUtils._normalize(direction);
|
|
15085
|
+
tangent = MeshPathUtils._normalize(direction.clone());
|
|
15086
|
+
tangentEdge = edge;
|
|
15087
|
+
}
|
|
15088
|
+
if (t === 0 && (edge > 1 || closed)) {
|
|
15089
|
+
var previous = points[edge > 1 ? edge - 2 : points.length - 2];
|
|
15090
|
+
Vector3.subtract(points[edge - 1], previous, adjacent);
|
|
15091
|
+
} else if (t === 1 && (edge + 1 < points.length || closed)) {
|
|
15092
|
+
var next = points[edge + 1 < points.length ? edge + 1 : 1];
|
|
15093
|
+
Vector3.subtract(next, points[edge], adjacent);
|
|
15094
|
+
} else {
|
|
15095
|
+
tangents[i1] = tangent;
|
|
15096
|
+
continue;
|
|
15097
|
+
}
|
|
15098
|
+
MeshPathUtils._normalize(adjacent).add(direction);
|
|
15099
|
+
tangents[i1] = Vector3.dot(adjacent, adjacent) > 0 ? MeshPathUtils._normalize(adjacent.clone()) : tangent;
|
|
15100
|
+
}
|
|
15101
|
+
}
|
|
15102
|
+
return result;
|
|
15103
|
+
};
|
|
15104
|
+
MeshPathUtils.computeFrames = function computeFrames(points, closed, fallbackTangents) {
|
|
15105
|
+
var last = points.length - 1;
|
|
15106
|
+
var tangents = new Array(points.length);
|
|
15107
|
+
for(var i = 0; i <= last; i++){
|
|
15108
|
+
var before = points[i === 0 ? closed ? last - 1 : 0 : i - 1];
|
|
15109
|
+
var after = points[i === last ? closed ? 1 : last : i + 1];
|
|
15110
|
+
var tangent = new Vector3();
|
|
15111
|
+
Vector3.subtract(after, before, tangent);
|
|
15112
|
+
if (Vector3.dot(tangent, tangent) === 0 && fallbackTangents) {
|
|
15113
|
+
tangent.copyFrom(fallbackTangents[i]);
|
|
15114
|
+
}
|
|
15115
|
+
tangents[i] = MeshPathUtils._normalize(tangent);
|
|
15116
|
+
}
|
|
15117
|
+
var tangent1 = tangents[0];
|
|
15118
|
+
var axis = Math.abs(tangent1.x) <= Math.abs(tangent1.y) && Math.abs(tangent1.x) <= Math.abs(tangent1.z) ? new Vector3(1, 0, 0) : Math.abs(tangent1.y) <= Math.abs(tangent1.z) ? new Vector3(0, 1, 0) : new Vector3(0, 0, 1);
|
|
15119
|
+
var normal = new Vector3();
|
|
15120
|
+
var binormal = new Vector3();
|
|
15121
|
+
Vector3.cross(tangent1, axis, normal);
|
|
15122
|
+
MeshPathUtils._normalize(normal);
|
|
15123
|
+
Vector3.cross(tangent1, normal, binormal);
|
|
15124
|
+
MeshPathUtils._normalize(binormal);
|
|
15125
|
+
var normals = [
|
|
15126
|
+
normal
|
|
15127
|
+
];
|
|
15128
|
+
var binormals = [
|
|
15129
|
+
binormal
|
|
15130
|
+
];
|
|
15131
|
+
var rotationAxis = new Vector3();
|
|
15132
|
+
for(var i1 = 1; i1 <= last; i1++){
|
|
15133
|
+
Vector3.cross(tangents[i1 - 1], tangents[i1], rotationAxis);
|
|
15134
|
+
var sine = Math.hypot(rotationAxis.x, rotationAxis.y, rotationAxis.z);
|
|
15135
|
+
var normal1 = normals[i1 - 1];
|
|
15136
|
+
if (sine > 1e-10) {
|
|
15137
|
+
normal1 = MeshPathUtils._rotate(normal1, MeshPathUtils._normalize(rotationAxis), Math.atan2(sine, Vector3.dot(tangents[i1 - 1], tangents[i1])), new Vector3());
|
|
15138
|
+
}
|
|
15139
|
+
normals.push(normal1);
|
|
15140
|
+
var binormal1 = new Vector3();
|
|
15141
|
+
Vector3.cross(tangents[i1], normal1, binormal1);
|
|
15142
|
+
binormals.push(MeshPathUtils._normalize(binormal1));
|
|
15143
|
+
}
|
|
15144
|
+
if (closed) {
|
|
15145
|
+
Vector3.cross(normals[last], normals[0], rotationAxis);
|
|
15146
|
+
var angle = Math.atan2(Vector3.dot(tangents[0], rotationAxis), Vector3.dot(normals[last], normals[0]));
|
|
15147
|
+
for(var i2 = 1; i2 <= last; i2++){
|
|
15148
|
+
normals[i2] = MeshPathUtils._rotate(normals[i2], tangents[i2], angle * i2 / last, new Vector3());
|
|
15149
|
+
Vector3.cross(tangents[i2], normals[i2], binormals[i2]);
|
|
15150
|
+
MeshPathUtils._normalize(binormals[i2]);
|
|
15151
|
+
}
|
|
15152
|
+
}
|
|
15153
|
+
return {
|
|
15154
|
+
normals: normals,
|
|
15155
|
+
binormals: binormals
|
|
15156
|
+
};
|
|
15157
|
+
};
|
|
15158
|
+
MeshPathUtils._normalize = function _normalize(vector) {
|
|
15159
|
+
var length = Math.hypot(vector.x, vector.y, vector.z);
|
|
15160
|
+
return vector.scale(length > 0 ? 1 / length : 0);
|
|
15161
|
+
};
|
|
15162
|
+
MeshPathUtils._rotate = function _rotate(point, axis, angle, out) {
|
|
15163
|
+
var c = Math.cos(angle);
|
|
15164
|
+
var s = Math.sin(angle);
|
|
15165
|
+
var px = axis.y * point.z - axis.z * point.y;
|
|
15166
|
+
var py = axis.z * point.x - axis.x * point.z;
|
|
15167
|
+
var pz = axis.x * point.y - axis.y * point.x;
|
|
15168
|
+
var parallel = Vector3.dot(axis, point) * (1 - c);
|
|
15169
|
+
return out.set(point.x * c + px * s + axis.x * parallel, point.y * c + py * s + axis.y * parallel, point.z * c + pz * s + axis.z * parallel);
|
|
15170
|
+
};
|
|
15171
|
+
return MeshPathUtils;
|
|
15172
|
+
}();
|
|
15173
|
+
|
|
14915
15174
|
/**
|
|
14916
15175
|
* @internal
|
|
14917
|
-
*/ var
|
|
14918
|
-
|
|
14919
|
-
function
|
|
14920
|
-
var
|
|
14921
|
-
|
|
14922
|
-
|
|
14923
|
-
|
|
14924
|
-
|
|
14925
|
-
|
|
15176
|
+
*/ var PolygonUtils = /*#__PURE__*/ function() {
|
|
15177
|
+
function PolygonUtils() {}
|
|
15178
|
+
PolygonUtils.prepareContours = function prepareContours(shape) {
|
|
15179
|
+
var _shape_holes;
|
|
15180
|
+
return [].concat([
|
|
15181
|
+
shape.points
|
|
15182
|
+
], (_shape_holes = shape.holes) != null ? _shape_holes : []).map(function(points, index) {
|
|
15183
|
+
var contour = [];
|
|
15184
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(points), _step; !(_step = _iterator()).done;){
|
|
15185
|
+
var point = _step.value;
|
|
15186
|
+
var previous = contour[contour.length - 1];
|
|
15187
|
+
if (!previous || previous.x !== point.x || previous.y !== point.y) {
|
|
15188
|
+
contour.push(point);
|
|
15189
|
+
}
|
|
15190
|
+
}
|
|
15191
|
+
var first = contour[0];
|
|
15192
|
+
var last = contour[contour.length - 1];
|
|
15193
|
+
if (contour.length > 1 && first.x === last.x && first.y === last.y) {
|
|
15194
|
+
contour.pop();
|
|
15195
|
+
}
|
|
15196
|
+
if (contour.length < 3) {
|
|
15197
|
+
throw new Error("A mesh contour needs at least three distinct points.");
|
|
15198
|
+
}
|
|
15199
|
+
var area = 0;
|
|
15200
|
+
for(var i = 0; i < contour.length; i++){
|
|
15201
|
+
var next = contour[(i + 1) % contour.length];
|
|
15202
|
+
area += contour[i].x * next.y - next.x * contour[i].y;
|
|
15203
|
+
}
|
|
15204
|
+
if (area > 0 !== (index === 0)) {
|
|
15205
|
+
contour.reverse();
|
|
15206
|
+
}
|
|
15207
|
+
return contour;
|
|
15208
|
+
});
|
|
15209
|
+
};
|
|
15210
|
+
PolygonUtils.triangulateContours = function triangulateContours(contours) {
|
|
15211
|
+
var points = [];
|
|
15212
|
+
var holes = [];
|
|
15213
|
+
for(var i = 0; i < contours.length; i++){
|
|
15214
|
+
if (i > 0) {
|
|
15215
|
+
holes.push(points.length);
|
|
15216
|
+
}
|
|
15217
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(contours[i]), _step; !(_step = _iterator()).done;){
|
|
15218
|
+
var point = _step.value;
|
|
15219
|
+
points.push(point);
|
|
15220
|
+
}
|
|
15221
|
+
}
|
|
15222
|
+
var coordinates = new Float64Array(points.length * 2);
|
|
15223
|
+
for(var i1 = 0; i1 < points.length; i1++){
|
|
15224
|
+
coordinates[2 * i1] = points[i1].x;
|
|
15225
|
+
coordinates[2 * i1 + 1] = points[i1].y;
|
|
15226
|
+
}
|
|
15227
|
+
var indices = PolygonUtils.triangulate(coordinates, holes);
|
|
15228
|
+
for(var i2 = 0; i2 < indices.length; i2 += 3){
|
|
15229
|
+
var a = points[indices[i2]];
|
|
15230
|
+
var b = points[indices[i2 + 1]];
|
|
15231
|
+
var c = points[indices[i2 + 2]];
|
|
15232
|
+
if ((b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x) < 0) {
|
|
15233
|
+
var ref;
|
|
15234
|
+
ref = [
|
|
15235
|
+
indices[i2 + 2],
|
|
15236
|
+
indices[i2 + 1]
|
|
15237
|
+
], indices[i2 + 1] = ref[0], indices[i2 + 2] = ref[1];
|
|
15238
|
+
}
|
|
15239
|
+
}
|
|
15240
|
+
return {
|
|
15241
|
+
points: points,
|
|
15242
|
+
indices: indices
|
|
15243
|
+
};
|
|
15244
|
+
};
|
|
15245
|
+
PolygonUtils.triangulate = function triangulate(data, holeIndices) {
|
|
15246
|
+
if (holeIndices === void 0) holeIndices = [];
|
|
15247
|
+
var hasHoles = holeIndices.length > 0;
|
|
15248
|
+
var outerLen = hasHoles ? holeIndices[0] * 2 : data.length;
|
|
15249
|
+
var outerNode = PolygonUtils._linkedList(data, 0, outerLen, true);
|
|
15250
|
+
var triangles = [];
|
|
15251
|
+
if (!outerNode || outerNode.next === outerNode.prev) {
|
|
15252
|
+
return triangles;
|
|
15253
|
+
}
|
|
15254
|
+
var minX = 0, minY = 0, invSize = 0;
|
|
15255
|
+
if (hasHoles) {
|
|
15256
|
+
outerNode = PolygonUtils._eliminateHoles(data, holeIndices, outerNode);
|
|
15257
|
+
}
|
|
15258
|
+
// Spatial indexing avoids testing every vertex against each ear in large polygons
|
|
15259
|
+
if (data.length > 160) {
|
|
15260
|
+
minX = data[0];
|
|
15261
|
+
minY = data[1];
|
|
15262
|
+
var maxX = minX;
|
|
15263
|
+
var maxY = minY;
|
|
15264
|
+
for(var i = 2; i < outerLen; i += 2){
|
|
15265
|
+
var x = data[i];
|
|
15266
|
+
var y = data[i + 1];
|
|
15267
|
+
if (x < minX) {
|
|
15268
|
+
minX = x;
|
|
15269
|
+
}
|
|
15270
|
+
if (y < minY) {
|
|
15271
|
+
minY = y;
|
|
15272
|
+
}
|
|
15273
|
+
if (x > maxX) {
|
|
15274
|
+
maxX = x;
|
|
15275
|
+
}
|
|
15276
|
+
if (y > maxY) {
|
|
15277
|
+
maxY = y;
|
|
15278
|
+
}
|
|
15279
|
+
}
|
|
15280
|
+
// Morton codes use 15 bits per coordinate
|
|
15281
|
+
invSize = Math.max(maxX - minX, maxY - minY);
|
|
15282
|
+
invSize = invSize !== 0 ? 32767 / invSize : 0;
|
|
15283
|
+
}
|
|
15284
|
+
PolygonUtils._earcutLinked(outerNode, triangles, minX, minY, invSize, 0);
|
|
15285
|
+
return triangles;
|
|
15286
|
+
};
|
|
15287
|
+
PolygonUtils._linkedList = function _linkedList(data, start, end, clockwise) {
|
|
15288
|
+
var last = null;
|
|
15289
|
+
if (clockwise === PolygonUtils._signedArea(data, start, end) > 0) {
|
|
15290
|
+
for(var i = start; i < end; i += 2){
|
|
15291
|
+
last = PolygonUtils._insertNode(i / 2 | 0, data[i], data[i + 1], last);
|
|
15292
|
+
}
|
|
15293
|
+
} else {
|
|
15294
|
+
for(var i1 = end - 2; i1 >= start; i1 -= 2){
|
|
15295
|
+
last = PolygonUtils._insertNode(i1 / 2 | 0, data[i1], data[i1 + 1], last);
|
|
15296
|
+
}
|
|
15297
|
+
}
|
|
15298
|
+
if (last && PolygonUtils._equals(last, last.next)) {
|
|
15299
|
+
PolygonUtils._removeNode(last);
|
|
15300
|
+
last = last.next;
|
|
15301
|
+
}
|
|
15302
|
+
return last;
|
|
15303
|
+
};
|
|
15304
|
+
PolygonUtils._filterPoints = function _filterPoints(start, end) {
|
|
15305
|
+
if (end === void 0) end = start;
|
|
15306
|
+
var p = start;
|
|
15307
|
+
var again;
|
|
15308
|
+
do {
|
|
15309
|
+
again = false;
|
|
15310
|
+
if (!p.steiner && (PolygonUtils._equals(p, p.next) || PolygonUtils._area(p.prev, p, p.next) === 0)) {
|
|
15311
|
+
PolygonUtils._removeNode(p);
|
|
15312
|
+
p = end = p.prev;
|
|
15313
|
+
if (p === p.next) {
|
|
15314
|
+
break;
|
|
15315
|
+
}
|
|
15316
|
+
again = true;
|
|
15317
|
+
} else {
|
|
15318
|
+
p = p.next;
|
|
15319
|
+
}
|
|
15320
|
+
}while (again || p !== end);
|
|
15321
|
+
return end;
|
|
15322
|
+
};
|
|
15323
|
+
PolygonUtils._earcutLinked = function _earcutLinked(ear, triangles, minX, minY, invSize, pass) {
|
|
15324
|
+
if (!pass && invSize) {
|
|
15325
|
+
PolygonUtils._indexCurve(ear, minX, minY, invSize);
|
|
15326
|
+
}
|
|
15327
|
+
var stop = ear;
|
|
15328
|
+
while(ear.prev !== ear.next){
|
|
15329
|
+
var prev = ear.prev;
|
|
15330
|
+
var next = ear.next;
|
|
15331
|
+
if (invSize ? PolygonUtils._isEarHashed(ear, minX, minY, invSize) : PolygonUtils._isEar(ear)) {
|
|
15332
|
+
triangles.push(prev.i, ear.i, next.i);
|
|
15333
|
+
PolygonUtils._removeNode(ear);
|
|
15334
|
+
// Skipping the adjacent vertex reduces narrow triangles
|
|
15335
|
+
ear = next.next;
|
|
15336
|
+
stop = next.next;
|
|
15337
|
+
continue;
|
|
15338
|
+
}
|
|
15339
|
+
ear = next;
|
|
15340
|
+
if (ear === stop) {
|
|
15341
|
+
// Retry after removing degeneracies, then heal intersections or split the ring
|
|
15342
|
+
if (!pass) {
|
|
15343
|
+
PolygonUtils._earcutLinked(PolygonUtils._filterPoints(ear), triangles, minX, minY, invSize, 1);
|
|
15344
|
+
} else if (pass === 1) {
|
|
15345
|
+
ear = PolygonUtils._cureLocalIntersections(PolygonUtils._filterPoints(ear), triangles);
|
|
15346
|
+
PolygonUtils._earcutLinked(ear, triangles, minX, minY, invSize, 2);
|
|
15347
|
+
} else if (pass === 2) {
|
|
15348
|
+
PolygonUtils._splitEarcut(ear, triangles, minX, minY, invSize);
|
|
15349
|
+
}
|
|
15350
|
+
break;
|
|
15351
|
+
}
|
|
15352
|
+
}
|
|
15353
|
+
};
|
|
15354
|
+
PolygonUtils._isEar = function _isEar(ear) {
|
|
15355
|
+
var a = ear.prev, b = ear, c = ear.next;
|
|
15356
|
+
if (PolygonUtils._area(a, b, c) >= 0) {
|
|
15357
|
+
return false;
|
|
15358
|
+
}
|
|
15359
|
+
var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
|
|
15360
|
+
var x0 = Math.min(ax, bx, cx), y0 = Math.min(ay, by, cy), x1 = Math.max(ax, bx, cx), y1 = Math.max(ay, by, cy);
|
|
15361
|
+
var p = c.next;
|
|
15362
|
+
while(p !== a){
|
|
15363
|
+
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && PolygonUtils._pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, p.x, p.y) && PolygonUtils._area(p.prev, p, p.next) >= 0) {
|
|
15364
|
+
return false;
|
|
15365
|
+
}
|
|
15366
|
+
p = p.next;
|
|
15367
|
+
}
|
|
15368
|
+
return true;
|
|
15369
|
+
};
|
|
15370
|
+
PolygonUtils._isEarHashed = function _isEarHashed(ear, minX, minY, invSize) {
|
|
15371
|
+
var a = ear.prev, b = ear, c = ear.next;
|
|
15372
|
+
if (PolygonUtils._area(a, b, c) >= 0) {
|
|
15373
|
+
return false;
|
|
15374
|
+
}
|
|
15375
|
+
var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
|
|
15376
|
+
var x0 = Math.min(ax, bx, cx), y0 = Math.min(ay, by, cy), x1 = Math.max(ax, bx, cx), y1 = Math.max(ay, by, cy);
|
|
15377
|
+
var minZ = PolygonUtils._zOrder(x0, y0, minX, minY, invSize), maxZ = PolygonUtils._zOrder(x1, y1, minX, minY, invSize);
|
|
15378
|
+
var p = ear.prevZ, n = ear.nextZ;
|
|
15379
|
+
while(p && p.z >= minZ && n && n.z <= maxZ){
|
|
15380
|
+
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && PolygonUtils._pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, p.x, p.y) && PolygonUtils._area(p.prev, p, p.next) >= 0) {
|
|
15381
|
+
return false;
|
|
15382
|
+
}
|
|
15383
|
+
p = p.prevZ;
|
|
15384
|
+
if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && PolygonUtils._pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, n.x, n.y) && PolygonUtils._area(n.prev, n, n.next) >= 0) {
|
|
15385
|
+
return false;
|
|
15386
|
+
}
|
|
15387
|
+
n = n.nextZ;
|
|
15388
|
+
}
|
|
15389
|
+
while(p && p.z >= minZ){
|
|
15390
|
+
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && PolygonUtils._pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, p.x, p.y) && PolygonUtils._area(p.prev, p, p.next) >= 0) {
|
|
15391
|
+
return false;
|
|
15392
|
+
}
|
|
15393
|
+
p = p.prevZ;
|
|
15394
|
+
}
|
|
15395
|
+
while(n && n.z <= maxZ){
|
|
15396
|
+
if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && PolygonUtils._pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, n.x, n.y) && PolygonUtils._area(n.prev, n, n.next) >= 0) {
|
|
15397
|
+
return false;
|
|
15398
|
+
}
|
|
15399
|
+
n = n.nextZ;
|
|
15400
|
+
}
|
|
15401
|
+
return true;
|
|
15402
|
+
};
|
|
15403
|
+
PolygonUtils._cureLocalIntersections = function _cureLocalIntersections(start, triangles) {
|
|
15404
|
+
var p = start;
|
|
15405
|
+
do {
|
|
15406
|
+
var a = p.prev, b = p.next.next;
|
|
15407
|
+
if (!PolygonUtils._equals(a, b) && PolygonUtils._intersects(a, p, p.next, b) && PolygonUtils._locallyInside(a, b) && PolygonUtils._locallyInside(b, a)) {
|
|
15408
|
+
triangles.push(a.i, p.i, b.i);
|
|
15409
|
+
PolygonUtils._removeNode(p);
|
|
15410
|
+
PolygonUtils._removeNode(p.next);
|
|
15411
|
+
p = start = b;
|
|
15412
|
+
}
|
|
15413
|
+
p = p.next;
|
|
15414
|
+
}while (p !== start);
|
|
15415
|
+
return PolygonUtils._filterPoints(p);
|
|
15416
|
+
};
|
|
15417
|
+
PolygonUtils._splitEarcut = function _splitEarcut(start, triangles, minX, minY, invSize) {
|
|
15418
|
+
var a = start;
|
|
15419
|
+
do {
|
|
15420
|
+
var b = a.next.next;
|
|
15421
|
+
while(b !== a.prev){
|
|
15422
|
+
if (a.i !== b.i && PolygonUtils._isValidDiagonal(a, b)) {
|
|
15423
|
+
var c = PolygonUtils._splitPolygon(a, b);
|
|
15424
|
+
a = PolygonUtils._filterPoints(a, a.next);
|
|
15425
|
+
c = PolygonUtils._filterPoints(c, c.next);
|
|
15426
|
+
PolygonUtils._earcutLinked(a, triangles, minX, minY, invSize, 0);
|
|
15427
|
+
PolygonUtils._earcutLinked(c, triangles, minX, minY, invSize, 0);
|
|
15428
|
+
return;
|
|
15429
|
+
}
|
|
15430
|
+
b = b.next;
|
|
15431
|
+
}
|
|
15432
|
+
a = a.next;
|
|
15433
|
+
}while (a !== start);
|
|
15434
|
+
};
|
|
15435
|
+
PolygonUtils._eliminateHoles = function _eliminateHoles(data, holeIndices, outerNode) {
|
|
15436
|
+
var queue = [];
|
|
15437
|
+
for(var i = 0, len = holeIndices.length; i < len; i++){
|
|
15438
|
+
var start = holeIndices[i] * 2;
|
|
15439
|
+
var end = i < len - 1 ? holeIndices[i + 1] * 2 : data.length;
|
|
15440
|
+
var list = PolygonUtils._linkedList(data, start, end, false);
|
|
15441
|
+
if (list === list.next) {
|
|
15442
|
+
list.steiner = true;
|
|
15443
|
+
}
|
|
15444
|
+
queue.push(PolygonUtils._getLeftmost(list));
|
|
15445
|
+
}
|
|
15446
|
+
queue.sort(PolygonUtils._compareXYSlope);
|
|
15447
|
+
for(var i1 = 0; i1 < queue.length; i1++){
|
|
15448
|
+
outerNode = PolygonUtils._eliminateHole(queue[i1], outerNode);
|
|
15449
|
+
}
|
|
15450
|
+
return outerNode;
|
|
15451
|
+
};
|
|
15452
|
+
PolygonUtils._compareXYSlope = function _compareXYSlope(a, b) {
|
|
15453
|
+
var result = a.x - b.x;
|
|
15454
|
+
// Touching holes must be bridged in counterclockwise order at their shared vertex
|
|
15455
|
+
if (result === 0) {
|
|
15456
|
+
result = a.y - b.y;
|
|
15457
|
+
if (result === 0) {
|
|
15458
|
+
var aSlope = (a.next.y - a.y) / (a.next.x - a.x);
|
|
15459
|
+
var bSlope = (b.next.y - b.y) / (b.next.x - b.x);
|
|
15460
|
+
result = aSlope - bSlope;
|
|
15461
|
+
}
|
|
15462
|
+
}
|
|
15463
|
+
return result;
|
|
15464
|
+
};
|
|
15465
|
+
PolygonUtils._eliminateHole = function _eliminateHole(hole, outerNode) {
|
|
15466
|
+
var bridge = PolygonUtils._findHoleBridge(hole, outerNode);
|
|
15467
|
+
if (!bridge) {
|
|
15468
|
+
return outerNode;
|
|
15469
|
+
}
|
|
15470
|
+
var bridgeReverse = PolygonUtils._splitPolygon(bridge, hole);
|
|
15471
|
+
// Joining rings can introduce collinear vertices on either side of the bridge
|
|
15472
|
+
PolygonUtils._filterPoints(bridgeReverse, bridgeReverse.next);
|
|
15473
|
+
return PolygonUtils._filterPoints(bridge, bridge.next);
|
|
15474
|
+
};
|
|
15475
|
+
PolygonUtils._findHoleBridge = function _findHoleBridge(hole, outerNode) {
|
|
15476
|
+
var p = outerNode;
|
|
15477
|
+
var hx = hole.x;
|
|
15478
|
+
var hy = hole.y;
|
|
15479
|
+
var qx = -Infinity;
|
|
15480
|
+
var m = null;
|
|
15481
|
+
// Cast left from the hole and choose a visible endpoint on the nearest intersected edge
|
|
15482
|
+
if (PolygonUtils._equals(hole, p)) {
|
|
15483
|
+
return p;
|
|
15484
|
+
}
|
|
15485
|
+
do {
|
|
15486
|
+
if (PolygonUtils._equals(hole, p.next)) {
|
|
15487
|
+
return p.next;
|
|
15488
|
+
} else if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
|
|
15489
|
+
var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
|
|
15490
|
+
if (x <= hx && x > qx) {
|
|
15491
|
+
qx = x;
|
|
15492
|
+
m = p.x < p.next.x ? p : p.next;
|
|
15493
|
+
if (x === hx) {
|
|
15494
|
+
return m;
|
|
15495
|
+
}
|
|
15496
|
+
}
|
|
15497
|
+
}
|
|
15498
|
+
p = p.next;
|
|
15499
|
+
}while (p !== outerNode);
|
|
15500
|
+
if (!m) {
|
|
15501
|
+
return null;
|
|
15502
|
+
}
|
|
15503
|
+
// A vertex inside the candidate triangle may provide a closer visible bridge
|
|
15504
|
+
var stop = m;
|
|
15505
|
+
var mx = m.x;
|
|
15506
|
+
var my = m.y;
|
|
15507
|
+
var tanMin = Infinity;
|
|
15508
|
+
p = m;
|
|
15509
|
+
do {
|
|
15510
|
+
if (hx >= p.x && p.x >= mx && hx !== p.x && PolygonUtils._pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
|
|
15511
|
+
var tan = Math.abs(hy - p.y) / (hx - p.x);
|
|
15512
|
+
if (PolygonUtils._locallyInside(p, hole) && (tan < tanMin || tan === tanMin && (p.x > m.x || p.x === m.x && PolygonUtils._sectorContainsSector(m, p)))) {
|
|
15513
|
+
m = p;
|
|
15514
|
+
tanMin = tan;
|
|
15515
|
+
}
|
|
15516
|
+
}
|
|
15517
|
+
p = p.next;
|
|
15518
|
+
}while (p !== stop);
|
|
15519
|
+
return m;
|
|
15520
|
+
};
|
|
15521
|
+
PolygonUtils._sectorContainsSector = function _sectorContainsSector(m, p) {
|
|
15522
|
+
return PolygonUtils._area(m.prev, m, p.prev) < 0 && PolygonUtils._area(p.next, m, m.next) < 0;
|
|
15523
|
+
};
|
|
15524
|
+
PolygonUtils._indexCurve = function _indexCurve(start, minX, minY, invSize) {
|
|
15525
|
+
var p = start;
|
|
15526
|
+
do {
|
|
15527
|
+
if (p.z === 0) {
|
|
15528
|
+
p.z = PolygonUtils._zOrder(p.x, p.y, minX, minY, invSize);
|
|
15529
|
+
}
|
|
15530
|
+
p.prevZ = p.prev;
|
|
15531
|
+
p.nextZ = p.next;
|
|
15532
|
+
p = p.next;
|
|
15533
|
+
}while (p !== start);
|
|
15534
|
+
p.prevZ.nextZ = null;
|
|
15535
|
+
p.prevZ = null;
|
|
15536
|
+
PolygonUtils._sortLinked(p);
|
|
15537
|
+
};
|
|
15538
|
+
PolygonUtils._sortLinked = function _sortLinked(list) {
|
|
15539
|
+
// Bottom-up merge sort keeps the Morton-code list linked without allocating an array
|
|
15540
|
+
var numMerges;
|
|
15541
|
+
var inSize = 1;
|
|
15542
|
+
do {
|
|
15543
|
+
var p = list;
|
|
15544
|
+
var e = void 0;
|
|
15545
|
+
list = null;
|
|
15546
|
+
var tail = null;
|
|
15547
|
+
numMerges = 0;
|
|
15548
|
+
while(p){
|
|
15549
|
+
numMerges++;
|
|
15550
|
+
var q = p;
|
|
15551
|
+
var pSize = 0;
|
|
15552
|
+
for(var i = 0; i < inSize; i++){
|
|
15553
|
+
pSize++;
|
|
15554
|
+
q = q.nextZ;
|
|
15555
|
+
if (!q) {
|
|
15556
|
+
break;
|
|
15557
|
+
}
|
|
15558
|
+
}
|
|
15559
|
+
var qSize = inSize;
|
|
15560
|
+
while(pSize > 0 || qSize > 0 && q){
|
|
15561
|
+
if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
|
|
15562
|
+
e = p;
|
|
15563
|
+
p = p.nextZ;
|
|
15564
|
+
pSize--;
|
|
15565
|
+
} else {
|
|
15566
|
+
e = q;
|
|
15567
|
+
q = q.nextZ;
|
|
15568
|
+
qSize--;
|
|
15569
|
+
}
|
|
15570
|
+
if (tail) {
|
|
15571
|
+
tail.nextZ = e;
|
|
15572
|
+
} else {
|
|
15573
|
+
list = e;
|
|
15574
|
+
}
|
|
15575
|
+
e.prevZ = tail;
|
|
15576
|
+
tail = e;
|
|
15577
|
+
}
|
|
15578
|
+
p = q;
|
|
15579
|
+
}
|
|
15580
|
+
tail.nextZ = null;
|
|
15581
|
+
inSize *= 2;
|
|
15582
|
+
}while (numMerges > 1);
|
|
15583
|
+
return list;
|
|
15584
|
+
};
|
|
15585
|
+
PolygonUtils._zOrder = function _zOrder(x, y, minX, minY, invSize) {
|
|
15586
|
+
x = (x - minX) * invSize | 0;
|
|
15587
|
+
y = (y - minY) * invSize | 0;
|
|
15588
|
+
x = (x | x << 8) & 0x00ff00ff;
|
|
15589
|
+
x = (x | x << 4) & 0x0f0f0f0f;
|
|
15590
|
+
x = (x | x << 2) & 0x33333333;
|
|
15591
|
+
x = (x | x << 1) & 0x55555555;
|
|
15592
|
+
y = (y | y << 8) & 0x00ff00ff;
|
|
15593
|
+
y = (y | y << 4) & 0x0f0f0f0f;
|
|
15594
|
+
y = (y | y << 2) & 0x33333333;
|
|
15595
|
+
y = (y | y << 1) & 0x55555555;
|
|
15596
|
+
return x | y << 1;
|
|
15597
|
+
};
|
|
15598
|
+
PolygonUtils._getLeftmost = function _getLeftmost(start) {
|
|
15599
|
+
var p = start, leftmost = start;
|
|
15600
|
+
do {
|
|
15601
|
+
if (p.x < leftmost.x || p.x === leftmost.x && p.y < leftmost.y) {
|
|
15602
|
+
leftmost = p;
|
|
15603
|
+
}
|
|
15604
|
+
p = p.next;
|
|
15605
|
+
}while (p !== start);
|
|
15606
|
+
return leftmost;
|
|
15607
|
+
};
|
|
15608
|
+
PolygonUtils._pointInTriangle = function _pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
|
|
15609
|
+
return (cx - px) * (ay - py) >= (ax - px) * (cy - py) && (ax - px) * (by - py) >= (bx - px) * (ay - py) && (bx - px) * (cy - py) >= (cx - px) * (by - py);
|
|
15610
|
+
};
|
|
15611
|
+
PolygonUtils._pointInTriangleExceptFirst = function _pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, px, py) {
|
|
15612
|
+
return !(ax === px && ay === py) && PolygonUtils._pointInTriangle(ax, ay, bx, by, cx, cy, px, py);
|
|
15613
|
+
};
|
|
15614
|
+
PolygonUtils._isValidDiagonal = function _isValidDiagonal(a, b) {
|
|
15615
|
+
return !!(a.next.i !== b.i && a.prev.i !== b.i && !PolygonUtils._intersectsPolygon(a, b) && (PolygonUtils._locallyInside(a, b) && PolygonUtils._locallyInside(b, a) && PolygonUtils._middleInside(a, b) && (PolygonUtils._area(a.prev, a, b.prev) || PolygonUtils._area(a, b.prev, b)) || PolygonUtils._equals(a, b) && PolygonUtils._area(a.prev, a, a.next) > 0 && PolygonUtils._area(b.prev, b, b.next) > 0));
|
|
15616
|
+
};
|
|
15617
|
+
PolygonUtils._area = function _area(p, q, r) {
|
|
15618
|
+
return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
|
|
15619
|
+
};
|
|
15620
|
+
PolygonUtils._equals = function _equals(p1, p2) {
|
|
15621
|
+
return p1.x === p2.x && p1.y === p2.y;
|
|
15622
|
+
};
|
|
15623
|
+
PolygonUtils._intersects = function _intersects(p1, q1, p2, q2) {
|
|
15624
|
+
var o1 = PolygonUtils._sign(PolygonUtils._area(p1, q1, p2));
|
|
15625
|
+
var o2 = PolygonUtils._sign(PolygonUtils._area(p1, q1, q2));
|
|
15626
|
+
var o3 = PolygonUtils._sign(PolygonUtils._area(p2, q2, p1));
|
|
15627
|
+
var o4 = PolygonUtils._sign(PolygonUtils._area(p2, q2, q1));
|
|
15628
|
+
if (o1 !== o2 && o3 !== o4) {
|
|
15629
|
+
return true;
|
|
15630
|
+
}
|
|
15631
|
+
if (o1 === 0 && PolygonUtils._onSegment(p1, p2, q1)) {
|
|
15632
|
+
return true;
|
|
15633
|
+
}
|
|
15634
|
+
if (o2 === 0 && PolygonUtils._onSegment(p1, q2, q1)) {
|
|
15635
|
+
return true;
|
|
15636
|
+
}
|
|
15637
|
+
if (o3 === 0 && PolygonUtils._onSegment(p2, p1, q2)) {
|
|
15638
|
+
return true;
|
|
15639
|
+
}
|
|
15640
|
+
if (o4 === 0 && PolygonUtils._onSegment(p2, q1, q2)) {
|
|
15641
|
+
return true;
|
|
15642
|
+
}
|
|
15643
|
+
return false;
|
|
15644
|
+
};
|
|
15645
|
+
PolygonUtils._onSegment = function _onSegment(p, q, r) {
|
|
15646
|
+
return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);
|
|
15647
|
+
};
|
|
15648
|
+
PolygonUtils._sign = function _sign(num) {
|
|
15649
|
+
return num > 0 ? 1 : num < 0 ? -1 : 0;
|
|
15650
|
+
};
|
|
15651
|
+
PolygonUtils._intersectsPolygon = function _intersectsPolygon(a, b) {
|
|
15652
|
+
var p = a;
|
|
15653
|
+
do {
|
|
15654
|
+
if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && PolygonUtils._intersects(p, p.next, a, b)) {
|
|
15655
|
+
return true;
|
|
15656
|
+
}
|
|
15657
|
+
p = p.next;
|
|
15658
|
+
}while (p !== a);
|
|
15659
|
+
return false;
|
|
15660
|
+
};
|
|
15661
|
+
PolygonUtils._locallyInside = function _locallyInside(a, b) {
|
|
15662
|
+
return PolygonUtils._area(a.prev, a, a.next) < 0 ? PolygonUtils._area(a, b, a.next) >= 0 && PolygonUtils._area(a, a.prev, b) >= 0 : PolygonUtils._area(a, b, a.prev) < 0 || PolygonUtils._area(a, a.next, b) < 0;
|
|
15663
|
+
};
|
|
15664
|
+
PolygonUtils._middleInside = function _middleInside(a, b) {
|
|
15665
|
+
var p = a;
|
|
15666
|
+
var inside = false;
|
|
15667
|
+
var px = (a.x + b.x) / 2;
|
|
15668
|
+
var py = (a.y + b.y) / 2;
|
|
15669
|
+
do {
|
|
15670
|
+
if (p.y > py !== p.next.y > py && px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x) {
|
|
15671
|
+
inside = !inside;
|
|
15672
|
+
}
|
|
15673
|
+
p = p.next;
|
|
15674
|
+
}while (p !== a);
|
|
15675
|
+
return inside;
|
|
15676
|
+
};
|
|
15677
|
+
PolygonUtils._splitPolygon = function _splitPolygon(a, b) {
|
|
15678
|
+
var a2 = new TriangulationNode(a.i, a.x, a.y), b2 = new TriangulationNode(b.i, b.x, b.y), an = a.next, bp = b.prev;
|
|
15679
|
+
a.next = b;
|
|
15680
|
+
b.prev = a;
|
|
15681
|
+
a2.next = an;
|
|
15682
|
+
an.prev = a2;
|
|
15683
|
+
b2.next = a2;
|
|
15684
|
+
a2.prev = b2;
|
|
15685
|
+
bp.next = b2;
|
|
15686
|
+
b2.prev = bp;
|
|
15687
|
+
return b2;
|
|
15688
|
+
};
|
|
15689
|
+
PolygonUtils._insertNode = function _insertNode(i, x, y, last) {
|
|
15690
|
+
var p = new TriangulationNode(i, x, y);
|
|
15691
|
+
if (last) {
|
|
15692
|
+
p.next = last.next;
|
|
15693
|
+
p.prev = last;
|
|
15694
|
+
last.next.prev = p;
|
|
15695
|
+
last.next = p;
|
|
15696
|
+
}
|
|
15697
|
+
return p;
|
|
15698
|
+
};
|
|
15699
|
+
PolygonUtils._removeNode = function _removeNode(p) {
|
|
15700
|
+
p.next.prev = p.prev;
|
|
15701
|
+
p.prev.next = p.next;
|
|
15702
|
+
if (p.prevZ) {
|
|
15703
|
+
p.prevZ.nextZ = p.nextZ;
|
|
15704
|
+
}
|
|
15705
|
+
if (p.nextZ) {
|
|
15706
|
+
p.nextZ.prevZ = p.prevZ;
|
|
15707
|
+
}
|
|
15708
|
+
};
|
|
15709
|
+
PolygonUtils._signedArea = function _signedArea(data, start, end) {
|
|
15710
|
+
var sum = 0;
|
|
15711
|
+
for(var i = start, j = end - 2; i < end; i += 2){
|
|
15712
|
+
sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
|
|
15713
|
+
j = i;
|
|
15714
|
+
}
|
|
15715
|
+
return sum;
|
|
15716
|
+
};
|
|
15717
|
+
return PolygonUtils;
|
|
15718
|
+
}();
|
|
15719
|
+
var TriangulationNode = function TriangulationNode(i, x, y) {
|
|
15720
|
+
this.prev = this;
|
|
15721
|
+
this.next = this;
|
|
15722
|
+
this.z = 0;
|
|
15723
|
+
this.prevZ = null;
|
|
15724
|
+
this.nextZ = null;
|
|
15725
|
+
this.steiner = false;
|
|
15726
|
+
this.i = i;
|
|
15727
|
+
this.x = x;
|
|
15728
|
+
this.y = y;
|
|
15729
|
+
};
|
|
15730
|
+
|
|
14926
15731
|
/**
|
|
14927
15732
|
* @internal
|
|
14928
|
-
*/ var
|
|
14929
|
-
|
|
14930
|
-
function
|
|
14931
|
-
var
|
|
14932
|
-
|
|
14933
|
-
|
|
14934
|
-
|
|
14935
|
-
|
|
14936
|
-
|
|
15733
|
+
*/ var SubdivisionUtils = /*#__PURE__*/ function() {
|
|
15734
|
+
function SubdivisionUtils() {}
|
|
15735
|
+
SubdivisionUtils.subdivideQuads = function subdivideQuads(positions, quads, iterations) {
|
|
15736
|
+
var vertexCount = positions.length / 3;
|
|
15737
|
+
var faceCount = quads.length / 4;
|
|
15738
|
+
var growth = Math.pow(4, iterations);
|
|
15739
|
+
// Each pass adds one face point and two shared edge points per quad on a closed surface
|
|
15740
|
+
var resultPositions = new Float32Array((vertexCount + faceCount * (growth - 1)) * 3);
|
|
15741
|
+
var resultQuads = new Uint32Array(quads.length * growth);
|
|
15742
|
+
resultPositions.set(positions);
|
|
15743
|
+
resultQuads.set(quads);
|
|
15744
|
+
var maxFaceCount = iterations > 0 ? faceCount * growth / 4 : 0;
|
|
15745
|
+
var facePoints = new Float64Array(maxFaceCount * 3);
|
|
15746
|
+
var faceEdges = new Uint32Array(maxFaceCount * 4);
|
|
15747
|
+
var edgePoints = new Float64Array(maxFaceCount * 6);
|
|
15748
|
+
var edgeIndices = new Uint32Array(maxFaceCount * 2);
|
|
15749
|
+
var edges = new Map();
|
|
15750
|
+
var edgeOrder = [
|
|
15751
|
+
0,
|
|
15752
|
+
3,
|
|
15753
|
+
1,
|
|
15754
|
+
2
|
|
15755
|
+
];
|
|
15756
|
+
for(var iteration = 0; iteration < iterations; iteration++){
|
|
15757
|
+
edges.clear();
|
|
15758
|
+
var edgeCount = 0;
|
|
15759
|
+
for(var faceIndex = 0; faceIndex < faceCount; faceIndex++){
|
|
15760
|
+
var faceOffset = faceIndex * 4;
|
|
15761
|
+
var pointOffset = faceIndex * 3;
|
|
15762
|
+
var x = 0;
|
|
15763
|
+
var y = 0;
|
|
15764
|
+
var z = 0;
|
|
15765
|
+
for(var corner = 0; corner < 4; corner++){
|
|
15766
|
+
var offset = 3 * resultQuads[faceOffset + corner];
|
|
15767
|
+
x += 0.25 * resultPositions[offset];
|
|
15768
|
+
y += 0.25 * resultPositions[offset + 1];
|
|
15769
|
+
z += 0.25 * resultPositions[offset + 2];
|
|
15770
|
+
}
|
|
15771
|
+
facePoints[pointOffset] = x;
|
|
15772
|
+
facePoints[pointOffset + 1] = y;
|
|
15773
|
+
facePoints[pointOffset + 2] = z;
|
|
15774
|
+
for(var corner1 = 0; corner1 < 4; corner1++){
|
|
15775
|
+
var a = resultQuads[faceOffset + corner1];
|
|
15776
|
+
var b = resultQuads[faceOffset + (corner1 + 1) % 4];
|
|
15777
|
+
var key = Math.min(a, b) * vertexCount + Math.max(a, b);
|
|
15778
|
+
var edge = edges.get(key);
|
|
15779
|
+
if (edge === undefined) {
|
|
15780
|
+
edge = edgeCount++;
|
|
15781
|
+
edges.set(key, edge);
|
|
15782
|
+
edgeIndices[edge] = 0;
|
|
15783
|
+
edgePoints[edge * 3] = 0.25 * (resultPositions[3 * a] + resultPositions[3 * b]);
|
|
15784
|
+
edgePoints[edge * 3 + 1] = 0.25 * (resultPositions[3 * a + 1] + resultPositions[3 * b + 1]);
|
|
15785
|
+
edgePoints[edge * 3 + 2] = 0.25 * (resultPositions[3 * a + 2] + resultPositions[3 * b + 2]);
|
|
15786
|
+
}
|
|
15787
|
+
faceEdges[faceOffset + corner1] = edge;
|
|
15788
|
+
edgePoints[edge * 3] += 0.25 * x;
|
|
15789
|
+
edgePoints[edge * 3 + 1] += 0.25 * y;
|
|
15790
|
+
edgePoints[edge * 3 + 2] += 0.25 * z;
|
|
15791
|
+
}
|
|
15792
|
+
}
|
|
15793
|
+
var nextVertexIndex = vertexCount + faceCount;
|
|
15794
|
+
for(var faceIndex1 = 0; faceIndex1 < faceCount; faceIndex1++){
|
|
15795
|
+
var facePointIndex = vertexCount + faceIndex1;
|
|
15796
|
+
resultPositions[3 * facePointIndex] = facePoints[3 * faceIndex1];
|
|
15797
|
+
resultPositions[3 * facePointIndex + 1] = facePoints[3 * faceIndex1 + 1];
|
|
15798
|
+
resultPositions[3 * facePointIndex + 2] = facePoints[3 * faceIndex1 + 2];
|
|
15799
|
+
for(var corner2 = 0; corner2 < 4; corner2++){
|
|
15800
|
+
var edge1 = faceEdges[faceIndex1 * 4 + edgeOrder[corner2]];
|
|
15801
|
+
if (edgeIndices[edge1] === 0) {
|
|
15802
|
+
var index = nextVertexIndex++;
|
|
15803
|
+
edgeIndices[edge1] = index;
|
|
15804
|
+
resultPositions[3 * index] = edgePoints[3 * edge1];
|
|
15805
|
+
resultPositions[3 * index + 1] = edgePoints[3 * edge1 + 1];
|
|
15806
|
+
resultPositions[3 * index + 2] = edgePoints[3 * edge1 + 2];
|
|
15807
|
+
}
|
|
15808
|
+
}
|
|
15809
|
+
}
|
|
15810
|
+
// Expand backward so the output cannot overwrite an unread input quad
|
|
15811
|
+
for(var faceIndex2 = faceCount - 1; faceIndex2 >= 0; faceIndex2--){
|
|
15812
|
+
for(var corner3 = 3; corner3 >= 0; corner3--){
|
|
15813
|
+
var offset1 = 4 * (4 * faceIndex2 + corner3);
|
|
15814
|
+
resultQuads[offset1] = resultQuads[4 * faceIndex2 + corner3];
|
|
15815
|
+
resultQuads[offset1 + 1] = edgeIndices[faceEdges[4 * faceIndex2 + corner3]];
|
|
15816
|
+
resultQuads[offset1 + 2] = vertexCount + faceIndex2;
|
|
15817
|
+
resultQuads[offset1 + 3] = edgeIndices[faceEdges[4 * faceIndex2 + (corner3 + 3) % 4]];
|
|
15818
|
+
}
|
|
15819
|
+
}
|
|
15820
|
+
vertexCount = nextVertexIndex;
|
|
15821
|
+
faceCount *= 4;
|
|
15822
|
+
}
|
|
15823
|
+
return {
|
|
15824
|
+
positions: resultPositions,
|
|
15825
|
+
quads: resultQuads
|
|
15826
|
+
};
|
|
15827
|
+
};
|
|
15828
|
+
return SubdivisionUtils;
|
|
15829
|
+
}();
|
|
14937
15830
|
|
|
14938
15831
|
/**
|
|
14939
|
-
*
|
|
15832
|
+
* Creates primitive meshes in local space. Angle ranges use degrees.
|
|
15833
|
+
* Meshes have one sub-mesh unless material grouping is enabled.
|
|
15834
|
+
* @remarks
|
|
15835
|
+
* Input arrays and vectors are copied. Changing them later does not update the mesh.
|
|
15836
|
+
* Device restoration uses the original creation inputs; later mesh edits are not backed up.
|
|
14940
15837
|
*/ var PrimitiveMesh = /*#__PURE__*/ function() {
|
|
14941
15838
|
function PrimitiveMesh() {}
|
|
14942
15839
|
/**
|
|
14943
|
-
* Create a sphere
|
|
14944
|
-
*
|
|
14945
|
-
*
|
|
14946
|
-
* @param
|
|
14947
|
-
* @param
|
|
14948
|
-
* @
|
|
14949
|
-
|
|
14950
|
-
|
|
14951
|
-
|
|
14952
|
-
|
|
14953
|
-
var
|
|
14954
|
-
|
|
14955
|
-
var
|
|
14956
|
-
|
|
14957
|
-
|
|
14958
|
-
|
|
14959
|
-
|
|
14960
|
-
|
|
14961
|
-
|
|
14962
|
-
|
|
14963
|
-
|
|
14964
|
-
|
|
14965
|
-
|
|
14966
|
-
*
|
|
14967
|
-
|
|
14968
|
-
|
|
14969
|
-
|
|
14970
|
-
|
|
14971
|
-
|
|
14972
|
-
|
|
14973
|
-
|
|
14974
|
-
|
|
14975
|
-
|
|
14976
|
-
|
|
14977
|
-
|
|
14978
|
-
|
|
14979
|
-
|
|
14980
|
-
|
|
14981
|
-
|
|
14982
|
-
|
|
14983
|
-
|
|
14984
|
-
|
|
14985
|
-
|
|
14986
|
-
|
|
14987
|
-
|
|
14988
|
-
|
|
14989
|
-
|
|
14990
|
-
|
|
14991
|
-
|
|
14992
|
-
|
|
14993
|
-
|
|
14994
|
-
|
|
15840
|
+
* Create a sphere or an open spherical section from a subdivided cube.
|
|
15841
|
+
* U follows the horizontal angle interval and V follows the vertical angle interval, each scaled to 0–1.
|
|
15842
|
+
* The horizontal start marks the U seam; V increases from the upper to the lower boundary.
|
|
15843
|
+
* @param engine - The engine that owns the mesh
|
|
15844
|
+
* @param radius - The radius in local units
|
|
15845
|
+
* @param options - Optional mesh generation settings
|
|
15846
|
+
* @returns The generated mesh
|
|
15847
|
+
*/ PrimitiveMesh.createSphere = function createSphere(engine, radius, options) {
|
|
15848
|
+
var _options_subdivisionLevel;
|
|
15849
|
+
var subdivisionLevel = (_options_subdivisionLevel = options == null ? void 0 : options.subdivisionLevel) != null ? _options_subdivisionLevel : 3;
|
|
15850
|
+
var horizontalAngleRange = options == null ? void 0 : options.horizontalAngleRange;
|
|
15851
|
+
var verticalAngleRange = options == null ? void 0 : options.verticalAngleRange;
|
|
15852
|
+
var _horizontalAngleRange_x, _horizontalAngleRange_y, _verticalAngleRange_x, _verticalAngleRange_y;
|
|
15853
|
+
return PrimitiveMesh._createMesh(engine, PrimitiveMesh._createSphereData, [
|
|
15854
|
+
radius,
|
|
15855
|
+
subdivisionLevel,
|
|
15856
|
+
(_horizontalAngleRange_x = horizontalAngleRange == null ? void 0 : horizontalAngleRange.x) != null ? _horizontalAngleRange_x : 0,
|
|
15857
|
+
(_horizontalAngleRange_y = horizontalAngleRange == null ? void 0 : horizontalAngleRange.y) != null ? _horizontalAngleRange_y : 360,
|
|
15858
|
+
(_verticalAngleRange_x = verticalAngleRange == null ? void 0 : verticalAngleRange.x) != null ? _verticalAngleRange_x : 0,
|
|
15859
|
+
(_verticalAngleRange_y = verticalAngleRange == null ? void 0 : verticalAngleRange.y) != null ? _verticalAngleRange_y : 180
|
|
15860
|
+
], options);
|
|
15861
|
+
};
|
|
15862
|
+
/**
|
|
15863
|
+
* Create an axis-aligned cuboid centered at the origin.
|
|
15864
|
+
* @remarks
|
|
15865
|
+
* Each face spans 0–1 in U/V. Face directions (+U, +V) are:
|
|
15866
|
+
* +Y: (+X, +Z); -Y: (+X, -Z); -X: (+Z, -Y);
|
|
15867
|
+
* +X: (-Z, -Y); +Z: (+X, -Y); -Z: (-X, -Y).
|
|
15868
|
+
* @param engine - The engine that owns the mesh
|
|
15869
|
+
* @param width - The full size along X in local units
|
|
15870
|
+
* @param height - The full size along Y in local units
|
|
15871
|
+
* @param depth - The full size along Z in local units
|
|
15872
|
+
* @param options - Optional mesh generation settings
|
|
15873
|
+
* @returns The generated mesh
|
|
15874
|
+
*/ PrimitiveMesh.createCuboid = function createCuboid(engine, width, height, depth, options) {
|
|
15875
|
+
var _options_widthSegments;
|
|
15876
|
+
var widthSegments = (_options_widthSegments = options == null ? void 0 : options.widthSegments) != null ? _options_widthSegments : 1;
|
|
15877
|
+
var _options_heightSegments;
|
|
15878
|
+
var heightSegments = (_options_heightSegments = options == null ? void 0 : options.heightSegments) != null ? _options_heightSegments : widthSegments;
|
|
15879
|
+
var _options_depthSegments;
|
|
15880
|
+
var depthSegments = (_options_depthSegments = options == null ? void 0 : options.depthSegments) != null ? _options_depthSegments : widthSegments;
|
|
15881
|
+
return PrimitiveMesh._createMesh(engine, PrimitiveMesh._createCuboidData, [
|
|
15882
|
+
width,
|
|
15883
|
+
height,
|
|
15884
|
+
depth,
|
|
15885
|
+
widthSegments,
|
|
15886
|
+
heightSegments,
|
|
15887
|
+
depthSegments
|
|
15888
|
+
], options);
|
|
15889
|
+
};
|
|
15890
|
+
/**
|
|
15891
|
+
* Create a plane in XZ facing +Y, centered at the origin.
|
|
15892
|
+
* UVs span 0–1, with U along +X and V along +Z.
|
|
15893
|
+
* @param engine - The engine that owns the mesh
|
|
15894
|
+
* @param width - The full size along X in local units
|
|
15895
|
+
* @param depth - The full size along Z in local units
|
|
15896
|
+
* @param options - Optional mesh generation settings
|
|
15897
|
+
* @returns The generated mesh
|
|
15898
|
+
*/ PrimitiveMesh.createPlane = function createPlane(engine, width, depth, options) {
|
|
15899
|
+
var _options_widthSegments;
|
|
15900
|
+
var widthSegments = (_options_widthSegments = options == null ? void 0 : options.widthSegments) != null ? _options_widthSegments : 1;
|
|
15901
|
+
var _options_depthSegments;
|
|
15902
|
+
var depthSegments = (_options_depthSegments = options == null ? void 0 : options.depthSegments) != null ? _options_depthSegments : widthSegments;
|
|
15903
|
+
return PrimitiveMesh._createMesh(engine, PrimitiveMesh._createPlaneData, [
|
|
15904
|
+
width,
|
|
15905
|
+
depth,
|
|
15906
|
+
widthSegments,
|
|
15907
|
+
depthSegments
|
|
15908
|
+
], options);
|
|
15909
|
+
};
|
|
15910
|
+
/**
|
|
15911
|
+
* Create a cylinder centered on Y with equal end radii.
|
|
15912
|
+
* U spans the angular range from 0 to 1; V runs from 0 at the top to 1 at the bottom.
|
|
15913
|
+
* The default side seam is at -Z. Both caps use planar UVs with U along +X and V along -Z.
|
|
15914
|
+
* @param engine - The engine that owns the mesh
|
|
15915
|
+
* @param radius - The radius in local units
|
|
15916
|
+
* @param height - The full size along Y in local units
|
|
15917
|
+
* @param options - Optional mesh generation settings
|
|
15918
|
+
* @returns The generated mesh
|
|
15919
|
+
*/ PrimitiveMesh.createCylinder = function createCylinder(engine, radius, height, options) {
|
|
15920
|
+
var _options_radialSegments;
|
|
15921
|
+
var radialSegments = (_options_radialSegments = options == null ? void 0 : options.radialSegments) != null ? _options_radialSegments : 20;
|
|
15922
|
+
var _options_heightSegments;
|
|
15923
|
+
var heightSegments = (_options_heightSegments = options == null ? void 0 : options.heightSegments) != null ? _options_heightSegments : 1;
|
|
15924
|
+
var _options_caps;
|
|
15925
|
+
var caps = (_options_caps = options == null ? void 0 : options.caps) != null ? _options_caps : PrimitiveMeshCapMode.Both;
|
|
15926
|
+
var angleRange = options == null ? void 0 : options.angleRange;
|
|
15927
|
+
var _angleRange_x;
|
|
15928
|
+
var startAngle = (_angleRange_x = angleRange == null ? void 0 : angleRange.x) != null ? _angleRange_x : 0;
|
|
15929
|
+
var _angleRange_y, _options_separateMaterialSlots;
|
|
15930
|
+
return PrimitiveMesh._createMesh(engine, PrimitiveMesh._createCylinderData, [
|
|
15931
|
+
radius,
|
|
15932
|
+
radius,
|
|
15933
|
+
height,
|
|
15934
|
+
radialSegments,
|
|
15935
|
+
heightSegments,
|
|
15936
|
+
caps === PrimitiveMeshCapMode.Both || caps === PrimitiveMeshCapMode.Top,
|
|
15937
|
+
caps === PrimitiveMeshCapMode.Both || caps === PrimitiveMeshCapMode.Bottom,
|
|
15938
|
+
startAngle,
|
|
15939
|
+
((_angleRange_y = angleRange == null ? void 0 : angleRange.y) != null ? _angleRange_y : 360) - startAngle,
|
|
15940
|
+
(_options_separateMaterialSlots = options == null ? void 0 : options.separateMaterialSlots) != null ? _options_separateMaterialSlots : false
|
|
15941
|
+
], options);
|
|
15942
|
+
};
|
|
15943
|
+
/**
|
|
15944
|
+
* Create a truncated cone centered on Y with independently sized ends.
|
|
15945
|
+
* U spans the angular range from 0 to 1; V runs from 0 at the top to 1 at the bottom.
|
|
15946
|
+
* The default side seam is at -Z. Both caps use planar UVs with U along +X and V along -Z.
|
|
15947
|
+
* @param engine - The engine that owns the mesh
|
|
15948
|
+
* @param topRadius - The top radius in local units
|
|
15949
|
+
* @param bottomRadius - The bottom radius in local units
|
|
15950
|
+
* @param height - The full size along Y in local units
|
|
15951
|
+
* @param options - Optional mesh generation settings
|
|
15952
|
+
* @returns The generated mesh
|
|
15953
|
+
*/ PrimitiveMesh.createTruncatedCone = function createTruncatedCone(engine, topRadius, bottomRadius, height, options) {
|
|
15954
|
+
var _options_radialSegments;
|
|
15955
|
+
var radialSegments = (_options_radialSegments = options == null ? void 0 : options.radialSegments) != null ? _options_radialSegments : 20;
|
|
15956
|
+
var _options_heightSegments;
|
|
15957
|
+
var heightSegments = (_options_heightSegments = options == null ? void 0 : options.heightSegments) != null ? _options_heightSegments : 1;
|
|
15958
|
+
var _options_caps;
|
|
15959
|
+
var caps = (_options_caps = options == null ? void 0 : options.caps) != null ? _options_caps : PrimitiveMeshCapMode.Both;
|
|
15960
|
+
var angleRange = options == null ? void 0 : options.angleRange;
|
|
15961
|
+
var _angleRange_x;
|
|
15962
|
+
var startAngle = (_angleRange_x = angleRange == null ? void 0 : angleRange.x) != null ? _angleRange_x : 0;
|
|
15963
|
+
var _angleRange_y, _options_separateMaterialSlots;
|
|
15964
|
+
return PrimitiveMesh._createMesh(engine, PrimitiveMesh._createCylinderData, [
|
|
15965
|
+
topRadius,
|
|
15966
|
+
bottomRadius,
|
|
15967
|
+
height,
|
|
15968
|
+
radialSegments,
|
|
15969
|
+
heightSegments,
|
|
15970
|
+
caps === PrimitiveMeshCapMode.Both || caps === PrimitiveMeshCapMode.Top,
|
|
15971
|
+
caps === PrimitiveMeshCapMode.Both || caps === PrimitiveMeshCapMode.Bottom,
|
|
15972
|
+
startAngle,
|
|
15973
|
+
((_angleRange_y = angleRange == null ? void 0 : angleRange.y) != null ? _angleRange_y : 360) - startAngle,
|
|
15974
|
+
(_options_separateMaterialSlots = options == null ? void 0 : options.separateMaterialSlots) != null ? _options_separateMaterialSlots : false
|
|
15975
|
+
], options);
|
|
15976
|
+
};
|
|
15977
|
+
/**
|
|
15978
|
+
* Create a cone centered on Y with its tip at the top.
|
|
15979
|
+
* U spans the angular range from 0 to 1; V runs from 0 at the tip to 1 at the base.
|
|
15980
|
+
* The default side seam is at -Z. The base uses planar UVs with U along +X and V along -Z.
|
|
15981
|
+
* @param engine - The engine that owns the mesh
|
|
15982
|
+
* @param radius - The bottom radius in local units
|
|
15983
|
+
* @param height - The full size along Y in local units
|
|
15984
|
+
* @param options - Optional mesh generation settings
|
|
15985
|
+
* @returns The generated mesh
|
|
15986
|
+
*/ PrimitiveMesh.createCone = function createCone(engine, radius, height, options) {
|
|
15987
|
+
var _options_radialSegments;
|
|
15988
|
+
var radialSegments = (_options_radialSegments = options == null ? void 0 : options.radialSegments) != null ? _options_radialSegments : 20;
|
|
15989
|
+
var _options_heightSegments;
|
|
15990
|
+
var heightSegments = (_options_heightSegments = options == null ? void 0 : options.heightSegments) != null ? _options_heightSegments : 1;
|
|
15991
|
+
var _options_cap;
|
|
15992
|
+
var cap = (_options_cap = options == null ? void 0 : options.cap) != null ? _options_cap : true;
|
|
15993
|
+
var angleRange = options == null ? void 0 : options.angleRange;
|
|
15994
|
+
var _angleRange_x;
|
|
15995
|
+
var startAngle = (_angleRange_x = angleRange == null ? void 0 : angleRange.x) != null ? _angleRange_x : 0;
|
|
15996
|
+
var _angleRange_y;
|
|
15997
|
+
return PrimitiveMesh._createMesh(engine, PrimitiveMesh._createCylinderData, [
|
|
15998
|
+
0,
|
|
15999
|
+
radius,
|
|
16000
|
+
height,
|
|
16001
|
+
radialSegments,
|
|
16002
|
+
heightSegments,
|
|
16003
|
+
false,
|
|
16004
|
+
cap,
|
|
16005
|
+
startAngle,
|
|
16006
|
+
((_angleRange_y = angleRange == null ? void 0 : angleRange.y) != null ? _angleRange_y : 360) - startAngle
|
|
16007
|
+
], options);
|
|
16008
|
+
};
|
|
16009
|
+
/**
|
|
16010
|
+
* Create a capsule centered on Y.
|
|
16011
|
+
* U runs around Y from -Z towards -X. V runs from 0 at the top to 1 at the bottom,
|
|
16012
|
+
* proportional to surface length along the hemispheres and cylinder.
|
|
16013
|
+
* @param engine - The engine that owns the mesh
|
|
16014
|
+
* @param radius - The radius of the cylinder and hemispherical ends in local units
|
|
16015
|
+
* @param cylinderHeight - The straight cylindrical section height in local units; total height is `cylinderHeight + 2 * radius`
|
|
16016
|
+
* @param options - Optional mesh generation settings
|
|
16017
|
+
* @returns The generated mesh
|
|
16018
|
+
*/ PrimitiveMesh.createCapsule = function createCapsule(engine, radius, cylinderHeight, options) {
|
|
16019
|
+
var _options_radialSegments;
|
|
16020
|
+
var radialSegments = (_options_radialSegments = options == null ? void 0 : options.radialSegments) != null ? _options_radialSegments : 6;
|
|
16021
|
+
var _options_capSegments;
|
|
16022
|
+
var capSegments = (_options_capSegments = options == null ? void 0 : options.capSegments) != null ? _options_capSegments : radialSegments;
|
|
16023
|
+
var _options_heightSegments;
|
|
16024
|
+
var heightSegments = (_options_heightSegments = options == null ? void 0 : options.heightSegments) != null ? _options_heightSegments : 1;
|
|
16025
|
+
return PrimitiveMesh._createMesh(engine, PrimitiveMesh._createCapsuleData, [
|
|
16026
|
+
radius,
|
|
16027
|
+
cylinderHeight,
|
|
16028
|
+
radialSegments,
|
|
16029
|
+
capSegments,
|
|
16030
|
+
heightSegments
|
|
16031
|
+
], options);
|
|
16032
|
+
};
|
|
16033
|
+
/**
|
|
16034
|
+
* Create a torus centered in XY around Z.
|
|
16035
|
+
* U spans the ring angle interval and V spans the tube angle interval, each scaled to 0–1.
|
|
16036
|
+
* @param engine - The engine that owns the mesh
|
|
16037
|
+
* @param radius - The distance from the origin to the tube centerline in local units
|
|
16038
|
+
* @param tubeRadius - The radius of the tube cross-section in local units
|
|
16039
|
+
* @param options - Optional mesh generation settings
|
|
16040
|
+
* @returns The generated mesh
|
|
16041
|
+
*/ PrimitiveMesh.createTorus = function createTorus(engine, radius, tubeRadius, options) {
|
|
16042
|
+
var _options_ringSegments;
|
|
16043
|
+
var ringSegments = (_options_ringSegments = options == null ? void 0 : options.ringSegments) != null ? _options_ringSegments : 30;
|
|
16044
|
+
var _options_radialSegments;
|
|
16045
|
+
var radialSegments = (_options_radialSegments = options == null ? void 0 : options.radialSegments) != null ? _options_radialSegments : 30;
|
|
16046
|
+
var ringAngleRange = options == null ? void 0 : options.ringAngleRange;
|
|
16047
|
+
var tubeAngleRange = options == null ? void 0 : options.tubeAngleRange;
|
|
16048
|
+
var _ringAngleRange_x;
|
|
16049
|
+
var startAngle = (_ringAngleRange_x = ringAngleRange == null ? void 0 : ringAngleRange.x) != null ? _ringAngleRange_x : 0;
|
|
16050
|
+
var _tubeAngleRange_x;
|
|
16051
|
+
var tubeStartAngle = (_tubeAngleRange_x = tubeAngleRange == null ? void 0 : tubeAngleRange.x) != null ? _tubeAngleRange_x : 0;
|
|
16052
|
+
var _ringAngleRange_y, _tubeAngleRange_y;
|
|
16053
|
+
return PrimitiveMesh._createMesh(engine, PrimitiveMesh._createTorusData, [
|
|
16054
|
+
radius,
|
|
16055
|
+
tubeRadius,
|
|
16056
|
+
radialSegments,
|
|
16057
|
+
ringSegments,
|
|
16058
|
+
((_ringAngleRange_y = ringAngleRange == null ? void 0 : ringAngleRange.y) != null ? _ringAngleRange_y : 360) - startAngle,
|
|
16059
|
+
tubeStartAngle,
|
|
16060
|
+
((_tubeAngleRange_y = tubeAngleRange == null ? void 0 : tubeAngleRange.y) != null ? _tubeAngleRange_y : 360) - tubeStartAngle,
|
|
16061
|
+
startAngle
|
|
16062
|
+
], options);
|
|
16063
|
+
};
|
|
16064
|
+
/**
|
|
16065
|
+
* Create a filled disk or sector in XY facing +Z.
|
|
16066
|
+
* UVs project X/Y onto the full disk's bounding square; angular cuts do not rescale them.
|
|
16067
|
+
* @param engine - The engine that owns the mesh
|
|
16068
|
+
* @param radius - The radius in local units
|
|
16069
|
+
* @param options - Optional mesh generation settings
|
|
16070
|
+
* @returns The generated mesh
|
|
16071
|
+
*/ PrimitiveMesh.createCircle = function createCircle(engine, radius, options) {
|
|
16072
|
+
var _options_segments;
|
|
16073
|
+
var segments = (_options_segments = options == null ? void 0 : options.segments) != null ? _options_segments : 32;
|
|
16074
|
+
var angleRange = options == null ? void 0 : options.angleRange;
|
|
16075
|
+
var _angleRange_x;
|
|
16076
|
+
var startAngle = (_angleRange_x = angleRange == null ? void 0 : angleRange.x) != null ? _angleRange_x : 0;
|
|
16077
|
+
var _angleRange_y;
|
|
16078
|
+
return PrimitiveMesh._createMesh(engine, PrimitiveMesh._createCircleData, [
|
|
16079
|
+
radius,
|
|
16080
|
+
segments,
|
|
16081
|
+
startAngle,
|
|
16082
|
+
((_angleRange_y = angleRange == null ? void 0 : angleRange.y) != null ? _angleRange_y : 360) - startAngle
|
|
16083
|
+
], options);
|
|
16084
|
+
};
|
|
16085
|
+
/**
|
|
16086
|
+
* Create a ring or ring sector in XY facing +Z.
|
|
16087
|
+
* UVs project X/Y onto the outer disk's bounding square; angular cuts do not rescale them.
|
|
16088
|
+
* @param engine - The engine that owns the mesh
|
|
16089
|
+
* @param outerRadius - The outer radius in local units
|
|
16090
|
+
* @param innerRadius - The inner radius in local units
|
|
16091
|
+
* @param options - Optional mesh generation settings
|
|
16092
|
+
* @returns The generated mesh
|
|
16093
|
+
*/ PrimitiveMesh.createRing = function createRing(engine, outerRadius, innerRadius, options) {
|
|
16094
|
+
var _options_ringSegments;
|
|
16095
|
+
var ringSegments = (_options_ringSegments = options == null ? void 0 : options.ringSegments) != null ? _options_ringSegments : 32;
|
|
16096
|
+
var _options_widthSegments;
|
|
16097
|
+
var widthSegments = (_options_widthSegments = options == null ? void 0 : options.widthSegments) != null ? _options_widthSegments : 1;
|
|
16098
|
+
var angleRange = options == null ? void 0 : options.angleRange;
|
|
16099
|
+
var _angleRange_x;
|
|
16100
|
+
var startAngle = (_angleRange_x = angleRange == null ? void 0 : angleRange.x) != null ? _angleRange_x : 0;
|
|
16101
|
+
var _angleRange_y;
|
|
16102
|
+
return PrimitiveMesh._createMesh(engine, PrimitiveMesh._createRingData, [
|
|
16103
|
+
innerRadius,
|
|
16104
|
+
outerRadius,
|
|
16105
|
+
ringSegments,
|
|
16106
|
+
widthSegments,
|
|
16107
|
+
startAngle,
|
|
16108
|
+
((_angleRange_y = angleRange == null ? void 0 : angleRange.y) != null ? _angleRange_y : 360) - startAngle
|
|
16109
|
+
], options);
|
|
16110
|
+
};
|
|
16111
|
+
/**
|
|
16112
|
+
* Create a regular tetrahedron or its spherical subdivision.
|
|
16113
|
+
* UVs use spherical projection around Y, with the U seam at +X and V from 0 at +Y to 1 at -Y.
|
|
16114
|
+
* Triangles crossing the U seam may use values above 1.
|
|
16115
|
+
* @param engine - The engine that owns the mesh
|
|
16116
|
+
* @param radius - The distance from the origin to each vertex in local units
|
|
16117
|
+
* @param options - Optional mesh generation settings
|
|
16118
|
+
* @returns The generated mesh
|
|
16119
|
+
*/ PrimitiveMesh.createTetrahedron = function createTetrahedron(engine, radius, options) {
|
|
16120
|
+
var _options_edgeSegments;
|
|
16121
|
+
var edgeSegments = (_options_edgeSegments = options == null ? void 0 : options.edgeSegments) != null ? _options_edgeSegments : 1;
|
|
16122
|
+
return PrimitiveMesh._createMesh(engine, PrimitiveMesh._createRegularPolyhedronData, [
|
|
16123
|
+
"tetrahedron",
|
|
16124
|
+
radius,
|
|
16125
|
+
edgeSegments
|
|
16126
|
+
], options);
|
|
16127
|
+
};
|
|
16128
|
+
/**
|
|
16129
|
+
* Create a regular octahedron or its spherical subdivision.
|
|
16130
|
+
* UVs use spherical projection around Y, with the U seam at +X and V from 0 at +Y to 1 at -Y.
|
|
16131
|
+
* Triangles crossing the U seam may use values above 1.
|
|
16132
|
+
* @param engine - The engine that owns the mesh
|
|
16133
|
+
* @param radius - The distance from the origin to each vertex in local units
|
|
16134
|
+
* @param options - Optional mesh generation settings
|
|
16135
|
+
* @returns The generated mesh
|
|
16136
|
+
*/ PrimitiveMesh.createOctahedron = function createOctahedron(engine, radius, options) {
|
|
16137
|
+
var _options_edgeSegments;
|
|
16138
|
+
var edgeSegments = (_options_edgeSegments = options == null ? void 0 : options.edgeSegments) != null ? _options_edgeSegments : 1;
|
|
16139
|
+
return PrimitiveMesh._createMesh(engine, PrimitiveMesh._createRegularPolyhedronData, [
|
|
16140
|
+
"octahedron",
|
|
16141
|
+
radius,
|
|
16142
|
+
edgeSegments
|
|
16143
|
+
], options);
|
|
16144
|
+
};
|
|
16145
|
+
/**
|
|
16146
|
+
* Create a regular icosahedron or its spherical subdivision.
|
|
16147
|
+
* UVs use spherical projection around Y, with the U seam at +X and V from 0 at +Y to 1 at -Y.
|
|
16148
|
+
* Triangles crossing the U seam may use values above 1.
|
|
16149
|
+
* @param engine - The engine that owns the mesh
|
|
16150
|
+
* @param radius - The distance from the origin to each vertex in local units
|
|
16151
|
+
* @param options - Optional mesh generation settings
|
|
16152
|
+
* @returns The generated mesh
|
|
16153
|
+
*/ PrimitiveMesh.createIcosahedron = function createIcosahedron(engine, radius, options) {
|
|
16154
|
+
var _options_edgeSegments;
|
|
16155
|
+
var edgeSegments = (_options_edgeSegments = options == null ? void 0 : options.edgeSegments) != null ? _options_edgeSegments : 1;
|
|
16156
|
+
return PrimitiveMesh._createMesh(engine, PrimitiveMesh._createRegularPolyhedronData, [
|
|
16157
|
+
"icosahedron",
|
|
16158
|
+
radius,
|
|
16159
|
+
edgeSegments
|
|
16160
|
+
], options);
|
|
16161
|
+
};
|
|
16162
|
+
/**
|
|
16163
|
+
* Create a regular dodecahedron or its spherical subdivision.
|
|
16164
|
+
* UVs use spherical projection around Y, with the U seam at +X and V from 0 at +Y to 1 at -Y.
|
|
16165
|
+
* Triangles crossing the U seam may use values above 1.
|
|
16166
|
+
* @param engine - The engine that owns the mesh
|
|
16167
|
+
* @param radius - The distance from the origin to each vertex in local units
|
|
16168
|
+
* @param options - Optional mesh generation settings
|
|
16169
|
+
* @returns The generated mesh
|
|
16170
|
+
*/ PrimitiveMesh.createDodecahedron = function createDodecahedron(engine, radius, options) {
|
|
16171
|
+
var _options_edgeSegments;
|
|
16172
|
+
var edgeSegments = (_options_edgeSegments = options == null ? void 0 : options.edgeSegments) != null ? _options_edgeSegments : 1;
|
|
16173
|
+
return PrimitiveMesh._createMesh(engine, PrimitiveMesh._createRegularPolyhedronData, [
|
|
16174
|
+
"dodecahedron",
|
|
16175
|
+
radius,
|
|
16176
|
+
edgeSegments
|
|
16177
|
+
], options);
|
|
16178
|
+
};
|
|
16179
|
+
/**
|
|
16180
|
+
* Create a surface of revolution by rotating a radius-height profile around Y.
|
|
16181
|
+
* No end caps are added automatically.
|
|
16182
|
+
* Define inner walls and closed ends in the profile when needed.
|
|
16183
|
+
* U spans the revolution from 0 to 1; V advances uniformly by profile point index from 0 to 1.
|
|
16184
|
+
* @param engine - The engine that owns the mesh
|
|
16185
|
+
* @param profile - The profile points in input order, with at least two points; X is radius and Y is height. Repeat the first point to close the profile
|
|
16186
|
+
* @param options - Optional mesh generation settings
|
|
16187
|
+
* @returns The generated mesh
|
|
16188
|
+
*/ PrimitiveMesh.createRevolvedSurface = function createRevolvedSurface(engine, profile, options) {
|
|
16189
|
+
var _options_segments;
|
|
16190
|
+
var segments = (_options_segments = options == null ? void 0 : options.segments) != null ? _options_segments : 12;
|
|
16191
|
+
var angleRange = options == null ? void 0 : options.angleRange;
|
|
16192
|
+
var _angleRange_x;
|
|
16193
|
+
var startAngle = (_angleRange_x = angleRange == null ? void 0 : angleRange.x) != null ? _angleRange_x : 0;
|
|
16194
|
+
var _angleRange_y;
|
|
16195
|
+
return PrimitiveMesh._createMesh(engine, PrimitiveMesh._createRevolvedSurfaceData, [
|
|
16196
|
+
profile,
|
|
16197
|
+
segments,
|
|
16198
|
+
startAngle,
|
|
16199
|
+
((_angleRange_y = angleRange == null ? void 0 : angleRange.y) != null ? _angleRange_y : 360) - startAngle
|
|
16200
|
+
], options);
|
|
16201
|
+
};
|
|
16202
|
+
/**
|
|
16203
|
+
* Sweep a circular cross-section along a path without end caps.
|
|
16204
|
+
* U measures normalized path distance; V runs around the generated path frame from 0 to 1.
|
|
16205
|
+
* @param engine - The engine that owns the mesh
|
|
16206
|
+
* @param path - The centerline points, resampled at equal distances along the polyline; at least two distinct points are required
|
|
16207
|
+
* @param radius - The radius of the cross-section in local units
|
|
16208
|
+
* @param options - Optional mesh generation settings
|
|
16209
|
+
* @returns The generated mesh
|
|
16210
|
+
*/ PrimitiveMesh.createTube = function createTube(engine, path, radius, options) {
|
|
16211
|
+
var _options_pathSegments;
|
|
16212
|
+
var pathSegments = (_options_pathSegments = options == null ? void 0 : options.pathSegments) != null ? _options_pathSegments : 64;
|
|
16213
|
+
var _options_radialSegments;
|
|
16214
|
+
var radialSegments = (_options_radialSegments = options == null ? void 0 : options.radialSegments) != null ? _options_radialSegments : 8;
|
|
16215
|
+
var _options_closedPath;
|
|
16216
|
+
var closedPath = (_options_closedPath = options == null ? void 0 : options.closedPath) != null ? _options_closedPath : false;
|
|
16217
|
+
return PrimitiveMesh._createMesh(engine, PrimitiveMesh._createTubeData, [
|
|
16218
|
+
path,
|
|
16219
|
+
radius,
|
|
16220
|
+
pathSegments,
|
|
16221
|
+
radialSegments,
|
|
16222
|
+
closedPath
|
|
16223
|
+
], options);
|
|
16224
|
+
};
|
|
16225
|
+
/**
|
|
16226
|
+
* Create a zero-thickness polygon mesh in the XY plane, facing +Z.
|
|
16227
|
+
* UVs use the local X/Y coordinates directly, without normalization.
|
|
16228
|
+
* @param engine - The engine that owns the mesh
|
|
16229
|
+
* @param shapes - A contour, a polygon with holes, or an array of polygons; closing points need not be repeated
|
|
16230
|
+
* @param options - Optional mesh generation settings
|
|
16231
|
+
* @returns The triangulated polygon mesh without side walls
|
|
16232
|
+
*/ PrimitiveMesh.createPolygon = function createPolygon(engine, shapes, options) {
|
|
16233
|
+
return PrimitiveMesh._createMesh(engine, PrimitiveMesh._createPolygonData, [
|
|
16234
|
+
PrimitiveMesh._polygons(shapes)
|
|
16235
|
+
], options);
|
|
16236
|
+
};
|
|
16237
|
+
PrimitiveMesh.createExtrudedPolygon = function createExtrudedPolygon(engine, shapes, depthOrPath, options) {
|
|
16238
|
+
var extrudedPolygonOptions = options;
|
|
16239
|
+
var _extrudedPolygonOptions_depthSegments;
|
|
16240
|
+
var depthSegments = (_extrudedPolygonOptions_depthSegments = extrudedPolygonOptions == null ? void 0 : extrudedPolygonOptions.depthSegments) != null ? _extrudedPolygonOptions_depthSegments : 1;
|
|
16241
|
+
var _extrudedPolygonOptions_pathSegments;
|
|
16242
|
+
var pathSegments = (_extrudedPolygonOptions_pathSegments = extrudedPolygonOptions == null ? void 0 : extrudedPolygonOptions.pathSegments) != null ? _extrudedPolygonOptions_pathSegments : 1;
|
|
16243
|
+
var _extrudedPolygonOptions_closedPath;
|
|
16244
|
+
var closedPath = (_extrudedPolygonOptions_closedPath = extrudedPolygonOptions == null ? void 0 : extrudedPolygonOptions.closedPath) != null ? _extrudedPolygonOptions_closedPath : false;
|
|
16245
|
+
var _extrudedPolygonOptions_bevelWidth;
|
|
16246
|
+
var bevelWidth = (_extrudedPolygonOptions_bevelWidth = extrudedPolygonOptions == null ? void 0 : extrudedPolygonOptions.bevelWidth) != null ? _extrudedPolygonOptions_bevelWidth : 0;
|
|
16247
|
+
var _extrudedPolygonOptions_bevelDepth;
|
|
16248
|
+
var bevelDepth = (_extrudedPolygonOptions_bevelDepth = extrudedPolygonOptions == null ? void 0 : extrudedPolygonOptions.bevelDepth) != null ? _extrudedPolygonOptions_bevelDepth : bevelWidth;
|
|
16249
|
+
var _extrudedPolygonOptions_contourOffset;
|
|
16250
|
+
var contourOffset = (_extrudedPolygonOptions_contourOffset = extrudedPolygonOptions == null ? void 0 : extrudedPolygonOptions.contourOffset) != null ? _extrudedPolygonOptions_contourOffset : 0;
|
|
16251
|
+
var _extrudedPolygonOptions_bevelSegments;
|
|
16252
|
+
var bevelSegments = (_extrudedPolygonOptions_bevelSegments = extrudedPolygonOptions == null ? void 0 : extrudedPolygonOptions.bevelSegments) != null ? _extrudedPolygonOptions_bevelSegments : 3;
|
|
16253
|
+
var path = typeof depthOrPath === "number" ? undefined : depthOrPath;
|
|
16254
|
+
var depth = typeof depthOrPath === "number" ? depthOrPath : 0;
|
|
16255
|
+
return PrimitiveMesh._createMesh(engine, PrimitiveMesh._createExtrudedPolygonData, [
|
|
16256
|
+
PrimitiveMesh._polygons(shapes),
|
|
16257
|
+
depth,
|
|
16258
|
+
path ? pathSegments : depthSegments,
|
|
16259
|
+
path,
|
|
16260
|
+
path ? closedPath : false,
|
|
16261
|
+
bevelDepth,
|
|
16262
|
+
bevelWidth,
|
|
16263
|
+
contourOffset,
|
|
16264
|
+
bevelSegments
|
|
16265
|
+
], options);
|
|
16266
|
+
};
|
|
16267
|
+
/**
|
|
16268
|
+
* Create a closed torus knot. At least one of `axisTurns` and `crossSectionTurns` must be nonzero.
|
|
16269
|
+
* U follows the knot parameter from 0 to 1; V runs around the generated tube cross-section from 0 to 1.
|
|
16270
|
+
* @param engine - The engine that owns the mesh
|
|
16271
|
+
* @param radius - The base radius of the torus in local units
|
|
16272
|
+
* @param tubeRadius - The radius of the tube cross-section in local units
|
|
16273
|
+
* @param axisTurns - The signed integer revolution count around the torus axis; negative values reverse the winding
|
|
16274
|
+
* @param crossSectionTurns - The signed integer revolution count around the torus cross-section; negative values reverse the winding
|
|
16275
|
+
* @param options - Optional mesh generation settings
|
|
16276
|
+
* @returns The generated mesh
|
|
16277
|
+
*/ PrimitiveMesh.createTorusKnot = function createTorusKnot(engine, radius, tubeRadius, axisTurns, crossSectionTurns, options) {
|
|
16278
|
+
var _options_pathSegments;
|
|
16279
|
+
var pathSegments = (_options_pathSegments = options == null ? void 0 : options.pathSegments) != null ? _options_pathSegments : 64;
|
|
16280
|
+
var _options_radialSegments;
|
|
16281
|
+
var radialSegments = (_options_radialSegments = options == null ? void 0 : options.radialSegments) != null ? _options_radialSegments : 8;
|
|
16282
|
+
return PrimitiveMesh._createMesh(engine, PrimitiveMesh._createTorusKnotData, [
|
|
16283
|
+
radius,
|
|
16284
|
+
tubeRadius,
|
|
16285
|
+
pathSegments,
|
|
16286
|
+
radialSegments,
|
|
16287
|
+
axisTurns,
|
|
16288
|
+
crossSectionTurns
|
|
16289
|
+
], options);
|
|
16290
|
+
};
|
|
16291
|
+
/**
|
|
16292
|
+
* Create an axis-aligned cuboid with rounded edges and corners.
|
|
16293
|
+
* @remarks
|
|
16294
|
+
* UVs preserve the face orientations of {@link PrimitiveMesh.createCuboid} and account for rounded edge length.
|
|
16295
|
+
* @param engine - The engine that owns the mesh
|
|
16296
|
+
* @param width - The full size along X in local units
|
|
16297
|
+
* @param height - The full size along Y in local units
|
|
16298
|
+
* @param depth - The full size along Z in local units
|
|
16299
|
+
* @param cornerRadius - The edge and corner radius in local units, clamped to half the smallest dimension
|
|
16300
|
+
* @param options - Optional mesh generation settings
|
|
16301
|
+
* @returns The generated mesh
|
|
16302
|
+
*/ PrimitiveMesh.createRoundedCuboid = function createRoundedCuboid(engine, width, height, depth, cornerRadius, options) {
|
|
16303
|
+
var _options_roundingSegments;
|
|
16304
|
+
var roundingSegments = (_options_roundingSegments = options == null ? void 0 : options.roundingSegments) != null ? _options_roundingSegments : 2;
|
|
16305
|
+
return PrimitiveMesh._createMesh(engine, PrimitiveMesh._createRoundedCuboidData, [
|
|
16306
|
+
width,
|
|
16307
|
+
height,
|
|
16308
|
+
depth,
|
|
16309
|
+
cornerRadius,
|
|
16310
|
+
roundingSegments
|
|
16311
|
+
], options);
|
|
16312
|
+
};
|
|
16313
|
+
PrimitiveMesh._createPlaneData = function _createPlaneData(width, depth, widthSegments, depthSegments) {
|
|
16314
|
+
var columns = PrimitiveMesh._getSegmentCount(widthSegments);
|
|
16315
|
+
var rows = PrimitiveMesh._getSegmentCount(depthSegments);
|
|
16316
|
+
var data = new PrimitiveMeshBuilder((columns + 1) * (rows + 1), columns * rows * 6);
|
|
16317
|
+
for(var y = 0; y <= rows; y++){
|
|
16318
|
+
for(var x = 0; x <= columns; x++){
|
|
16319
|
+
data.addVertex((x / columns - 0.5) * width, 0, (y / rows - 0.5) * depth, 0, 1, 0, x / columns, y / rows);
|
|
16320
|
+
}
|
|
16321
|
+
}
|
|
16322
|
+
for(var y1 = 0; y1 < rows; y1++){
|
|
16323
|
+
for(var x1 = 0; x1 < columns; x1++){
|
|
16324
|
+
var a = y1 * (columns + 1) + x1;
|
|
16325
|
+
var c = a + columns + 1;
|
|
16326
|
+
data.addTriangle(a, c, a + 1);
|
|
16327
|
+
data.addTriangle(a + 1, c, c + 1);
|
|
16328
|
+
}
|
|
16329
|
+
}
|
|
16330
|
+
data.boundsExtent = new Vector3(width / 2, 0, depth / 2);
|
|
16331
|
+
return data;
|
|
14995
16332
|
};
|
|
14996
|
-
|
|
14997
|
-
|
|
14998
|
-
|
|
14999
|
-
|
|
15000
|
-
|
|
15001
|
-
|
|
15002
|
-
|
|
15003
|
-
|
|
15004
|
-
|
|
15005
|
-
|
|
15006
|
-
|
|
15007
|
-
|
|
15008
|
-
|
|
15009
|
-
|
|
15010
|
-
|
|
15011
|
-
|
|
15012
|
-
|
|
15013
|
-
|
|
15014
|
-
|
|
15015
|
-
|
|
16333
|
+
PrimitiveMesh._createCuboidData = function _createCuboidData(width, height, depth, widthSegments, heightSegments, depthSegments) {
|
|
16334
|
+
var x = width / 2;
|
|
16335
|
+
var y = height / 2;
|
|
16336
|
+
var z = depth / 2;
|
|
16337
|
+
var sx = PrimitiveMesh._getSegmentCount(widthSegments);
|
|
16338
|
+
var sy = PrimitiveMesh._getSegmentCount(heightSegments);
|
|
16339
|
+
var sz = PrimitiveMesh._getSegmentCount(depthSegments);
|
|
16340
|
+
var data = new PrimitiveMeshBuilder(2 * ((sx + 1) * (sy + 1) + (sx + 1) * (sz + 1) + (sy + 1) * (sz + 1)), 12 * (sx * sy + sx * sz + sy * sz));
|
|
16341
|
+
// Origins and UV directions preserve the existing cuboid texture orientation
|
|
16342
|
+
grid(new Vector3(-x, y, -z), new Vector3(2 * x, 0, 0), new Vector3(0, 0, 2 * z), new Vector3(0, 1, 0), sx, sz, false, false);
|
|
16343
|
+
grid(new Vector3(-x, -y, -z), new Vector3(2 * x, 0, 0), new Vector3(0, 0, 2 * z), new Vector3(0, -1, 0), sx, sz, false, true);
|
|
16344
|
+
grid(new Vector3(-x, y, -z), new Vector3(0, 0, 2 * z), new Vector3(0, -2 * y, 0), new Vector3(-1, 0, 0), sz, sy, false, false);
|
|
16345
|
+
grid(new Vector3(x, y, -z), new Vector3(0, 0, 2 * z), new Vector3(0, -2 * y, 0), new Vector3(1, 0, 0), sz, sy, true, false);
|
|
16346
|
+
grid(new Vector3(-x, y, z), new Vector3(2 * x, 0, 0), new Vector3(0, -2 * y, 0), new Vector3(0, 0, 1), sx, sy, false, false);
|
|
16347
|
+
grid(new Vector3(-x, y, -z), new Vector3(2 * x, 0, 0), new Vector3(0, -2 * y, 0), new Vector3(0, 0, -1), sx, sy, true, false);
|
|
16348
|
+
data.boundsExtent = new Vector3(width / 2, height / 2, depth / 2);
|
|
16349
|
+
return data;
|
|
16350
|
+
function grid(origin, u, v, normal, columns, rows, flipU, flipV) {
|
|
16351
|
+
var base = data.vertexCount;
|
|
16352
|
+
var start = data.indexCount;
|
|
16353
|
+
var crossDot = (u.y * v.z - u.z * v.y) * normal.x + (u.z * v.x - u.x * v.z) * normal.y + (u.x * v.y - u.y * v.x) * normal.z;
|
|
16354
|
+
for(var row = 0; row <= rows; row++){
|
|
16355
|
+
for(var column = 0; column <= columns; column++){
|
|
16356
|
+
var a = column / columns;
|
|
16357
|
+
var b = row / rows;
|
|
16358
|
+
data.addVertex(origin.x + u.x * a + v.x * b, origin.y + u.y * a + v.y * b, origin.z + u.z * a + v.z * b, normal.x, normal.y, normal.z, flipU ? 1 - a : a, flipV ? 1 - b : b);
|
|
16359
|
+
}
|
|
16360
|
+
}
|
|
16361
|
+
for(var row1 = 0; row1 < rows; row1++){
|
|
16362
|
+
for(var column1 = 0; column1 < columns; column1++){
|
|
16363
|
+
var a1 = base + row1 * (columns + 1) + column1;
|
|
16364
|
+
var c = a1 + columns + 1;
|
|
16365
|
+
if (crossDot > 0) {
|
|
16366
|
+
data.addTriangle(a1, a1 + 1, c);
|
|
16367
|
+
data.addTriangle(a1 + 1, c + 1, c);
|
|
16368
|
+
} else {
|
|
16369
|
+
data.addTriangle(a1, c, a1 + 1);
|
|
16370
|
+
data.addTriangle(a1 + 1, c, c + 1);
|
|
16371
|
+
}
|
|
16372
|
+
}
|
|
16373
|
+
}
|
|
16374
|
+
data.addGroup(start);
|
|
16375
|
+
}
|
|
15016
16376
|
};
|
|
15017
|
-
|
|
15018
|
-
|
|
15019
|
-
|
|
15020
|
-
|
|
15021
|
-
|
|
15022
|
-
|
|
15023
|
-
|
|
15024
|
-
|
|
15025
|
-
|
|
15026
|
-
|
|
15027
|
-
|
|
15028
|
-
|
|
15029
|
-
|
|
15030
|
-
|
|
15031
|
-
|
|
15032
|
-
|
|
15033
|
-
|
|
15034
|
-
|
|
15035
|
-
|
|
15036
|
-
|
|
15037
|
-
|
|
15038
|
-
|
|
16377
|
+
PrimitiveMesh._createCylinderData = function _createCylinderData(radiusTop, radiusBottom, height, radialSegments, heightSegments, includeTopCap, includeBottomCap, startAngleDegrees, arcDegrees, separateMaterialSlots) {
|
|
16378
|
+
if (separateMaterialSlots === void 0) separateMaterialSlots = false;
|
|
16379
|
+
var radial = PrimitiveMesh._getSegmentCount(radialSegments, 3);
|
|
16380
|
+
var vertical = PrimitiveMesh._getSegmentCount(heightSegments);
|
|
16381
|
+
var startAngle = Math.PI + MathUtil.degreeToRadian(startAngleDegrees);
|
|
16382
|
+
var arc = MathUtil.degreeToRadian(arcDegrees);
|
|
16383
|
+
var circle = PrimitiveMesh._createArcSamples(radial, startAngle, arc);
|
|
16384
|
+
var slope = height === 0 ? 0 : (radiusBottom - radiusTop) / height;
|
|
16385
|
+
var full = Math.abs(arc) === Math.PI * 2;
|
|
16386
|
+
var capCount = (includeTopCap && radiusTop !== 0 ? 1 : 0) + (includeBottomCap && radiusBottom !== 0 ? 1 : 0);
|
|
16387
|
+
var sideTriangles = 2 * vertical - (radiusTop === 0 ? 1 : 0) - (radiusBottom === 0 ? 1 : 0);
|
|
16388
|
+
var data = new PrimitiveMeshBuilder((radial + 1) * (vertical + 1) + capCount * (radial + (full ? 1 : 2)), radial * (sideTriangles + capCount) * 3);
|
|
16389
|
+
for(var y = 0; y <= vertical; y++){
|
|
16390
|
+
var v = y / vertical;
|
|
16391
|
+
var radius = radiusBottom + (radiusTop - radiusBottom) * v;
|
|
16392
|
+
for(var x = 0; x <= radial; x++){
|
|
16393
|
+
var u = x / radial;
|
|
16394
|
+
var cos = circle[x * 2];
|
|
16395
|
+
var sin = circle[x * 2 + 1];
|
|
16396
|
+
data.addVertex(radius * sin, (v - 0.5) * height, radius * cos, sin, slope, cos, u, 1 - v);
|
|
16397
|
+
}
|
|
16398
|
+
}
|
|
16399
|
+
for(var y1 = 0; y1 < vertical; y1++){
|
|
16400
|
+
for(var x1 = 0; x1 < radial; x1++){
|
|
16401
|
+
var a = y1 * (radial + 1) + x1;
|
|
16402
|
+
var c = a + radial + 1;
|
|
16403
|
+
if (radiusBottom !== 0 || y1 !== 0) {
|
|
16404
|
+
data.addTriangle(a + 1, c, a);
|
|
16405
|
+
}
|
|
16406
|
+
if (radiusTop !== 0 || y1 !== vertical - 1) {
|
|
16407
|
+
data.addTriangle(a + 1, c + 1, c);
|
|
16408
|
+
}
|
|
16409
|
+
}
|
|
16410
|
+
}
|
|
16411
|
+
data.addGroup(0);
|
|
16412
|
+
var capStart = data.indexCount;
|
|
16413
|
+
// Interleave ungrouped caps to preserve transparent blending order
|
|
16414
|
+
var interleaveCaps = capCount === 2 && !separateMaterialSlots;
|
|
16415
|
+
if (includeTopCap) {
|
|
16416
|
+
cap(radiusTop, 1);
|
|
16417
|
+
}
|
|
16418
|
+
if (includeBottomCap) {
|
|
16419
|
+
cap(radiusBottom, -1);
|
|
16420
|
+
}
|
|
16421
|
+
if (interleaveCaps) {
|
|
16422
|
+
data.addGroup(capStart);
|
|
16423
|
+
}
|
|
16424
|
+
data.boundsExtent = new Vector3(Math.max(radiusTop, radiusBottom), height / 2, Math.max(radiusTop, radiusBottom));
|
|
16425
|
+
return data;
|
|
16426
|
+
function cap(radius, sign) {
|
|
16427
|
+
if (radius === 0) {
|
|
16428
|
+
return;
|
|
16429
|
+
}
|
|
16430
|
+
var start = data.indexCount;
|
|
16431
|
+
var center = data.addVertex(0, sign * height / 2, 0, 0, sign, 0, 0.5, 0.5);
|
|
16432
|
+
var rowStart = sign > 0 ? vertical * (radial + 1) : 0;
|
|
16433
|
+
var inverseDiameter = 1 / (2 * radius);
|
|
16434
|
+
// A partial cap includes both endpoints; a full cap reuses its first rim vertex
|
|
16435
|
+
var rimCount = full ? radial : radial + 1;
|
|
16436
|
+
for(var x = 0; x < rimCount; x++){
|
|
16437
|
+
var offset = (rowStart + x) * 8;
|
|
16438
|
+
var positionX = data.vertices[offset];
|
|
16439
|
+
var positionZ = data.vertices[offset + 2];
|
|
16440
|
+
data.addVertex(positionX, sign * height / 2, positionZ, 0, sign, 0, positionX * inverseDiameter + 0.5, 0.5 - positionZ * inverseDiameter);
|
|
16441
|
+
}
|
|
16442
|
+
var indexOffset = interleaveCaps ? capStart + (sign > 0 ? 3 : 0) : start;
|
|
16443
|
+
var indexStride = interleaveCaps ? 6 : 3;
|
|
16444
|
+
for(var x1 = 0; x1 < radial; x1++){
|
|
16445
|
+
var current = center + x1 + 1;
|
|
16446
|
+
var next = full && x1 === radial - 1 ? center + 1 : current + 1;
|
|
16447
|
+
data.indices[indexOffset] = center;
|
|
16448
|
+
data.indices[indexOffset + 1] = sign > 0 ? current : next;
|
|
16449
|
+
data.indices[indexOffset + 2] = sign > 0 ? next : current;
|
|
16450
|
+
indexOffset += indexStride;
|
|
16451
|
+
}
|
|
16452
|
+
data.indexCount += radial * 3;
|
|
16453
|
+
if (!interleaveCaps) {
|
|
16454
|
+
data.addGroup(start);
|
|
16455
|
+
}
|
|
16456
|
+
}
|
|
16457
|
+
};
|
|
16458
|
+
PrimitiveMesh._createCapsuleData = function _createCapsuleData(radius, cylinderHeight, radialSegments, capSegments, heightSegments) {
|
|
16459
|
+
var radial = PrimitiveMesh._getSegmentCount(radialSegments, 3);
|
|
16460
|
+
var caps = PrimitiveMesh._getSegmentCount(capSegments);
|
|
16461
|
+
var vertical = PrimitiveMesh._getSegmentCount(heightSegments);
|
|
16462
|
+
var rows = caps * 2 + vertical;
|
|
16463
|
+
var circle = PrimitiveMesh._createArcSamples(radial, Math.PI);
|
|
16464
|
+
var capLength = Math.PI * radius / 2;
|
|
16465
|
+
var totalLength = capLength * 2 + cylinderHeight;
|
|
16466
|
+
var data = new PrimitiveMeshBuilder((radial + 1) * (rows + 1), radial * (rows - 1) * 6);
|
|
16467
|
+
for(var y = 0; y <= rows; y++){
|
|
16468
|
+
var py = void 0;
|
|
16469
|
+
var ringRadius = void 0;
|
|
16470
|
+
var ny = void 0;
|
|
16471
|
+
var distance = void 0;
|
|
16472
|
+
if (y <= caps) {
|
|
16473
|
+
var angle = y / caps * Math.PI / 2;
|
|
16474
|
+
ringRadius = radius * Math.sin(angle);
|
|
16475
|
+
ny = -Math.cos(angle);
|
|
16476
|
+
py = -cylinderHeight / 2 + radius * ny;
|
|
16477
|
+
distance = y / caps * capLength;
|
|
16478
|
+
} else if (y <= caps + vertical) {
|
|
16479
|
+
ringRadius = radius;
|
|
16480
|
+
ny = 0;
|
|
16481
|
+
py = -cylinderHeight / 2 + (y - caps) / vertical * cylinderHeight;
|
|
16482
|
+
distance = capLength + (y - caps) / vertical * cylinderHeight;
|
|
16483
|
+
} else {
|
|
16484
|
+
var angle1 = (y - caps - vertical) / caps * Math.PI / 2;
|
|
16485
|
+
ringRadius = radius * Math.cos(angle1);
|
|
16486
|
+
ny = Math.sin(angle1);
|
|
16487
|
+
py = cylinderHeight / 2 + radius * ny;
|
|
16488
|
+
distance = capLength + cylinderHeight + (y - caps - vertical) / caps * capLength;
|
|
16489
|
+
}
|
|
16490
|
+
var normalRadius = Math.sqrt(Math.max(0, 1 - ny * ny));
|
|
16491
|
+
// Center pole UVs between the other two vertices of each triangle
|
|
16492
|
+
var offset = y === 0 ? -0.5 / radial : y === rows ? 0.5 / radial : 0;
|
|
16493
|
+
for(var x = 0; x <= radial; x++){
|
|
16494
|
+
var cos = circle[x * 2];
|
|
16495
|
+
var sin = circle[x * 2 + 1];
|
|
16496
|
+
data.addVertex(ringRadius * sin, py, ringRadius * cos, sin * normalRadius, ny, cos * normalRadius, x / radial + offset, totalLength > 0 ? 1 - distance / totalLength : 0);
|
|
16497
|
+
}
|
|
16498
|
+
}
|
|
16499
|
+
for(var y1 = 0; y1 < rows; y1++){
|
|
16500
|
+
for(var x1 = 0; x1 < radial; x1++){
|
|
16501
|
+
var a = y1 * (radial + 1) + x1;
|
|
16502
|
+
var c = a + radial + 1;
|
|
16503
|
+
if (y1 !== 0) {
|
|
16504
|
+
data.addTriangle(a + 1, c, a);
|
|
16505
|
+
}
|
|
16506
|
+
if (y1 !== rows - 1) {
|
|
16507
|
+
data.addTriangle(a + 1, c + 1, c);
|
|
16508
|
+
}
|
|
16509
|
+
}
|
|
16510
|
+
}
|
|
16511
|
+
data.boundsExtent = new Vector3(radius, cylinderHeight / 2 + radius, radius);
|
|
16512
|
+
return data;
|
|
15039
16513
|
};
|
|
15040
|
-
|
|
15041
|
-
|
|
15042
|
-
|
|
15043
|
-
|
|
15044
|
-
|
|
15045
|
-
|
|
15046
|
-
|
|
15047
|
-
|
|
15048
|
-
|
|
15049
|
-
|
|
15050
|
-
|
|
15051
|
-
|
|
15052
|
-
|
|
15053
|
-
|
|
15054
|
-
|
|
15055
|
-
|
|
15056
|
-
|
|
15057
|
-
|
|
15058
|
-
|
|
15059
|
-
|
|
15060
|
-
|
|
15061
|
-
|
|
16514
|
+
PrimitiveMesh._createTorusData = function _createTorusData(radius, tubeRadius, radialSegments, ringSegments, arcDegrees, tubeStartAngleDegrees, tubeArcDegrees, startAngleDegrees) {
|
|
16515
|
+
var radial = PrimitiveMesh._getSegmentCount(radialSegments, 3);
|
|
16516
|
+
var tubular = PrimitiveMesh._getSegmentCount(ringSegments, 1);
|
|
16517
|
+
var arc = MathUtil.degreeToRadian(arcDegrees);
|
|
16518
|
+
var tubeStart = MathUtil.degreeToRadian(tubeStartAngleDegrees);
|
|
16519
|
+
var tubeArc = MathUtil.degreeToRadian(tubeArcDegrees);
|
|
16520
|
+
var circle = PrimitiveMesh._createArcSamples(tubular, MathUtil.degreeToRadian(startAngleDegrees), arc);
|
|
16521
|
+
var data = new PrimitiveMeshBuilder((radial + 1) * (tubular + 1), radial * tubular * 6);
|
|
16522
|
+
for(var y = 0; y <= radial; y++){
|
|
16523
|
+
var v = tubeStart + y / radial * tubeArc;
|
|
16524
|
+
var cosV = Math.cos(v);
|
|
16525
|
+
var nz = Math.sin(v);
|
|
16526
|
+
for(var x = 0; x <= tubular; x++){
|
|
16527
|
+
var cosU = circle[x * 2];
|
|
16528
|
+
var sinU = circle[x * 2 + 1];
|
|
16529
|
+
var nx = cosV * cosU;
|
|
16530
|
+
var ny = cosV * sinU;
|
|
16531
|
+
data.addVertex(radius * cosU + tubeRadius * nx, radius * sinU + tubeRadius * ny, tubeRadius * nz, nx, ny, nz, x / tubular, y / radial);
|
|
16532
|
+
}
|
|
16533
|
+
}
|
|
16534
|
+
for(var y1 = 0; y1 < radial; y1++){
|
|
16535
|
+
for(var x1 = 0; x1 < tubular; x1++){
|
|
16536
|
+
var a = y1 * (tubular + 1) + x1;
|
|
16537
|
+
var c = a + tubular + 1;
|
|
16538
|
+
data.addTriangle(c, a, c + 1);
|
|
16539
|
+
data.addTriangle(a, a + 1, c + 1);
|
|
16540
|
+
}
|
|
16541
|
+
}
|
|
16542
|
+
data.boundsExtent = new Vector3(radius + tubeRadius, radius + tubeRadius, tubeRadius);
|
|
16543
|
+
return data;
|
|
15062
16544
|
};
|
|
15063
|
-
|
|
15064
|
-
|
|
15065
|
-
|
|
15066
|
-
|
|
15067
|
-
|
|
15068
|
-
|
|
15069
|
-
|
|
15070
|
-
|
|
15071
|
-
|
|
15072
|
-
|
|
15073
|
-
|
|
15074
|
-
|
|
15075
|
-
|
|
15076
|
-
|
|
15077
|
-
|
|
15078
|
-
|
|
15079
|
-
PrimitiveMesh._setConeData(mesh, radius, height, radialSegments, heightSegments, noLongerAccessible, false);
|
|
15080
|
-
var vertexBuffer = mesh.vertexBufferBindings[0].buffer;
|
|
15081
|
-
engine.resourceManager.addContentRestorer(new PrimitiveMeshRestorer(mesh, new ConeRestoreInfo(radius, height, radialSegments, heightSegments, vertexBuffer, noLongerAccessible)));
|
|
15082
|
-
return mesh;
|
|
16545
|
+
PrimitiveMesh._createCircleData = function _createCircleData(radius, segments, startAngle, arcDegrees) {
|
|
16546
|
+
var count = PrimitiveMesh._getSegmentCount(segments, 3);
|
|
16547
|
+
var start = MathUtil.degreeToRadian(startAngle);
|
|
16548
|
+
var arc = MathUtil.degreeToRadian(arcDegrees);
|
|
16549
|
+
var data = new PrimitiveMeshBuilder(count + 2, count * 3);
|
|
16550
|
+
data.addVertex(0, 0, 0, 0, 0, 1, 0.5, 0.5);
|
|
16551
|
+
for(var i = 0; i <= count; i++){
|
|
16552
|
+
var angle = start + i / count * arc;
|
|
16553
|
+
var x = Math.cos(angle);
|
|
16554
|
+
var y = Math.sin(angle);
|
|
16555
|
+
data.addVertex(radius * x, radius * y, 0, 0, 0, 1, (x + 1) / 2, (y + 1) / 2);
|
|
16556
|
+
if (i > 0) {
|
|
16557
|
+
data.addTriangle(0, i, i + 1);
|
|
16558
|
+
}
|
|
16559
|
+
}
|
|
16560
|
+
return data;
|
|
15083
16561
|
};
|
|
15084
|
-
|
|
15085
|
-
|
|
15086
|
-
|
|
15087
|
-
|
|
15088
|
-
|
|
15089
|
-
|
|
15090
|
-
|
|
15091
|
-
|
|
15092
|
-
|
|
15093
|
-
|
|
15094
|
-
|
|
15095
|
-
|
|
15096
|
-
|
|
15097
|
-
|
|
15098
|
-
|
|
15099
|
-
var
|
|
15100
|
-
|
|
15101
|
-
|
|
15102
|
-
|
|
15103
|
-
|
|
16562
|
+
PrimitiveMesh._createRingData = function _createRingData(innerRadius, outerRadius, ringSegments, widthSegments, startAngle, arcDegrees) {
|
|
16563
|
+
var radial = PrimitiveMesh._getSegmentCount(ringSegments, 3);
|
|
16564
|
+
var width = PrimitiveMesh._getSegmentCount(widthSegments);
|
|
16565
|
+
var start = MathUtil.degreeToRadian(startAngle);
|
|
16566
|
+
var arc = MathUtil.degreeToRadian(arcDegrees);
|
|
16567
|
+
var circle = PrimitiveMesh._createArcSamples(radial, start, arc);
|
|
16568
|
+
var data = new PrimitiveMeshBuilder((radial + 1) * (width + 1), radial * width * 6);
|
|
16569
|
+
for(var y = 0; y <= width; y++){
|
|
16570
|
+
var radius = innerRadius + (outerRadius - innerRadius) * y / width;
|
|
16571
|
+
for(var x = 0; x <= radial; x++){
|
|
16572
|
+
var px = radius * circle[x * 2];
|
|
16573
|
+
var py = radius * circle[x * 2 + 1];
|
|
16574
|
+
data.addVertex(px, py, 0, 0, 0, 1, outerRadius !== 0 ? (px / outerRadius + 1) / 2 : 0.5, outerRadius !== 0 ? (py / outerRadius + 1) / 2 : 0.5);
|
|
16575
|
+
}
|
|
16576
|
+
}
|
|
16577
|
+
for(var y1 = 0; y1 < width; y1++){
|
|
16578
|
+
for(var x1 = 0; x1 < radial; x1++){
|
|
16579
|
+
var a = y1 * (radial + 1) + x1;
|
|
16580
|
+
var c = a + radial + 1;
|
|
16581
|
+
data.addTriangle(a, c, a + 1);
|
|
16582
|
+
data.addTriangle(a + 1, c, c + 1);
|
|
16583
|
+
}
|
|
16584
|
+
}
|
|
16585
|
+
return data;
|
|
15104
16586
|
};
|
|
15105
|
-
|
|
15106
|
-
|
|
15107
|
-
|
|
15108
|
-
|
|
15109
|
-
|
|
15110
|
-
var
|
|
15111
|
-
var
|
|
15112
|
-
PrimitiveMesh.
|
|
16587
|
+
PrimitiveMesh._createRoundedCuboidData = function _createRoundedCuboidData(width, height, depth, cornerRadius, roundingSegments) {
|
|
16588
|
+
var radius = Math.max(0, Math.min(cornerRadius, width / 2, height / 2, depth / 2));
|
|
16589
|
+
if (radius === 0) {
|
|
16590
|
+
return PrimitiveMesh._createCuboidData(width, height, depth, 1, 1, 1);
|
|
16591
|
+
}
|
|
16592
|
+
var cornerSegments = PrimitiveMesh._getSegmentCount(roundingSegments);
|
|
16593
|
+
var count = cornerSegments * 2 + 1;
|
|
16594
|
+
var data = PrimitiveMesh._createCuboidData(width, height, depth, count, count, count);
|
|
16595
|
+
var inner = new Vector3(width / 2 - radius, height / 2 - radius, depth / 2 - radius);
|
|
16596
|
+
var center = new Vector3();
|
|
16597
|
+
var delta = new Vector3();
|
|
16598
|
+
var components = [
|
|
16599
|
+
"x",
|
|
16600
|
+
"y",
|
|
16601
|
+
"z"
|
|
16602
|
+
];
|
|
16603
|
+
var uvAxes = {
|
|
16604
|
+
x: [
|
|
16605
|
+
"z",
|
|
16606
|
+
"y"
|
|
16607
|
+
],
|
|
16608
|
+
y: [
|
|
16609
|
+
"x",
|
|
16610
|
+
"z"
|
|
16611
|
+
],
|
|
16612
|
+
z: [
|
|
16613
|
+
"x",
|
|
16614
|
+
"y"
|
|
16615
|
+
]
|
|
16616
|
+
};
|
|
16617
|
+
for(var i = 0; i < data.vertexCount * 8; i += 8){
|
|
16618
|
+
var faceAxis = data.vertices[i + 3] !== 0 ? "x" : data.vertices[i + 4] !== 0 ? "y" : "z";
|
|
16619
|
+
for(var axis = 0; axis < 3; axis++){
|
|
16620
|
+
var component = components[axis];
|
|
16621
|
+
var halfSize = inner[component] + radius;
|
|
16622
|
+
var gridIndex = Math.round((data.vertices[i + axis] / halfSize + 1) / 2 * count);
|
|
16623
|
+
var p = gridIndex <= cornerSegments ? -inner[component] - radius * (1 - gridIndex / cornerSegments) : inner[component] + radius * (gridIndex - cornerSegments - 1) / cornerSegments;
|
|
16624
|
+
center[component] = Math.max(-inner[component], Math.min(inner[component], p));
|
|
16625
|
+
delta[component] = p - center[component];
|
|
16626
|
+
}
|
|
16627
|
+
var length = Math.hypot(delta.x, delta.y, delta.z);
|
|
16628
|
+
for(var axis1 = 0; axis1 < 3; axis1++){
|
|
16629
|
+
var component1 = components[axis1];
|
|
16630
|
+
var n = delta[component1] / length;
|
|
16631
|
+
data.vertices[i + axis1] = center[component1] + n * radius;
|
|
16632
|
+
data.vertices[i + 3 + axis1] = n;
|
|
16633
|
+
}
|
|
16634
|
+
for(var uv = 0; uv < 2; uv++){
|
|
16635
|
+
var component2 = uvAxes[faceAxis][uv];
|
|
16636
|
+
var angle = Math.atan2(Math.abs(delta[component2]), Math.abs(delta[faceAxis]));
|
|
16637
|
+
var distance = Math.abs(center[component2]) + radius * angle;
|
|
16638
|
+
var surfaceLength = inner[component2] * 2 + Math.PI * radius / 2;
|
|
16639
|
+
var direction = Math.sign(data.vertices[i + 6 + uv] - 0.5);
|
|
16640
|
+
data.vertices[i + 6 + uv] = 0.5 + direction * distance / surfaceLength;
|
|
16641
|
+
}
|
|
16642
|
+
}
|
|
16643
|
+
return data;
|
|
16644
|
+
};
|
|
16645
|
+
PrimitiveMesh._createRevolvedSurfaceData = function _createRevolvedSurfaceData(points, segmentCount, startAngle, arcDegrees) {
|
|
16646
|
+
if (points.length < 2) {
|
|
16647
|
+
throw new Error("A revolved surface profile needs at least two points.");
|
|
16648
|
+
}
|
|
16649
|
+
var count = PrimitiveMesh._getSegmentCount(segmentCount);
|
|
16650
|
+
var start = MathUtil.degreeToRadian(startAngle);
|
|
16651
|
+
var arc = MathUtil.degreeToRadian(arcDegrees);
|
|
16652
|
+
var data = new PrimitiveMeshBuilder((count + 1) * points.length, count * (points.length - 1) * 6);
|
|
16653
|
+
var normals = [];
|
|
16654
|
+
for(var i = 0; i < points.length; i++){
|
|
16655
|
+
var previous = points[Math.max(0, i - 1)];
|
|
16656
|
+
var current = points[i];
|
|
16657
|
+
var next = points[Math.min(points.length - 1, i + 1)];
|
|
16658
|
+
var a = PrimitiveMesh._normalizeVector(new Vector3(current.y - previous.y, previous.x - current.x, 0));
|
|
16659
|
+
var b = PrimitiveMesh._normalizeVector(new Vector3(next.y - current.y, current.x - next.x, 0));
|
|
16660
|
+
normals.push(PrimitiveMesh._normalizeVector(a.add(b)));
|
|
16661
|
+
}
|
|
16662
|
+
for(var x = 0; x <= count; x++){
|
|
16663
|
+
var angle = start + x / count * arc;
|
|
16664
|
+
var sin = Math.sin(angle);
|
|
16665
|
+
var cos = Math.cos(angle);
|
|
16666
|
+
for(var y = 0; y < points.length; y++){
|
|
16667
|
+
var point = points[y];
|
|
16668
|
+
var normal = normals[y];
|
|
16669
|
+
data.addVertex(point.x * sin, point.y, point.x * cos, normal.x * sin, normal.y, normal.x * cos, x / count, y / (points.length - 1));
|
|
16670
|
+
}
|
|
16671
|
+
}
|
|
16672
|
+
for(var x1 = 0; x1 < count; x1++){
|
|
16673
|
+
for(var y1 = 0; y1 < points.length - 1; y1++){
|
|
16674
|
+
var a1 = x1 * points.length + y1;
|
|
16675
|
+
var b1 = a1 + points.length;
|
|
16676
|
+
if (points[y1].x !== 0) {
|
|
16677
|
+
data.addTriangle(a1, b1, a1 + 1);
|
|
16678
|
+
}
|
|
16679
|
+
if (points[y1 + 1].x !== 0) {
|
|
16680
|
+
data.addTriangle(b1, b1 + 1, a1 + 1);
|
|
16681
|
+
}
|
|
16682
|
+
}
|
|
16683
|
+
}
|
|
16684
|
+
return data;
|
|
16685
|
+
};
|
|
16686
|
+
PrimitiveMesh._createTubeData = function _createTubeData(path, radius, pathSegments, radialSegments, closedPath) {
|
|
16687
|
+
var tangents = [];
|
|
16688
|
+
var points = MeshPathUtils.sample(path, PrimitiveMesh._getSegmentCount(pathSegments), closedPath, tangents);
|
|
16689
|
+
return PrimitiveMesh._createTubeSurfaceData(points, radius, radialSegments, closedPath, tangents);
|
|
16690
|
+
};
|
|
16691
|
+
PrimitiveMesh._createTubeSurfaceData = function _createTubeSurfaceData(points, radius, radialSegments, closedPath, fallbackTangents) {
|
|
16692
|
+
var count = points.length - 1;
|
|
16693
|
+
var radial = PrimitiveMesh._getSegmentCount(radialSegments, 3);
|
|
16694
|
+
var frames = MeshPathUtils.computeFrames(points, closedPath, fallbackTangents);
|
|
16695
|
+
var data = new PrimitiveMeshBuilder((count + 1) * (radial + 1), count * radial * 6);
|
|
16696
|
+
var circle = PrimitiveMesh._createArcSamples(radial);
|
|
16697
|
+
for(var y = 0; y <= count; y++){
|
|
16698
|
+
var point = points[y];
|
|
16699
|
+
var normal = frames.normals[y];
|
|
16700
|
+
var binormal = frames.binormals[y];
|
|
16701
|
+
for(var x = 0; x <= radial; x++){
|
|
16702
|
+
var c = circle[x * 2];
|
|
16703
|
+
var s = circle[x * 2 + 1];
|
|
16704
|
+
var nx = normal.x * c + binormal.x * s;
|
|
16705
|
+
var ny = normal.y * c + binormal.y * s;
|
|
16706
|
+
var nz = normal.z * c + binormal.z * s;
|
|
16707
|
+
data.addVertex(point.x + radius * nx, point.y + radius * ny, point.z + radius * nz, nx, ny, nz, y / count, x / radial);
|
|
16708
|
+
}
|
|
16709
|
+
}
|
|
16710
|
+
for(var y1 = 0; y1 < count; y1++){
|
|
16711
|
+
for(var x1 = 0; x1 < radial; x1++){
|
|
16712
|
+
var a = y1 * (radial + 1) + x1;
|
|
16713
|
+
var c1 = a + radial + 1;
|
|
16714
|
+
data.addTriangle(a, a + 1, c1);
|
|
16715
|
+
data.addTriangle(a + 1, c1 + 1, c1);
|
|
16716
|
+
}
|
|
16717
|
+
}
|
|
16718
|
+
return data;
|
|
16719
|
+
};
|
|
16720
|
+
PrimitiveMesh._createTorusKnotData = function _createTorusKnotData(radius, tubeRadius, pathSegments, radialSegments, axisTurns, crossSectionTurns) {
|
|
16721
|
+
if (axisTurns === 0 && crossSectionTurns === 0) {
|
|
16722
|
+
throw new Error("A torus knot needs at least one nonzero winding.");
|
|
16723
|
+
}
|
|
16724
|
+
var count = PrimitiveMesh._getSegmentCount(pathSegments);
|
|
16725
|
+
var points = [];
|
|
16726
|
+
var tangents = [];
|
|
16727
|
+
for(var i = 0; i < count; i++){
|
|
16728
|
+
var angle = i / count * Math.PI * 2;
|
|
16729
|
+
var u = axisTurns * angle;
|
|
16730
|
+
var v = crossSectionTurns * angle;
|
|
16731
|
+
points.push(new Vector3(radius * (2 + Math.cos(v)) * Math.cos(u) / 2, radius * (2 + Math.cos(v)) * Math.sin(u) / 2, radius * Math.sin(v) / 2));
|
|
16732
|
+
var radialDerivative = -crossSectionTurns * Math.sin(v);
|
|
16733
|
+
var angularDerivative = axisTurns * (2 + Math.cos(v));
|
|
16734
|
+
tangents.push(new Vector3(radialDerivative * Math.cos(u) - angularDerivative * Math.sin(u), radialDerivative * Math.sin(u) + angularDerivative * Math.cos(u), crossSectionTurns * Math.cos(v)));
|
|
16735
|
+
}
|
|
16736
|
+
points.push(points[0]);
|
|
16737
|
+
tangents.push(tangents[0]);
|
|
16738
|
+
return PrimitiveMesh._createTubeSurfaceData(points, tubeRadius, radialSegments, true, tangents);
|
|
16739
|
+
};
|
|
16740
|
+
PrimitiveMesh._createRegularPolyhedronData = function _createRegularPolyhedronData(type, radius, segments) {
|
|
16741
|
+
var _PrimitiveMesh__regularPolyhedra_type = PrimitiveMesh._regularPolyhedra[type], positions = _PrimitiveMesh__regularPolyhedra_type[0], indices = _PrimitiveMesh__regularPolyhedra_type[1];
|
|
16742
|
+
var divisions = PrimitiveMesh._getSegmentCount(segments);
|
|
16743
|
+
var vertexCount = indices.length * divisions * divisions;
|
|
16744
|
+
var data = new PrimitiveMeshBuilder(vertexCount, vertexCount);
|
|
16745
|
+
var vertices = new Float64Array((divisions + 1) * (divisions + 2) * 8 / 2);
|
|
16746
|
+
var left = new Vector3();
|
|
16747
|
+
var right = new Vector3();
|
|
16748
|
+
var point = new Vector3();
|
|
16749
|
+
for(var face = 0; face < indices.length; face += 3){
|
|
16750
|
+
var offset = 0;
|
|
16751
|
+
for(var i = 0; i <= divisions; i++){
|
|
16752
|
+
left.copyFromArray(positions, indices[face] * 3);
|
|
16753
|
+
right.copyFromArray(positions, indices[face + 1] * 3);
|
|
16754
|
+
point.copyFromArray(positions, indices[face + 2] * 3);
|
|
16755
|
+
Vector3.lerp(left, point, i / divisions, left);
|
|
16756
|
+
Vector3.lerp(right, point, i / divisions, right);
|
|
16757
|
+
for(var j = 0; j <= divisions - i; j++){
|
|
16758
|
+
Vector3.lerp(left, right, divisions === i ? 0 : j / (divisions - i), point);
|
|
16759
|
+
PrimitiveMesh._normalizeVector(point);
|
|
16760
|
+
vertices[offset] = point.x * radius;
|
|
16761
|
+
vertices[offset + 1] = point.y * radius;
|
|
16762
|
+
vertices[offset + 2] = point.z * radius;
|
|
16763
|
+
point.copyToArray(vertices, offset + 3);
|
|
16764
|
+
vertices[offset + 6] = Math.atan2(point.z, -point.x) / (2 * Math.PI) + 0.5;
|
|
16765
|
+
vertices[offset + 7] = Math.acos(Math.max(-1, Math.min(1, point.y))) / Math.PI;
|
|
16766
|
+
offset += 8;
|
|
16767
|
+
}
|
|
16768
|
+
}
|
|
16769
|
+
var row = 0;
|
|
16770
|
+
for(var i1 = 0; i1 < divisions; i1++){
|
|
16771
|
+
var next = row + divisions - i1 + 1;
|
|
16772
|
+
for(var j1 = 0; j1 < divisions - i1; j1++){
|
|
16773
|
+
PrimitiveMesh._addPolyhedronFace(data, vertices, (row + j1 + 1) * 8, (next + j1) * 8, (row + j1) * 8, divisions === 1);
|
|
16774
|
+
if (j1 < divisions - i1 - 1) {
|
|
16775
|
+
PrimitiveMesh._addPolyhedronFace(data, vertices, (row + j1 + 1) * 8, (next + j1 + 1) * 8, (next + j1) * 8, divisions === 1);
|
|
16776
|
+
}
|
|
16777
|
+
}
|
|
16778
|
+
row = next;
|
|
16779
|
+
}
|
|
16780
|
+
}
|
|
16781
|
+
return data;
|
|
16782
|
+
};
|
|
16783
|
+
PrimitiveMesh._addPolyhedronFace = function _addPolyhedronFace(data, vertices, a, b, c, flat) {
|
|
16784
|
+
var uA = vertices[a + 6];
|
|
16785
|
+
var uB = vertices[b + 6];
|
|
16786
|
+
var uC = vertices[c + 6];
|
|
16787
|
+
var poleA = Math.abs(vertices[a + 4]) > 1 - 1e-10;
|
|
16788
|
+
var poleB = Math.abs(vertices[b + 4]) > 1 - 1e-10;
|
|
16789
|
+
var poleC = Math.abs(vertices[c + 4]) > 1 - 1e-10;
|
|
16790
|
+
if (poleA) {
|
|
16791
|
+
uA = uB;
|
|
16792
|
+
}
|
|
16793
|
+
if (poleB) {
|
|
16794
|
+
uB = uC;
|
|
16795
|
+
}
|
|
16796
|
+
if (poleC) {
|
|
16797
|
+
uC = uA;
|
|
16798
|
+
}
|
|
16799
|
+
var minU = Math.min(uA, uB, uC);
|
|
16800
|
+
var maxU = Math.max(uA, uB, uC);
|
|
16801
|
+
var middleU = uA === minU ? Math.min(uB, uC) : uB === minU ? Math.min(uA, uC) : Math.min(uA, uB);
|
|
16802
|
+
// Choose the shortest U interval before averaging pole coordinates
|
|
16803
|
+
var gap = 1 + minU - maxU;
|
|
16804
|
+
var startU = minU;
|
|
16805
|
+
if (middleU - minU > gap) {
|
|
16806
|
+
gap = middleU - minU;
|
|
16807
|
+
startU = middleU;
|
|
16808
|
+
}
|
|
16809
|
+
if (maxU - middleU > gap) {
|
|
16810
|
+
startU = maxU;
|
|
16811
|
+
}
|
|
16812
|
+
if (uA < startU) {
|
|
16813
|
+
uA += 1;
|
|
16814
|
+
}
|
|
16815
|
+
if (uB < startU) {
|
|
16816
|
+
uB += 1;
|
|
16817
|
+
}
|
|
16818
|
+
if (uC < startU) {
|
|
16819
|
+
uC += 1;
|
|
16820
|
+
}
|
|
16821
|
+
if (poleA) {
|
|
16822
|
+
uA = (uB + uC) / 2;
|
|
16823
|
+
}
|
|
16824
|
+
if (poleB) {
|
|
16825
|
+
uB = (uC + uA) / 2;
|
|
16826
|
+
}
|
|
16827
|
+
if (poleC) {
|
|
16828
|
+
uC = (uA + uB) / 2;
|
|
16829
|
+
}
|
|
16830
|
+
var nx = 0;
|
|
16831
|
+
var ny = 0;
|
|
16832
|
+
var nz = 0;
|
|
16833
|
+
if (flat) {
|
|
16834
|
+
var abX = vertices[b] - vertices[a];
|
|
16835
|
+
var abY = vertices[b + 1] - vertices[a + 1];
|
|
16836
|
+
var abZ = vertices[b + 2] - vertices[a + 2];
|
|
16837
|
+
var acX = vertices[c] - vertices[a];
|
|
16838
|
+
var acY = vertices[c + 1] - vertices[a + 1];
|
|
16839
|
+
var acZ = vertices[c + 2] - vertices[a + 2];
|
|
16840
|
+
nx = abY * acZ - abZ * acY;
|
|
16841
|
+
ny = abZ * acX - abX * acZ;
|
|
16842
|
+
nz = abX * acY - abY * acX;
|
|
16843
|
+
var length = Math.hypot(nx, ny, nz);
|
|
16844
|
+
var inverse = length > 0 ? 1 / length : 0;
|
|
16845
|
+
nx *= inverse;
|
|
16846
|
+
ny *= inverse;
|
|
16847
|
+
nz *= inverse;
|
|
16848
|
+
}
|
|
16849
|
+
var start = data.vertexCount;
|
|
16850
|
+
for(var i = 0; i < 3; i++){
|
|
16851
|
+
var offset = i === 0 ? a : i === 1 ? b : c;
|
|
16852
|
+
data.addVertex(vertices[offset], vertices[offset + 1], vertices[offset + 2], flat ? nx : vertices[offset + 3], flat ? ny : vertices[offset + 4], flat ? nz : vertices[offset + 5], i === 0 ? uA : i === 1 ? uB : uC, vertices[offset + 7]);
|
|
16853
|
+
}
|
|
16854
|
+
data.addTriangle(start, start + 1, start + 2);
|
|
16855
|
+
};
|
|
16856
|
+
PrimitiveMesh._createPolygonData = function _createPolygonData(shapes) {
|
|
16857
|
+
var data = new PrimitiveMeshBuilder();
|
|
16858
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(shapes), _step; !(_step = _iterator()).done;){
|
|
16859
|
+
var polygon = _step.value;
|
|
16860
|
+
var contours = PolygonUtils.prepareContours(polygon);
|
|
16861
|
+
var _PolygonUtils_triangulateContours = PolygonUtils.triangulateContours(contours), points = _PolygonUtils_triangulateContours.points, indices = _PolygonUtils_triangulateContours.indices;
|
|
16862
|
+
var base = data.vertexCount;
|
|
16863
|
+
var start = data.indexCount;
|
|
16864
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(points), _step1; !(_step1 = _iterator1()).done;){
|
|
16865
|
+
var point = _step1.value;
|
|
16866
|
+
data.addVertex(point.x, point.y, 0, 0, 0, 1, point.x, point.y);
|
|
16867
|
+
}
|
|
16868
|
+
for(var _iterator2 = _create_for_of_iterator_helper_loose(indices), _step2; !(_step2 = _iterator2()).done;){
|
|
16869
|
+
var index = _step2.value;
|
|
16870
|
+
data.addIndex(base + index);
|
|
16871
|
+
}
|
|
16872
|
+
data.addGroup(start);
|
|
16873
|
+
}
|
|
16874
|
+
return data;
|
|
16875
|
+
};
|
|
16876
|
+
PrimitiveMesh._createExtrudedPolygonData = function _createExtrudedPolygonData(shapes, depth, stepCount, pathInput, closedPath, bevelDepth, bevelWidth, contourOffset, bevelSegmentCount) {
|
|
16877
|
+
var data = new PrimitiveMeshBuilder();
|
|
16878
|
+
var steps = PrimitiveMesh._getSegmentCount(stepCount, closedPath ? 3 : 1);
|
|
16879
|
+
var tangents = [];
|
|
16880
|
+
var path = pathInput ? MeshPathUtils.sample(pathInput, steps, closedPath, tangents) : undefined;
|
|
16881
|
+
var frames = path ? MeshPathUtils.computeFrames(path, closedPath, tangents) : undefined;
|
|
16882
|
+
var bevelEnabled = !path && bevelWidth > 0;
|
|
16883
|
+
var bevelSegments = bevelEnabled ? PrimitiveMesh._getSegmentCount(bevelSegmentCount) : 0;
|
|
16884
|
+
var thickness = bevelEnabled ? Math.min(bevelDepth, depth / 2) : 0;
|
|
16885
|
+
var size = bevelEnabled ? bevelWidth : 0;
|
|
16886
|
+
var offset = path ? 0 : contourOffset;
|
|
16887
|
+
var layers = [];
|
|
16888
|
+
var uvA = new Vector2();
|
|
16889
|
+
var uvB = new Vector2();
|
|
16890
|
+
var uvC = new Vector2();
|
|
16891
|
+
var uvD = new Vector2();
|
|
16892
|
+
for(var i = 0; i < bevelSegments; i++){
|
|
16893
|
+
var angle = i / bevelSegments * Math.PI / 2;
|
|
16894
|
+
layers.push({
|
|
16895
|
+
z: thickness * (1 - Math.cos(angle)),
|
|
16896
|
+
inset: size * (1 - Math.sin(angle))
|
|
16897
|
+
});
|
|
16898
|
+
}
|
|
16899
|
+
for(var i1 = 0; i1 <= steps; i1++){
|
|
16900
|
+
layers.push({
|
|
16901
|
+
z: thickness + (depth - thickness * 2) * i1 / steps,
|
|
16902
|
+
inset: 0
|
|
16903
|
+
});
|
|
16904
|
+
}
|
|
16905
|
+
for(var i2 = 1; i2 <= bevelSegments; i2++){
|
|
16906
|
+
var angle1 = i2 / bevelSegments * Math.PI / 2;
|
|
16907
|
+
layers.push({
|
|
16908
|
+
z: depth - thickness + thickness * Math.sin(angle1),
|
|
16909
|
+
inset: size * (1 - Math.cos(angle1))
|
|
16910
|
+
});
|
|
16911
|
+
}
|
|
16912
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(shapes), _step; !(_step = _iterator()).done;){
|
|
16913
|
+
var _loop = function(i3) {
|
|
16914
|
+
offsetContours[i3] = i3 > 0 && layers[i3].inset === layers[i3 - 1].inset ? offsetContours[i3 - 1] : contours.map(function(contour) {
|
|
16915
|
+
return PrimitiveMesh._insetContour(contour, layers[i3].inset - offset);
|
|
16916
|
+
});
|
|
16917
|
+
};
|
|
16918
|
+
var polygon = _step.value;
|
|
16919
|
+
var cap = function cap(layer, top) {
|
|
16920
|
+
var _PolygonUtils_triangulateContours = PolygonUtils.triangulateContours(offsetContours[layer]), points = _PolygonUtils_triangulateContours.points, indices = _PolygonUtils_triangulateContours.indices;
|
|
16921
|
+
var positions = rings[layer].flat();
|
|
16922
|
+
for(var i = 0; i < indices.length; i += 3){
|
|
16923
|
+
var a = indices[i];
|
|
16924
|
+
var b = indices[i + (top ? 1 : 2)];
|
|
16925
|
+
var c = indices[i + (top ? 2 : 1)];
|
|
16926
|
+
data.addFace(positions[a], positions[b], positions[c], points[a], points[b], points[c]);
|
|
16927
|
+
}
|
|
16928
|
+
};
|
|
16929
|
+
var contours = PolygonUtils.prepareContours(polygon);
|
|
16930
|
+
var offsetContours = new Array(layers.length);
|
|
16931
|
+
for(var i3 = 0; i3 < layers.length; i3++)_loop(i3);
|
|
16932
|
+
var rings = offsetContours.map(function(contour, layer) {
|
|
16933
|
+
var z = layers[layer].z;
|
|
16934
|
+
var center = path == null ? void 0 : path[layer];
|
|
16935
|
+
var normal = frames == null ? void 0 : frames.normals[layer];
|
|
16936
|
+
var binormal = frames == null ? void 0 : frames.binormals[layer];
|
|
16937
|
+
return contour.map(function(points) {
|
|
16938
|
+
return points.map(function(point) {
|
|
16939
|
+
return center ? new Vector3(center.x + normal.x * point.x + binormal.x * point.y, center.y + normal.y * point.x + binormal.y * point.y, center.z + normal.z * point.x + binormal.z * point.y) : new Vector3(point.x, point.y, z);
|
|
16940
|
+
});
|
|
16941
|
+
});
|
|
16942
|
+
});
|
|
16943
|
+
if (!closedPath) {
|
|
16944
|
+
var capStart = data.indexCount;
|
|
16945
|
+
cap(0, false);
|
|
16946
|
+
cap(layers.length - 1, true);
|
|
16947
|
+
data.addGroup(capStart);
|
|
16948
|
+
}
|
|
16949
|
+
var sideStart = data.indexCount;
|
|
16950
|
+
for(var contour = 0; contour < contours.length; contour++){
|
|
16951
|
+
var original = contours[contour];
|
|
16952
|
+
var distances = [
|
|
16953
|
+
0
|
|
16954
|
+
];
|
|
16955
|
+
for(var point = 0; point < original.length; point++){
|
|
16956
|
+
var next = original[(point + 1) % original.length];
|
|
16957
|
+
distances.push(distances[point] + Math.hypot(next.x - original[point].x, next.y - original[point].y));
|
|
16958
|
+
}
|
|
16959
|
+
for(var layer = 0; layer < layers.length - 1; layer++){
|
|
16960
|
+
for(var point1 = 0; point1 < original.length; point1++){
|
|
16961
|
+
var next1 = (point1 + 1) % original.length;
|
|
16962
|
+
var a = rings[layer][contour][point1];
|
|
16963
|
+
var b = rings[layer][contour][next1];
|
|
16964
|
+
var c = rings[layer + 1][contour][point1];
|
|
16965
|
+
var d = rings[layer + 1][contour][next1];
|
|
16966
|
+
uvA.set(distances[point1], layer / (layers.length - 1));
|
|
16967
|
+
uvB.set(distances[point1 + 1], uvA.y);
|
|
16968
|
+
uvC.set(uvA.x, (layer + 1) / (layers.length - 1));
|
|
16969
|
+
uvD.set(uvB.x, uvC.y);
|
|
16970
|
+
data.addFace(a, b, c, uvA, uvB, uvC);
|
|
16971
|
+
data.addFace(b, d, c, uvB, uvD, uvC);
|
|
16972
|
+
}
|
|
16973
|
+
}
|
|
16974
|
+
}
|
|
16975
|
+
data.addGroup(sideStart);
|
|
16976
|
+
}
|
|
16977
|
+
return data;
|
|
16978
|
+
};
|
|
16979
|
+
PrimitiveMesh._insetContour = function _insetContour(contour, distance) {
|
|
16980
|
+
if (distance === 0) {
|
|
16981
|
+
return contour;
|
|
16982
|
+
}
|
|
16983
|
+
return contour.map(function(point, index) {
|
|
16984
|
+
var previous = contour[(index + contour.length - 1) % contour.length];
|
|
16985
|
+
var next = contour[(index + 1) % contour.length];
|
|
16986
|
+
var ax = point.x - previous.x;
|
|
16987
|
+
var ay = point.y - previous.y;
|
|
16988
|
+
var bx = next.x - point.x;
|
|
16989
|
+
var by = next.y - point.y;
|
|
16990
|
+
var al = Math.hypot(ax, ay);
|
|
16991
|
+
var bl = Math.hypot(bx, by);
|
|
16992
|
+
var nx = -ay / al - by / bl;
|
|
16993
|
+
var ny = ax / al + bx / bl;
|
|
16994
|
+
var denominator = nx * (-by / bl) + ny * (bx / bl);
|
|
16995
|
+
var scale = Math.abs(denominator) > 1e-10 ? distance / denominator : 0;
|
|
16996
|
+
return new Vector2(point.x + nx * scale, point.y + ny * scale);
|
|
16997
|
+
});
|
|
16998
|
+
};
|
|
16999
|
+
PrimitiveMesh._createSphereData = function _createSphereData(radius, subdivisionLevel, horizontalStart, horizontalEnd, verticalStart, verticalEnd) {
|
|
17000
|
+
var horizontalArc = Math.min(360, horizontalEnd - horizontalStart);
|
|
17001
|
+
verticalStart = Math.max(0, verticalStart);
|
|
17002
|
+
verticalEnd = Math.min(180, verticalEnd);
|
|
17003
|
+
if (horizontalArc < 360 || verticalStart > 0 || verticalEnd < 180) {
|
|
17004
|
+
var surface = PrimitiveMesh._createSphereSurfaceData(1, subdivisionLevel);
|
|
17005
|
+
return PrimitiveMesh._createSphereSectionData(surface, radius, horizontalStart, horizontalArc, verticalStart, verticalEnd);
|
|
17006
|
+
}
|
|
17007
|
+
var data = PrimitiveMesh._createSphereSurfaceData(radius, subdivisionLevel);
|
|
17008
|
+
if (horizontalStart !== 0) {
|
|
17009
|
+
var angle = MathUtil.degreeToRadian(horizontalStart);
|
|
17010
|
+
var cos = Math.cos(angle);
|
|
17011
|
+
var sin = Math.sin(angle);
|
|
17012
|
+
var vertices = data.vertices;
|
|
17013
|
+
for(var i = 0; i < vertices.length; i += 8){
|
|
17014
|
+
var x = vertices[i];
|
|
17015
|
+
var z = vertices[i + 2];
|
|
17016
|
+
var nx = vertices[i + 3];
|
|
17017
|
+
var nz = vertices[i + 5];
|
|
17018
|
+
vertices[i] = x * cos + z * sin;
|
|
17019
|
+
vertices[i + 2] = -x * sin + z * cos;
|
|
17020
|
+
vertices[i + 3] = nx * cos + nz * sin;
|
|
17021
|
+
vertices[i + 5] = -nx * sin + nz * cos;
|
|
17022
|
+
}
|
|
17023
|
+
}
|
|
17024
|
+
return data;
|
|
17025
|
+
};
|
|
17026
|
+
PrimitiveMesh._createSphereSectionData = function _createSphereSectionData(surface, radius, horizontalStart, horizontalArc, verticalStart, verticalEnd) {
|
|
17027
|
+
var data = new PrimitiveMeshBuilder(surface.vertexCount, surface.indexCount);
|
|
17028
|
+
if (horizontalArc <= 0 || verticalEnd <= verticalStart) {
|
|
17029
|
+
return data;
|
|
17030
|
+
}
|
|
17031
|
+
var vertices = surface.vertices;
|
|
17032
|
+
var indices = surface.indices;
|
|
17033
|
+
var horizontalArcRadians = MathUtil.degreeToRadian(horizontalArc);
|
|
17034
|
+
var verticalStartRadians = MathUtil.degreeToRadian(verticalStart);
|
|
17035
|
+
var verticalArcRadians = MathUtil.degreeToRadian(verticalEnd - verticalStart);
|
|
17036
|
+
var startAngle = MathUtil.degreeToRadian(horizontalStart);
|
|
17037
|
+
var cos = Math.cos(startAngle);
|
|
17038
|
+
var sin = Math.sin(startAngle);
|
|
17039
|
+
var fullTurn = horizontalArc === 360;
|
|
17040
|
+
var segmentCount = fullTurn ? 1 : Math.ceil(horizontalArc / 180);
|
|
17041
|
+
var boundaries = [];
|
|
17042
|
+
for(var i = 0; i < segmentCount; i++){
|
|
17043
|
+
var start = horizontalArcRadians * i / segmentCount;
|
|
17044
|
+
var end = horizontalArcRadians * (i + 1) / segmentCount;
|
|
17045
|
+
boundaries.push({
|
|
17046
|
+
start: new Vector3(Math.sin(start), 0, Math.cos(start)),
|
|
17047
|
+
end: new Vector3(-Math.sin(end), 0, -Math.cos(end))
|
|
17048
|
+
});
|
|
17049
|
+
}
|
|
17050
|
+
var topNormal = new Vector3(0, -1, 0);
|
|
17051
|
+
var bottomNormal = new Vector3(0, 1, 0);
|
|
17052
|
+
var topOffset = -Math.cos(verticalStartRadians);
|
|
17053
|
+
var bottomOffset = Math.cos(MathUtil.degreeToRadian(verticalEnd));
|
|
17054
|
+
var vertexMap = new Map();
|
|
17055
|
+
var trianglePoints = [
|
|
17056
|
+
new Vector3(),
|
|
17057
|
+
new Vector3(),
|
|
17058
|
+
new Vector3()
|
|
17059
|
+
];
|
|
17060
|
+
var verticalPoints = [];
|
|
17061
|
+
var clippedPoints = [];
|
|
17062
|
+
var polygonPoints = [];
|
|
17063
|
+
var points = new Array(3);
|
|
17064
|
+
var uvs = new Float64Array(6);
|
|
17065
|
+
var poles = new Array(3);
|
|
17066
|
+
var ab = new Vector3();
|
|
17067
|
+
var ac = new Vector3();
|
|
17068
|
+
for(var i1 = 0; i1 < indices.length; i1 += 3){
|
|
17069
|
+
var triangle = trianglePoints;
|
|
17070
|
+
var triangleCount = 3;
|
|
17071
|
+
for(var corner = 0; corner < 3; corner++){
|
|
17072
|
+
var offset = indices[i1 + corner] * 8;
|
|
17073
|
+
PrimitiveMesh._normalizeVector(triangle[corner].set(vertices[offset], vertices[offset + 1], vertices[offset + 2]));
|
|
17074
|
+
}
|
|
17075
|
+
if (verticalStart > 0) {
|
|
17076
|
+
triangleCount = PrimitiveMesh._clipSpherePolygon(triangle, triangleCount, topNormal, topOffset, verticalPoints);
|
|
17077
|
+
triangle = verticalPoints;
|
|
17078
|
+
}
|
|
17079
|
+
if (verticalEnd < 180) {
|
|
17080
|
+
var output = triangle === trianglePoints ? verticalPoints : trianglePoints;
|
|
17081
|
+
triangleCount = PrimitiveMesh._clipSpherePolygon(triangle, triangleCount, bottomNormal, bottomOffset, output);
|
|
17082
|
+
triangle = output;
|
|
17083
|
+
}
|
|
17084
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(boundaries), _step; !(_step = _iterator()).done;){
|
|
17085
|
+
var boundary = _step.value;
|
|
17086
|
+
var polygon = triangle;
|
|
17087
|
+
var polygonCount = triangleCount;
|
|
17088
|
+
if (!fullTurn) {
|
|
17089
|
+
polygonCount = PrimitiveMesh._clipSpherePolygon(polygon, polygonCount, boundary.start, 0, clippedPoints);
|
|
17090
|
+
polygonCount = PrimitiveMesh._clipSpherePolygon(clippedPoints, polygonCount, boundary.end, 0, polygonPoints);
|
|
17091
|
+
polygon = polygonPoints;
|
|
17092
|
+
}
|
|
17093
|
+
for(var corner1 = 1; corner1 + 1 < polygonCount; corner1++){
|
|
17094
|
+
points[0] = polygon[0];
|
|
17095
|
+
points[1] = polygon[corner1];
|
|
17096
|
+
points[2] = polygon[corner1 + 1];
|
|
17097
|
+
Vector3.subtract(points[1], points[0], ab);
|
|
17098
|
+
Vector3.subtract(points[2], points[0], ac);
|
|
17099
|
+
Vector3.cross(ab, ac, ab);
|
|
17100
|
+
if (ab.length() < 1e-12) {
|
|
17101
|
+
continue;
|
|
17102
|
+
}
|
|
17103
|
+
var minU = Infinity;
|
|
17104
|
+
var maxU = -Infinity;
|
|
17105
|
+
var nonPoleCount = 0;
|
|
17106
|
+
for(var j = 0; j < 3; j++){
|
|
17107
|
+
var point = points[j];
|
|
17108
|
+
var angle = Math.atan2(point.z, -point.x);
|
|
17109
|
+
angle = angle < -1e-10 ? angle + Math.PI * 2 : Math.max(0, angle);
|
|
17110
|
+
var u = MathUtil.clamp(angle / horizontalArcRadians, 0, 1);
|
|
17111
|
+
uvs[j * 2] = u;
|
|
17112
|
+
uvs[j * 2 + 1] = MathUtil.clamp((Math.acos(MathUtil.clamp(point.y, -1, 1)) - verticalStartRadians) / verticalArcRadians, 0, 1);
|
|
17113
|
+
poles[j] = Math.hypot(point.x, point.z) <= 1e-10;
|
|
17114
|
+
if (!poles[j]) {
|
|
17115
|
+
minU = Math.min(minU, u);
|
|
17116
|
+
maxU = Math.max(maxU, u);
|
|
17117
|
+
nonPoleCount++;
|
|
17118
|
+
}
|
|
17119
|
+
}
|
|
17120
|
+
var sumU = 0;
|
|
17121
|
+
for(var j1 = 0; j1 < 3; j1++){
|
|
17122
|
+
if (!poles[j1]) {
|
|
17123
|
+
if (fullTurn && maxU - minU > 0.5 && uvs[j1 * 2] < 0.5) {
|
|
17124
|
+
uvs[j1 * 2] += 1;
|
|
17125
|
+
}
|
|
17126
|
+
sumU += uvs[j1 * 2];
|
|
17127
|
+
}
|
|
17128
|
+
}
|
|
17129
|
+
for(var j2 = 0; j2 < 3; j2++){
|
|
17130
|
+
var point1 = points[j2];
|
|
17131
|
+
var u1 = poles[j2] ? sumU / nonPoleCount : uvs[j2 * 2];
|
|
17132
|
+
var v = uvs[j2 * 2 + 1];
|
|
17133
|
+
var key = Math.round(point1.x * 1e10) + "," + Math.round(point1.y * 1e10) + "," + Math.round(point1.z * 1e10) + "," + Math.round(u1 * 1e10) + "," + Math.round(v * 1e10);
|
|
17134
|
+
var index = vertexMap.get(key);
|
|
17135
|
+
if (index === undefined) {
|
|
17136
|
+
var nx = point1.x * cos + point1.z * sin;
|
|
17137
|
+
var nz = -point1.x * sin + point1.z * cos;
|
|
17138
|
+
index = data.addVertex(radius * nx, radius * point1.y, radius * nz, nx, point1.y, nz, u1, v);
|
|
17139
|
+
vertexMap.set(key, index);
|
|
17140
|
+
}
|
|
17141
|
+
data.addIndex(index);
|
|
17142
|
+
}
|
|
17143
|
+
}
|
|
17144
|
+
}
|
|
17145
|
+
}
|
|
17146
|
+
data.boundsExtent = new Vector3(radius, radius, radius);
|
|
17147
|
+
return data;
|
|
17148
|
+
};
|
|
17149
|
+
PrimitiveMesh._clipSpherePolygon = function _clipSpherePolygon(polygon, count, normal, offset, out) {
|
|
17150
|
+
if (count === 0) {
|
|
17151
|
+
return 0;
|
|
17152
|
+
}
|
|
17153
|
+
var resultCount = 0;
|
|
17154
|
+
var previous = polygon[count - 1];
|
|
17155
|
+
var previousDistance = Vector3.dot(previous, normal) - offset;
|
|
17156
|
+
for(var i = 0; i < count; i++){
|
|
17157
|
+
var current = polygon[i];
|
|
17158
|
+
var distance = Vector3.dot(current, normal) - offset;
|
|
17159
|
+
var inside = distance >= -1e-9;
|
|
17160
|
+
var previousInside = previousDistance >= -1e-9;
|
|
17161
|
+
if (inside !== previousInside) {
|
|
17162
|
+
var _out, _ref;
|
|
17163
|
+
var _;
|
|
17164
|
+
var point = (_ = (_out = out)[_ref = resultCount++]) != null ? _ : _out[_ref] = new Vector3();
|
|
17165
|
+
var t = previousDistance / (previousDistance - distance);
|
|
17166
|
+
if (t < 1e-10) {
|
|
17167
|
+
point.copyFrom(previous);
|
|
17168
|
+
} else if (t > 1 - 1e-10) {
|
|
17169
|
+
point.copyFrom(current);
|
|
17170
|
+
} else {
|
|
17171
|
+
Vector3.lerp(previous, current, t, point);
|
|
17172
|
+
// Preserve latitude boundaries when projecting the intersection back onto the sphere
|
|
17173
|
+
var length = Math.hypot(point.x, point.z);
|
|
17174
|
+
var scale = length > 0 ? Math.sqrt(Math.max(0, 1 - point.y * point.y)) / length : 0;
|
|
17175
|
+
point.x *= scale;
|
|
17176
|
+
point.z *= scale;
|
|
17177
|
+
}
|
|
17178
|
+
}
|
|
17179
|
+
if (inside) {
|
|
17180
|
+
var _out1, _ref1;
|
|
17181
|
+
var _1;
|
|
17182
|
+
((_1 = (_out1 = out)[_ref1 = resultCount++]) != null ? _1 : _out1[_ref1] = new Vector3()).copyFrom(current);
|
|
17183
|
+
}
|
|
17184
|
+
previous = current;
|
|
17185
|
+
previousDistance = distance;
|
|
17186
|
+
}
|
|
17187
|
+
return resultCount;
|
|
17188
|
+
};
|
|
17189
|
+
PrimitiveMesh._createSphereSurfaceData = function _createSphereSurfaceData(radius, subdivisionLevel) {
|
|
17190
|
+
// Level 7 exceeds the 16-bit vertex index range
|
|
17191
|
+
var level = MathUtil.clamp(Math.floor(subdivisionLevel), 1, 6);
|
|
17192
|
+
var _SubdivisionUtils_subdivideQuads = SubdivisionUtils.subdivideQuads(PrimitiveMesh._sphereSeedPositions, PrimitiveMesh._sphereSeedCells, level), positions = _SubdivisionUtils_subdivideQuads.positions, cells = _SubdivisionUtils_subdivideQuads.quads;
|
|
15113
17193
|
var positionCount = positions.length / 3;
|
|
15114
17194
|
var cellsCount = cells.length / 4;
|
|
15115
|
-
var poleOffset = positionCount + Math.pow(2,
|
|
15116
|
-
//
|
|
15117
|
-
// 2 vertices at each pole are idle
|
|
17195
|
+
var poleOffset = positionCount + Math.pow(2, level + 1) - 1;
|
|
17196
|
+
// Reserve pole duplicates so each triangle can use a local U coordinate
|
|
15118
17197
|
var vertexCount = poleOffset + 16;
|
|
15119
17198
|
var vertices = new Float32Array(vertexCount * 8);
|
|
15120
|
-
var indices =
|
|
17199
|
+
var indices = new Uint16Array(cellsCount * 6);
|
|
15121
17200
|
var seamCount = 0;
|
|
15122
17201
|
var seamVertices = {};
|
|
15123
|
-
// Get normals, uvs, and scale to radius
|
|
15124
17202
|
for(var i = 0; i < positionCount; i++){
|
|
15125
17203
|
var offset = 3 * i;
|
|
15126
17204
|
var x = positions[offset];
|
|
@@ -15139,875 +17217,182 @@ var BufferUpdateInfo = /*#__PURE__*/ function() {
|
|
|
15139
17217
|
vertices[offset + 5] = z;
|
|
15140
17218
|
vertices[offset + 6] = (Math.PI - Math.atan2(z, x)) / (2 * Math.PI);
|
|
15141
17219
|
vertices[offset + 7] = Math.acos(y) / Math.PI;
|
|
17220
|
+
// Duplicate the seam so adjacent triangles can use U = 0 and U = 1
|
|
15142
17221
|
if (vertices[offset + 6] === 0) {
|
|
15143
|
-
// Generate seam vertex
|
|
15144
17222
|
var seamOffset = 8 * (positionCount + seamCount++);
|
|
15145
17223
|
vertices.set(vertices.subarray(offset, offset + 8), seamOffset);
|
|
15146
17224
|
vertices[seamOffset + 6] = 1.0;
|
|
15147
|
-
// Cache seam vertex
|
|
15148
17225
|
seamVertices[offset / 8] = seamOffset / 8;
|
|
15149
17226
|
}
|
|
15150
17227
|
}
|
|
15151
|
-
// Get indices
|
|
15152
17228
|
var offset1 = 0;
|
|
15153
|
-
|
|
17229
|
+
var poleIndex = 0;
|
|
15154
17230
|
for(var i1 = 0; i1 < cellsCount; i1++){
|
|
15155
17231
|
var idx = 4 * i1;
|
|
15156
17232
|
var indexA = cells[idx];
|
|
15157
17233
|
var indexB = cells[idx + 1];
|
|
15158
17234
|
var indexC = cells[idx + 2];
|
|
15159
17235
|
var indexD = cells[idx + 3];
|
|
15160
|
-
// Handle seam by replacing vertex index to seam vertex index if necessary
|
|
15161
17236
|
var floatIndexA = 8 * indexA;
|
|
15162
17237
|
var floatIndexB = 8 * indexB;
|
|
15163
17238
|
var floatIndexC = 8 * indexC;
|
|
15164
17239
|
var floatIndexD = 8 * indexD;
|
|
15165
|
-
//
|
|
17240
|
+
// Use the U = 1 copies on the negative-Z side of the seam
|
|
15166
17241
|
if (vertices[floatIndexA + 2] + vertices[floatIndexB + 2] + vertices[floatIndexC + 2] < 0) {
|
|
15167
|
-
vertices[floatIndexA + 6] === 0
|
|
15168
|
-
|
|
15169
|
-
|
|
15170
|
-
vertices[
|
|
17242
|
+
if (vertices[floatIndexA + 6] === 0) {
|
|
17243
|
+
indexA = seamVertices[indexA];
|
|
17244
|
+
}
|
|
17245
|
+
if (vertices[floatIndexB + 6] === 0) {
|
|
17246
|
+
indexB = seamVertices[indexB];
|
|
17247
|
+
}
|
|
17248
|
+
if (vertices[floatIndexC + 6] === 0) {
|
|
17249
|
+
indexC = seamVertices[indexC];
|
|
17250
|
+
}
|
|
17251
|
+
if (vertices[floatIndexD + 6] === 0) {
|
|
17252
|
+
indexD = seamVertices[indexD];
|
|
17253
|
+
}
|
|
15171
17254
|
}
|
|
15172
17255
|
indices[offset1] = indexA;
|
|
15173
17256
|
indices[offset1 + 1] = indexB;
|
|
15174
17257
|
indices[offset1 + 2] = indexC;
|
|
15175
|
-
|
|
17258
|
+
poleIndex = PrimitiveMesh._replacePoleUV(indices, vertices, offset1, poleOffset, poleIndex);
|
|
15176
17259
|
indices[offset1 + 3] = indexA;
|
|
15177
17260
|
indices[offset1 + 4] = indexC;
|
|
15178
17261
|
indices[offset1 + 5] = indexD;
|
|
15179
|
-
|
|
17262
|
+
poleIndex = PrimitiveMesh._replacePoleUV(indices, vertices, offset1 + 3, poleOffset, poleIndex);
|
|
15180
17263
|
offset1 += 6;
|
|
15181
17264
|
}
|
|
15182
|
-
|
|
15183
|
-
|
|
15184
|
-
|
|
15185
|
-
|
|
15186
|
-
}
|
|
15187
|
-
PrimitiveMesh._initialize(sphereMesh, vertices, indices, noLongerAccessible, isRestoreMode, restoreVertexBuffer);
|
|
15188
|
-
};
|
|
15189
|
-
/**
|
|
15190
|
-
* @internal
|
|
15191
|
-
*/ PrimitiveMesh._setSphereData = function _setSphereData(sphereMesh, radius, segments, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
|
|
15192
|
-
segments = Math.max(2, Math.floor(segments));
|
|
15193
|
-
var count = segments + 1;
|
|
15194
|
-
var vertexCount = count * count;
|
|
15195
|
-
var rectangleCount = segments * segments;
|
|
15196
|
-
var indices = PrimitiveMesh._generateIndices(sphereMesh.engine, vertexCount, rectangleCount * 6);
|
|
15197
|
-
var thetaRange = Math.PI;
|
|
15198
|
-
var alphaRange = thetaRange * 2;
|
|
15199
|
-
var countReciprocal = 1.0 / count;
|
|
15200
|
-
var segmentsReciprocal = 1.0 / segments;
|
|
15201
|
-
var vertexFloatCount = 8;
|
|
15202
|
-
var vertices = new Float32Array(vertexCount * vertexFloatCount);
|
|
15203
|
-
for(var i = 0; i < vertexCount; ++i){
|
|
15204
|
-
var x = i % count;
|
|
15205
|
-
var y = i * countReciprocal | 0;
|
|
15206
|
-
var u = x * segmentsReciprocal;
|
|
15207
|
-
var v = y * segmentsReciprocal;
|
|
15208
|
-
var alphaDelta = u * alphaRange;
|
|
15209
|
-
var thetaDelta = v * thetaRange;
|
|
15210
|
-
var sinTheta = Math.sin(thetaDelta);
|
|
15211
|
-
var posX = -radius * Math.cos(alphaDelta) * sinTheta;
|
|
15212
|
-
var posY = radius * Math.cos(thetaDelta);
|
|
15213
|
-
var posZ = radius * Math.sin(alphaDelta) * sinTheta;
|
|
15214
|
-
var offset = i * vertexFloatCount;
|
|
15215
|
-
// Position
|
|
15216
|
-
vertices[offset++] = posX;
|
|
15217
|
-
vertices[offset++] = posY;
|
|
15218
|
-
vertices[offset++] = posZ;
|
|
15219
|
-
// Normal
|
|
15220
|
-
vertices[offset++] = posX;
|
|
15221
|
-
vertices[offset++] = posY;
|
|
15222
|
-
vertices[offset++] = posZ;
|
|
15223
|
-
// TexCoord
|
|
15224
|
-
vertices[offset++] = u;
|
|
15225
|
-
vertices[offset++] = v;
|
|
15226
|
-
}
|
|
15227
|
-
var offset1 = 0;
|
|
15228
|
-
for(var i1 = 0; i1 < rectangleCount; ++i1){
|
|
15229
|
-
var x1 = i1 % segments;
|
|
15230
|
-
var y1 = i1 * segmentsReciprocal | 0;
|
|
15231
|
-
var a = y1 * count + x1;
|
|
15232
|
-
var b = a + 1;
|
|
15233
|
-
var c = a + count;
|
|
15234
|
-
var d = c + 1;
|
|
15235
|
-
indices[offset1++] = b;
|
|
15236
|
-
indices[offset1++] = a;
|
|
15237
|
-
indices[offset1++] = d;
|
|
15238
|
-
indices[offset1++] = a;
|
|
15239
|
-
indices[offset1++] = c;
|
|
15240
|
-
indices[offset1++] = d;
|
|
15241
|
-
}
|
|
15242
|
-
if (!isRestoreMode) {
|
|
15243
|
-
var bounds = sphereMesh.bounds;
|
|
15244
|
-
bounds.min.set(-radius, -radius, -radius);
|
|
15245
|
-
bounds.max.set(radius, radius, radius);
|
|
15246
|
-
}
|
|
15247
|
-
PrimitiveMesh._initialize(sphereMesh, vertices, indices, noLongerAccessible, isRestoreMode, restoreVertexBuffer);
|
|
15248
|
-
};
|
|
15249
|
-
/**
|
|
15250
|
-
* @internal
|
|
15251
|
-
*/ PrimitiveMesh._subdiveCatmullClark = function _subdiveCatmullClark(step, positions, cells) {
|
|
15252
|
-
var edges = new Map();
|
|
15253
|
-
var faces = new Array();
|
|
15254
|
-
positions.set(PrimitiveMesh._sphereSeedPositions);
|
|
15255
|
-
cells.set(PrimitiveMesh._sphereSeedCells);
|
|
15256
|
-
for(var i = 0; i < step; i++){
|
|
15257
|
-
var cellCount = 6 * Math.pow(4, i);
|
|
15258
|
-
var positionCount = 4 * cellCount + 2;
|
|
15259
|
-
edges.clear();
|
|
15260
|
-
faces.length = 0;
|
|
15261
|
-
// Get cell face's facePoint
|
|
15262
|
-
for(var j = 0; j < cellCount; j++){
|
|
15263
|
-
var face = faces[j] = {
|
|
15264
|
-
facePoint: new Vector3(),
|
|
15265
|
-
adjacentEdges: new Array(4)
|
|
15266
|
-
};
|
|
15267
|
-
// Get cell's edgePoint
|
|
15268
|
-
for(var k = 0; k < 4; k++){
|
|
15269
|
-
var offset = 3 * cells[4 * j + k];
|
|
15270
|
-
face.facePoint.x += 0.25 * positions[offset];
|
|
15271
|
-
face.facePoint.y += 0.25 * positions[offset + 1];
|
|
15272
|
-
face.facePoint.z += 0.25 * positions[offset + 2];
|
|
15273
|
-
}
|
|
15274
|
-
// Get cell edges
|
|
15275
|
-
for(var k1 = 0; k1 < 4; k1++){
|
|
15276
|
-
var vertexIdxA = cells[4 * j + k1];
|
|
15277
|
-
var vertexIdxB = cells[4 * j + (k1 + 1) % 4];
|
|
15278
|
-
var edgeIdxKey = Math.min(vertexIdxA, vertexIdxB) * positionCount + Math.max(vertexIdxA, vertexIdxB);
|
|
15279
|
-
if (!edges.has(edgeIdxKey)) {
|
|
15280
|
-
var edge = {
|
|
15281
|
-
edgePoint: new Vector3(),
|
|
15282
|
-
edgePointIndex: undefined
|
|
15283
|
-
};
|
|
15284
|
-
var offsetA = 3 * vertexIdxA;
|
|
15285
|
-
var offsetB = 3 * vertexIdxB;
|
|
15286
|
-
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]));
|
|
15287
|
-
edges.set(edgeIdxKey, edge);
|
|
15288
|
-
}
|
|
15289
|
-
var edge1 = edges.get(edgeIdxKey);
|
|
15290
|
-
face.adjacentEdges[k1] = edge1;
|
|
15291
|
-
var edgePoint = edge1.edgePoint;
|
|
15292
|
-
var facePoint = face.facePoint;
|
|
15293
|
-
edgePoint.x += 0.25 * facePoint.x;
|
|
15294
|
-
edgePoint.y += 0.25 * facePoint.y;
|
|
15295
|
-
edgePoint.z += 0.25 * facePoint.z;
|
|
15296
|
-
}
|
|
15297
|
-
}
|
|
15298
|
-
var prePointCount = cellCount + 2;
|
|
15299
|
-
var edgePointOffset = prePointCount + cellCount;
|
|
15300
|
-
var pointIdx = 0;
|
|
15301
|
-
this._sphereEdgeIdx = 0;
|
|
15302
|
-
var preCells = cells.slice(0, 4 * cellCount);
|
|
15303
|
-
// Get New positions, which consists of updated positions of existing points, face points and edge points
|
|
15304
|
-
for(var j1 = 0; j1 < cellCount; j1++){
|
|
15305
|
-
// Add face point to new positions
|
|
15306
|
-
var face1 = faces[j1];
|
|
15307
|
-
face1.facePoint.copyToArray(positions, 3 * (prePointCount + j1));
|
|
15308
|
-
// Get the face point index
|
|
15309
|
-
var ic = prePointCount + j1;
|
|
15310
|
-
var id = void 0, ib = void 0, temp = void 0;
|
|
15311
|
-
// ia -- id -- ia
|
|
15312
|
-
// | | |
|
|
15313
|
-
// ib -- ic -- ib
|
|
15314
|
-
// | | |
|
|
15315
|
-
// ia -- id -- ia
|
|
15316
|
-
for(var k2 = 0; k2 < 4; k2++){
|
|
15317
|
-
// Get the updated existing point index
|
|
15318
|
-
var ia = preCells[pointIdx++];
|
|
15319
|
-
// ib and id share four edge points in one cell
|
|
15320
|
-
switch(k2){
|
|
15321
|
-
case 0:
|
|
15322
|
-
{
|
|
15323
|
-
var edgeB = face1.adjacentEdges[k2 % 4];
|
|
15324
|
-
var edgeD = face1.adjacentEdges[(k2 + 3) % 4];
|
|
15325
|
-
ib = this._calculateEdgeIndex(positions, edgeB, edgePointOffset);
|
|
15326
|
-
id = this._calculateEdgeIndex(positions, edgeD, edgePointOffset);
|
|
15327
|
-
temp = id;
|
|
15328
|
-
break;
|
|
15329
|
-
}
|
|
15330
|
-
case 1:
|
|
15331
|
-
case 2:
|
|
15332
|
-
{
|
|
15333
|
-
var edgeB1 = face1.adjacentEdges[k2 % 4];
|
|
15334
|
-
id = ib;
|
|
15335
|
-
ib = this._calculateEdgeIndex(positions, edgeB1, edgePointOffset);
|
|
15336
|
-
break;
|
|
15337
|
-
}
|
|
15338
|
-
case 3:
|
|
15339
|
-
{
|
|
15340
|
-
id = ib;
|
|
15341
|
-
ib = temp;
|
|
15342
|
-
break;
|
|
15343
|
-
}
|
|
15344
|
-
}
|
|
15345
|
-
var idx = 4 * (4 * j1 + k2);
|
|
15346
|
-
cells[idx] = ia;
|
|
15347
|
-
cells[idx + 1] = ib;
|
|
15348
|
-
cells[idx + 2] = ic;
|
|
15349
|
-
cells[idx + 3] = id;
|
|
15350
|
-
}
|
|
15351
|
-
}
|
|
15352
|
-
}
|
|
17265
|
+
var data = new PrimitiveMeshBuilder();
|
|
17266
|
+
data.setData(vertices, indices);
|
|
17267
|
+
data.boundsExtent = new Vector3(radius, radius, radius);
|
|
17268
|
+
return data;
|
|
15353
17269
|
};
|
|
15354
|
-
|
|
15355
|
-
* Duplicate vertices at the poles and adjust their UV coordinates.
|
|
15356
|
-
*/ PrimitiveMesh._generateAndReplacePoleUV = function _generateAndReplacePoleUV(indices, vertices, idx, poleOffset) {
|
|
17270
|
+
PrimitiveMesh._replacePoleUV = function _replacePoleUV(indices, vertices, idx, poleOffset, poleIndex) {
|
|
15357
17271
|
var v = vertices[8 * indices[idx] + 7];
|
|
15358
17272
|
if (v === 0 || v === 1) {
|
|
15359
17273
|
var offset = 8 * indices[idx];
|
|
15360
|
-
var addedOffset = 8 * (poleOffset +
|
|
17274
|
+
var addedOffset = 8 * (poleOffset + poleIndex);
|
|
15361
17275
|
vertices.set(vertices.subarray(offset, offset + 8), addedOffset);
|
|
15362
17276
|
vertices[addedOffset + 6] = 0.5 * (vertices[offset + 6] + vertices[8 * indices[idx + 1] + 6] + vertices[8 * indices[idx + 2] + 6] - 0.5);
|
|
15363
|
-
indices[idx] = poleOffset +
|
|
17277
|
+
indices[idx] = poleOffset + poleIndex++;
|
|
15364
17278
|
}
|
|
17279
|
+
return poleIndex;
|
|
15365
17280
|
};
|
|
15366
|
-
|
|
15367
|
-
|
|
15368
|
-
|
|
15369
|
-
|
|
15370
|
-
|
|
15371
|
-
} else {
|
|
15372
|
-
edge.edgePoint.copyToArray(positions, 3 * (offset + PrimitiveMesh._sphereEdgeIdx));
|
|
15373
|
-
var index = offset + PrimitiveMesh._sphereEdgeIdx++;
|
|
15374
|
-
edge.edgePointIndex = index;
|
|
15375
|
-
return index;
|
|
15376
|
-
}
|
|
15377
|
-
};
|
|
15378
|
-
/**
|
|
15379
|
-
* @internal
|
|
15380
|
-
*/ PrimitiveMesh._setCuboidData = function _setCuboidData(cuboidMesh, width, height, depth, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
|
|
15381
|
-
var halfWidth = width / 2;
|
|
15382
|
-
var halfHeight = height / 2;
|
|
15383
|
-
var halfDepth = depth / 2;
|
|
15384
|
-
var vertexFloatCount = 8;
|
|
15385
|
-
var vertices = new Float32Array(24 * vertexFloatCount);
|
|
15386
|
-
// Up
|
|
15387
|
-
vertices[0] = -halfWidth, vertices[1] = halfHeight, vertices[2] = -halfDepth;
|
|
15388
|
-
vertices[6] = 0, vertices[7] = 0;
|
|
15389
|
-
vertices[8] = halfWidth, vertices[9] = halfHeight, vertices[10] = -halfDepth;
|
|
15390
|
-
vertices[14] = 1, vertices[15] = 0;
|
|
15391
|
-
vertices[16] = halfWidth, vertices[17] = halfHeight, vertices[18] = halfDepth;
|
|
15392
|
-
vertices[22] = 1, vertices[23] = 1;
|
|
15393
|
-
vertices[24] = -halfWidth, vertices[25] = halfHeight, vertices[26] = halfDepth;
|
|
15394
|
-
vertices[30] = 0, vertices[31] = 1;
|
|
15395
|
-
for(var i = 0; i < 4; i++){
|
|
15396
|
-
var normalOffset = vertexFloatCount * i + 3;
|
|
15397
|
-
vertices[normalOffset++] = 0, vertices[normalOffset++] = 1, vertices[normalOffset++] = 0;
|
|
15398
|
-
}
|
|
15399
|
-
// Down
|
|
15400
|
-
vertices[32] = -halfWidth, vertices[33] = -halfHeight, vertices[34] = -halfDepth;
|
|
15401
|
-
vertices[38] = 0, vertices[39] = 1;
|
|
15402
|
-
vertices[40] = halfWidth, vertices[41] = -halfHeight, vertices[42] = -halfDepth;
|
|
15403
|
-
vertices[46] = 1, vertices[47] = 1;
|
|
15404
|
-
vertices[48] = halfWidth, vertices[49] = -halfHeight, vertices[50] = halfDepth;
|
|
15405
|
-
vertices[54] = 1, vertices[55] = 0;
|
|
15406
|
-
vertices[56] = -halfWidth, vertices[57] = -halfHeight, vertices[58] = halfDepth;
|
|
15407
|
-
vertices[62] = 0, vertices[63] = 0;
|
|
15408
|
-
for(var i1 = 0; i1 < 4; i1++){
|
|
15409
|
-
var normalOffset1 = vertexFloatCount * i1 + 35;
|
|
15410
|
-
vertices[normalOffset1++] = 0, vertices[normalOffset1++] = -1, vertices[normalOffset1++] = 0;
|
|
15411
|
-
}
|
|
15412
|
-
// Left
|
|
15413
|
-
vertices[64] = -halfWidth, vertices[65] = halfHeight, vertices[66] = -halfDepth;
|
|
15414
|
-
vertices[70] = 0, vertices[71] = 0;
|
|
15415
|
-
vertices[72] = -halfWidth, vertices[73] = halfHeight, vertices[74] = halfDepth;
|
|
15416
|
-
vertices[78] = 1, vertices[79] = 0;
|
|
15417
|
-
vertices[80] = -halfWidth, vertices[81] = -halfHeight, vertices[82] = halfDepth;
|
|
15418
|
-
vertices[86] = 1, vertices[87] = 1;
|
|
15419
|
-
vertices[88] = -halfWidth, vertices[89] = -halfHeight, vertices[90] = -halfDepth;
|
|
15420
|
-
vertices[94] = 0, vertices[95] = 1;
|
|
15421
|
-
for(var i2 = 0; i2 < 4; i2++){
|
|
15422
|
-
var normalOffset2 = vertexFloatCount * i2 + 67;
|
|
15423
|
-
vertices[normalOffset2++] = -1, vertices[normalOffset2++] = 0, vertices[normalOffset2++] = 0;
|
|
15424
|
-
}
|
|
15425
|
-
// Right
|
|
15426
|
-
vertices[96] = halfWidth, vertices[97] = halfHeight, vertices[98] = -halfDepth;
|
|
15427
|
-
vertices[102] = 1, vertices[103] = 0;
|
|
15428
|
-
vertices[104] = halfWidth, vertices[105] = halfHeight, vertices[106] = halfDepth;
|
|
15429
|
-
vertices[110] = 0, vertices[111] = 0;
|
|
15430
|
-
vertices[112] = halfWidth, vertices[113] = -halfHeight, vertices[114] = halfDepth;
|
|
15431
|
-
vertices[118] = 0, vertices[119] = 1;
|
|
15432
|
-
vertices[120] = halfWidth, vertices[121] = -halfHeight, vertices[122] = -halfDepth;
|
|
15433
|
-
vertices[126] = 1, vertices[127] = 1;
|
|
15434
|
-
for(var i3 = 0; i3 < 4; i3++){
|
|
15435
|
-
var normalOffset3 = vertexFloatCount * i3 + 99;
|
|
15436
|
-
vertices[normalOffset3++] = 1, vertices[normalOffset3++] = 0, vertices[normalOffset3++] = 0;
|
|
15437
|
-
}
|
|
15438
|
-
// Front
|
|
15439
|
-
vertices[128] = -halfWidth, vertices[129] = halfHeight, vertices[130] = halfDepth;
|
|
15440
|
-
vertices[134] = 0, vertices[135] = 0;
|
|
15441
|
-
vertices[136] = halfWidth, vertices[137] = halfHeight, vertices[138] = halfDepth;
|
|
15442
|
-
vertices[142] = 1, vertices[143] = 0;
|
|
15443
|
-
vertices[144] = halfWidth, vertices[145] = -halfHeight, vertices[146] = halfDepth;
|
|
15444
|
-
vertices[150] = 1, vertices[151] = 1;
|
|
15445
|
-
vertices[152] = -halfWidth, vertices[153] = -halfHeight, vertices[154] = halfDepth;
|
|
15446
|
-
vertices[158] = 0, vertices[159] = 1;
|
|
15447
|
-
for(var i4 = 0; i4 < 4; i4++){
|
|
15448
|
-
var normalOffset4 = vertexFloatCount * i4 + 131;
|
|
15449
|
-
vertices[normalOffset4++] = 0, vertices[normalOffset4++] = 0, vertices[normalOffset4++] = 1;
|
|
15450
|
-
}
|
|
15451
|
-
// Back
|
|
15452
|
-
vertices[160] = -halfWidth, vertices[161] = halfHeight, vertices[162] = -halfDepth;
|
|
15453
|
-
vertices[166] = 1, vertices[167] = 0;
|
|
15454
|
-
vertices[168] = halfWidth, vertices[169] = halfHeight, vertices[170] = -halfDepth;
|
|
15455
|
-
vertices[174] = 0, vertices[175] = 0;
|
|
15456
|
-
vertices[176] = halfWidth, vertices[177] = -halfHeight, vertices[178] = -halfDepth;
|
|
15457
|
-
vertices[182] = 0, vertices[183] = 1;
|
|
15458
|
-
vertices[184] = -halfWidth, vertices[185] = -halfHeight, vertices[186] = -halfDepth;
|
|
15459
|
-
vertices[190] = 1, vertices[191] = 1;
|
|
15460
|
-
for(var i5 = 0; i5 < 4; i5++){
|
|
15461
|
-
var normalOffset5 = vertexFloatCount * i5 + 163;
|
|
15462
|
-
vertices[normalOffset5++] = 0, vertices[normalOffset5++] = 0, vertices[normalOffset5++] = -1;
|
|
15463
|
-
}
|
|
15464
|
-
var indices = new Uint16Array(36);
|
|
15465
|
-
// prettier-ignore
|
|
15466
|
-
// Up
|
|
15467
|
-
indices[0] = 0, indices[1] = 2, indices[2] = 1, indices[3] = 2, indices[4] = 0, indices[5] = 3, // Down
|
|
15468
|
-
indices[6] = 4, indices[7] = 6, indices[8] = 7, indices[9] = 6, indices[10] = 4, indices[11] = 5, // Left
|
|
15469
|
-
indices[12] = 8, indices[13] = 10, indices[14] = 9, indices[15] = 10, indices[16] = 8, indices[17] = 11, // Right
|
|
15470
|
-
indices[18] = 12, indices[19] = 14, indices[20] = 15, indices[21] = 14, indices[22] = 12, indices[23] = 13, // Front
|
|
15471
|
-
indices[24] = 16, indices[25] = 18, indices[26] = 17, indices[27] = 18, indices[28] = 16, indices[29] = 19, // Back
|
|
15472
|
-
indices[30] = 20, indices[31] = 22, indices[32] = 23, indices[33] = 22, indices[34] = 20, indices[35] = 21;
|
|
15473
|
-
if (!isRestoreMode) {
|
|
15474
|
-
var bounds = cuboidMesh.bounds;
|
|
15475
|
-
bounds.min.set(-halfWidth, -halfHeight, -halfDepth);
|
|
15476
|
-
bounds.max.set(halfWidth, halfHeight, halfDepth);
|
|
15477
|
-
}
|
|
15478
|
-
PrimitiveMesh._initialize(cuboidMesh, vertices, indices, noLongerAccessible, isRestoreMode, restoreVertexBuffer);
|
|
15479
|
-
};
|
|
15480
|
-
/**
|
|
15481
|
-
* @internal
|
|
15482
|
-
*/ PrimitiveMesh._setPlaneData = function _setPlaneData(planeMesh, width, height, horizontalSegments, verticalSegments, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
|
|
15483
|
-
horizontalSegments = Math.max(1, Math.floor(horizontalSegments));
|
|
15484
|
-
verticalSegments = Math.max(1, Math.floor(verticalSegments));
|
|
15485
|
-
var horizontalCount = horizontalSegments + 1;
|
|
15486
|
-
var verticalCount = verticalSegments + 1;
|
|
15487
|
-
var halfWidth = width / 2;
|
|
15488
|
-
var halfHeight = height / 2;
|
|
15489
|
-
var gridWidth = width / horizontalSegments;
|
|
15490
|
-
var gridHeight = height / verticalSegments;
|
|
15491
|
-
var vertexCount = horizontalCount * verticalCount;
|
|
15492
|
-
var rectangleCount = verticalSegments * horizontalSegments;
|
|
15493
|
-
var indices = PrimitiveMesh._generateIndices(planeMesh.engine, vertexCount, rectangleCount * 6);
|
|
15494
|
-
var horizontalCountReciprocal = 1.0 / horizontalCount;
|
|
15495
|
-
var horizontalSegmentsReciprocal = 1.0 / horizontalSegments;
|
|
15496
|
-
var verticalSegmentsReciprocal = 1.0 / verticalSegments;
|
|
15497
|
-
var vertexFloatCount = 8;
|
|
15498
|
-
var vertices = new Float32Array(vertexCount * vertexFloatCount);
|
|
15499
|
-
for(var i = 0; i < vertexCount; ++i){
|
|
15500
|
-
var x = i % horizontalCount;
|
|
15501
|
-
var z = i * horizontalCountReciprocal | 0;
|
|
15502
|
-
var offset = i * vertexFloatCount;
|
|
15503
|
-
// Position
|
|
15504
|
-
vertices[offset++] = x * gridWidth - halfWidth;
|
|
15505
|
-
vertices[offset++] = 0;
|
|
15506
|
-
vertices[offset++] = z * gridHeight - halfHeight;
|
|
15507
|
-
// Normal
|
|
15508
|
-
vertices[offset++] = 0;
|
|
15509
|
-
vertices[offset++] = 1;
|
|
15510
|
-
vertices[offset++] = 0;
|
|
15511
|
-
// TexCoord
|
|
15512
|
-
vertices[offset++] = x * horizontalSegmentsReciprocal;
|
|
15513
|
-
vertices[offset++] = z * verticalSegmentsReciprocal;
|
|
17281
|
+
PrimitiveMesh._createMesh = function _createMesh(engine, generate, args, options) {
|
|
17282
|
+
var _options_keepMeshData;
|
|
17283
|
+
var keepMeshData = (_options_keepMeshData = options == null ? void 0 : options.keepMeshData) != null ? _options_keepMeshData : false;
|
|
17284
|
+
for(var i = 0; i < args.length; i++){
|
|
17285
|
+
args[i] = PrimitiveMesh._copy(args[i]);
|
|
15514
17286
|
}
|
|
15515
|
-
var
|
|
15516
|
-
|
|
15517
|
-
|
|
15518
|
-
|
|
15519
|
-
|
|
15520
|
-
|
|
15521
|
-
|
|
15522
|
-
|
|
15523
|
-
|
|
15524
|
-
|
|
15525
|
-
|
|
15526
|
-
|
|
15527
|
-
|
|
15528
|
-
|
|
15529
|
-
|
|
15530
|
-
|
|
15531
|
-
|
|
15532
|
-
|
|
15533
|
-
|
|
15534
|
-
|
|
15535
|
-
|
|
15536
|
-
|
|
15537
|
-
|
|
15538
|
-
|
|
15539
|
-
|
|
15540
|
-
|
|
15541
|
-
|
|
15542
|
-
if (height === void 0) height = 2;
|
|
15543
|
-
if (radialSegments === void 0) radialSegments = 20;
|
|
15544
|
-
if (heightSegments === void 0) heightSegments = 1;
|
|
15545
|
-
radialSegments = Math.floor(radialSegments);
|
|
15546
|
-
heightSegments = Math.floor(heightSegments);
|
|
15547
|
-
var radialCount = radialSegments + 1;
|
|
15548
|
-
var verticalCount = heightSegments + 1;
|
|
15549
|
-
var halfHeight = height * 0.5;
|
|
15550
|
-
var unitHeight = height / heightSegments;
|
|
15551
|
-
var torsoVertexCount = radialCount * verticalCount;
|
|
15552
|
-
var torsoRectangleCount = radialSegments * heightSegments;
|
|
15553
|
-
var capTriangleCount = radialSegments * 2;
|
|
15554
|
-
var totalVertexCount = torsoVertexCount + 2 + capTriangleCount;
|
|
15555
|
-
var indices = PrimitiveMesh._generateIndices(cylinderMesh.engine, totalVertexCount, torsoRectangleCount * 6 + capTriangleCount * 3);
|
|
15556
|
-
var radialCountReciprocal = 1.0 / radialCount;
|
|
15557
|
-
var radialSegmentsReciprocal = 1.0 / radialSegments;
|
|
15558
|
-
var heightSegmentsReciprocal = 1.0 / heightSegments;
|
|
15559
|
-
var vertexFloatCount = 8;
|
|
15560
|
-
var vertices = new Float32Array(totalVertexCount * vertexFloatCount);
|
|
15561
|
-
var indicesOffset = 0;
|
|
15562
|
-
// Create torso
|
|
15563
|
-
var thetaStart = Math.PI;
|
|
15564
|
-
var thetaRange = Math.PI * 2;
|
|
15565
|
-
var radiusDiff = radiusBottom - radiusTop;
|
|
15566
|
-
var slope = radiusDiff / height;
|
|
15567
|
-
var radiusSlope = radiusDiff / heightSegments;
|
|
15568
|
-
for(var i = 0; i < torsoVertexCount; ++i){
|
|
15569
|
-
var x = i % radialCount;
|
|
15570
|
-
var y = i * radialCountReciprocal | 0;
|
|
15571
|
-
var u = x * radialSegmentsReciprocal;
|
|
15572
|
-
var v = y * heightSegmentsReciprocal;
|
|
15573
|
-
var theta = thetaStart + u * thetaRange;
|
|
15574
|
-
var sinTheta = Math.sin(theta);
|
|
15575
|
-
var cosTheta = Math.cos(theta);
|
|
15576
|
-
var radius = radiusBottom - y * radiusSlope;
|
|
15577
|
-
var posX = radius * sinTheta;
|
|
15578
|
-
var posY = y * unitHeight - halfHeight;
|
|
15579
|
-
var posZ = radius * cosTheta;
|
|
15580
|
-
var offset = i * vertexFloatCount;
|
|
15581
|
-
// Position
|
|
15582
|
-
vertices[offset++] = posX;
|
|
15583
|
-
vertices[offset++] = posY;
|
|
15584
|
-
vertices[offset++] = posZ;
|
|
15585
|
-
// Normal
|
|
15586
|
-
vertices[offset++] = sinTheta;
|
|
15587
|
-
vertices[offset++] = slope;
|
|
15588
|
-
vertices[offset++] = cosTheta;
|
|
15589
|
-
// TexCoord
|
|
15590
|
-
vertices[offset++] = u;
|
|
15591
|
-
vertices[offset++] = 1 - v;
|
|
15592
|
-
}
|
|
15593
|
-
for(var i1 = 0; i1 < torsoRectangleCount; ++i1){
|
|
15594
|
-
var x1 = i1 % radialSegments;
|
|
15595
|
-
var y1 = i1 * radialSegmentsReciprocal | 0;
|
|
15596
|
-
var a = y1 * radialCount + x1;
|
|
15597
|
-
var b = a + 1;
|
|
15598
|
-
var c = a + radialCount;
|
|
15599
|
-
var d = c + 1;
|
|
15600
|
-
indices[indicesOffset++] = b;
|
|
15601
|
-
indices[indicesOffset++] = c;
|
|
15602
|
-
indices[indicesOffset++] = a;
|
|
15603
|
-
indices[indicesOffset++] = b;
|
|
15604
|
-
indices[indicesOffset++] = d;
|
|
15605
|
-
indices[indicesOffset++] = c;
|
|
15606
|
-
}
|
|
15607
|
-
var offset1 = torsoVertexCount * vertexFloatCount;
|
|
15608
|
-
// Bottom position
|
|
15609
|
-
vertices[offset1++] = 0;
|
|
15610
|
-
vertices[offset1++] = -halfHeight;
|
|
15611
|
-
vertices[offset1++] = 0;
|
|
15612
|
-
// Bottom normal
|
|
15613
|
-
vertices[offset1++] = 0;
|
|
15614
|
-
vertices[offset1++] = -1;
|
|
15615
|
-
vertices[offset1++] = 0;
|
|
15616
|
-
// Bottom texCoord
|
|
15617
|
-
vertices[offset1++] = 0.5;
|
|
15618
|
-
vertices[offset1++] = 0.5;
|
|
15619
|
-
// Top position
|
|
15620
|
-
vertices[offset1++] = 0;
|
|
15621
|
-
vertices[offset1++] = halfHeight;
|
|
15622
|
-
vertices[offset1++] = 0;
|
|
15623
|
-
// Top normal
|
|
15624
|
-
vertices[offset1++] = 0;
|
|
15625
|
-
vertices[offset1++] = 1;
|
|
15626
|
-
vertices[offset1++] = 0;
|
|
15627
|
-
// Top texCoord
|
|
15628
|
-
vertices[offset1++] = 0.5;
|
|
15629
|
-
vertices[offset1++] = 0.5;
|
|
15630
|
-
// Add cap vertices
|
|
15631
|
-
offset1 = (torsoVertexCount + 2) * vertexFloatCount;
|
|
15632
|
-
var diameterTopReciprocal = 1.0 / (radiusTop * 2);
|
|
15633
|
-
var diameterBottomReciprocal = 1.0 / (radiusBottom * 2);
|
|
15634
|
-
var positionStride = radialCount * heightSegments;
|
|
15635
|
-
for(var i2 = 0; i2 < radialSegments; ++i2){
|
|
15636
|
-
var curPosBottomOffset = i2 * vertexFloatCount;
|
|
15637
|
-
var curPosX = vertices[curPosBottomOffset];
|
|
15638
|
-
var curPosZ = vertices[curPosBottomOffset + 2];
|
|
15639
|
-
// Bottom position
|
|
15640
|
-
vertices[offset1++] = curPosX;
|
|
15641
|
-
vertices[offset1++] = -halfHeight;
|
|
15642
|
-
vertices[offset1++] = curPosZ;
|
|
15643
|
-
// Bottom normal
|
|
15644
|
-
vertices[offset1++] = 0;
|
|
15645
|
-
vertices[offset1++] = -1;
|
|
15646
|
-
vertices[offset1++] = 0;
|
|
15647
|
-
// Bottom texcoord
|
|
15648
|
-
vertices[offset1++] = curPosX * diameterBottomReciprocal + 0.5;
|
|
15649
|
-
vertices[offset1++] = 0.5 - curPosZ * diameterBottomReciprocal;
|
|
15650
|
-
var curPosTopOffset = (i2 + positionStride) * vertexFloatCount;
|
|
15651
|
-
curPosX = vertices[curPosTopOffset];
|
|
15652
|
-
curPosZ = vertices[curPosTopOffset + 2];
|
|
15653
|
-
// Top position
|
|
15654
|
-
vertices[offset1++] = curPosX;
|
|
15655
|
-
vertices[offset1++] = halfHeight;
|
|
15656
|
-
vertices[offset1++] = curPosZ;
|
|
15657
|
-
// Top normal
|
|
15658
|
-
vertices[offset1++] = 0;
|
|
15659
|
-
vertices[offset1++] = 1;
|
|
15660
|
-
vertices[offset1++] = 0;
|
|
15661
|
-
// Top texcoord
|
|
15662
|
-
vertices[offset1++] = curPosX * diameterTopReciprocal + 0.5;
|
|
15663
|
-
vertices[offset1++] = 0.5 - curPosZ * diameterTopReciprocal;
|
|
15664
|
-
}
|
|
15665
|
-
// Add cap indices
|
|
15666
|
-
var topCapIndex = torsoVertexCount + 1;
|
|
15667
|
-
var bottomIndiceIndex = torsoVertexCount + 2;
|
|
15668
|
-
var topIndiceIndex = bottomIndiceIndex + 1;
|
|
15669
|
-
for(var i3 = 0; i3 < radialSegments; ++i3){
|
|
15670
|
-
var firstStride = i3 * 2;
|
|
15671
|
-
var secondStride = i3 === radialSegments - 1 ? 0 : firstStride + 2;
|
|
15672
|
-
// Bottom
|
|
15673
|
-
indices[indicesOffset++] = torsoVertexCount;
|
|
15674
|
-
indices[indicesOffset++] = bottomIndiceIndex + secondStride;
|
|
15675
|
-
indices[indicesOffset++] = bottomIndiceIndex + firstStride;
|
|
15676
|
-
// Top
|
|
15677
|
-
indices[indicesOffset++] = topCapIndex;
|
|
15678
|
-
indices[indicesOffset++] = topIndiceIndex + firstStride;
|
|
15679
|
-
indices[indicesOffset++] = topIndiceIndex + secondStride;
|
|
15680
|
-
}
|
|
15681
|
-
if (!isRestoreMode) {
|
|
15682
|
-
var bounds = cylinderMesh.bounds;
|
|
15683
|
-
var radiusMax = Math.max(radiusTop, radiusBottom);
|
|
15684
|
-
bounds.min.set(-radiusMax, -halfHeight, -radiusMax);
|
|
15685
|
-
bounds.max.set(radiusMax, halfHeight, radiusMax);
|
|
15686
|
-
}
|
|
15687
|
-
PrimitiveMesh._initialize(cylinderMesh, vertices, indices, noLongerAccessible, isRestoreMode, restoreVertexBuffer);
|
|
15688
|
-
};
|
|
15689
|
-
/**
|
|
15690
|
-
* @internal
|
|
15691
|
-
*/ PrimitiveMesh._setTorusData = function _setTorusData(torusMesh, radius, tubeRadius, radialSegments, tubularSegments, arc, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
|
|
15692
|
-
radialSegments = Math.floor(radialSegments);
|
|
15693
|
-
tubularSegments = Math.floor(tubularSegments);
|
|
15694
|
-
var vertexCount = (radialSegments + 1) * (tubularSegments + 1);
|
|
15695
|
-
var rectangleCount = radialSegments * tubularSegments;
|
|
15696
|
-
var indices = PrimitiveMesh._generateIndices(torusMesh.engine, vertexCount, rectangleCount * 6);
|
|
15697
|
-
var vertexFloatCount = 8;
|
|
15698
|
-
var vertices = new Float32Array(vertexCount * vertexFloatCount);
|
|
15699
|
-
arc = arc / 180 * Math.PI;
|
|
15700
|
-
var offset = 0;
|
|
15701
|
-
var normal = PrimitiveMesh._tempVec30;
|
|
15702
|
-
for(var i = 0; i <= radialSegments; i++){
|
|
15703
|
-
for(var j = 0; j <= tubularSegments; j++){
|
|
15704
|
-
var u = j / tubularSegments * arc;
|
|
15705
|
-
var v = i / radialSegments * Math.PI * 2;
|
|
15706
|
-
var cosV = Math.cos(v);
|
|
15707
|
-
var sinV = Math.sin(v);
|
|
15708
|
-
var cosU = Math.cos(u);
|
|
15709
|
-
var sinU = Math.sin(u);
|
|
15710
|
-
// Position
|
|
15711
|
-
var positionX = (radius + tubeRadius * cosV) * cosU;
|
|
15712
|
-
var positionY = (radius + tubeRadius * cosV) * sinU;
|
|
15713
|
-
var positionZ = tubeRadius * sinV;
|
|
15714
|
-
vertices[offset++] = positionX;
|
|
15715
|
-
vertices[offset++] = positionY;
|
|
15716
|
-
vertices[offset++] = positionZ;
|
|
15717
|
-
// Normal
|
|
15718
|
-
var centerX = radius * cosU;
|
|
15719
|
-
var centerY = radius * sinU;
|
|
15720
|
-
normal.set(positionX - centerX, positionY - centerY, positionZ).normalize();
|
|
15721
|
-
vertices[offset++] = normal.x;
|
|
15722
|
-
vertices[offset++] = normal.y;
|
|
15723
|
-
vertices[offset++] = normal.z;
|
|
15724
|
-
// UV
|
|
15725
|
-
vertices[offset++] = j / tubularSegments;
|
|
15726
|
-
vertices[offset++] = i / radialSegments;
|
|
15727
|
-
}
|
|
15728
|
-
}
|
|
15729
|
-
offset = 0;
|
|
15730
|
-
for(var i1 = 1; i1 <= radialSegments; i1++){
|
|
15731
|
-
for(var j1 = 1; j1 <= tubularSegments; j1++){
|
|
15732
|
-
var a = (tubularSegments + 1) * i1 + j1 - 1;
|
|
15733
|
-
var b = (tubularSegments + 1) * (i1 - 1) + j1 - 1;
|
|
15734
|
-
var c = (tubularSegments + 1) * (i1 - 1) + j1;
|
|
15735
|
-
var d = (tubularSegments + 1) * i1 + j1;
|
|
15736
|
-
indices[offset++] = a;
|
|
15737
|
-
indices[offset++] = b;
|
|
15738
|
-
indices[offset++] = d;
|
|
15739
|
-
indices[offset++] = b;
|
|
15740
|
-
indices[offset++] = c;
|
|
15741
|
-
indices[offset++] = d;
|
|
15742
|
-
}
|
|
15743
|
-
}
|
|
15744
|
-
if (!isRestoreMode) {
|
|
15745
|
-
var bounds = torusMesh.bounds;
|
|
15746
|
-
var outerRadius = radius + tubeRadius;
|
|
15747
|
-
bounds.min.set(-outerRadius, -outerRadius, -tubeRadius);
|
|
15748
|
-
bounds.max.set(outerRadius, outerRadius, tubeRadius);
|
|
15749
|
-
}
|
|
15750
|
-
PrimitiveMesh._initialize(torusMesh, vertices, indices, noLongerAccessible, isRestoreMode, restoreVertexBuffer);
|
|
15751
|
-
};
|
|
15752
|
-
/**
|
|
15753
|
-
* @internal
|
|
15754
|
-
*/ PrimitiveMesh._setConeData = function _setConeData(coneMesh, radius, height, radialSegments, heightSegments, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
|
|
15755
|
-
radialSegments = Math.floor(radialSegments);
|
|
15756
|
-
heightSegments = Math.floor(heightSegments);
|
|
15757
|
-
var radialCount = radialSegments + 1;
|
|
15758
|
-
var verticalCount = heightSegments + 1;
|
|
15759
|
-
var halfHeight = height * 0.5;
|
|
15760
|
-
var unitHeight = height / heightSegments;
|
|
15761
|
-
var torsoVertexCount = radialCount * verticalCount;
|
|
15762
|
-
var torsoRectangleCount = radialSegments * heightSegments;
|
|
15763
|
-
var totalVertexCount = torsoVertexCount + 1 + radialSegments;
|
|
15764
|
-
var indices = PrimitiveMesh._generateIndices(coneMesh.engine, totalVertexCount, torsoRectangleCount * 6 + radialSegments * 3);
|
|
15765
|
-
var radialCountReciprocal = 1.0 / radialCount;
|
|
15766
|
-
var radialSegmentsReciprocal = 1.0 / radialSegments;
|
|
15767
|
-
var heightSegmentsReciprocal = 1.0 / heightSegments;
|
|
15768
|
-
var vertexFloatCount = 8;
|
|
15769
|
-
var vertices = new Float32Array(totalVertexCount * 8);
|
|
15770
|
-
var indicesOffset = 0;
|
|
15771
|
-
// Create torso
|
|
15772
|
-
var thetaStart = Math.PI;
|
|
15773
|
-
var thetaRange = Math.PI * 2;
|
|
15774
|
-
var slope = radius / height;
|
|
15775
|
-
for(var i = 0; i < torsoVertexCount; ++i){
|
|
15776
|
-
var x = i % radialCount;
|
|
15777
|
-
var y = i * radialCountReciprocal | 0;
|
|
15778
|
-
var u = x * radialSegmentsReciprocal;
|
|
15779
|
-
var v = y * heightSegmentsReciprocal;
|
|
15780
|
-
var theta = thetaStart + u * thetaRange;
|
|
15781
|
-
var sinTheta = Math.sin(theta);
|
|
15782
|
-
var cosTheta = Math.cos(theta);
|
|
15783
|
-
var curRadius = radius - v * radius;
|
|
15784
|
-
var posX = curRadius * sinTheta;
|
|
15785
|
-
var posY = y * unitHeight - halfHeight;
|
|
15786
|
-
var posZ = curRadius * cosTheta;
|
|
15787
|
-
var offset = i * vertexFloatCount;
|
|
15788
|
-
// Position
|
|
15789
|
-
vertices[offset++] = posX;
|
|
15790
|
-
vertices[offset++] = posY;
|
|
15791
|
-
vertices[offset++] = posZ;
|
|
15792
|
-
// Normal
|
|
15793
|
-
vertices[offset++] = sinTheta;
|
|
15794
|
-
vertices[offset++] = slope;
|
|
15795
|
-
vertices[offset++] = cosTheta;
|
|
15796
|
-
// Texcoord
|
|
15797
|
-
vertices[offset++] = u;
|
|
15798
|
-
vertices[offset++] = 1 - v;
|
|
15799
|
-
}
|
|
15800
|
-
for(var i1 = 0; i1 < torsoRectangleCount; ++i1){
|
|
15801
|
-
var x1 = i1 % radialSegments;
|
|
15802
|
-
var y1 = i1 * radialSegmentsReciprocal | 0;
|
|
15803
|
-
var a = y1 * radialCount + x1;
|
|
15804
|
-
var b = a + 1;
|
|
15805
|
-
var c = a + radialCount;
|
|
15806
|
-
var d = c + 1;
|
|
15807
|
-
indices[indicesOffset++] = b;
|
|
15808
|
-
indices[indicesOffset++] = c;
|
|
15809
|
-
indices[indicesOffset++] = a;
|
|
15810
|
-
indices[indicesOffset++] = b;
|
|
15811
|
-
indices[indicesOffset++] = d;
|
|
15812
|
-
indices[indicesOffset++] = c;
|
|
15813
|
-
}
|
|
15814
|
-
var offset1 = torsoVertexCount * vertexFloatCount;
|
|
15815
|
-
// Bottom position
|
|
15816
|
-
vertices[offset1++] = 0;
|
|
15817
|
-
vertices[offset1++] = -halfHeight;
|
|
15818
|
-
vertices[offset1++] = 0;
|
|
15819
|
-
// Bottom normal
|
|
15820
|
-
vertices[offset1++] = 0;
|
|
15821
|
-
vertices[offset1++] = -1;
|
|
15822
|
-
vertices[offset1++] = 0;
|
|
15823
|
-
// Bottom texcoord
|
|
15824
|
-
vertices[offset1++] = 0.5;
|
|
15825
|
-
vertices[offset1++] = 0.5;
|
|
15826
|
-
// Add bottom cap vertices
|
|
15827
|
-
offset1 = (torsoVertexCount + 1) * vertexFloatCount;
|
|
15828
|
-
var diameterBottomReciprocal = 1.0 / (radius * 2);
|
|
15829
|
-
for(var i2 = 0; i2 < radialSegments; ++i2){
|
|
15830
|
-
var curPosX = vertices[i2 * vertexFloatCount];
|
|
15831
|
-
var curPosZ = vertices[i2 * vertexFloatCount + 2];
|
|
15832
|
-
// Bottom position
|
|
15833
|
-
vertices[offset1++] = curPosX;
|
|
15834
|
-
vertices[offset1++] = -halfHeight;
|
|
15835
|
-
vertices[offset1++] = curPosZ;
|
|
15836
|
-
// Bottom normal
|
|
15837
|
-
vertices[offset1++] = 0;
|
|
15838
|
-
vertices[offset1++] = -1;
|
|
15839
|
-
vertices[offset1++] = 0;
|
|
15840
|
-
// Bottom texcoord
|
|
15841
|
-
vertices[offset1++] = curPosX * diameterBottomReciprocal + 0.5;
|
|
15842
|
-
vertices[offset1++] = 0.5 - curPosZ * diameterBottomReciprocal;
|
|
15843
|
-
}
|
|
15844
|
-
var bottomIndiceIndex = torsoVertexCount + 1;
|
|
15845
|
-
for(var i3 = 0; i3 < radialSegments; ++i3){
|
|
15846
|
-
var firstStride = i3;
|
|
15847
|
-
var secondStride = i3 === radialSegments - 1 ? 0 : firstStride + 1;
|
|
15848
|
-
// Bottom
|
|
15849
|
-
indices[indicesOffset++] = torsoVertexCount;
|
|
15850
|
-
indices[indicesOffset++] = bottomIndiceIndex + secondStride;
|
|
15851
|
-
indices[indicesOffset++] = bottomIndiceIndex + firstStride;
|
|
15852
|
-
}
|
|
15853
|
-
if (!isRestoreMode) {
|
|
15854
|
-
var bounds = coneMesh.bounds;
|
|
15855
|
-
bounds.min.set(-radius, -halfHeight, -radius);
|
|
15856
|
-
bounds.max.set(radius, halfHeight, radius);
|
|
15857
|
-
}
|
|
15858
|
-
PrimitiveMesh._initialize(coneMesh, vertices, indices, noLongerAccessible, isRestoreMode, restoreVertexBuffer);
|
|
15859
|
-
};
|
|
15860
|
-
/**
|
|
15861
|
-
* @internal
|
|
15862
|
-
*/ PrimitiveMesh._setCapsuleData = function _setCapsuleData(capsuleMesh, radius, height, radialSegments, heightSegments, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
|
|
15863
|
-
radialSegments = Math.max(2, Math.floor(radialSegments));
|
|
15864
|
-
heightSegments = Math.floor(heightSegments);
|
|
15865
|
-
var radialCount = radialSegments + 1;
|
|
15866
|
-
var verticalCount = heightSegments + 1;
|
|
15867
|
-
var halfHeight = height * 0.5;
|
|
15868
|
-
var unitHeight = height / heightSegments;
|
|
15869
|
-
var torsoVertexCount = radialCount * verticalCount;
|
|
15870
|
-
var torsoRectangleCount = radialSegments * heightSegments;
|
|
15871
|
-
var capVertexCount = radialCount * radialCount;
|
|
15872
|
-
var capRectangleCount = radialSegments * radialSegments;
|
|
15873
|
-
var totalVertexCount = torsoVertexCount + 2 * capVertexCount;
|
|
15874
|
-
var indices = PrimitiveMesh._generateIndices(capsuleMesh.engine, totalVertexCount, (torsoRectangleCount + 2 * capRectangleCount) * 6);
|
|
15875
|
-
var radialCountReciprocal = 1.0 / radialCount;
|
|
15876
|
-
var radialSegmentsReciprocal = 1.0 / radialSegments;
|
|
15877
|
-
var heightSegmentsReciprocal = 1.0 / heightSegments;
|
|
15878
|
-
var thetaStart = Math.PI;
|
|
15879
|
-
var thetaRange = Math.PI * 2;
|
|
15880
|
-
var vertexFloatCount = 8;
|
|
15881
|
-
var vertices = new Float32Array(totalVertexCount * vertexFloatCount);
|
|
15882
|
-
var indicesOffset = 0;
|
|
15883
|
-
// create torso
|
|
15884
|
-
for(var i = 0; i < torsoVertexCount; ++i){
|
|
15885
|
-
var x = i % radialCount;
|
|
15886
|
-
var y = i * radialCountReciprocal | 0;
|
|
15887
|
-
var u = x * radialSegmentsReciprocal;
|
|
15888
|
-
var v = y * heightSegmentsReciprocal;
|
|
15889
|
-
var theta = thetaStart + u * thetaRange;
|
|
15890
|
-
var sinTheta = Math.sin(theta);
|
|
15891
|
-
var cosTheta = Math.cos(theta);
|
|
15892
|
-
var offset = i * vertexFloatCount;
|
|
15893
|
-
// position
|
|
15894
|
-
vertices[offset++] = radius * sinTheta;
|
|
15895
|
-
vertices[offset++] = y * unitHeight - halfHeight;
|
|
15896
|
-
vertices[offset++] = radius * cosTheta;
|
|
15897
|
-
// Normal
|
|
15898
|
-
vertices[offset++] = sinTheta;
|
|
15899
|
-
vertices[offset++] = 0;
|
|
15900
|
-
vertices[offset++] = cosTheta;
|
|
15901
|
-
// Texcoord
|
|
15902
|
-
vertices[offset++] = u;
|
|
15903
|
-
vertices[offset++] = 1 - v;
|
|
15904
|
-
}
|
|
15905
|
-
for(var i1 = 0; i1 < torsoRectangleCount; ++i1){
|
|
15906
|
-
var x1 = i1 % radialSegments;
|
|
15907
|
-
var y1 = i1 * radialSegmentsReciprocal | 0;
|
|
15908
|
-
var a = y1 * radialCount + x1;
|
|
15909
|
-
var b = a + 1;
|
|
15910
|
-
var c = a + radialCount;
|
|
15911
|
-
var d = c + 1;
|
|
15912
|
-
indices[indicesOffset++] = b;
|
|
15913
|
-
indices[indicesOffset++] = c;
|
|
15914
|
-
indices[indicesOffset++] = a;
|
|
15915
|
-
indices[indicesOffset++] = b;
|
|
15916
|
-
indices[indicesOffset++] = d;
|
|
15917
|
-
indices[indicesOffset++] = c;
|
|
15918
|
-
}
|
|
15919
|
-
PrimitiveMesh._createCapsuleCap(radius, height, radialSegments, thetaStart, thetaRange, torsoVertexCount, 1, vertices, indices, indicesOffset);
|
|
15920
|
-
PrimitiveMesh._createCapsuleCap(radius, height, radialSegments, thetaStart, -thetaRange, torsoVertexCount + capVertexCount, -1, vertices, indices, indicesOffset + 6 * capRectangleCount);
|
|
15921
|
-
if (!isRestoreMode) {
|
|
15922
|
-
var bounds = capsuleMesh.bounds;
|
|
15923
|
-
bounds.min.set(-radius, -radius - halfHeight, -radius);
|
|
15924
|
-
bounds.max.set(radius, radius + halfHeight, radius);
|
|
15925
|
-
}
|
|
15926
|
-
PrimitiveMesh._initialize(capsuleMesh, vertices, indices, noLongerAccessible, isRestoreMode, restoreVertexBuffer);
|
|
15927
|
-
};
|
|
15928
|
-
PrimitiveMesh._initialize = function _initialize(mesh, vertices, indices, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
|
|
15929
|
-
if (isRestoreMode) {
|
|
15930
|
-
restoreVertexBuffer.setData(vertices);
|
|
15931
|
-
mesh.setIndices(indices);
|
|
15932
|
-
mesh.uploadData(noLongerAccessible);
|
|
17287
|
+
var data = generate.apply(void 0, [].concat(args));
|
|
17288
|
+
data.trim();
|
|
17289
|
+
if (data.vertexCount > 65535 && !engine._hardwareRenderer.canIUse(GLCapabilityType.elementIndexUint)) {
|
|
17290
|
+
throw new Error("The vertex count is over limit.");
|
|
17291
|
+
}
|
|
17292
|
+
var mesh = new ModelMesh(engine);
|
|
17293
|
+
var vertices = data.vertices;
|
|
17294
|
+
var indices = data.indices;
|
|
17295
|
+
mesh.setVertexElements([
|
|
17296
|
+
new VertexElement(VertexAttribute.Position, 0, VertexElementFormat.Vector3, 0),
|
|
17297
|
+
new VertexElement(VertexAttribute.Normal, 12, VertexElementFormat.Vector3, 0),
|
|
17298
|
+
new VertexElement(VertexAttribute.UV, 24, VertexElementFormat.Vector2, 0)
|
|
17299
|
+
]);
|
|
17300
|
+
var vertexBuffer = new Buffer(mesh.engine, BufferBindFlag.VertexBuffer, vertices, BufferUsage.Static, true);
|
|
17301
|
+
mesh.setVertexBufferBinding(vertexBuffer, 32, 0);
|
|
17302
|
+
mesh.setIndices(indices);
|
|
17303
|
+
mesh.calculateTangents();
|
|
17304
|
+
PrimitiveMesh._setBounds(mesh, data);
|
|
17305
|
+
mesh.uploadData(!keepMeshData);
|
|
17306
|
+
if (!keepMeshData) {
|
|
17307
|
+
vertexBuffer.markAsUnreadable();
|
|
17308
|
+
}
|
|
17309
|
+
if ((options == null ? void 0 : options.separateMaterialSlots) && data.groups.length) {
|
|
17310
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(data.groups), _step; !(_step = _iterator()).done;){
|
|
17311
|
+
var group = _step.value;
|
|
17312
|
+
mesh.addSubMesh(group.start, group.count);
|
|
17313
|
+
}
|
|
15933
17314
|
} else {
|
|
15934
|
-
var vertexElements = [
|
|
15935
|
-
new VertexElement(VertexAttribute.Position, 0, VertexElementFormat.Vector3, 0),
|
|
15936
|
-
new VertexElement(VertexAttribute.Normal, 12, VertexElementFormat.Vector3, 0),
|
|
15937
|
-
new VertexElement(VertexAttribute.UV, 24, VertexElementFormat.Vector2, 0)
|
|
15938
|
-
];
|
|
15939
|
-
mesh.setVertexElements(vertexElements);
|
|
15940
|
-
var vertexBuffer = new Buffer(mesh.engine, BufferBindFlag.VertexBuffer, vertices, BufferUsage.Static, true);
|
|
15941
|
-
mesh.setVertexBufferBinding(vertexBuffer, 32, 0);
|
|
15942
|
-
mesh.setIndices(indices);
|
|
15943
|
-
mesh.calculateTangents();
|
|
15944
|
-
mesh.uploadData(noLongerAccessible);
|
|
15945
17315
|
mesh.addSubMesh(0, indices.length);
|
|
15946
17316
|
}
|
|
17317
|
+
engine.resourceManager.addContentRestorer(new PrimitiveMeshRestorer(mesh, generate, args));
|
|
17318
|
+
return mesh;
|
|
15947
17319
|
};
|
|
15948
|
-
PrimitiveMesh.
|
|
15949
|
-
|
|
15950
|
-
|
|
15951
|
-
|
|
15952
|
-
|
|
15953
|
-
|
|
15954
|
-
|
|
17320
|
+
PrimitiveMesh._polygons = function _polygons(input) {
|
|
17321
|
+
if (!Array.isArray(input)) {
|
|
17322
|
+
return [
|
|
17323
|
+
input
|
|
17324
|
+
];
|
|
17325
|
+
}
|
|
17326
|
+
if (input.length === 0 || "points" in input[0]) {
|
|
17327
|
+
return input;
|
|
17328
|
+
}
|
|
17329
|
+
return [
|
|
17330
|
+
{
|
|
17331
|
+
points: input
|
|
15955
17332
|
}
|
|
15956
|
-
|
|
15957
|
-
|
|
15958
|
-
|
|
15959
|
-
|
|
15960
|
-
|
|
15961
|
-
|
|
15962
|
-
|
|
15963
|
-
|
|
15964
|
-
|
|
15965
|
-
var
|
|
15966
|
-
var
|
|
15967
|
-
var
|
|
15968
|
-
|
|
15969
|
-
|
|
15970
|
-
|
|
15971
|
-
|
|
15972
|
-
|
|
15973
|
-
|
|
15974
|
-
var theta = thetaStart + u * thetaRange;
|
|
15975
|
-
var alpha = v * Math.PI * 0.5;
|
|
15976
|
-
var sinAlpha = Math.sin(alpha);
|
|
15977
|
-
var posX = radius * Math.sin(theta) * sinAlpha;
|
|
15978
|
-
var posY = radius * Math.cos(alpha) * posIndex + halfHeight;
|
|
15979
|
-
var posZ = radius * Math.cos(theta) * sinAlpha;
|
|
15980
|
-
var index = (i + offset) * vertexFloatCount;
|
|
15981
|
-
// Position
|
|
15982
|
-
vertices[index++] = posX;
|
|
15983
|
-
vertices[index++] = posY;
|
|
15984
|
-
vertices[index++] = posZ;
|
|
15985
|
-
// Normal
|
|
15986
|
-
vertices[index++] = posX;
|
|
15987
|
-
vertices[index++] = posY - halfHeight;
|
|
15988
|
-
vertices[index++] = posZ;
|
|
15989
|
-
// Texcoord
|
|
15990
|
-
vertices[index++] = u;
|
|
15991
|
-
vertices[index++] = v;
|
|
15992
|
-
}
|
|
15993
|
-
for(var i1 = 0; i1 < capRectangleCount; ++i1){
|
|
15994
|
-
var x1 = i1 % radialSegments;
|
|
15995
|
-
var y1 = i1 * radialSegmentsReciprocal | 0;
|
|
15996
|
-
var a = y1 * radialCount + x1 + offset;
|
|
15997
|
-
var b = a + 1;
|
|
15998
|
-
var c = a + radialCount;
|
|
15999
|
-
var d = c + 1;
|
|
16000
|
-
indices[indicesOffset++] = b;
|
|
16001
|
-
indices[indicesOffset++] = a;
|
|
16002
|
-
indices[indicesOffset++] = d;
|
|
16003
|
-
indices[indicesOffset++] = a;
|
|
16004
|
-
indices[indicesOffset++] = c;
|
|
16005
|
-
indices[indicesOffset++] = d;
|
|
17333
|
+
];
|
|
17334
|
+
};
|
|
17335
|
+
PrimitiveMesh._setBounds = function _setBounds(mesh, data) {
|
|
17336
|
+
var extent = data.boundsExtent;
|
|
17337
|
+
if (extent) {
|
|
17338
|
+
mesh.bounds.min.set(-extent.x || 0, -extent.y || 0, -extent.z || 0);
|
|
17339
|
+
mesh.bounds.max.copyFrom(extent);
|
|
17340
|
+
return;
|
|
17341
|
+
}
|
|
17342
|
+
var minX = Infinity, minY = Infinity, minZ = Infinity;
|
|
17343
|
+
var maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;
|
|
17344
|
+
for(var i = 0; i < data.vertices.length; i += 8){
|
|
17345
|
+
minX = Math.min(minX, data.vertices[i]);
|
|
17346
|
+
minY = Math.min(minY, data.vertices[i + 1]);
|
|
17347
|
+
minZ = Math.min(minZ, data.vertices[i + 2]);
|
|
17348
|
+
maxX = Math.max(maxX, data.vertices[i]);
|
|
17349
|
+
maxY = Math.max(maxY, data.vertices[i + 1]);
|
|
17350
|
+
maxZ = Math.max(maxZ, data.vertices[i + 2]);
|
|
16006
17351
|
}
|
|
17352
|
+
if (!data.vertices.length) {
|
|
17353
|
+
minX = minY = minZ = maxX = maxY = maxZ = 0;
|
|
17354
|
+
}
|
|
17355
|
+
mesh.bounds.min.set(minX, minY, minZ);
|
|
17356
|
+
mesh.bounds.max.set(maxX, maxY, maxZ);
|
|
17357
|
+
};
|
|
17358
|
+
PrimitiveMesh._copy = function _copy(value) {
|
|
17359
|
+
if (_instanceof(value, Vector2) || _instanceof(value, Vector3)) {
|
|
17360
|
+
return value.clone();
|
|
17361
|
+
}
|
|
17362
|
+
if (Array.isArray(value)) {
|
|
17363
|
+
return value.map(PrimitiveMesh._copy);
|
|
17364
|
+
}
|
|
17365
|
+
if (value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object") {
|
|
17366
|
+
var result = {};
|
|
17367
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(value)), _step; !(_step = _iterator()).done;){
|
|
17368
|
+
var key = _step.value;
|
|
17369
|
+
result[key] = PrimitiveMesh._copy(value[key]);
|
|
17370
|
+
}
|
|
17371
|
+
return result;
|
|
17372
|
+
}
|
|
17373
|
+
return value;
|
|
17374
|
+
};
|
|
17375
|
+
PrimitiveMesh._createArcSamples = function _createArcSamples(segments, start, arc) {
|
|
17376
|
+
if (start === void 0) start = 0;
|
|
17377
|
+
if (arc === void 0) arc = Math.PI * 2;
|
|
17378
|
+
var samples = new Float64Array((segments + 1) * 2);
|
|
17379
|
+
for(var i = 0; i <= segments; i++){
|
|
17380
|
+
var angle = start + i / segments * arc;
|
|
17381
|
+
samples[i * 2] = Math.cos(angle);
|
|
17382
|
+
samples[i * 2 + 1] = Math.sin(angle);
|
|
17383
|
+
}
|
|
17384
|
+
return samples;
|
|
17385
|
+
};
|
|
17386
|
+
PrimitiveMesh._getSegmentCount = function _getSegmentCount(value, minimum) {
|
|
17387
|
+
if (minimum === void 0) minimum = 1;
|
|
17388
|
+
return Math.max(minimum, Math.floor(value));
|
|
17389
|
+
};
|
|
17390
|
+
PrimitiveMesh._normalizeVector = function _normalizeVector(vector) {
|
|
17391
|
+
var length = Math.hypot(vector.x, vector.y, vector.z);
|
|
17392
|
+
return vector.scale(length > 0 ? 1 / length : 0);
|
|
16007
17393
|
};
|
|
16008
17394
|
return PrimitiveMesh;
|
|
16009
17395
|
}();
|
|
16010
|
-
PrimitiveMesh._tempVec30 = new Vector3();
|
|
16011
17396
|
PrimitiveMesh._sphereSeedPositions = new Float32Array([
|
|
16012
17397
|
-1,
|
|
16013
17398
|
1,
|
|
@@ -16060,8 +17445,364 @@ PrimitiveMesh._sphereSeedCells = new Float32Array([
|
|
|
16060
17445
|
2,
|
|
16061
17446
|
1
|
|
16062
17447
|
]);
|
|
16063
|
-
PrimitiveMesh.
|
|
16064
|
-
PrimitiveMesh.
|
|
17448
|
+
PrimitiveMesh._goldenRatio = (1 + Math.sqrt(5)) / 2;
|
|
17449
|
+
PrimitiveMesh._inverseGoldenRatio = 1 / PrimitiveMesh._goldenRatio;
|
|
17450
|
+
PrimitiveMesh._regularPolyhedra = {
|
|
17451
|
+
tetrahedron: [
|
|
17452
|
+
[
|
|
17453
|
+
1,
|
|
17454
|
+
1,
|
|
17455
|
+
1,
|
|
17456
|
+
-1,
|
|
17457
|
+
-1,
|
|
17458
|
+
1,
|
|
17459
|
+
-1,
|
|
17460
|
+
1,
|
|
17461
|
+
-1,
|
|
17462
|
+
1,
|
|
17463
|
+
-1,
|
|
17464
|
+
-1
|
|
17465
|
+
],
|
|
17466
|
+
[
|
|
17467
|
+
2,
|
|
17468
|
+
1,
|
|
17469
|
+
0,
|
|
17470
|
+
0,
|
|
17471
|
+
3,
|
|
17472
|
+
2,
|
|
17473
|
+
1,
|
|
17474
|
+
3,
|
|
17475
|
+
0,
|
|
17476
|
+
2,
|
|
17477
|
+
3,
|
|
17478
|
+
1
|
|
17479
|
+
]
|
|
17480
|
+
],
|
|
17481
|
+
octahedron: [
|
|
17482
|
+
[
|
|
17483
|
+
1,
|
|
17484
|
+
0,
|
|
17485
|
+
0,
|
|
17486
|
+
-1,
|
|
17487
|
+
0,
|
|
17488
|
+
0,
|
|
17489
|
+
0,
|
|
17490
|
+
1,
|
|
17491
|
+
0,
|
|
17492
|
+
0,
|
|
17493
|
+
-1,
|
|
17494
|
+
0,
|
|
17495
|
+
0,
|
|
17496
|
+
0,
|
|
17497
|
+
1,
|
|
17498
|
+
0,
|
|
17499
|
+
0,
|
|
17500
|
+
-1
|
|
17501
|
+
],
|
|
17502
|
+
[
|
|
17503
|
+
0,
|
|
17504
|
+
2,
|
|
17505
|
+
4,
|
|
17506
|
+
0,
|
|
17507
|
+
4,
|
|
17508
|
+
3,
|
|
17509
|
+
0,
|
|
17510
|
+
3,
|
|
17511
|
+
5,
|
|
17512
|
+
0,
|
|
17513
|
+
5,
|
|
17514
|
+
2,
|
|
17515
|
+
1,
|
|
17516
|
+
2,
|
|
17517
|
+
5,
|
|
17518
|
+
1,
|
|
17519
|
+
5,
|
|
17520
|
+
3,
|
|
17521
|
+
1,
|
|
17522
|
+
3,
|
|
17523
|
+
4,
|
|
17524
|
+
1,
|
|
17525
|
+
4,
|
|
17526
|
+
2
|
|
17527
|
+
]
|
|
17528
|
+
],
|
|
17529
|
+
icosahedron: [
|
|
17530
|
+
[
|
|
17531
|
+
-1,
|
|
17532
|
+
PrimitiveMesh._goldenRatio,
|
|
17533
|
+
0,
|
|
17534
|
+
1,
|
|
17535
|
+
PrimitiveMesh._goldenRatio,
|
|
17536
|
+
0,
|
|
17537
|
+
-1,
|
|
17538
|
+
-PrimitiveMesh._goldenRatio,
|
|
17539
|
+
0,
|
|
17540
|
+
1,
|
|
17541
|
+
-PrimitiveMesh._goldenRatio,
|
|
17542
|
+
0,
|
|
17543
|
+
0,
|
|
17544
|
+
-1,
|
|
17545
|
+
PrimitiveMesh._goldenRatio,
|
|
17546
|
+
0,
|
|
17547
|
+
1,
|
|
17548
|
+
PrimitiveMesh._goldenRatio,
|
|
17549
|
+
0,
|
|
17550
|
+
-1,
|
|
17551
|
+
-PrimitiveMesh._goldenRatio,
|
|
17552
|
+
0,
|
|
17553
|
+
1,
|
|
17554
|
+
-PrimitiveMesh._goldenRatio,
|
|
17555
|
+
PrimitiveMesh._goldenRatio,
|
|
17556
|
+
0,
|
|
17557
|
+
-1,
|
|
17558
|
+
PrimitiveMesh._goldenRatio,
|
|
17559
|
+
0,
|
|
17560
|
+
1,
|
|
17561
|
+
-PrimitiveMesh._goldenRatio,
|
|
17562
|
+
0,
|
|
17563
|
+
-1,
|
|
17564
|
+
-PrimitiveMesh._goldenRatio,
|
|
17565
|
+
0,
|
|
17566
|
+
1
|
|
17567
|
+
],
|
|
17568
|
+
[
|
|
17569
|
+
0,
|
|
17570
|
+
11,
|
|
17571
|
+
5,
|
|
17572
|
+
0,
|
|
17573
|
+
5,
|
|
17574
|
+
1,
|
|
17575
|
+
0,
|
|
17576
|
+
1,
|
|
17577
|
+
7,
|
|
17578
|
+
0,
|
|
17579
|
+
7,
|
|
17580
|
+
10,
|
|
17581
|
+
0,
|
|
17582
|
+
10,
|
|
17583
|
+
11,
|
|
17584
|
+
1,
|
|
17585
|
+
5,
|
|
17586
|
+
9,
|
|
17587
|
+
5,
|
|
17588
|
+
11,
|
|
17589
|
+
4,
|
|
17590
|
+
11,
|
|
17591
|
+
10,
|
|
17592
|
+
2,
|
|
17593
|
+
10,
|
|
17594
|
+
7,
|
|
17595
|
+
6,
|
|
17596
|
+
7,
|
|
17597
|
+
1,
|
|
17598
|
+
8,
|
|
17599
|
+
3,
|
|
17600
|
+
9,
|
|
17601
|
+
4,
|
|
17602
|
+
3,
|
|
17603
|
+
4,
|
|
17604
|
+
2,
|
|
17605
|
+
3,
|
|
17606
|
+
2,
|
|
17607
|
+
6,
|
|
17608
|
+
3,
|
|
17609
|
+
6,
|
|
17610
|
+
8,
|
|
17611
|
+
3,
|
|
17612
|
+
8,
|
|
17613
|
+
9,
|
|
17614
|
+
4,
|
|
17615
|
+
9,
|
|
17616
|
+
5,
|
|
17617
|
+
2,
|
|
17618
|
+
4,
|
|
17619
|
+
11,
|
|
17620
|
+
6,
|
|
17621
|
+
2,
|
|
17622
|
+
10,
|
|
17623
|
+
8,
|
|
17624
|
+
6,
|
|
17625
|
+
7,
|
|
17626
|
+
9,
|
|
17627
|
+
8,
|
|
17628
|
+
1
|
|
17629
|
+
]
|
|
17630
|
+
],
|
|
17631
|
+
dodecahedron: [
|
|
17632
|
+
[
|
|
17633
|
+
-1,
|
|
17634
|
+
-1,
|
|
17635
|
+
-1,
|
|
17636
|
+
-1,
|
|
17637
|
+
-1,
|
|
17638
|
+
1,
|
|
17639
|
+
-1,
|
|
17640
|
+
1,
|
|
17641
|
+
-1,
|
|
17642
|
+
-1,
|
|
17643
|
+
1,
|
|
17644
|
+
1,
|
|
17645
|
+
1,
|
|
17646
|
+
-1,
|
|
17647
|
+
-1,
|
|
17648
|
+
1,
|
|
17649
|
+
-1,
|
|
17650
|
+
1,
|
|
17651
|
+
1,
|
|
17652
|
+
1,
|
|
17653
|
+
-1,
|
|
17654
|
+
1,
|
|
17655
|
+
1,
|
|
17656
|
+
1,
|
|
17657
|
+
0,
|
|
17658
|
+
-PrimitiveMesh._inverseGoldenRatio,
|
|
17659
|
+
-PrimitiveMesh._goldenRatio,
|
|
17660
|
+
0,
|
|
17661
|
+
-PrimitiveMesh._inverseGoldenRatio,
|
|
17662
|
+
PrimitiveMesh._goldenRatio,
|
|
17663
|
+
0,
|
|
17664
|
+
PrimitiveMesh._inverseGoldenRatio,
|
|
17665
|
+
-PrimitiveMesh._goldenRatio,
|
|
17666
|
+
0,
|
|
17667
|
+
PrimitiveMesh._inverseGoldenRatio,
|
|
17668
|
+
PrimitiveMesh._goldenRatio,
|
|
17669
|
+
-PrimitiveMesh._inverseGoldenRatio,
|
|
17670
|
+
-PrimitiveMesh._goldenRatio,
|
|
17671
|
+
0,
|
|
17672
|
+
-PrimitiveMesh._inverseGoldenRatio,
|
|
17673
|
+
PrimitiveMesh._goldenRatio,
|
|
17674
|
+
0,
|
|
17675
|
+
PrimitiveMesh._inverseGoldenRatio,
|
|
17676
|
+
-PrimitiveMesh._goldenRatio,
|
|
17677
|
+
0,
|
|
17678
|
+
PrimitiveMesh._inverseGoldenRatio,
|
|
17679
|
+
PrimitiveMesh._goldenRatio,
|
|
17680
|
+
0,
|
|
17681
|
+
-PrimitiveMesh._goldenRatio,
|
|
17682
|
+
0,
|
|
17683
|
+
-PrimitiveMesh._inverseGoldenRatio,
|
|
17684
|
+
PrimitiveMesh._goldenRatio,
|
|
17685
|
+
0,
|
|
17686
|
+
-PrimitiveMesh._inverseGoldenRatio,
|
|
17687
|
+
-PrimitiveMesh._goldenRatio,
|
|
17688
|
+
0,
|
|
17689
|
+
PrimitiveMesh._inverseGoldenRatio,
|
|
17690
|
+
PrimitiveMesh._goldenRatio,
|
|
17691
|
+
0,
|
|
17692
|
+
PrimitiveMesh._inverseGoldenRatio
|
|
17693
|
+
],
|
|
17694
|
+
[
|
|
17695
|
+
3,
|
|
17696
|
+
11,
|
|
17697
|
+
7,
|
|
17698
|
+
3,
|
|
17699
|
+
7,
|
|
17700
|
+
15,
|
|
17701
|
+
3,
|
|
17702
|
+
15,
|
|
17703
|
+
13,
|
|
17704
|
+
7,
|
|
17705
|
+
19,
|
|
17706
|
+
17,
|
|
17707
|
+
7,
|
|
17708
|
+
17,
|
|
17709
|
+
6,
|
|
17710
|
+
7,
|
|
17711
|
+
6,
|
|
17712
|
+
15,
|
|
17713
|
+
17,
|
|
17714
|
+
4,
|
|
17715
|
+
8,
|
|
17716
|
+
17,
|
|
17717
|
+
8,
|
|
17718
|
+
10,
|
|
17719
|
+
17,
|
|
17720
|
+
10,
|
|
17721
|
+
6,
|
|
17722
|
+
8,
|
|
17723
|
+
0,
|
|
17724
|
+
16,
|
|
17725
|
+
8,
|
|
17726
|
+
16,
|
|
17727
|
+
2,
|
|
17728
|
+
8,
|
|
17729
|
+
2,
|
|
17730
|
+
10,
|
|
17731
|
+
0,
|
|
17732
|
+
12,
|
|
17733
|
+
1,
|
|
17734
|
+
0,
|
|
17735
|
+
1,
|
|
17736
|
+
18,
|
|
17737
|
+
0,
|
|
17738
|
+
18,
|
|
17739
|
+
16,
|
|
17740
|
+
6,
|
|
17741
|
+
10,
|
|
17742
|
+
2,
|
|
17743
|
+
6,
|
|
17744
|
+
2,
|
|
17745
|
+
13,
|
|
17746
|
+
6,
|
|
17747
|
+
13,
|
|
17748
|
+
15,
|
|
17749
|
+
2,
|
|
17750
|
+
16,
|
|
17751
|
+
18,
|
|
17752
|
+
2,
|
|
17753
|
+
18,
|
|
17754
|
+
3,
|
|
17755
|
+
2,
|
|
17756
|
+
3,
|
|
17757
|
+
13,
|
|
17758
|
+
18,
|
|
17759
|
+
1,
|
|
17760
|
+
9,
|
|
17761
|
+
18,
|
|
17762
|
+
9,
|
|
17763
|
+
11,
|
|
17764
|
+
18,
|
|
17765
|
+
11,
|
|
17766
|
+
3,
|
|
17767
|
+
4,
|
|
17768
|
+
14,
|
|
17769
|
+
12,
|
|
17770
|
+
4,
|
|
17771
|
+
12,
|
|
17772
|
+
0,
|
|
17773
|
+
4,
|
|
17774
|
+
0,
|
|
17775
|
+
8,
|
|
17776
|
+
11,
|
|
17777
|
+
9,
|
|
17778
|
+
5,
|
|
17779
|
+
11,
|
|
17780
|
+
5,
|
|
17781
|
+
19,
|
|
17782
|
+
11,
|
|
17783
|
+
19,
|
|
17784
|
+
7,
|
|
17785
|
+
19,
|
|
17786
|
+
5,
|
|
17787
|
+
14,
|
|
17788
|
+
19,
|
|
17789
|
+
14,
|
|
17790
|
+
4,
|
|
17791
|
+
19,
|
|
17792
|
+
4,
|
|
17793
|
+
17,
|
|
17794
|
+
1,
|
|
17795
|
+
12,
|
|
17796
|
+
14,
|
|
17797
|
+
1,
|
|
17798
|
+
14,
|
|
17799
|
+
5,
|
|
17800
|
+
1,
|
|
17801
|
+
5,
|
|
17802
|
+
9
|
|
17803
|
+
]
|
|
17804
|
+
]
|
|
17805
|
+
};
|
|
16065
17806
|
|
|
16066
17807
|
/**
|
|
16067
17808
|
* Skin used for skinned mesh renderer.
|
|
@@ -16432,7 +18173,7 @@ __decorate([
|
|
|
16432
18173
|
/**
|
|
16433
18174
|
* @internal
|
|
16434
18175
|
*/ var BasicResources = /*#__PURE__*/ function() {
|
|
16435
|
-
function BasicResources(engine) {
|
|
18176
|
+
function BasicResources(engine, shaders) {
|
|
16436
18177
|
this.engine = engine;
|
|
16437
18178
|
// prettier-ignore
|
|
16438
18179
|
var vertices = new Float32Array([
|
|
@@ -16464,9 +18205,9 @@ __decorate([
|
|
|
16464
18205
|
0,
|
|
16465
18206
|
2
|
|
16466
18207
|
]); // left-top
|
|
16467
|
-
var blitMaterial = new Material(engine,
|
|
18208
|
+
var blitMaterial = new Material(engine, shaders.blit);
|
|
16468
18209
|
blitMaterial._addReferCount(1);
|
|
16469
|
-
var blitScreenMaterial = new Material(engine,
|
|
18210
|
+
var blitScreenMaterial = new Material(engine, shaders.blitScreen);
|
|
16470
18211
|
blitScreenMaterial._addReferCount(1);
|
|
16471
18212
|
this.blitMaterial = blitMaterial;
|
|
16472
18213
|
this.blitScreenMaterial = blitScreenMaterial;
|
|
@@ -16492,11 +18233,11 @@ __decorate([
|
|
|
16492
18233
|
]);
|
|
16493
18234
|
this.uintWhiteTexture2D = this._create1x1Texture(engine, 0, TextureFormat.R32G32B32A32_UInt, whitePixel32, false);
|
|
16494
18235
|
}
|
|
16495
|
-
this.spriteDefaultMaterial = this._create2DMaterial(engine,
|
|
16496
|
-
this.textDefaultMaterial = this._create2DMaterial(engine,
|
|
16497
|
-
this.spriteMaskDefaultMaterial = this.
|
|
16498
|
-
this.meshMagentaMaterial = this._createMagentaMaterial(engine,
|
|
16499
|
-
this.particleMagentaMaterial = this._createMagentaMaterial(engine,
|
|
18236
|
+
this.spriteDefaultMaterial = this._create2DMaterial(engine, shaders.sprite);
|
|
18237
|
+
this.textDefaultMaterial = this._create2DMaterial(engine, shaders.text);
|
|
18238
|
+
this.spriteMaskDefaultMaterial = this._create2DMaterial(engine, shaders.spriteMask);
|
|
18239
|
+
this.meshMagentaMaterial = this._createMagentaMaterial(engine, shaders.unlit);
|
|
18240
|
+
this.particleMagentaMaterial = this._createMagentaMaterial(engine, shaders.particle);
|
|
16500
18241
|
}
|
|
16501
18242
|
var _proto = BasicResources.prototype;
|
|
16502
18243
|
/**
|
|
@@ -16591,17 +18332,12 @@ __decorate([
|
|
|
16591
18332
|
material.isGCIgnored = true;
|
|
16592
18333
|
return material;
|
|
16593
18334
|
};
|
|
16594
|
-
_proto._createMagentaMaterial = function _createMagentaMaterial(engine,
|
|
16595
|
-
var material = new BaseMaterial(engine,
|
|
18335
|
+
_proto._createMagentaMaterial = function _createMagentaMaterial(engine, shader) {
|
|
18336
|
+
var material = new BaseMaterial(engine, shader);
|
|
16596
18337
|
material.isGCIgnored = true;
|
|
16597
18338
|
material.shaderData.setColor("material_BaseColor", new Color(1.0, 0.0, 1.01, 1.0));
|
|
16598
18339
|
return material;
|
|
16599
18340
|
};
|
|
16600
|
-
_proto._createSpriteMaskMaterial = function _createSpriteMaskMaterial(engine) {
|
|
16601
|
-
var material = new Material(engine, Shader.find("2D/SpriteMask"));
|
|
16602
|
-
material.isGCIgnored = true;
|
|
16603
|
-
return material;
|
|
16604
|
-
};
|
|
16605
18341
|
BasicResources.getMaskInteractionRenderStates = function getMaskInteractionRenderStates(maskInteraction) {
|
|
16606
18342
|
var visibleInsideMask = maskInteraction === SpriteMaskInteraction.VisibleInsideMask;
|
|
16607
18343
|
var renderStates;
|
|
@@ -16760,12 +18496,6 @@ function _construct(Parent, args, Class) {
|
|
|
16760
18496
|
return Layer;
|
|
16761
18497
|
}({});
|
|
16762
18498
|
|
|
16763
|
-
function _type_of(obj) {
|
|
16764
|
-
"@swc/helpers - typeof";
|
|
16765
|
-
|
|
16766
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
16767
|
-
}
|
|
16768
|
-
|
|
16769
18499
|
/**
|
|
16770
18500
|
* @internal
|
|
16771
18501
|
*/ var CloneUtil = /*#__PURE__*/ function() {
|
|
@@ -23949,10 +25679,10 @@ var PostProcessUberPass = /*#__PURE__*/ function(PostProcessPass) {
|
|
|
23949
25679
|
_this = PostProcessPass.call(this, engine) || this, _this._mipDownRT = [], _this._mipUpRT = [];
|
|
23950
25680
|
_this.event = PostProcessPassEvent.AfterUber - 1;
|
|
23951
25681
|
// Uber Material
|
|
23952
|
-
var uberMaterial = new Material(engine,
|
|
25682
|
+
var uberMaterial = new Material(engine, Engine._builtinShaders.uber);
|
|
23953
25683
|
_this._uberMaterial = uberMaterial;
|
|
23954
25684
|
// Bloom Material
|
|
23955
|
-
var bloomMaterial = new Material(engine,
|
|
25685
|
+
var bloomMaterial = new Material(engine, Engine._builtinShaders.bloom);
|
|
23956
25686
|
_this._bloomMaterial = bloomMaterial;
|
|
23957
25687
|
// ShaderData initialization
|
|
23958
25688
|
var bloomShaderData = bloomMaterial.shaderData;
|
|
@@ -24327,7 +26057,7 @@ Sky._projectionMatrix = new Matrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, Sky._epsilon -
|
|
|
24327
26057
|
this._solidColor = new Color(0.05087608817155679, 0.05087608817155679, 0.05087608817155679, 1.0);
|
|
24328
26058
|
this._texture = null;
|
|
24329
26059
|
this._initMesh(_engine);
|
|
24330
|
-
this._initMaterial(_engine);
|
|
26060
|
+
this._initMaterial(_engine, Engine._builtinShaders.backgroundTexture);
|
|
24331
26061
|
}
|
|
24332
26062
|
var _proto = Background.prototype;
|
|
24333
26063
|
/**
|
|
@@ -24392,8 +26122,8 @@ Sky._projectionMatrix = new Matrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, Sky._epsilon -
|
|
|
24392
26122
|
}(ContentRestorer))());
|
|
24393
26123
|
this._mesh._addReferCount(1);
|
|
24394
26124
|
};
|
|
24395
|
-
_proto._initMaterial = function _initMaterial(engine) {
|
|
24396
|
-
var material = this._material = new Material(engine,
|
|
26125
|
+
_proto._initMaterial = function _initMaterial(engine, shader) {
|
|
26126
|
+
var material = this._material = new Material(engine, shader);
|
|
24397
26127
|
material._addReferCount(1);
|
|
24398
26128
|
};
|
|
24399
26129
|
_proto._createPlane = function _createPlane(engine) {
|
|
@@ -25319,10 +27049,10 @@ Camera = __decorate([
|
|
|
25319
27049
|
* Scalable Ambient Obscurance render pass.
|
|
25320
27050
|
*/ var ScalableAmbientObscurancePass = /*#__PURE__*/ function(PipelinePass) {
|
|
25321
27051
|
_inherits(ScalableAmbientObscurancePass, PipelinePass);
|
|
25322
|
-
function ScalableAmbientObscurancePass(engine) {
|
|
27052
|
+
function ScalableAmbientObscurancePass(engine, shader) {
|
|
25323
27053
|
var _this;
|
|
25324
27054
|
_this = PipelinePass.call(this, engine) || this, _this._invProjScaleXY = new Vector2(), _this._offsetX = new Vector4(), _this._offsetY = new Vector4();
|
|
25325
|
-
var material = new Material(engine,
|
|
27055
|
+
var material = new Material(engine, shader);
|
|
25326
27056
|
material._addReferCount(1);
|
|
25327
27057
|
_this._material = material;
|
|
25328
27058
|
_this.isSupported = _this.engine._hardwareRenderer.capability.isFragmentHighPrecision;
|
|
@@ -25445,7 +27175,6 @@ Camera = __decorate([
|
|
|
25445
27175
|
};
|
|
25446
27176
|
return ScalableAmbientObscurancePass;
|
|
25447
27177
|
}(PipelinePass);
|
|
25448
|
-
ScalableAmbientObscurancePass.SHADER_NAME = "Lighting/ScalableAmbientOcclusion";
|
|
25449
27178
|
ScalableAmbientObscurancePass._invRadiusSquaredProp = ShaderProperty.getByName("material_invRadiusSquared");
|
|
25450
27179
|
ScalableAmbientObscurancePass._intensityProp = ShaderProperty.getByName("material_intensity");
|
|
25451
27180
|
ScalableAmbientObscurancePass._projectionScaleRadiusProp = ShaderProperty.getByName("material_projectionScaleRadius");
|
|
@@ -25791,15 +27520,15 @@ PostProcessManager._tempVector3 = new Vector3();
|
|
|
25791
27520
|
* Processing sRGB Conversion and FXAA.
|
|
25792
27521
|
*/ var FinalPass = /*#__PURE__*/ function(PipelinePass) {
|
|
25793
27522
|
_inherits(FinalPass, PipelinePass);
|
|
25794
|
-
function FinalPass(engine) {
|
|
27523
|
+
function FinalPass(engine, sRGBShader, antiAliasingShader) {
|
|
25795
27524
|
var _this;
|
|
25796
27525
|
_this = PipelinePass.call(this, engine) || this;
|
|
25797
27526
|
// SRGB Material
|
|
25798
|
-
var sRGBmaterial = new Material(engine,
|
|
27527
|
+
var sRGBmaterial = new Material(engine, sRGBShader);
|
|
25799
27528
|
sRGBmaterial._addReferCount(1);
|
|
25800
27529
|
_this._sRGBmaterial = sRGBmaterial;
|
|
25801
27530
|
// FXAA Material
|
|
25802
|
-
var antiAliasingMaterial = new Material(engine,
|
|
27531
|
+
var antiAliasingMaterial = new Material(engine, antiAliasingShader);
|
|
25803
27532
|
antiAliasingMaterial._addReferCount(1);
|
|
25804
27533
|
_this._antiAliasingMaterial = antiAliasingMaterial;
|
|
25805
27534
|
return _this;
|
|
@@ -26880,12 +28609,13 @@ CascadedShadowCasterPass._tempMatrix0 = new Matrix();
|
|
|
26880
28609
|
this._shouldCopyBackgroundColor = false;
|
|
26881
28610
|
this._camera = camera;
|
|
26882
28611
|
var engine = camera.engine;
|
|
28612
|
+
var shaders = Engine._builtinShaders;
|
|
26883
28613
|
this._cullingResults = new CullingResults();
|
|
26884
28614
|
this._cascadedShadowCasterPass = new CascadedShadowCasterPass(camera);
|
|
26885
28615
|
this._depthOnlyPass = new DepthOnlyPass(engine);
|
|
26886
|
-
this._saoPass = new ScalableAmbientObscurancePass(engine);
|
|
28616
|
+
this._saoPass = new ScalableAmbientObscurancePass(engine, shaders.scalableAmbientOcclusion);
|
|
26887
28617
|
this._opaqueTexturePass = new OpaqueTexturePass(engine);
|
|
26888
|
-
this._finalPass = new FinalPass(engine);
|
|
28618
|
+
this._finalPass = new FinalPass(engine, shaders.finalSRGB, shaders.finalAntiAliasing);
|
|
26889
28619
|
}
|
|
26890
28620
|
var _proto = BasicRenderPipeline.prototype;
|
|
26891
28621
|
/**
|
|
@@ -27369,7 +29099,7 @@ var OverlayCamera = function OverlayCamera() {
|
|
|
27369
29099
|
if (!hardwareRenderer.canIUse(GLCapabilityType.sRGB)) {
|
|
27370
29100
|
_this._macroCollection.enable(Engine._noSRGBSupportMacro);
|
|
27371
29101
|
}
|
|
27372
|
-
_this._basicResources = new BasicResources(_this);
|
|
29102
|
+
_this._basicResources = new BasicResources(_this, Engine._builtinShaders);
|
|
27373
29103
|
_this._particleBufferUtils = new ParticleBufferUtils(_this);
|
|
27374
29104
|
var uberPass = new PostProcessUberPass(_this);
|
|
27375
29105
|
_this.addPostProcessPass(uberPass);
|
|
@@ -34047,7 +35777,7 @@ function _assert_this_initialized(self) {
|
|
|
34047
35777
|
_inherits(SkyBoxMaterial, Material);
|
|
34048
35778
|
function SkyBoxMaterial(engine) {
|
|
34049
35779
|
var _this;
|
|
34050
|
-
_this = Material.call(this, engine,
|
|
35780
|
+
_this = Material.call(this, engine, Engine._builtinShaders.skybox) || this, _this._tintColor = new Color(1, 1, 1, 1);
|
|
34051
35781
|
_this.shaderData.setFloat(SkyBoxMaterial._rotationProp, 0);
|
|
34052
35782
|
_this.shaderData.setFloat(SkyBoxMaterial._exposureProp, 1);
|
|
34053
35783
|
_this.shaderData.setColor(SkyBoxMaterial._tintColorProp, _this._tintColor);
|
|
@@ -34128,7 +35858,7 @@ SkyBoxMaterial._exposureProp = ShaderProperty.getByName("material_Exposure");
|
|
|
34128
35858
|
_inherits(SkyProceduralMaterial, Material);
|
|
34129
35859
|
function SkyProceduralMaterial(engine) {
|
|
34130
35860
|
var _this;
|
|
34131
|
-
_this = Material.call(this, engine,
|
|
35861
|
+
_this = Material.call(this, engine, Engine._builtinShaders.skyProcedural) || this;
|
|
34132
35862
|
_this.sunMode = 2;
|
|
34133
35863
|
_this.sunSize = 0.04;
|
|
34134
35864
|
_this.sunSizeConvergence = 5;
|
|
@@ -35297,14 +37027,13 @@ __decorate([
|
|
|
35297
37027
|
return TransformFeedback;
|
|
35298
37028
|
}(GraphicsResource);
|
|
35299
37029
|
|
|
35300
|
-
var FEEDBACK_SHADER_NAME$1 = "Effect/ParticleFeedback";
|
|
35301
37030
|
var GATHER_PASS_NAME = "SubEmitterTrajectoryGather";
|
|
35302
37031
|
/**
|
|
35303
37032
|
* Maintains parent trajectory state aligned with sub-emitted particle slots.
|
|
35304
37033
|
* @internal
|
|
35305
37034
|
*/ var ParticleSubEmitterSpawnState = /*#__PURE__*/ function() {
|
|
35306
|
-
function ParticleSubEmitterSpawnState(engine, particleCapacity, needsRenderBinding) {
|
|
35307
|
-
var
|
|
37035
|
+
function ParticleSubEmitterSpawnState(engine, shader, particleCapacity, needsRenderBinding) {
|
|
37036
|
+
var _shader_subShaders_;
|
|
35308
37037
|
this._subPrimitive = new SubPrimitive(0, 0, MeshTopology.Points);
|
|
35309
37038
|
this._renderBinding = null;
|
|
35310
37039
|
this._pendingParentTrajectoryBinding = null;
|
|
@@ -35313,11 +37042,11 @@ var GATHER_PASS_NAME = "SubEmitterTrajectoryGather";
|
|
|
35313
37042
|
this._pendingChildrenPerParent = 0;
|
|
35314
37043
|
this._pendingParentCount = 0;
|
|
35315
37044
|
this._activeGatherProgram = null;
|
|
35316
|
-
var gatherPass =
|
|
37045
|
+
var gatherPass = !shader.destroyed && ((_shader_subShaders_ = shader.subShaders[0]) == null ? void 0 : _shader_subShaders_.passes.find(function(pass) {
|
|
35317
37046
|
return pass.name === GATHER_PASS_NAME;
|
|
35318
|
-
});
|
|
37047
|
+
}));
|
|
35319
37048
|
if (!gatherPass) {
|
|
35320
|
-
throw new Error(GATHER_PASS_NAME + " pass is not
|
|
37049
|
+
throw new Error(GATHER_PASS_NAME + " pass is not available in " + shader.name + ".");
|
|
35321
37050
|
}
|
|
35322
37051
|
this._gatherPass = gatherPass;
|
|
35323
37052
|
var primitive = this._primitive = new Primitive(engine);
|
|
@@ -35652,25 +37381,19 @@ ParticleSubEmitterSpawnState._gatherMacros = new ShaderMacroCollection();
|
|
|
35652
37381
|
return TransformFeedbackSimulator;
|
|
35653
37382
|
}();
|
|
35654
37383
|
|
|
35655
|
-
var FEEDBACK_SHADER_NAME = "Effect/ParticleFeedback";
|
|
35656
37384
|
var FEEDBACK_PASS_NAME = "TransformFeedback";
|
|
35657
37385
|
/**
|
|
35658
37386
|
* @internal
|
|
35659
37387
|
* Particle-specific Transform Feedback simulation.
|
|
35660
37388
|
*/ var ParticleTransformFeedbackSimulator = /*#__PURE__*/ function() {
|
|
35661
|
-
function ParticleTransformFeedbackSimulator(engine, trajectoryEnabled, particleCount) {
|
|
35662
|
-
var
|
|
37389
|
+
function ParticleTransformFeedbackSimulator(engine, shader, trajectoryEnabled, particleCount) {
|
|
37390
|
+
var _shader_subShaders_;
|
|
35663
37391
|
this.trajectoryEnabled = trajectoryEnabled;
|
|
35664
|
-
|
|
35665
|
-
var feedbackShader = Shader.find(FEEDBACK_SHADER_NAME);
|
|
35666
|
-
if (!feedbackShader) {
|
|
35667
|
-
throw new Error("" + FEEDBACK_SHADER_NAME + ' shader is not registered. Import "@galacean/engine" before constructing the engine, ' + "or register the shader manually if you build a custom engine flavor.");
|
|
35668
|
-
}
|
|
35669
|
-
var feedbackPass = (_feedbackShader_subShaders_ = feedbackShader.subShaders[0]) == null ? void 0 : _feedbackShader_subShaders_.passes.find(function(pass) {
|
|
37392
|
+
var feedbackPass = !shader.destroyed && ((_shader_subShaders_ = shader.subShaders[0]) == null ? void 0 : _shader_subShaders_.passes.find(function(pass) {
|
|
35670
37393
|
return pass.name === FEEDBACK_PASS_NAME;
|
|
35671
|
-
});
|
|
37394
|
+
}));
|
|
35672
37395
|
if (!feedbackPass) {
|
|
35673
|
-
throw new Error(FEEDBACK_PASS_NAME + " pass is not
|
|
37396
|
+
throw new Error(FEEDBACK_PASS_NAME + " pass is not available in " + shader.name + ".");
|
|
35674
37397
|
}
|
|
35675
37398
|
var vertexStride;
|
|
35676
37399
|
var feedbackVaryings;
|
|
@@ -40398,7 +42121,8 @@ __decorate([
|
|
|
40398
42121
|
* @internal
|
|
40399
42122
|
*/ _proto._setTransformFeedback = function _setTransformFeedback() {
|
|
40400
42123
|
var _this__feedbackSimulator, _this__feedbackSimulator1;
|
|
40401
|
-
var
|
|
42124
|
+
var engine = this._renderer.engine;
|
|
42125
|
+
var isWebGL2 = engine._hardwareRenderer.isWebGL2;
|
|
40402
42126
|
var useTrajectory = isWebGL2 && (this.subEmitters._hasSubEmitterOfType(ParticleSubEmitterType.Death, false) || this.subEmitters._hasSubEmitterOfType(ParticleSubEmitterType.Birth, false));
|
|
40403
42127
|
var useFeedback = isWebGL2 && (useTrajectory || this.limitVelocityOverLifetime.enabled || this.noise.enabled || this.inheritVelocity._needTransformFeedback() || this.velocityOverLifetime._needTransformFeedback());
|
|
40404
42128
|
var _this__feedbackSimulator_trajectoryEnabled;
|
|
@@ -40408,7 +42132,7 @@ __decorate([
|
|
|
40408
42132
|
}
|
|
40409
42133
|
this._clearActiveParticles();
|
|
40410
42134
|
(_this__feedbackSimulator1 = this._feedbackSimulator) == null ? void 0 : _this__feedbackSimulator1.destroy();
|
|
40411
|
-
this._feedbackSimulator = useFeedback ? new ParticleTransformFeedbackSimulator(
|
|
42135
|
+
this._feedbackSimulator = useFeedback ? new ParticleTransformFeedbackSimulator(engine, Engine._builtinShaders.particleFeedback, useTrajectory, this._currentParticleCount) : null;
|
|
40412
42136
|
if (useFeedback) {
|
|
40413
42137
|
this._renderer.shaderData.enableMacro(ParticleGenerator._transformFeedbackMacro);
|
|
40414
42138
|
// Feedback buffer swaps every frame; VAO caching would bake stale buffer handles.
|
|
@@ -40925,7 +42649,8 @@ __decorate([
|
|
|
40925
42649
|
if (this._subEmitterSpawnState) {
|
|
40926
42650
|
return;
|
|
40927
42651
|
}
|
|
40928
|
-
|
|
42652
|
+
var engine = this._renderer.engine;
|
|
42653
|
+
this._subEmitterSpawnState = new ParticleSubEmitterSpawnState(engine, Engine._builtinShaders.particleFeedback, this._currentParticleCount, !this._feedbackSimulator);
|
|
40929
42654
|
this._renderer.shaderData.enableMacro(ParticleGenerator._hasSubEmitterSpawnedParticlesMacro);
|
|
40930
42655
|
this._reorganizeGeometryBuffers();
|
|
40931
42656
|
};
|
|
@@ -41256,7 +42981,7 @@ __decorate([
|
|
|
41256
42981
|
*/ var ParticleMaterial = /*#__PURE__*/ function(EffectMaterial) {
|
|
41257
42982
|
_inherits(ParticleMaterial, EffectMaterial);
|
|
41258
42983
|
function ParticleMaterial(engine, shader) {
|
|
41259
|
-
if (shader === void 0) shader =
|
|
42984
|
+
if (shader === void 0) shader = Engine._builtinShaders.particle;
|
|
41260
42985
|
return EffectMaterial.call(this, engine, shader) || this;
|
|
41261
42986
|
}
|
|
41262
42987
|
var _proto = ParticleMaterial.prototype;
|
|
@@ -42627,7 +44352,7 @@ __decorate([
|
|
|
42627
44352
|
*/ var TrailMaterial = /*#__PURE__*/ function(EffectMaterial) {
|
|
42628
44353
|
_inherits(TrailMaterial, EffectMaterial);
|
|
42629
44354
|
function TrailMaterial(engine) {
|
|
42630
|
-
return EffectMaterial.call(this, engine,
|
|
44355
|
+
return EffectMaterial.call(this, engine, Engine._builtinShaders.trail) || this;
|
|
42631
44356
|
}
|
|
42632
44357
|
var _proto = TrailMaterial.prototype;
|
|
42633
44358
|
/**
|
|
@@ -43065,7 +44790,7 @@ AudioManager._recovering = false;
|
|
|
43065
44790
|
if (!gainNode) {
|
|
43066
44791
|
this._gainNode = gainNode = AudioManager.getContext().createGain();
|
|
43067
44792
|
gainNode.connect(AudioManager.getGainNode());
|
|
43068
|
-
gainNode.gain.
|
|
44793
|
+
gainNode.gain.value = this._volume;
|
|
43069
44794
|
}
|
|
43070
44795
|
return gainNode;
|
|
43071
44796
|
};
|
|
@@ -43133,11 +44858,12 @@ AudioManager._recovering = false;
|
|
|
43133
44858
|
return this._volume;
|
|
43134
44859
|
},
|
|
43135
44860
|
set: function set(value) {
|
|
43136
|
-
var // No node yet -> _ensureGainNode() applies _volume on first play
|
|
43137
|
-
_this__gainNode;
|
|
43138
44861
|
value = Math.min(Math.max(0, value), 1.0);
|
|
43139
44862
|
this._volume = value;
|
|
43140
|
-
|
|
44863
|
+
// No node yet -> _ensureGainNode() applies _volume on first play
|
|
44864
|
+
if (this._gainNode) {
|
|
44865
|
+
this._gainNode.gain.value = value;
|
|
44866
|
+
}
|
|
43141
44867
|
}
|
|
43142
44868
|
},
|
|
43143
44869
|
{
|
|
@@ -43367,5 +45093,5 @@ __decorate([
|
|
|
43367
45093
|
return Polyfill;
|
|
43368
45094
|
}();
|
|
43369
45095
|
|
|
43370
|
-
export { AmbientLight, AmbientOcclusion, AmbientOcclusionQuality, AnimationArrayCurve, AnimationBoolCurve, AnimationClip, AnimationClipCurveBinding, AnimationColorCurve, AnimationCurve, AnimationEvent, AnimationFloatArrayCurve, AnimationFloatCurve, AnimationQuaternionCurve, AnimationRectCurve, AnimationRefCurve, AnimationStringCurve, AnimationVector2Curve, AnimationVector3Curve, AnimationVector4Curve, Animator, AnimatorCondition, AnimatorConditionMode, AnimatorController, AnimatorControllerLayer, AnimatorControllerParameter, AnimatorCullingMode, AnimatorLayerBlendingMode, AnimatorLayerMask, AnimatorState, AnimatorStateInstance, AnimatorStateMachine, AnimatorStateTransition, AntiAliasing, AssetPromise, AssetType, AudioClip, AudioManager, AudioSource, Background, BackgroundMode, BackgroundTextureFillMode, BaseMaterial, BasicRenderPipeline, BlendFactor, BlendMode, BlendOperation, BlendShape, BlendShapeFrame, BlinnPhongMaterial, Blitter, BloomDownScaleMode, BloomEffect, BoolUpdateFlag, BoxColliderShape, BoxShape, Buffer, BufferAsset, BufferBindFlag, BufferMesh, BufferUsage, BufferUtil, Burst, Camera, CameraClearFlags, CameraModifyFlags, CameraType, Canvas, CapsuleColliderShape, CharRenderInfo, CharacterController, CircleShape, ClearableObjectPool, Collider, ColliderShape, ColliderShapeUpAxis, Collision, CollisionDetectionMode, ColorOverLifetimeModule, ColorWriteMask, CompareFunction, Component, ConeEmitType, ConeShape, ContactPoint, ContentRestorer, ControllerCollisionFlag, ControllerNonWalkableMode, CubeProbe, CullMode, CurveKey, CustomDataModule, DataObject, DataType, DependentMode, DepthTextureMode, DiffuseMode, DirectLight, DisorderedArray, Downsampling, DynamicCollider, DynamicColliderConstraints, EmissionModule, Engine, EngineEventType, EngineObject, Entity, EntityModifyFlags, EventDispatcher, FinalPass, FixedJoint, FogMode, Font, FontStyle, GLCapabilityType, GradientAlphaKey, GradientColorKey, HemisphereShape, HingeJoint, HitResult, IndexBufferBinding, IndexFormat, InheritVelocityModule, InputManager, InterpolationType, JSONAsset, Joint, JointLimits, JointMotor, Keyframe, Keys, Layer, LayerPathMask, Light, LimitVelocityOverLifetimeModule, Loader, Logger, MSAASamples, MainModule, Material, Mesh, MeshColliderShape, MeshColliderShapeCookingFlag, MeshRenderer, MeshShape, MeshTopology, ModelMesh, NoiseModule, OverflowMode, PBRMaterial, ParticleCompositeCurve, ParticleCompositeGradient, ParticleCurve, ParticleCurveMode, ParticleGenerator, ParticleGradient, ParticleGradientMode, ParticleInheritVelocityMode, ParticleMaterial, ParticleRenderMode, ParticleRenderer, ParticleScaleMode, ParticleShapeArcMode, ParticleShapeType, ParticleSimulationSpace, ParticleStopMode, ParticleSubEmitterInheritProperty, ParticleSubEmitterType, PhysicsMaterial, PhysicsMaterialCombineMode, PhysicsScene, PipelineStage, PlaneColliderShape, Platform, PointLight, Pointer, PointerButton, PointerEventData, PointerEventEmitter, PointerPhase, Polyfill, PostProcess, PostProcessEffect, PostProcessEffectBoolParameter, PostProcessEffectColorParameter, PostProcessEffectEnumParameter, PostProcessEffectFloatParameter, PostProcessEffectParameter, PostProcessEffectTextureParameter, PostProcessEffectVector2Parameter, PostProcessEffectVector3Parameter, PostProcessEffectVector4Parameter, PostProcessManager, PostProcessPass, PostProcessPassEvent, PostProcessUberPass, Primitive, PrimitiveMesh, Probe, ReferResource, RefractionMode, RenderBufferDepthFormat, RenderElement, RenderFace, RenderQueue, RenderQueueFlags, RenderQueueType, RenderStateElementKey, RenderTarget, Renderer, RendererUpdateFlags, RenderingStatistics, ReplacementFailureStrategy, ResourceManager, ReturnableObjectPool, RotationOverLifetimeModule, SafeLoopArray, Scene, SceneManager, Script, SetDataOptions, Shader, ShaderData, ShaderDataGroup, ShaderFactory, ShaderLanguage, ShaderMacro, ShaderMacroCollection, ShaderPass, ShaderPreprocessorDirective, ShaderProperty, ShaderPropertyType, ShaderTagKey, ShadowCascadesMode, ShadowResolution, ShadowType, Signal, SimpleSpriteAssembler, SizeOverLifetimeModule, Skin, SkinnedMeshRenderer, Sky, SkyBoxMaterial, SkyProceduralMaterial, SlicedSpriteAssembler, SphereColliderShape, SphereShape, SpotLight, SpringJoint, Sprite, SpriteAtlas, SpriteDrawMode, SpriteMask, SpriteMaskInteraction, SpriteMaskLayer, SpriteModifyFlags, SpriteRenderer, SpriteTileMode, StateMachineScript, StaticCollider, StencilOperation, SubEmitter, SubEmittersModule, SubFont, SubMesh, SubPrimitive, SubShader, SunMode, SystemInfo, TextAsset, TextHorizontalAlignment, TextRenderer, TextUtils, TextVerticalAlignment, Texture, Texture2D, Texture2DArray, TextureCoordinate, TextureCube, TextureCubeFace, TextureDepthCompareFunction, TextureFilterMode, TextureFormat, TextureSheetAnimationModule, TextureUsage, TextureUtils, TextureWrapMode, TiledSpriteAssembler, Time, TonemappingEffect, TonemappingMode, TrailMaterial, TrailRenderer, TrailTextureMode, Transform, TransformModifyFlags, UnlitMaterial, Utils, VelocityOverLifetimeModule, VertexAttribute, VertexBufferBinding, VertexElement, VertexElementFormat, VertexMergeBatcher, WrapMode, XRManager, assignmentClone, deepClone, dependentComponents, ignoreClone, registerPointerEventEmitter, request, resourceLoader };
|
|
45096
|
+
export { AmbientLight, AmbientOcclusion, AmbientOcclusionQuality, AnimationArrayCurve, AnimationBoolCurve, AnimationClip, AnimationClipCurveBinding, AnimationColorCurve, AnimationCurve, AnimationEvent, AnimationFloatArrayCurve, AnimationFloatCurve, AnimationQuaternionCurve, AnimationRectCurve, AnimationRefCurve, AnimationStringCurve, AnimationVector2Curve, AnimationVector3Curve, AnimationVector4Curve, Animator, AnimatorCondition, AnimatorConditionMode, AnimatorController, AnimatorControllerLayer, AnimatorControllerParameter, AnimatorCullingMode, AnimatorLayerBlendingMode, AnimatorLayerMask, AnimatorState, AnimatorStateInstance, AnimatorStateMachine, AnimatorStateTransition, AntiAliasing, AssetPromise, AssetType, AudioClip, AudioManager, AudioSource, Background, BackgroundMode, BackgroundTextureFillMode, BaseMaterial, BasicRenderPipeline, BlendFactor, BlendMode, BlendOperation, BlendShape, BlendShapeFrame, BlinnPhongMaterial, Blitter, BloomDownScaleMode, BloomEffect, BoolUpdateFlag, BoxColliderShape, BoxShape, Buffer, BufferAsset, BufferBindFlag, BufferMesh, BufferUsage, BufferUtil, Burst, Camera, CameraClearFlags, CameraModifyFlags, CameraType, Canvas, CapsuleColliderShape, CharRenderInfo, CharacterController, CircleShape, ClearableObjectPool, Collider, ColliderShape, ColliderShapeUpAxis, Collision, CollisionDetectionMode, ColorOverLifetimeModule, ColorWriteMask, CompareFunction, Component, ConeEmitType, ConeShape, ContactPoint, ContentRestorer, ControllerCollisionFlag, ControllerNonWalkableMode, CubeProbe, CullMode, CurveKey, CustomDataModule, DataObject, DataType, DependentMode, DepthTextureMode, DiffuseMode, DirectLight, DisorderedArray, Downsampling, DynamicCollider, DynamicColliderConstraints, EmissionModule, Engine, EngineEventType, EngineObject, Entity, EntityModifyFlags, EventDispatcher, FinalPass, FixedJoint, FogMode, Font, FontStyle, GLCapabilityType, GradientAlphaKey, GradientColorKey, HemisphereShape, HingeJoint, HitResult, IndexBufferBinding, IndexFormat, InheritVelocityModule, InputManager, InterpolationType, JSONAsset, Joint, JointLimits, JointMotor, Keyframe, Keys, Layer, LayerPathMask, Light, LimitVelocityOverLifetimeModule, Loader, Logger, MSAASamples, MainModule, Material, Mesh, MeshColliderShape, MeshColliderShapeCookingFlag, MeshRenderer, MeshShape, MeshTopology, ModelMesh, NoiseModule, OverflowMode, PBRMaterial, ParticleCompositeCurve, ParticleCompositeGradient, ParticleCurve, ParticleCurveMode, ParticleGenerator, ParticleGradient, ParticleGradientMode, ParticleInheritVelocityMode, ParticleMaterial, ParticleRenderMode, ParticleRenderer, ParticleScaleMode, ParticleShapeArcMode, ParticleShapeType, ParticleSimulationSpace, ParticleStopMode, ParticleSubEmitterInheritProperty, ParticleSubEmitterType, PhysicsMaterial, PhysicsMaterialCombineMode, PhysicsScene, PipelineStage, PlaneColliderShape, Platform, PointLight, Pointer, PointerButton, PointerEventData, PointerEventEmitter, PointerPhase, Polyfill, PostProcess, PostProcessEffect, PostProcessEffectBoolParameter, PostProcessEffectColorParameter, PostProcessEffectEnumParameter, PostProcessEffectFloatParameter, PostProcessEffectParameter, PostProcessEffectTextureParameter, PostProcessEffectVector2Parameter, PostProcessEffectVector3Parameter, PostProcessEffectVector4Parameter, PostProcessManager, PostProcessPass, PostProcessPassEvent, PostProcessUberPass, Primitive, PrimitiveMesh, PrimitiveMeshCapMode, Probe, ReferResource, RefractionMode, RenderBufferDepthFormat, RenderElement, RenderFace, RenderQueue, RenderQueueFlags, RenderQueueType, RenderStateElementKey, RenderTarget, Renderer, RendererUpdateFlags, RenderingStatistics, ReplacementFailureStrategy, ResourceManager, ReturnableObjectPool, RotationOverLifetimeModule, SafeLoopArray, Scene, SceneManager, Script, SetDataOptions, Shader, ShaderData, ShaderDataGroup, ShaderFactory, ShaderLanguage, ShaderMacro, ShaderMacroCollection, ShaderPass, ShaderPreprocessorDirective, ShaderProperty, ShaderPropertyType, ShaderTagKey, ShadowCascadesMode, ShadowResolution, ShadowType, Signal, SimpleSpriteAssembler, SizeOverLifetimeModule, Skin, SkinnedMeshRenderer, Sky, SkyBoxMaterial, SkyProceduralMaterial, SlicedSpriteAssembler, SphereColliderShape, SphereShape, SpotLight, SpringJoint, Sprite, SpriteAtlas, SpriteDrawMode, SpriteMask, SpriteMaskInteraction, SpriteMaskLayer, SpriteModifyFlags, SpriteRenderer, SpriteTileMode, StateMachineScript, StaticCollider, StencilOperation, SubEmitter, SubEmittersModule, SubFont, SubMesh, SubPrimitive, SubShader, SunMode, SystemInfo, TextAsset, TextHorizontalAlignment, TextRenderer, TextUtils, TextVerticalAlignment, Texture, Texture2D, Texture2DArray, TextureCoordinate, TextureCube, TextureCubeFace, TextureDepthCompareFunction, TextureFilterMode, TextureFormat, TextureSheetAnimationModule, TextureUsage, TextureUtils, TextureWrapMode, TiledSpriteAssembler, Time, TonemappingEffect, TonemappingMode, TrailMaterial, TrailRenderer, TrailTextureMode, Transform, TransformModifyFlags, UnlitMaterial, Utils, VelocityOverLifetimeModule, VertexAttribute, VertexBufferBinding, VertexElement, VertexElementFormat, VertexMergeBatcher, WrapMode, XRManager, assignmentClone, deepClone, dependentComponents, ignoreClone, registerPointerEventEmitter, request, resourceLoader };
|
|
43371
45097
|
//# sourceMappingURL=module.js.map
|