Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for KTX2 loader #266

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
enable meshopt loader if necessary
marwie committed Jun 30, 2024
commit 25172903bb785bebb047c9136736b56f8b290980
3 changes: 2 additions & 1 deletion src/utils/parser.js
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ function parse(gltf, { fileName = 'model', ...options } = {}) {
gltf.scene.traverse((child) => objects.push(child))
const json = gltf.parser.json;
const needsDraco = json.extensionsRequired && json.extensionsRequired.includes('KHR_draco_mesh_compression');
const needsMeshopt = json.extensionsUsed && json.extensionsUsed.includes('KHR_meshopt_compression');
const needsKTX2Loader = json.extensionsRequired && json.extensionsRequired.includes('KHR_texture_basisu');

// Browse for duplicates
@@ -497,7 +498,7 @@ ${parseExtras(gltf.parser.json.asset && gltf.parser.json.asset.extras)}*/`
? `const { nodes, materials${hasAnimations ? ', animations' : ''} } = useGLTF('${url}'${
needsDraco ? ", true" : options.draco ? `, ${JSON.stringify(options.draco)}` : ', false'
}
, false, ${needsKTX2Loader ? `(loader) => {
, ${needsMeshopt ? 'true' : 'false'}, ${needsKTX2Loader ? `(loader) => {
const { gl } = useThree();
const THREE_PATH = \`https://unpkg.com/three@0.$\{REVISION\}.x\`;
const ktx2Loader = new KTX2Loader().setTranscoderPath(\`$\{THREE_PATH\}/examples/jsm/libs/basis/\`);