Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DracoCompression

Draco compression (https://google.github.io/draco/)

This class wraps the Draco module.

Encoder

The encoder is not currently implemented.

Decoder

By default, the configuration points to a copy of the Draco decoder files for glTF from the babylon.js preview cdn https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js.

To update the configuration, use the following code:

    DracoCompression.Configuration = {
        decoder: {
            wasmUrl: "<url to the WebAssembly library>",
            wasmBinaryUrl: "<url to the WebAssembly binary>",
            fallbackUrl: "<url to the fallback JavaScript library>",
        }
    };

Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support WebAssembly or only support the JavaScript version. Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser. Use DracoCompression.DecoderAvailable to determine if the decoder configuration is available for the current context.

To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:

    var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
see

https://playground.babylonjs.com/#DMZIBD#0

Hierarchy

  • DracoCompression

Implements

Index

Constructors

constructor

  • Constructor

    Parameters

    • Optional numWorkers: number

      The number of workers for async operations. Specify 0 to disable web workers and run synchronously in the current context.

    Returns DracoCompression

Properties

Static ConfigurationSearch playground for Configuration

Static DefaultNumWorkersSearch playground for DefaultNumWorkers

DefaultNumWorkers: number

Default number of workers to create when creating the draco compression object.

Accessors

Static DecoderAvailable

  • get DecoderAvailable(): boolean
  • Returns true if the decoder configuration is available.

    Returns boolean

Static Default

  • Default instance for the draco compression object.

    Returns DracoCompression

Methods

decodeMeshAsyncSearch playground for decodeMeshAsync

  • decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {}, dividers?: {}): Promise<VertexData>
  • Decode Draco compressed mesh data to vertex data.

    Parameters

    • data: ArrayBuffer | ArrayBufferView

      The ArrayBuffer or ArrayBufferView for the Draco compression data

    • Optional attributes: {}

      A map of attributes from vertex buffer kinds to Draco unique ids

      • [kind: string]: number
    • Optional dividers: {}

      a list of optional dividers for normalization

      • [kind: string]: number

    Returns Promise<VertexData>

    A promise that resolves with the decoded vertex data

disposeSearch playground for dispose

  • dispose(): void
  • Stop all async operations and release resources.

    Returns void

whenReadyAsyncSearch playground for whenReadyAsync

  • whenReadyAsync(): Promise<void>
  • Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.

    Returns Promise<void>

    a promise that resolves when ready

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Method
  • Inherited property
  • Inherited method
  • Static property
  • Static method