MeshBuilder
public class MeshBuilder
extension MeshBuilder: NativeBase
extension MeshBuilder: Hashable
Builder for meshes. Such meshes can contain different kinds of primitives, like quads or
triangles. Both primitives support adding texture coordinates that are mapped to the
corners of the primitives. See TriangleMeshBuilder and QuadMeshBuilder for more details.
Note: Normals cannot be set as they are not necessary when using the MeshBuilder.
Example how to build a cube using QuadMeshBuilder
let cube = MeshBuilder()
.quad(a: Point3D(x: 0.5, y: 0.5, z: 0.5),
b: Point3D(x: -0.5, y: 0.5, z: 0.5),
c: Point3D(x: 0.5, y: -0.5, z: 0.5),
d: Point3D(x: -0.5, y: -0.5, z: 0.5))
.quad(a: Point3D(x: -0.5, y: 0.5, z: -0.5),
b: Point3D(x: 0.5, y: 0.5, z: -0.5),
c: Point3D(x: -0.5, y: -0.5, z: -0.5),
d: Point3D(x: 0.5, y: -0.5, z: -0.5))
.quad(a: Point3D(x: 0.5, y: 0.5, z: -0.5),
b: Point3D(x: 0.5, y: 0.5, z: 0.5),
c: Point3D(x: 0.5, y: -0.5, z: -0.5),
d: Point3D(x: 0.5, y: -0.5, z: 0.5))
.quad(a: Point3D(x: -0.5, y: 0.5, z: 0.5),
b: Point3D(x: -0.5, y: 0.5, z: -0.5),
c: Point3D(x: -0.5, y: -0.5, z: 0.5),
d: Point3D(x: -0.5, y: -0.5, z: -0.5))
.quad(a: Point3D(x: -0.5, y: 0.5, z: 0.5),
b: Point3D(x: 0.5, y: 0.5, z: 0.5),
c: Point3D(x: -0.5, y: 0.5, z: -0.5),
d: Point3D(x: 0.5, y: 0.5, z: -0.5))
.quad(a: Point3D(x: 0.5, y: -0.5, z: 0.5),
b: Point3D(x: -0.5, y: -0.5, z: 0.5),
c: Point3D(x: 0.5, y: -0.5, z: -0.5),
d: Point3D(x: -0.5, y: -0.5, z: -0.5))
.build()
-
Constructs an instance of MeshBuilder.
Declaration
Swift
public init() -
Adds a triangle.
Triangle visibility is determined via back-face culling. Front-facing triangles are expected to have counter-clockwise winding.
Declaration
Swift
public func triangle(a: Point3D, b: Point3D, c: Point3D) -> TriangleMeshBuilderParameters
aFirst vertex of the triangle.
bSecond vertex of the triangle.
cThird vertex of the triangle.
Return Value
A
TriangleMeshBuilderinstance. -
Adds a quad. Internally, this will be transformed into triangles abc and bdc.
Triangle visibility is determined via back-face culling. Front-facing triangles are expected to have counter-clockwise winding.
Declaration
Swift
public func quad(a: Point3D, b: Point3D, c: Point3D, d: Point3D) -> QuadMeshBuilderParameters
aFirst vertex of quad.
bSecond vertex of the quad.
cThird vertex of the quad.
dFourth vertex of the quad.
Return Value
A
QuadMeshBuilderinstance. -
Declaration
Swift
public func build() -> Mesh?Return Value
mesh containing added geometry or ‘null’ if no geometry was added.