Closed Ahmadre closed 2 months ago
This isn't very specific to R3F, but most loaders implement a parse
method which they call once they fetched a resource via their underlying FileLoader
. It will either accept text or an arraybuffer -- OBJLoader
expecting text. Alternatively, you could make your own loader and implement load
to make async requests as well if you want special handling/preprocessing.
function Box() {
const obj = useMemo(() => new OBJLoader().parse(text), [text])
return <primitive object={obj} scale={10} />
}
This isn't very specific to R3F, but most loaders implement a
parse
method which they call once they fetched a resource via their underlyingFileLoader
. It will either accept text or an arraybuffer --OBJLoader
expecting text. Alternatively, you could make your own loader and implementload
to make async requests as well if you want special handling/preprocessing.function Box() { const obj = useMemo(() => new OBJLoader().parse(text), [text]) return <primitive object={obj} scale={10} /> }
@CodyJasonBennett Thank you so much! You helped me a lot 😊
At first thank you so much for this awesome R3F ❤️
But I don't see any possibility to load my *.obj files via input bytes or string.
Let's assume you generate your OBJ-Files directly in React and it looks like this:
How can I pass this input string into
useLoader
or in general load my OBJ directly on runtime?