Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SvfReader

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: {@link Reader.FromFileSystem}, or {@link Reader.FromDerivativeService}. After that, you can parse the entire SVF into memory using {@link parse}, or parse individual SVF objects using methods like readFragments or enumerateGeometries.

example

const authProvider = new TwoLeggedAuthenticationProvider(APS_CLIENT_ID, APS_CLIENT_SECRET); const reader = await Reader.FromDerivativeService(MODEL_URN, VIEWABLE_GUID, authProvider); const scene = await reader.read(); // Read entire scene into an intermediate, in-memory representation console.log(scene);

example

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

Hierarchy

  • SvfReader

Index

Constructors

  • new SvfReader(svf: Buffer, resolve: ((uri: string) => Promise<Buffer>)): SvfReader
  • Parameters

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

          • uri: string

          Returns Promise<Buffer>

    Returns SvfReader

Properties

resolve: ((uri: string) => Promise<Buffer>)

Type declaration

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

      • uri: string

      Returns Promise<Buffer>

svf: ISvfRoot

Methods

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

    async
    generator

    Returns AsyncIterable<IFragment>

    Async iterator over parsed fragments.

  • enumerateGeometries(): AsyncIterable<IGeometryMetadata>
  • Retrieves, parses, and iterates over all SVF geometry metadata.

    async
    generator

    Returns AsyncIterable<IGeometryMetadata>

    Async iterator over parsed geometry metadata.

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

    async
    generator

    Returns AsyncIterable<null | IMaterial>

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

  • enumerateMeshPack(packNumber: number): AsyncIterable<null | IMesh | ILines | IPoints>
  • Retrieves, parses, and iterates over all meshes, lines, or points in a specific SVF meshpack.

    async
    generator

    Parameters

    • packNumber: number

    Returns AsyncIterable<null | IMesh | ILines | IPoints>

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

  • findAsset(query: { type?: AssetType; uri?: string }): undefined | ISvfManifestAsset
  • Parameters

    • query: { type?: AssetType; uri?: string }
      • Optional type?: AssetType
      • Optional uri?: string

    Returns undefined | ISvfManifestAsset

  • 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.

  • getManifest(): Promise<ISvfManifest>
  • Retrieves parsed SVF manifest.

    async

    Returns Promise<ISvfManifest>

    SVF manifest.

  • getMeshPackCount(): number
  • getMetadata(): Promise<ISvfMetadata>
  • Retrieves parsed SVF metadata.

    async

    Returns Promise<ISvfMetadata>

    SVF metadata.

  • getPropertyDb(): Promise<PropDbReader>
  • Retrieves and parses the property database.

    async

    Returns Promise<PropDbReader>

    Property database reader.

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

    Returns string[]

    Image asset URIs.

  • loadImage(uri: string): Promise<{ imageData: undefined | Buffer; normalizedUri: string }>
  • Loads an image.

    Parameters

    • uri: string

      Image URI.

    Returns Promise<{ imageData: undefined | Buffer; normalizedUri: string }>

  • read(options?: IReaderOptions): Promise<IScene>
  • Reads the entire scene 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 readFragments, enumerateGeometries, etc.

    async

    Parameters

    • Optional options: IReaderOptions

    Returns Promise<IScene>

    Intermediate, in-memory representation of the loaded scene.

  • readFragments(): Promise<IFragment[]>
  • Retrieves, parses, and collects all SVF fragments.

    async

    Returns Promise<IFragment[]>

    List of parsed fragments.

  • readGeometries(): Promise<IGeometryMetadata[]>
  • Retrieves, parses, and collects all SVF geometry metadata.

    async

    Returns Promise<IGeometryMetadata[]>

    List of parsed geometry metadata.

  • 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(packNumber: number): Promise<(null | IMesh | ILines | IPoints)[]>
  • 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).

  • Instantiates new reader for an SVF in APS Model Derivative service.

    async

    Parameters

    • urn: string

      APS model URN.

    • guid: string

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

    • authenticationProvider: IAuthenticationProvider

      Authentication provider for accessing the Model Derivative service.

    • Optional host: string

      Optional host URL to be used by all APS calls.

    • Optional region: string

      Optional region to be used by all APS calls.

    Returns Promise<SvfReader>

    Reader for the provided SVF.

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

    async

    Parameters

    • filepath: string

      Path to the *.svf file.

    Returns Promise<SvfReader>

    Reader for the provided SVF.

Generated using TypeDoc