Skip to content

Commit

Permalink
GLTFExtensionPlugin: Add support for meshoptDecoder
Browse files Browse the repository at this point in the history
  • Loading branch information
gkjohnson committed Dec 20, 2024
1 parent 13121a0 commit e1c196b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,10 @@ Available options are as follows:
// A list of other extensions to include in the loader. All elements are passed to the "GLTFLoader.register" function.
plugins: [],

// DRACOLoader and KTX2Loader instances to add to the loader.
// DRACOLoader, KTX2Loader, and MeshoptDecoder instances to add to the loader.
dracoLoader: null,
ktxLoader: null,
meshoptDecoder: null,

// Whether to automatically dispose of the DRACO and KTX Loaders when the plugin is disposed.
autoDispose: true,
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/three/GLTFExtensionsPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class GLTFExtensionsPlugin {

dracoLoader: null,
ktxLoader: null,
meshoptDecoder: null,
autoDispose: true,
...options,
};
Expand All @@ -27,6 +28,7 @@ export class GLTFExtensionsPlugin {

this.dracoLoader = options.dracoLoader;
this.ktxLoader = options.ktxLoader;
this.meshoptDecoder = options.meshoptDecoder;
this._gltfRegex = /\.(gltf|glb)$/g;
this._dracoRegex = /\.drc$/g;
this._loader = null;
Expand All @@ -49,6 +51,12 @@ export class GLTFExtensionsPlugin {

}

if ( this.meshoptDecoder ) {

loader.setMeshoptDecoder( this.meshoptDecoder );

}

if ( this.rtc ) {

loader.register( () => new GLTFCesiumRTCExtension() );
Expand Down

0 comments on commit e1c196b

Please sign in to comment.