#Is it possible to export multiple objects, each with their own GLTF Object component, at once?

1 messages · Page 1 of 1 (latest)

winter vale
#

Hey guys,

I currently have a bit of a cumbersome workflow whereby in my scene, I :

  1. Create a prefab
  2. Attach the GLTF OBJECT component
  3. Do a build to export the object as a .glb
  4. I transfer my new .glb asset to a new server.

If I put 2 or more prefabs in my scene with the GLTF OBJECT component, many times I end up with no .glb assets after the build. Is this a bug ? I have done it in another project where this did sometimes work, though not consistently. For clarity I am looking to do the same steps as above, but instead of needing to build after each individual prefab is ready for export, I want to set up multiple, do a build, and get multiple .glbs after the one build.

regal swallowBOT
# winter vale Hey guys, I currently have a bit of a cumbersome workflow whereby in my scene...

Thanks for reaching out @winter vale

Please read through the following and share the information requested. This will help us to better assist you.

Description

Describe the issue that you're seeing. Please be as detailed as possible e.g. is this issue happening in Unity or Blender, which Needle Engine version are you using, do you see any errors in the Editor or Browser console, etc.

Information:

  • If you're using Unity click the menu item Needle Engine/Report a Bug/Copy Project Info to Clipboard. Please share the results below.
  • Please provide code snippets using Discord Code Blocks
  • Have you contacted Needle through another channel or just through Discord?

Thanks for submitting!

💡 Did you know that we now also have a forum with AI support? Join now with your discord account!

shut fiber
#

Hey, can you explain more about what your goal / workflow is? This does not sound like a typical workflow.

Typically you'd just use a SceneSwitcher with your various objects and that's it, no copying/GltfObjects required

winter vale
#

Hey, yeah Im aware that its a bit of a strange set up.
We have a series of outcomes that can happen for a race. There are 120 outcomes in total, each about 1MB in size, so packing them in the project with the initial download is just not feasible, so instead, they are only downloaded as and when they are needed.

The steps above are the setup to get the animation assets ready for download. I discussed this with Marcel before Christmas. Its an odd set up but it solves our problem, so Im happy with it. Its just the GLTFs not exporting unless its a single GLTF Object in the scene thats slowing me down a bit.

shut fiber
#

packing them in the project with the initial download is just not feasible
There may be a misunderstanding – they will not be part of the initial download when using SceneSwitcher

#

That's quite literally its designed usecase 🙂

winter vale
#

Im pretty sure there was a reason that couldnt work. Id have to check the previous ticket.

verbal carbon
#

(and/or when referencing them in your project assets with an AssetReference type - which is what SceneSwitcher is using under the hood)

verbal carbon
winter vale
#

Okay thanks both. Ill take another look at this.

#

Can you just explain to me how the Scene Switcher works in terms of them not being part of the main download though please? I dont understand how assets put into the Scene Switcher list are not part of the initial download? Thats not clear to me. Where will the assets reside? (I assume they are compressed, but are tehy compressed to an extent that 120MB of assets is negligible?)

shut fiber
#

They will be exported as individual glb files and only loaded when needed - that’s a core design goal we have with needle engine

#

So things referenced in SceneSwitcher (or AssetReference) have zero footprint for initial download

winter vale
#

Okay, thank you. Ill take a look at a Scene Switcher example tomorrow and give that a go instead

verbal carbon
winter vale
#

Ah thats very helpful thank you. Ill take a look at this in the morning. Its certainly a less convoluted approach than the current way Im doing it

winter vale
#

