| | 1 | | using System; |
| | 2 | | using System.Collections; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using DCL.Helpers; |
| | 5 | | using UnityEngine; |
| | 6 | |
|
| | 7 | | public interface IPrimitiveMeshFactory |
| | 8 | | { |
| | 9 | | Mesh CreateMesh(PrimitiveMeshModel meshModelModel); |
| | 10 | | } |
| | 11 | |
|
| | 12 | | public class PrimitiveMeshFactory : IPrimitiveMeshFactory |
| | 13 | | { |
| | 14 | | public Mesh CreateMesh(PrimitiveMeshModel meshModelModel) |
| | 15 | | { |
| 31 | 16 | | Mesh mesh = null; |
| 31 | 17 | | switch (meshModelModel.type) |
| | 18 | | { |
| | 19 | | case PrimitiveMeshModel.Type.Box: |
| 18 | 20 | | mesh = PrimitiveMeshBuilder.BuildCube(1f); |
| 18 | 21 | | if (meshModelModel.uvs != null && meshModelModel.uvs.Count > 0) |
| | 22 | | { |
| 1 | 23 | | mesh.uv = Utils.FloatArrayToV2List(meshModelModel.uvs); |
| | 24 | | } |
| 1 | 25 | | break; |
| | 26 | | case PrimitiveMeshModel.Type.Sphere: |
| 5 | 27 | | mesh = PrimitiveMeshBuilder.BuildSphere(1f); |
| 5 | 28 | | break; |
| | 29 | | case PrimitiveMeshModel.Type.Plane: |
| 4 | 30 | | mesh = PrimitiveMeshBuilder.BuildPlane(1f); |
| 4 | 31 | | if (meshModelModel.uvs != null && meshModelModel.uvs.Count > 0) |
| | 32 | | { |
| 0 | 33 | | mesh.uv = Utils.FloatArrayToV2List(meshModelModel.uvs); |
| | 34 | | } |
| 0 | 35 | | break; |
| | 36 | | case PrimitiveMeshModel.Type.Cylinder: |
| 4 | 37 | | mesh = PrimitiveMeshBuilder.BuildCylinder(50, meshModelModel.radiusTop, meshModelModel.radiusBottom, 2f, |
| | 38 | | break; |
| | 39 | | } |
| 31 | 40 | | return mesh; |
| | 41 | | } |
| | 42 | | } |