Skip to content

How to load from an internal buffer #833

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

Open
dqmachine opened this issue Apr 3, 2025 · 2 comments
Open

How to load from an internal buffer #833

dqmachine opened this issue Apr 3, 2025 · 2 comments

Comments

@dqmachine
Copy link

On the GLTFSceneExporter, if I use ExportFile() to save file contents to an internal buffer, is their an equivalent method in the GLTFSceneImporter class to pull that content out of the buffer?

@hybridherbst
Copy link
Collaborator

hybridherbst commented Apr 3, 2025

Yes, you can use the Stream overload of GLTFSceneImporter to load from, for example, a MemoryStream. Is this what you're looking for?

Image

@dqmachine
Copy link
Author

dqmachine commented Apr 3, 2025

Not really. That would parse the root nodes out of the supplied stream buffer.

I wasn't very clear. The example is the following:
I export a GLB using the GLTFSceneExporter -> SaveGLB(). I have a separate audio context when aftersceneexport() is invoked, I call exporter->ExportFile() with contents of my audio. Looking at the ExportFile method(), it stored the contents of my MP3 into the GLB buffer and creates a bufferview.

Now, switching perspective, I want to write a loader to load the GLB and mp3. I create a scene importer and loadSceneAsync(). On the complete callback, I'm trying to load the MP3 that was stored to an internal buffer in the above example. I first looked for an equivalent ImportFile() (similar to the exportFile() above), but I do not see any equivalent functions. I tried to access the buffer, but I can't seem to get to any of the internal buffers directly.

How would I load an extra file written to the GLB buffer that is not a mesh, material, etc, which auto-load as part of the import process?

EDIT: Is there some way to access the internal buffers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants