Show / Hide Table of Contents

    Class GltfExtensions

    Extensions for glTF serialization.

    Inheritance
    System.Object
    GltfExtensions
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Elements.Serialization.glTF
    Assembly: Hypar.Elements.dll
    Syntax
    public static class GltfExtensions

    Properties

    GltfCachePath

    In normal function use, this should be set to null. If not null and set to a valid directory path, gltfs loaded for content elements will be cached to this directory, and can be explicitly loaded by calling LoadGltfCacheFromDisk(). This is used by hypar run and test capabilities to speed up repeated runs.

    Declaration
    public static string GltfCachePath { get; set; }
    Property Value
    Type Description
    System.String

    UseReferencedContentExtension

    If true, the model will write content elements using an experimental GLTF extension. This extension is not yet finalized and may change.

    Declaration
    public static bool UseReferencedContentExtension { get; set; }
    Property Value
    Type Description
    System.Boolean

    Methods

    GetGlbStreamFromPath(String)

    Get a stream from a glb path, either file reference or remote. The streams are cached based on the location, so updates to files may not be reflected immediately, especially during long running parent processes.

    Declaration
    public static Stream GetGlbStreamFromPath(string gltfLocation)
    Parameters
    Type Name Description
    System.String gltfLocation

    The URI of the gltf binary file

    Returns
    Type Description
    System.IO.Stream

    ToBase64String(Model, Boolean, Boolean)

    Serialize the model to a base64 encoded string.

    Declaration
    public static string ToBase64String(this Model model, bool drawEdges = false, bool mergeVertices = false)
    Parameters
    Type Name Description
    Model model
    System.Boolean drawEdges
    System.Boolean mergeVertices
    Returns
    Type Description
    System.String

    A Base64 string representing the model.

    ToGlTF(Model, Boolean, Boolean)

    Serialize the model to a byte array.

    Declaration
    public static byte[] ToGlTF(this Model model, bool drawEdges = false, bool mergeVertices = false)
    Parameters
    Type Name Description
    Model model

    The model to serialize.

    System.Boolean drawEdges

    Should edges of the model be drawn?

    System.Boolean mergeVertices

    Should vertices be merged in the resulting output?

    Returns
    Type Description
    System.Byte[]

    A byte array representing the model.

    ToGlTF(Model, String, Boolean, Boolean)

    Serialize the model to a gltf file on disk. If there is no geometry, an empty GLTF will still be produced.

    Declaration
    public static void ToGlTF(this Model model, string path, bool useBinarySerialization = true, bool drawEdges = false)
    Parameters
    Type Name Description
    Model model

    The model to serialize.

    System.String path

    The output path.

    System.Boolean useBinarySerialization

    Should binary serialization be used?

    System.Boolean drawEdges

    Should the solid edges be written to the gltf?

    ToGlTF(Model, String, out List<BaseError>, Boolean, Boolean)

    Serialize the model to a gltf file on disk. If there is no geometry, an empty GLTF will still be produced.

    Declaration
    public static void ToGlTF(this Model model, string path, out List<BaseError> errors, bool useBinarySerialization = true, bool drawEdges = false)
    Parameters
    Type Name Description
    Model model

    The model to serialize.

    System.String path

    The output path.

    System.Collections.Generic.List<BaseError> errors

    A collection of serialization errors

    System.Boolean useBinarySerialization

    Should binary serialization be used?

    System.Boolean drawEdges

    Should the solid edges be written to the gltf?