API function to export all loaded world entities as-is
Adds export options to Clipboard.exportEntities for global positioning, excluding non-domain entities, and pathnames for serverless JSONs.
Example script that binds Ctrl+S to open a save dialog
Closes #1411
I gave this a test and noticed two things: The example script doesn't do anything on my system. I ran:
const file = Window.save("Export world JSON", "", "*.json");
and then
if (file) {
Clipboard.exportEntities(file, 0, 0, 0, 3e38, {
domainOnly: true,
globalPositions: true,
paths: {
"/": {position: MyAvatar.position, orientation: MyAvatar.orientation}
}
});
instead.
Rotations appear wrong in the JSON. Every entity has the following rotation in the resulting JSON file, regardless of their real rotation.
"w": 1,
"x": -1.52587890625e-05,
"y": -1.52587890625e-05,
"z": -1.52587890625e-05
Though in practice it still works (left is the original, right is the export loaded as serverless):
There's now Clipboard.ExportOptions and Clipboard.ExportPlaces in the docs, and domainOnly has been removed. The selected entities mode can already include what entities it wants, and allowing avatar entities and local entities in the box selection doesn't really make sense as it'll always be full of HUD elements and other users' wearables.