Turn different geometry into OBJ files.
encode : (Length -> Basics.Float) -> Geometry -> String
Encode geometry in the OBJ format, parametrized by the function, that knows how to convert units.
obj =
encode Length.inMeters (triangles mesh)
To encode multipart files, control precision or add various metadata, see Advanced Encoding.
Represents encoded geometry.
triangles : TriangularMesh (Point3d Length.Meters coords) -> Geometry
Encode positions.
faces : TriangularMesh { a | position : Point3d Length.Meters coords, normal : Vector3d Quantity.Unitless coords } -> Geometry
Encode positions and normal vectors.
texturedTriangles : TriangularMesh { a | position : Point3d Length.Meters coords, uv : ( Basics.Float, Basics.Float ) } -> Geometry
Encode positions and UV (texture) coordinates.
texturedFaces : TriangularMesh { a | position : Point3d Length.Meters coords, normal : Vector3d Quantity.Unitless coords, uv : ( Basics.Float, Basics.Float ) } -> Geometry
Encode positions, UV and normal vectors.
polylines : List (Polyline3d Length.Meters coords) -> Geometry
points : List (Point3d Length.Meters coords) -> Geometry
encodeMultipart : (Length -> Basics.Float) -> List Geometry -> String
Like encode
, but for files made of multiple parts.
multipartObj =
encodeMultipart Length.inMeters
[ triangles roofMesh
, triangles wallsMesh
]
encodeCompact : (Length -> Basics.Float) -> List Geometry -> String
Like encodeMultipart
, but reindexes triangular meshes.
This is slower, but produces smaller result, because it
deduplicates stored data.
{ precision : Basics.Int
, object : Maybe String
, groups : List String
, material : Maybe String
}
Set decimal precision for geometry and label it with object, groups or material. May be useful for labeling parts in a multipart OBJ file.
multipartObj =
encodeMultipart Length.inMeters
[ trianglesWith { defaultOptions | object = Just "roof" } roofMesh
, trianglesWith { defaultOptions | object = Just "walls" } wallsMesh
]
Note: the precision is clamped between 1 and 10, string options are stripped of whitespace.
defaultOptions : Options
Default options for geometry.
defaultOptions =
{ precision = 6
, object = Nothing
, groups = []
, material = Nothing
}
triangles =
trianglesWith defaultOptions
trianglesWith : Options -> TriangularMesh (Point3d Length.Meters coords) -> Geometry
facesWith : Options -> TriangularMesh { a | position : Point3d Length.Meters coords, normal : Vector3d Quantity.Unitless coords } -> Geometry
texturedTrianglesWith : Options -> TriangularMesh { a | position : Point3d Length.Meters coords, uv : ( Basics.Float, Basics.Float ) } -> Geometry
texturedFacesWith : Options -> TriangularMesh { a | position : Point3d Length.Meters coords, normal : Vector3d Quantity.Unitless coords, uv : ( Basics.Float, Basics.Float ) } -> Geometry
polylinesWith : Options -> List (Polyline3d Length.Meters coords) -> Geometry
pointsWith : Options -> List (Point3d Length.Meters coords) -> Geometry