Open YBFACC opened 3 months ago
另外可能的问题:
使用 gltf 插件来处理 https://github.com/nytimes/rd-bundler-3d-plugins/tree/main
方法 3
使用 gltf 插件来处理 https://github.com/nytimes/rd-bundler-3d-plugins/tree/main
由于这个包要使用 sharp,国内服务器 npm 下载可能会报错
可以主动配置 .npmrc
配置下载路径
sharp_binary_host=https://npmmirror.com/mirrors/sharp
sharp_libvips_binary_host=https://npmmirror.com/mirrors/sharp-libvips
注意 这里使用 draco
会导致模型的加载器变更,会报错
textureCompress 能压缩材质。原来 18MB, 压缩完 5.9MB
import gltf from "vite-plugin-gltf"
import { draco, textureCompress } from "@gltf-transform/functions";
import sharp from 'sharp';
export default {
plugins: [
gltf({
transforms: [
textureCompress({ encoder: sharp, resize: [2048, 2048] }),
// draco()
],
}),
],
}
可见 https://cn.vitejs.dev/guide/assets.html
主要的 2 种方式