ThreePipe
    Preparing search index...

    Class DRACOLoader2

    Hierarchy

    Implements

    Index

    Constructors

    Properties

    decoderModulePending: Promise<any> | null = null
    encoderConfig: any = ...

    Encoder config — defaults to JS-only build because the default CDN path (DRACOLoader2.DRACO_LIBRARY_PATH, i.e. google/draco's javascript folder) ships only draco_encoder.js, not draco_encoder.wasm. Override to {} (auto-detect) or {type: 'wasm'} only if your decoder path hosts draco_encoder.wasm (e.g. draco3dgltf npm package).

    encoderPending: Promise<any> | null = null
    isDRACOLoader2: true
    DRACO_LIBRARY_PATH: string = 'https://cdn.jsdelivr.net/gh/google/draco@1.5.6/javascript/'

    Path to the draco decoder/encoder libraries, default uses jsdelivr CDN You may want to set this to your own path or use DRACOLoader2.SetDecoderJsString to bundle the draco decoder js file with your app source

    'https://cdn.jsdelivr.net/gh/google/draco@1.5.6/javascript/'
    
    LibraryValueMap: Record<string, any> = {}

    This is a hack to allow bundling the draco decoder js file with your app source See DRACOLoader2.SetDecoderJsString for example

    Methods

    • Set the decoder js string (JS-only build) Sample for how to set LibraryValueMap This is useful for bundling the draco decoder js file with your app source

      If you bundle only the JS build (no wasm), also call dracoLoader.setDecoderConfig({type: 'js'}) on the instance (or the wasm fetch will be attempted and fail). Alternatively use DRACOLoader2.SetDecoderWasmBinary to bundle the wasm build instead.

      Parameters

      • jsString: string

        the contents of draco_decoder.js file

      Returns void

      First put the draco_decoder.js file in your src folder, then import it in js/ts as a string

      import draco_decoder from './libs/draco_decoder.1.5.6.js?raw' // vite will load this as a string
      // console.log(draco_decoder) // this should be a string with js content
      DRACOLoader2.SetDecoderJsString(draco_decoder)
    • Set the decoder wasm wrapper js + wasm binary (WASM build) This is useful for bundling the draco wasm decoder with your app source instead of fetching from CDN.

      Parameters

      • wrapperJs: string

        the contents of draco_wasm_wrapper.js file (string)

      • wasmBinary: ArrayBuffer

        the contents of draco_decoder.wasm file (ArrayBuffer)

      Returns void

      import draco_wasm_wrapper from './libs/draco_wasm_wrapper.1.5.6.js?raw'
      import draco_decoder_wasm from './libs/draco_decoder.1.5.6.wasm?arraybuffer' // or any loader that returns ArrayBuffer
      DRACOLoader2.SetDecoderWasmBinary(draco_wasm_wrapper, draco_decoder_wasm)