DataTree
More actions
The FrooxEngine Data Tree format (FrDT) is the file format internally used by FrooxEngine to store a saved data model tree, such as an object, entire world or the user settings. It is a JSON based format, commonly using MongoDB's BSON binary representation instead of textual JSON. Encoded files may be 'raw', or be prefixed with a 9[1]-byte header.
Variants
Based on the encoding & compression type used, a data tree will use one of the following extensions:
.brson- Brotli compressed, may have header. (default when saving).lz4bson- LZ4 compressed, may have header (used in certain cases for locally stored assets such as when doing an emergency save in case of world crash and during internal save processing).7zbson- LZMA compressed, may have header (legacy, replaced by Brotli).frdt- Generic file format, must have header..bson- Raw BSON binary format..json- Raw JSON textual format.
When loading, the file extension must match the type of compression used. If the file has a header that specifies a different compression type than the one matching the extension, loading will fail.
Header
The structure FrDT header is as follows:
- magic (4-bytes): always
0x46724454('FrDT' ) - version (4-bytes): must be 0
- compression (7-byte encoded):
- 0 - Uncompressed (.frdt)
- 1 - LZ4 (.lz4bson)
- 2 - LZMA (.7zbson)
- 3 - Brotli (.brson)
Compression & encoding notes
7-Zip/LZMA
Resonite uses the 7-Zip LZMA SDK, and generates 'raw' or 'alone' LZMA data, which may not be supported by other LZMA libraries or tools. Resonite appends a 5-byte blob generated by 7-Zip which specifies the coder properties.
If you are not using the 7-Zip LZMA SDK, you may need to extract these properties (it appears Resonite will always use 0x5D00002000, which corresponds to dictionary size 2097152, 2 pos state bits, 3 lit context bits, 0 lit pos bits, algorithm 2, 32 fast bytes, match finder bt4, and no EOS marker), along with two 64-bit ints which encode the decompressed & compressed size respectively, for a total 21 byte header.
BSON
Resonite stores the entire data tree dictionary in a single BSON document so streamed decoding may not be possible.
JSON
JSON numbers are generally assumed to be IEEE-754 floating point doubles, but Resonite uses different types of numbers (such as 64-bit longs) which may not be expressible as doubles without precision loss.
Data structure
Note that, other than the JSON data types (boolean, string, number, null), Resonite does not store any type information in data trees, other than the names of components - it is expected that a reader would already have the full type information (i.e. by reflecting the component classes in the FrooxEngine assembly), while you can make reasonable assumptions (URIs are prefixed with '@', references to other elements follow a GUID-like 8-4-4-4-12 format, colorXes are arrays with 4 numbers and one of 'Linear'/'sRGB'/'sRGBAlpha'), these are always only going to be just guesses.
Furthermore, this information is valid for data trees created with the latest version of Resonite. Old versions may have differences in how data tree files are generated. For example, old versions stored the type name directly in the Worker's 'Type' field instead of using an integer index into the root's Types list.
| Field | Type | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| VersionNumber | string | Version of Resonite this object was saved with | ||||||||
| FeatureFlags | Dictionary of string to int | List of what features were enabled on the saving version of Resonite and which version of the feature. | ||||||||
| Types | List of string | List of data model types used in this tree. Index into this list is used to reference specific types later. | ||||||||
| TypeVersions | Dictionary of string to int | Mapping of which TypeVersion of a data model type is saved in this tree | ||||||||
| Assets | List of asset components | Assets not stored on slots in this tree (i.e. those on 'holder' slots) are held here. | ||||||||
Objects: Object
Worlds: |
Slot | The root slot of the object.
Despite this being called 'Slots' in World data trees, this will always be a single slot. | ||||||||
| Name | Worlds only
SyncField<string> |
|||||||||
| Access Level | Worlds only
SyncField<SessionAccessLevel> |
|||||||||
| Mobile Friendly | Worlds only
SyncField<boolean> |
|||||||||
| Assemblies | Worlds only
List of Data Model Assembly
|
List of assemblies present in this world | ||||||||
| SystemCompatibilityHash | Worlds only
string |
System compatibility hash of the version of Resonite used to save this world | ||||||||
| Configuration | Worlds only
WorldConfiguration |
Stores the session configuration (name, description tags, access level, user limit, etc) | ||||||||
| Keys | Worlds only
Dictionary of string to ReferenceID |
The world's global dictionary (stores references to things such as the skybox, locale, undo manager, default materials, default fonts, etc) | ||||||||
| Version String | Worlds only
string |
'Beta ' + VersionNumber | ||||||||
| Permissions | Worlds only
WorldPermissions |
| Field | Type | Description |
|---|---|---|
| ID | ReferenceID | |
| Persistent-ID | string | |
| ParentReference | ReferenceID | Used to reference the original parent slot when the object was saved |
| Components | SyncField<Component[]> | |
| Children | Slot[] | |
| Name | SyncField<string> | |
| Tag | SyncField<string> | |
| Active | SyncField<boolean> | |
| Position | SyncField<float3> | |
| Rotation | SyncField<floatQ> | |
| Scale | SyncField<float3> | |
| OrderOffset | SyncField<long> |
| Field | Type | Description |
|---|---|---|
| Type | int | Index to the Types array on the root of which type this component is |
| Data | Worker | |
| Data.ID | ReferenceID | |
| Data.persistent-ID | Slot components only
string |
|
| Data.persistent | Components in Assets list only
SyncField<boolean> |
|
| Data.UpdateOrder | SyncField<int> | |
| Data.Enabled | SyncField<boolean> | |
| Data.[...] | SyncField | Rest of the fields on this component |
| Field | Type |
|---|---|
| ID | ReferenceID |
| Data | T |
SyncList<T>'s are encoded as SyncField<SyncField<T>[]>
- ↑ Technically, the compression type used is stored using 7-bit variable encoding, so the header could be up to 14 bytes, but up to 128 compression types could be stored with a single byte and we are using 4 so far.