| | 1 | | using DCL; |
| | 2 | | using DCL.Helpers; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | internal class PrimitiveMeshFactory |
| | 6 | | { |
| | 7 | | public static Mesh CreateMesh(AssetPromise_PrimitiveMesh_Model meshModelModel) |
| | 8 | | { |
| 27 | 9 | | Mesh mesh = null; |
| 27 | 10 | | switch (meshModelModel.type) |
| | 11 | | { |
| | 12 | | case AssetPromise_PrimitiveMesh_Model.PrimitiveType.Box: |
| | 13 | | { |
| 19 | 14 | | if (meshModelModel.properties is PropertyUvs modelWithUvs) |
| | 15 | | { |
| 19 | 16 | | mesh = PrimitiveMeshBuilder.BuildCube(1f); |
| 19 | 17 | | if (modelWithUvs.uvs != null && modelWithUvs.uvs.Count > 0) |
| | 18 | | { |
| 1 | 19 | | mesh.uv = Utils.FloatArrayToV2List(modelWithUvs.uvs); |
| | 20 | | } |
| | 21 | | } |
| | 22 | | } |
| 1 | 23 | | break; |
| | 24 | | case AssetPromise_PrimitiveMesh_Model.PrimitiveType.Sphere: |
| 2 | 25 | | mesh = PrimitiveMeshBuilder.BuildSphere(1f); |
| 2 | 26 | | break; |
| | 27 | | case AssetPromise_PrimitiveMesh_Model.PrimitiveType.Plane: |
| | 28 | | { |
| 1 | 29 | | if (meshModelModel.properties is PropertyUvs modelWithUvs) |
| | 30 | | { |
| 1 | 31 | | mesh = PrimitiveMeshBuilder.BuildPlaneV2(1f); |
| 1 | 32 | | if (modelWithUvs.uvs != null && modelWithUvs.uvs.Count > 0) |
| | 33 | | { |
| 0 | 34 | | mesh.uv = Utils.FloatArrayToV2List(modelWithUvs.uvs); |
| | 35 | | } |
| | 36 | | } |
| | 37 | | } |
| 0 | 38 | | break; |
| | 39 | | case AssetPromise_PrimitiveMesh_Model.PrimitiveType.Cylinder: |
| | 40 | | { |
| 5 | 41 | | if (meshModelModel.properties is PropertyCylinder cylinder) |
| | 42 | | { |
| 5 | 43 | | mesh = PrimitiveMeshBuilder.BuildCylinder(50, cylinder.radiusTop, cylinder.radiusBottom, |
| | 44 | | 2f, 0f, true, false); |
| | 45 | | } |
| | 46 | | } |
| | 47 | | break; |
| | 48 | | } |
| 27 | 49 | | return mesh; |
| | 50 | | } |
| | 51 | | } |