Upload documents at runtime and display?

From your point of view, is it possible in principle, e.g. Upload documents to a scene and place them visible? This scene should then keep this information, save it and display it the next time it is called up.

Original Post on Discord

by user 684154017479524352

Hey :wave: Couple of questions?

Upload documents to a scene
By that you mean netowrking capabilities? So other users are able to load the same document? Or that when you open it locally that it remembers your last choice of document?

Documents
What format? Is it a PDF? What is the concept? Do you want to display it in 3d?

Any more details you wish to share?

Hey Kipash, Thank you. For example, I would like to place photos on a 3D object and then place this object freely in space. If the scene is closed and opened again, the saved photo objects should be visible in their place. This shouldn’t be done locally. It should be visible on the network.

by user 684154017479524352

I see :+1: Yes, it is possible.

Synchronizing and maintaining a room state is already built-in :ok_hand:

Any network message you send that has guid will be automatically saved on the server. And when a new user joins, all the messages chronologically will be sent to the new user so they can replicate the state of the scene.
You can store your images as base64 in to a string (data:image/png;base64,AAAAAA). Potentially if sizes would be a problem, you could switch to a binary format using flatbuffers.

Here’s a sample for downloading and applying a texture from an url source: https://engine.needle.tools/samples/?open=1#external-content (Info how to download samples: https://github.com/needle-tools/needle-engine-samples).
And overall, i would advice checking the networking samples: https://engine.needle.tools/samples/networking_players/

Also a summary of all built-in networking features can be found here: Networking | Needle Engine Documentation

That opens up a lot. Thanks very much!

by user 684154017479524352

Let us know when you would have any questions :slight_smile:

That works so far. Now all I have to do is teach needle to retrieve this dynamically created content. Do you have a quick idea here?

by user 684154017479524352

I see that you let your users to drag and drop an image file and then that file is encoded in base64 and the data url is created :+1:

What do you mean by retrieve this dynamically created content? From where do you want to retrieve that?
How to communicate with the needle instance?

The documents should be stored on a web server in a database. Then I have to load the document into Needle via a link. I Need to do some more research here.

by user 684154017479524352

Alright, let us know when anything wouldn’t be clear from the docs and samples :cactus:

If the file is in a database anyways you should be able to have a syncField for the URL + a change watcher:

@syncField(MyClass.prototype.createObjectFromUrl) 
url: string;

createObjectFromUrl(newUrl) {
  // create new object, load from that URL
  // put it into the scene
  // don't forget to clean up if there's a previously created object
}

Great, thank you.

by user 684154017479524352

added an ‘@’ that was missing to the snippet above