API

Class DracoDecoderExperimental

This class is an experimental version of DracoCompression and is subject to change.

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

This class wraps the Draco decoder module.

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

To update the configuration, use the following code:

    DracoDecoder.DefaultConfiguration = {
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 DracoDecoder.DefaultAvailable to determine if the decoder configuration is available for the current context.

To decode Draco compressed data, get the default DracoDecoder object and call decodeMeshToGeometryAsync:

    var geometry = await DracoDecoder.Default.decodeMeshToGeometryAsync(data);

Hierarchy

  • DracoCodec
    • DracoDecoder
Index
DefaultConfiguration: IDracoCodecConfiguration = ...

Default configuration for the DracoDecoder. Defaults to the following:

  • numWorkers: 50% of the available logical processors, capped to 4. If no logical processors are available, defaults to 1.
  • wasmUrl: "https://cdn.babylonjs.com/draco_wasm_wrapper_gltf.js"
  • wasmBinaryUrl: "https://cdn.babylonjs.com/draco_decoder_gltf.wasm"
  • fallbackUrl: "https://cdn.babylonjs.com/draco_decoder_gltf.js"
  • Experimental

    Decode Draco compressed mesh data to Babylon geometry.

    Parameters

    • name: string

      The name to use when creating the geometry

    • scene: Scene

      The scene to use when creating the geometry

    • data: ArrayBuffer | ArrayBufferView<ArrayBufferLike>

      The ArrayBuffer or ArrayBufferView of the Draco compressed data

    • Optionalattributes: { [kind: string]: number }

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

    Returns Promise<Geometry>

    A promise that resolves with the decoded geometry

  • Experimental

    Decode Draco compressed mesh data to mesh data.

    Parameters

    • data: ArrayBuffer | ArrayBufferView<ArrayBufferLike>

      The ArrayBuffer or ArrayBufferView of the compressed Draco data

    • Optionalattributes: { [kind: string]: number }

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

    • OptionalgltfNormalizedOverride: { [kind: string]: boolean }

      A map of attributes from vertex buffer kinds to normalized flags to override the Draco normalization

    Returns Promise<MeshData>

    A promise that resolves with the decoded mesh data

  • Experimental

    Returns a promise that resolves when ready. Call this manually to ensure the draco codec is ready before use.

    Returns Promise<void>

    a promise that resolves when ready

  • Experimental

    Reset the default DracoDecoder object to null and disposing the removed default instance. Note that if the workerPool is a member of the static DefaultConfiguration object it is recommended not to run dispose, unless the static worker pool is no longer needed.

    Parameters

    • OptionalskipDispose: boolean

      set to true to not dispose the removed default instance

    Returns void