Skip to content

Conversation

@yuripourre
Copy link
Contributor

@yuripourre yuripourre commented Aug 28, 2025

Title

Export scene as .babylon

Summary

Export the current scene as a .babylon file

Changes Made

Added export scene (.babylonjs)

  • In the File menu added an option to export the scene

Benefits

  • The current scene can be exported as .babylon (which can be easily used outside the editor).
  • The .babylon can be reimported in the editor as a composite object/prefab (like in Unity 3d)
Screenshot From 2025-09-01 19-25-38
Screencast.From.2025-09-01.19-26-04.mp4

Closes #601

@julien-moreau
Copy link
Contributor

In order to prepare prefabs, I suggest that a portion of the scene should be exporable via a right-click on a node in the graph. Instead of the entire scene
What do you think?

@yuripourre
Copy link
Contributor Author

@julien-moreau that's a really good idea. I will modify this PR.

@julien-moreau
Copy link
Contributor

For the full scene export, it can be in the right-click menu of the scene node

@yuripourre yuripourre marked this pull request as draft September 1, 2025 04:33
@yuripourre yuripourre force-pushed the export-scene branch 3 times, most recently from 0cc3e75 to 616af57 Compare September 2, 2025 02:41
@yuripourre yuripourre marked this pull request as ready for review September 2, 2025 02:42
@yuripourre
Copy link
Contributor Author

@julien-moreau Updated!

@yuripourre yuripourre changed the title feat: Add menu item to export scene feat: Add context menu item to export scene and nodes Sep 2, 2025
Copy link
Contributor

@julien-moreau julien-moreau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thinking about assets, I forgot last time.
What is the usage if the assets (textures assigned to materials for meshes for example) are not exported. The .babylon is kind of corrupted as it'll try to load assets not available near it.

@yuripourre
Copy link
Contributor Author

I thinking about assets, I forgot last time. What is the usage if the assets (textures assigned to materials for meshes for example) are not exported. The .babylon is kind of corrupted as it'll try to load assets not available near it.

That's true!
In that case, do you think the best way would be to export the texture in the .babylon file so the model can be loaded without issues? Even though it will not be available as asset when reloaded?

Or do you think when importing a .babylon file we could strip the assets from the file and import as separate assets?

We can also let the .babylon "prefab" break and let the user assign a different material.

@julien-moreau
Copy link
Contributor

I just fixed an issue in the editor when importing meshes: the process that extracts textures in case they were embeded.
I think packing everything in the .babylon may work: the .babylon file works as standalone, allows to quickly drag'n'drop it in the sandbox or load it in any project not done with the editor. In case it's added later in the editor it'll be able to extract the textures so that's perfect.

I was think about prefabs and it'll require some huge work finally. I think this PR can be the "export as babylon" feature. It does only that. In the future we'll create kind of a "create prefab" menu that will manage way more things (such as prefab Ids to retrieve resources if they already exist etc.).

@yuripourre
Copy link
Contributor Author

@julien-moreau that's great, then I will rebase and fix the comments somewhere this weekend.

For me that would be more than enough to use as prefabs while we don't have the proper feature.

Thanks for reviewing and the suggestions

@julien-moreau
Copy link
Contributor

For me that would be more than enough to use as prefabs while we don't have the proper feature.

I totally agree! We'll just not call it prefab for instance ^^

@yuripourre
Copy link
Contributor Author

@julien-moreau
I will try to test more later today but added particle systems and sound export

Copy link
Contributor

@julien-moreau julien-moreau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take it for the next release (as I'm releasing today some fixes). I'll probably merge it and rework it if needed. Thanks for the good base you provided!

@yuripourre
Copy link
Contributor Author

@julien-moreau whoa! Thank you so much for reviewing.
This feature is one of those that will make my life much easier.

Copy link
Contributor

@julien-moreau julien-moreau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, I took sprites support instead which took me more time than I have anticipated
I'll focus on this one after ^^

@yuripourre yuripourre force-pushed the export-scene branch 3 times, most recently from 20fec67 to 23d6edc Compare October 25, 2025 23:09
@b3nten
Copy link

b3nten commented Nov 2, 2025

This would be huge for composing scenes or parts of scenes and then loading them into a Babylon app that's written "manually" outside the editor. Hope it lands soon!

@julien-moreau
Copy link
Contributor

This would be huge for composing scenes or parts of scenes and then loading them into a Babylon app that's written "manually" outside the editor. Hope it lands soon!

Totally agree! I'm reviewing it ASAP
@yuripourre do you think this PR is ready for review?

@yuripourre
Copy link
Contributor Author

@julien-moreau, yes, please go ahead :)

Feel free to change if something can be better.

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

Successfully merging this pull request may close these issues.

[Feature Request] Export Scene

3 participants