From e1c196b90ebf3a3d35f560b1ea23b87afc114695 Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Fri, 20 Dec 2024 12:17:13 +0900 Subject: [PATCH] GLTFExtensionPlugin: Add support for meshoptDecoder --- src/plugins/README.md | 3 ++- src/plugins/three/GLTFExtensionsPlugin.js | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/plugins/README.md b/src/plugins/README.md index d9e18efed..4c5ec6a13 100644 --- a/src/plugins/README.md +++ b/src/plugins/README.md @@ -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, diff --git a/src/plugins/three/GLTFExtensionsPlugin.js b/src/plugins/three/GLTFExtensionsPlugin.js index fb93b6f7d..8813e259b 100644 --- a/src/plugins/three/GLTFExtensionsPlugin.js +++ b/src/plugins/three/GLTFExtensionsPlugin.js @@ -15,6 +15,7 @@ export class GLTFExtensionsPlugin { dracoLoader: null, ktxLoader: null, + meshoptDecoder: null, autoDispose: true, ...options, }; @@ -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; @@ -49,6 +51,12 @@ export class GLTFExtensionsPlugin { } + if ( this.meshoptDecoder ) { + + loader.setMeshoptDecoder( this.meshoptDecoder ); + + } + if ( this.rtc ) { loader.register( () => new GLTFCesiumRTCExtension() );