Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Reader

Utility class for parsing & reading SVF content from Model Derivative service or from local file system.

The class can only be instantiated using one of the two async static methods: Reader.FromFileSystem, or Reader.FromDerivativeService. After that, you can parse the entire SVF into memory using {@link parse}, or parse individual SVF objects using methods like {@link listFragments} or enumerateGeometries.

example

const auth = { client_id: 'forge client id', client_secret: 'forge client secreet' }; const reader = await Reader.FromDerivativeService('model urn', 'viewable guid', auth); const svf = await reader.read(); // Read entire SVF into memory console.log(svf);

example

const reader = await Reader.FromFileSystem('path/to/svf'); // Enumerate fragments (without building a list of all of them) for await (const fragment of reader.enumerateFragments()) { console.log(fragment); }

Hierarchy

  • Reader

Index

Constructors

Protected constructor

  • new Reader(svf: Buffer, resolve: function): Reader
  • Parameters

    • svf: Buffer
    • resolve: function
        • (uri: string): Promise<Buffer>
        • Parameters

          • uri: string

          Returns Promise<Buffer>

    Returns Reader

Properties

Protected resolve

resolve: function

Type declaration

    • (uri: string): Promise<Buffer>
    • Parameters

      • uri: string

      Returns Promise<Buffer>

Protected svf

Methods

enumerateFragments

  • enumerateFragments(): AsyncIterable<IFragment>
  • Retrieves, parses, and iterates over all SVF fragments.

    async
    generator

    Returns AsyncIterable<IFragment>

    Async iterator over parsed fragments.

enumerateGeometries

  • Retrieves, parses, and iterates over all SVF geometry metadata.

    async
    generator

    Returns AsyncIterable<IGeometryMetadata>

    Async iterator over parsed geometry metadata.

enumerateMaterials

  • enumerateMaterials(): AsyncIterable<IMaterial | null>
  • Retrieves, parses, and iterates over all SVF materials.

    async
    generator

    Returns AsyncIterable<IMaterial | null>

    Async iterator over parsed materials (or null values for unsupported material types).

enumerateMeshPack

  • Retrieves, parses, and iterates over all meshes, lines, or points in a specific SVF meshpack.

    async
    generator

    Parameters

    • packNumber: number

    Returns AsyncIterable<IMesh | ILines | IPoints | null>

    Async iterator over parsed meshes, lines, or points (or null values for unsupported mesh types).

Protected findAsset

getAsset

  • getAsset(uri: string): Promise<Buffer>
  • Retrieves raw binary data of a specific SVF asset.

    async

    Parameters

    • uri: string

      Asset URI.

    Returns Promise<Buffer>

    Asset content.

getMeshPackCount

  • getMeshPackCount(): number
  • Gets the number of available mesh packs.

    Returns number

getMetadata

getPropertyDb

listImages

  • listImages(): string[]
  • Finds URIs of all image assets referenced in the SVF. These can then be retrieved using getAsset.

    Returns string[]

    Image asset URIs.

read

  • Reads the entire SVF and all its referenced assets into memory. In cases where a more granular control is needed (for example, when trying to control memory consumption), consider parsing the different SVF elements individually, using methods like {@link listFragments}, enumerateGeometries, etc.

    Returns Promise<ISvfContent>

readFragments

  • Retrieves, parses, and collects all SVF fragments.

    async

    Returns Promise<IFragment[]>

    List of parsed fragments.

readGeometries

readMaterials

  • readMaterials(): Promise<(null | IMaterial)[]>
  • Retrieves, parses, and collects all SVF materials.

    async

    Returns Promise<(null | IMaterial)[]>

    List of parsed materials (or null values for unsupported material types).

readMeshPack

  • Retrieves, parses, and collects all meshes, lines, or points in a specific SVF meshpack.

    async

    Parameters

    • packNumber: number

      Index of mesh pack file.

    Returns Promise<(null | IMesh | ILines | IPoints)[]>

    List of parsed meshes, lines, or points (or null values for unsupported mesh types).

Static FromDerivativeService

  • FromDerivativeService(urn: string, guid: string, auth: IAuthOptions): Promise<Reader>
  • Instantiates new reader for an SVF in Forge Model Derivative service.

    async

    Parameters

    • urn: string

      Forge model URN.

    • guid: string

      Forge viewable GUID. The viewable(s) can be found in the manifest with type: 'resource', role: 'graphics', and mime: 'application/autodesk-svf'.

    • auth: IAuthOptions

      Credentials or access token for accessing the Model Derivative service.

    Returns Promise<Reader>

    Reader for the provided SVF.

Static FromFileSystem

  • FromFileSystem(filepath: string): Promise<Reader>
  • Instantiates new reader for an SVF on local file system.

    async

    Parameters

    • filepath: string

      Path to the *.svf file.

    Returns Promise<Reader>

    Reader for the provided SVF.

Generated using TypeDoc