Engine API Reference - v2.24.0-beta.13
    Preparing search index...

    Function meshoptInitialize

    • Initializes the decoder used to load glTF files compressed with the EXT_meshopt_compression or KHR_meshopt_compression extensions, such as files produced by gltfpack or glTF-Transform. Without a decoder, these files fail to load unless they also contain uncompressed fallback data.

      The decoder is the meshoptimizer JavaScript decoder (meshopt_decoder.mjs). Pass the decoder object itself, or the URL of the decoder module, which is then imported the first time a compressed file loads. Files using KHR_meshopt_compression need meshoptimizer 1.0 or later.

      Parameters

      • config: { decoder?: any; numWorkers?: number; url?: string }

        The decoder configuration.

        • Optionaldecoder?: any

          The decoder object, such as the MeshoptDecoder exported by the meshoptimizer package.

        • OptionalnumWorkers?: number

          The number of web workers to decode on. Defaults to 0, which decodes on the main thread.

        • Optionalurl?: string

          The URL of the decoder module. Ignored when decoder is set.

      Returns void

      import { MeshoptDecoder } from 'meshoptimizer';

      pc.meshoptInitialize({ decoder: MeshoptDecoder });
      pc.meshoptInitialize({ url: 'lib/meshopt_decoder.mjs' });