threepipe
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

plugin-gltf-transform.md 2.0KB


prev:

text: '@threepipe/plugin-geometry-generator'
link: './plugin-geometry-generator'

next:

text: '@threepipe/plugins-extra-importers'
link: './plugins-extra-importers'

@threepipe/plugin-gltf-transform

Exports GLTFDracoExportPlugin that extends the default gltf exporter to compress the file after export.

ExampleSource CodeAPI Reference

NPM Package

npm install @threepipe/plugin-gltf-transform

To use, simply add the plugin to the viewer and export using the viewer.export or viewer.exportScene functions. This also adds UI options to AssetExporterPlugin which are used when exporting using the plugin or using viewer.exportScene

The plugin overloads the default gltf exporter in the asset manager with GLTFDracoExporter. Using the gltf-transform library, it compresses the exported gltf file using the khr_draco_mesh_compression extension.

Note - Only glb export supported right now.

Sample Usage:

import {ThreeViewer, downloadBlob} from 'threepipe'
import {GLTFDracoExportPlugin} from '@threepipe/plugin-gltf-transform'

const viewer = new ThreeViewer({...})
viewer.addPluginSync(GLTFDracoExportPlugin)

await viewer.load('file.glb')

const blob = await viewer.exportScene({
  compress: true, // this must be specified, by default it's false.
  viewerConfig: true, // to export with viewer, scene and plugin settings
})
// download the file
downloadBlob(blob, 'scene.glb')