How to use KTX2Loader with useGLTF, and without use useKTX2() which seems to need explicit textures URIs #1335
Unanswered
epouliquen
asked this question in
Q&A
Replies: 2 comments 1 reply
-
Hello, did you found one solution ? I have the same issue. |
Beta Was this translation helpful? Give feedback.
0 replies
-
The extensionLoader setting must be set in the fourth parameter of useGLTF export declare function useGLTF<T extends string | string[]>(path: T, useDraco?: boolean | string, useMeshOpt?: boolean, extendLoader?: (loader: GLTFLoader) => void): T extends any[] ? GLTF[] : GLTF; I referenced gltf-viewer. import { useGLTF } from '@react-three/drei'
import { REVISION } from 'three'
import { KTX2Loader } from 'three/examples/jsm/loaders/KTX2Loader'
import { useThree } from '@react-three/fiber'
const { gl } = useThree()
const { scene } = useGLTF('/myScene-transformed.glb', false, false, (loader) => {
const THREE_PATH = `https://unpkg.com/three@0.${REVISION}.x`
const ktx2Loader = new KTX2Loader().setTranscoderPath(`${THREE_PATH}/examples/jsm/libs/basis/`)
loader.setKTX2Loader(ktx2Loader.detectSupport(gl))
}) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I have a glb + jsx file, coming from gltfjsx cli , and including KTX2 textures (embedded).
I'm trying to extend the loader as seen in sources, like this
but it doesn't work. I don't even see my "coucou" debug test in console.
reported error is :
THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures)
I don't understand ho to achieve same behaviour as in vanilla THREE.js
I also don't want to use useKTX2() as, if I understand well, need to explicit textures URIs and than apply one by one to materials...
for sure there is a way to pass the KTX2Loader to the GLTFLoader no ?
Thanks for your help.
Beta Was this translation helpful? Give feedback.
All reactions