Closed fire closed 1 year ago
Here's the updated mermaid.js diagram representing the relationship between PackedScene, MissingNode, Wasm Binary, and Embedded Script with the change that the Wasm Binary is executed to read:
sequenceDiagram
participant A as PackedScene
participant B as MissingNode
participant C as Wasm Binary
participant D as Executed to read
participant E as Custom Class Name
participant F as Data inside (Embedded Script)
A->>B: Passes MissingNode
B->>C: Passes Wasm Binary
C->>D: Executes to read
D->>E: Reads Custom Class Name
D->>F: Reads Data inside (Embedded Script)
Hey @fire I think that this is firmly outside of the scope of Godot Wasm issues and is probably a better fit for discussions. However, I'd love to try to understand your use case a little more and help you with your implementation as much as possible.
I think I'm missing some context for the graphs you've included. If you could help me understand how you're hoping to use Wasm modules, who owns them, etc., I'd be able to give better feedback. Are you interested in the security aspect as modules are to be uploaded by users? Are you more interested in using Wasm for heavy compute as an alternative to GDScript? Once loaded, what functions do the Wasm modules perform (high level)?
The UGC WASM modules, uploaded by users for universal access, are attached to a MissingNode
as a script, providing property data and behavior. The clever implementation involves MissingResource
for resources and a dictionary of Variant
s for node properties.
Behavior is within the dictionary in this design. Utilizing Godot's standard set_script
property, WASM Godot only needs to implement dependencies for MissingNode
and MissingResource
, excluding components like Node3D
.
Here's a reply to your questions.
V-Sekai utilizes WebAssembly (Wasm) to enhance performance, offering an alternative to GDScript.
User-uploaded Wasm modules undergo a two-step process for safety and unauthorized access prevention:
Wasm serves multiple purposes in V-Sekai:
Wasm modules facilitate advanced functions in virtual worlds and avatar-based social games, such as:
The UGC (User-Generated Content) WASM modules, uploaded by users for universal access, are attached to a MissingNode
as a script, providing property data and behavior. The clever implementation involves MissingResource
for resources and a dictionary of Variants
for node properties. Behavior is within the dictionary in this design. Utilizing Godot's standard set_script
property, WASM Godot only needs to implement dependencies for MissingNode
and MissingResource
, excluding components like Node3D
.
This article was assisted by AI.
I remade the article https://v-sekai.github.io/manuals/decisions/20230611-wasm-in-v-sekai.html.
Thanks for the info. I think I understand your use case a little clearer. Let's start with the simpler case of MissingNode
. You still certainly have a better sense of what you need so let me know your thoughts on the following.
Does this sound roughly correct? If you have a clearer understanding, could you create a simple POC that uses this flow but simply defines properties in either GDScript/C++? With that, I could add the Wasm translation layer.
We need to create a simple Godot Engine PackedScene with one node, called MissingNode.
This node will be initialized by a GDScript script (representing Godot-WASM). Let's call this missing_node.gd
Ref<Script>
property that print "Hello world!". Let's call this hello_world.gd
Ref<Script>
(representing Godot-WASM) Awesome if you could draft up a POC Godot project with exactly that, that would be helpful!
In the actual implementation (post-POC), you'd replace hello_world.gd
with logic contained in the UGC Wasm module, correct?
I think this is what I got for a wasm_test.tscn.
[gd_scene load_steps=2 format=3 uid="uid://muen6x7gxbjo"]
[sub_resource type="GDScript" id="GDScript_wmpej"]
script/source = "extends Node
func _enter_tree():
print(\"_enter_tree()\" % [])
"
[node name="Node3D" type="MissingNode"]
original_class = "Node3D"
script = SubResource("GDScript_wmpej")
It prints _enter_tree()
when the scene is executed.
Here's another scene. We assume we know nothing about Node3D in godot gdscript here.
[gd_scene load_steps=2 format=3 uid="uid://bk1cybq0p5ekv"]
[sub_resource type="GDScript" id="GDScript_jtge8"]
script/source = "extends Marker3D
func _enter_tree():
print(\"_enter_tree\")
print(\"Add position\")
var current_global_transform: Transform3D = get(\"global_transform\")
current_global_transform.origin = current_global_transform.origin + Vector3(0, 1, 0)
set(\"global_transform\", current_global_transform)
print(get("global_transform"))
"
[node name="Marker3D" type="MissingNode"]
original_class = "Marker3D"
script = SubResource("GDScript_jtge8")
tl;dr
MissingNode / MissingResource behaviour is a standard feature of Godot 4. It's been turned on and shipped in production.
I was using its properties with the fact that wasm can be degraded to use only Node and Resource methods to limit the godot-wasm implementation surface area.
After discussion we ended up with this conclusion.
The proposed solution uses WebAssembly (Wasm) to enhance performance and functionality in V-Sekai through User-Generated Content (UGC) Wasm modules. These modules are attached to an existing base node as a script, enabling them to provide property data and behavior for nodes in the virtual world or game.
I think the original discussion went off into MissingNode and MissingResource
I am looking for help trying to define the godot wasm interface for MissingNode, and MissingResource.
Godot wasm needs to handle downstream nodes like Node3D, Control and Node2D.
My goal is to create a generic interface for handling incomplete data and providing a generic interface for behavior, ensuring that the UGC system remains flexible and adaptable to various types of content.
The V-Sekai UGC System is designed to provide a seamless experience for users to create, interact with, and share custom game objects and resources. By leveraging the power of Godot WebAssembly (godot-wasm), this system can efficiently process and manage user-generated content (UGC) within the virtual world.
MissingResource
andMissingNode
play crucial roles in handling incomplete data and providing a generic interface for behavior, ensuring that the UGC system remains flexible and adaptable to various types of content.Security Note
Set a script will execute gdscript.
Sequence Diagram