Hey both, I just want to check in regarding the above. I have followed the approach outlined in the link provided by Marcel above. My exact use case is as follows (Marcel, we had a conversation about this privately a few months back so if you check your conversation history with me, its the only thing we've ever spoken about privately):

I have a path fbx object that controls the paths each horse (6 in total) takes. The horses themselves, and the animations for the horses are applied separately to each horse, completely independant of the path animation. I have 120 total possible path animations, and creating an animator controller with 120 animation states is not a solution because of the fact it would bloat the download size. Initially, I had ben creating a separate prefab for each possible outcome, so for example, animationData_123456.glb, animationData_654321 etc , and would download an animation from a different server only when needed. Following the advice here yesterday, specifically the approach outline in the link shared above by Marcel (not the SceneSwitcher approach as you said that that uses the same AssetReference logic under the hood), I now have a list of AssetReferences, which are the animationData prefabs I created, and I load them when needed like shown in the screenshot (I am only loading the first one for testing purposes in the screenshot). Is this a valid approach?

Apologies for going in circles with this point, but I still just cant get my head around how this will keep the project build small. If I do a build, is my build not going to be massively bloated by these animations, and if I make this publically downloadable how is going to remain small? Without these changes today, my project size is about 15MB without gzip compression, which is already large enough.

regal swallowBOT
regal swallowBOT
# winter vale Hey both, I just want to check in regarding the above. I have followed the appro...

Stephen, to ensure your project build remains small while still dynamically loading animations, your approach of using AssetReferences to load animations as needed is valid and aligns well with efficient resource management practices in web-based applications. Here's how it contributes to keeping the build size small:

  1. AssetReferences: By using AssetReferences for your animationData prefabs, you're not embedding the animations directly into your main build. Instead, these references act as pointers to the actual animation files that reside on a server. This means that the initial download size of your project will only include the necessaries to run the application, without all the animations.

  2. On-Demand Loading: Loading animations only when needed (lazy loading) is a strategic way to manage your resources. This ensures users download only the assets required for the current context or user action, significantly reducing the initial load size and time.

  3. Separated Animations: Keeping animations separate from the main build and loading them from a different server provides flexibility and scalability. As your project grows or changes, you can update or add animations without modifying the core project build, ensuring users always have access to the latest content without re-downloading the entire project.

However, it's important to manage and optimize the animations themselves:

  • Optimization: Ensure your .glb files are optimized for the web. This can involve reducing polygon counts, compressing textures, and using efficient animation keyframing to minimize file sizes without significant loss in quality.

  • Compression: Utilize server-side compression (e.g., gzip or Brotli) to reduce the file size of your animations during transmission. This can significantly lower the bandwidth required for downloading the animations.

thread_v5jZLD7FHFrhJSEipMsdokvO

regal swallowBOT
# winter vale Hey both, I just want to check in regarding the above. I have followed the appro...
  • Caching: Implement caching strategies on the client's browser or through service workers to store downloaded animations. This prevents re-downloading the same assets, speeding up load times for returning users and conserving bandwidth.

Your project size on the disk might appear large because it includes all possible animations, but the actual size downloaded by users will be much smaller and scalable based on their actions within the application. The key is that the build itself contains only the skeleton and minimal assets needed to run the application, with everything else being pulled dynamically as required. This approach aligns well with web development best practices for performance and efficiency.

0 messages left
thread_v5jZLD7FHFrhJSEipMsdokvO

winter vale
#

AssetReferences: By using AssetReferences for your animationData prefabs, you're not embedding the animations directly into your main build. Instead, these references act as pointers to the actual animation files that reside on a server - I think this is the part that wasn't clicking for me. Thanks bot. 🤖 ❤️

winter vale
#

Before adding a series of the AssetReferences as shown above, my dist folder after a build is 18.5MB, and after adding a handful of the assets, its now about 25.5. I can see that the various AnimationData glbs are now generated and in the dist folder. @shut fiber above, are you saying that even though these extra AnimationData glbs are now in my dist folder (increasing the size from 18 MB-25MB), if that dist folder was accessible for download via AWS or some other hosting platform, its only the core files that would be downloaded (not the full 25MB), and that each of those glbs would be downloaded separately only when referenced directly? My initial confusion a few months back came from seeing the glbs in the dist folder and I thought I had to come up with a solution that kept the dist folder small.

verbal carbon
#

The dist folder size doesn't immediately matter and just because you have many large files there doesn't mean they're downloaded immediately - usually quite the opposite is the case. When you assign a Prefab or Scene in Unity to a component it will be exported to a separate (!) GLB and your main scene only stores a string (the path) to that file. This file only gets loaded when it's needed (e.g. when a SceneSwitcher changes the scene or when you call a load on the AssetReference.

#

You can inspect this in your browsers networking tab for example (e.g. in your local server). Note i filtered by "Fetch/XHR" and "Hide data URLs"

winter vale
#

Thank you for this. This has clarified a lot of things, and made me realize how much I am under utilizing asset references. I think the core confusion on my end (not a web developer) came from the fact that ultimately I kept thinking "Im putting this dist folder on AWS. Everything in here is getting downloaded immediately". Thats where I went wrong. From a Unity POV, because the asset references were being added to a list in the inspector, I assumed the application would be loading them into memory, and hence why I assumed they would need to be part of that initial download.