| | 1 | | using System.Collections.Generic; |
| | 2 | |
|
| | 3 | | namespace DCL |
| | 4 | | { |
| | 5 | | public readonly struct AssetPromise_PrimitiveMesh_Model |
| | 6 | | { |
| | 7 | | public enum PrimitiveType |
| | 8 | | { |
| | 9 | | Box = 0, |
| | 10 | | Sphere = 1, |
| | 11 | | Plane = 2, |
| | 12 | | Cylinder = 3 |
| | 13 | | } |
| | 14 | |
|
| | 15 | | public readonly PrimitiveType type; |
| | 16 | | public readonly object properties; |
| | 17 | |
|
| | 18 | | // Do not use constructor directly, use `Create` method instead |
| | 19 | | private AssetPromise_PrimitiveMesh_Model(PrimitiveType type, object meshProperties) |
| | 20 | | { |
| | 21 | | this.type = type; |
| | 22 | | this.properties = meshProperties; |
| | 23 | | } |
| | 24 | |
|
| | 25 | | private static AssetPromise_PrimitiveMesh_Model Create<T>(PrimitiveType type, T properties) where T : struct |
| | 26 | | { |
| | 27 | | return new AssetPromise_PrimitiveMesh_Model(type, properties); |
| | 28 | | } |
| | 29 | |
|
| | 30 | | public static AssetPromise_PrimitiveMesh_Model CreateBox(IList<float> uvs) |
| | 31 | | { |
| | 32 | | return Create(PrimitiveType.Box, new PropertyUvs(uvs)); |
| | 33 | | } |
| | 34 | |
|
| | 35 | | public static AssetPromise_PrimitiveMesh_Model CreatePlane(IList<float> uvs) |
| | 36 | | { |
| | 37 | | return Create(PrimitiveType.Plane, new PropertyUvs(uvs)); |
| | 38 | | } |
| | 39 | |
|
| | 40 | | public static AssetPromise_PrimitiveMesh_Model CreateSphere() |
| | 41 | | { |
| | 42 | | return Create(PrimitiveType.Sphere, new PropertyEmpty()); |
| | 43 | | } |
| | 44 | |
|
| | 45 | | public static AssetPromise_PrimitiveMesh_Model CreateCylinder(float radiusTop, float radiusBottom) |
| | 46 | | { |
| | 47 | | return Create(PrimitiveType.Cylinder, new PropertyCylinder(radiusTop, radiusBottom)); |
| | 48 | | } |
| | 49 | | } |
| | 50 | |
|
| | 51 | | internal readonly struct PropertyEmpty { } |
| | 52 | |
|
| | 53 | | internal readonly struct PropertyUvs |
| | 54 | | { |
| | 55 | | public readonly IList<float> uvs; |
| | 56 | |
|
| | 57 | | public PropertyUvs(IList<float> uvs) |
| | 58 | | { |
| 0 | 59 | | this.uvs = uvs; |
| 0 | 60 | | } |
| | 61 | | } |
| | 62 | |
|
| | 63 | | internal readonly struct PropertyCylinder |
| | 64 | | { |
| | 65 | | public readonly float radiusTop; |
| | 66 | | public readonly float radiusBottom; |
| | 67 | |
|
| | 68 | | public PropertyCylinder(float radiusTop, float radiusBottom) |
| | 69 | | { |
| | 70 | | this.radiusTop = radiusTop; |
| | 71 | | this.radiusBottom = radiusBottom; |
| | 72 | | } |
| | 73 | | } |
| | 74 | | } |