Skip to content

使用 DRACOLoader

在本项目中使用 DRACOLoader 和官方示例并没有什么不同。唯一需要关注的点就是 setDecoderPath 这一步中配置的路径有限定的值。

js
    const dracoLoader = new DRACOLoader();
    // 使用标准版本的 draco worker 和 wasm
    dracoLoader.setDecoderPath('draco/');
    // 使用 gltf 版本的 draco worker 和 wasm
    dracoLoader.setDecoderPath('draco/gltf/');
    // 当然也支持不使用 wasm 的模式
    // dracoLoader.setDecoderConfig({ 
    //   type: 'js'
    // });

当然,如果你需要在 uni-apph5 模式下兼容,你仍需在对应条件编译下设置正确的网络路径,例如:

js
// #ifdef H5
dracoLoader.setDecoderPath('https://threejs.org/examples/libs/draco/gltf/'); 
// #endif