- C# 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| Project-Obsidian.SourceGenerators@e073aba491 | ||
| Properties | ||
| ProtoFlux | ||
| Util | ||
| .gitignore | ||
| .gitmodules | ||
| DataTreeAssetPlugin.csproj | ||
| DataTreeAssetPlugin.sln | ||
| Directory.Build.props.template | ||
| README.md | ||
Resonite Data Tree Asset Plugin
- A ProtoFlux node (
AttachSavedObject) for getting aStaticSavedObjectProviderasset from a URI. - A ProtoFlux node (
SpawnSavedObject) for loading the contents off aStaticSavedObjectProvidercomponent (aka. the fabled 'cloud-spawning' node) - A ProtoFlux node (
SaveSlotToAsset) for saving a Slot hierarchy to aStaticSavedObjectProviderasset.
Rationale
In Resonite, currently, objects loaded into the world always have some level of overhead, even if they are set to inactive, ranging from (v)RAM usage, network bandwidth & cache disk space by loading assets such as textures, models, audio, etc, to the fundamental CPU time cost and network bandwidth used to replicate these, and instantiate the slots & components on every client.
While there are workarounds, such as manually driving each asset to have it's URL field wiped out whenever it is not in use, the only approach for unloading entire hierarchies without intensive manual effort is to just to store these as seperate objects in your Resonite inventory, saving & spawniing/destroying them when needed. This can be annoying, time intensive & error prone as it requires users to find & spawn out multiple objects manually.
One such solution users have long requested is the ability to cloud-spawn assets, which this plugin builds upon this idea to provide a complete & thought out solution to this problem with a proof-of-concept implementation, relying on many building blocks already a part of Resonite for a simple & low implementation cost, but still flexibile & useful for a number of other use cases (such as objects & systems which have automated update systems, or interfaces for object repositories such as UniPocket, RedX or ResDex.)
By storing a data tree in an asset and adding a ProtoFlux node for saving a Slot hierarchy to a asset, this solves the concerns I see mentioned in regard to cloud spawning:
- Since we are storing the URL to an asset, and not a record ID, there is no concern around being able to spawn out private assets without a user's consent as asset URLs already do not have any sort of access control (any user with a resdb link to an asset can paste it in, or download it by resolving the url to an assets.resonite.com URL), with cloud spawning asset URLs already possible by hacking the FileMetadata component's OnImportFile method.
- By saving the slot as an asset, which, is referenced & saved with the world or containing object's. This ensures that the reference to a data tree can never be broken by another user deleting a record from their inventory without realising it was in use.
- While the asset a object record points to cannot be mutated presently, using the asset URL guarantees the object to be spawned out cannot be tampered with by changing the underlying asset a record points to (as asset URLs are built using the asset's hash). It also would also allow users to load dynamic content, by for example, having an external HTTP service generate data tree files on the fly.
- By adding a ProtoFlux node to save a slot to an asset, updating the saved object becomes easier, as for example, you could create a system to unpack & spawn out saved parts of an object as you need to work on them, and be able to pack them back in automatically using ProtoFlux, without having to manually save to inventory & update the record ID.
How It Works
StaticSavedObjectProvider Asset Type
Resonite already has a concept of storing data trees as assets, with the already existing, albeit, unused (even back in 2021 it was 'an old thing that has been added in the past, but I (Frooxius) forget the exact reason.') StaticSavedObjectProvider asset class. Since this is already in Resonite, and reusing it makes my life easier.
However, to correctly implement this idea, Resonite's existing record saving logic would need to be updated in order to ensure that when saving an object or world to a Record, that assets referenced by the data tree referenced by StaticSavedObjectProvider are recursively added to the final saved record's asset manifest, and for local: URLs, ensure that they are uploaded to the Cloud. Resonite does already recursively process data trees referenced (see FrooxEngine.DataTreeAssetProcessor), to replace the machine IDs in local URLs with the local machine ID, but does not process nested data tree assets when uploading to the cloud.
SpawnSavedObject ProtoFlux Node (aka. the fabled 'cloudspawn'ing node)
This node takes an async call, reference to a StaticSavedObjectProvider component (which could created from a URL with the AttachSavedObject node), and a Slot which the spawned object will be parented under. This node when called, loads the data tree (ensuring it is a valid Object data tree, and not, for example, a World), and perform the usual steps for spawning out an item, parenting it under the provided slot.
SaveSlotToAsset ProtoFlux Node
Similar to the RenderToTextureAsset node, this node takes in an async call1, a slot hierarchy to save, and returns a URI to a local asset, which can be attached for save with the world
Concerns
I do not see this asset as doing anything unprecidented within Resonite, for example, concerns about being able to save assets to disk from ProtoFlux (such as filling the disk cache with junk assets) could already be done with the RenderToTextureAsset node, and spawning assets by their Asset URL can already be performed by the current hacks for cloud spawning.
Furthermore, as previously mentioned, I do not believe the ability to spawn assets in the way added by this plugin presents any important security concerns, as to spawn an asset, you would already need to know the asset URL, which are already publically retrievable, record URLs would not be accepted.
Users could potentially make false assumptions that once an object has been packed into an asset like this, it is in any way protected, however, most users are already aware that anything the exists in the datamodel can be accessed by any other user into the session, and it should be reasonable to expect users to know that this statement would also apply to objects that have been packed into an asset, and that anyone else in a session would be able to retrieve the asset URL, and that this mechanism does not provide any additional security over just deactivating a slot hierarchy.
However, the ability to automatically save slot hierarchies could present a concern around asset protections, such as protected avatars. For example, a malicious user could create a malicious object with ProtoFlux that when invoked, would run as every user in the session, silently saving that user's Avatar into an asset on a hierarchy part of the malicious object, which then could be saved to the user's inventory, later using a mod, or tools to dump their inventory to extract assets that should have been protected. This isn't major has users could already create mods to do the same, but it would still be reasonable to prevent any protected asset being saved in this way, even if the local user is authorised to save it.
-
It would be nice if this could be done synchronously, to allow, for example, a system that automatically packs & unpacks certain hierarchies, might want to use the
OnSavingnode to ensure any unpacked objects are automatically packed in, but saving an asset, even to the LocalDB is done asynchronously, and these ProtoFlux events do not wait for asynchronous tasks to finish. ↩︎