# Collaborative online editing of 3D world using Castle Game Engine and mORMot2

**URL:** https://forum.castle-engine.io/t/collaborative-online-editing-of-3d-world-using-castle-game-engine-and-mormot2/1840
**Category:** News
**Created:** [March 27, 2025, 5:46pm UTC](https://forum.castle-engine.io/t/collaborative-online-editing-of-3d-world-using-castle-game-engine-and-mormot2/1840 "2025-03-27T17:46:23Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)
#### Post date: [March 27, 2025, 5:46pm UTC](https://forum.castle-engine.io/t/collaborative-online-editing-of-3d-world-using-castle-game-engine-and-mormot2/1840/1 "2025-03-27T17:46:23Z")

</div>

| [![Castle Game Engine and mORMot 2](https://forum.castle-engine.io/uploads/default/original/2X/3/39dd813023adb6e1cd818cb78d8bfc1d47f79f69.png)](https://castle-engine.io/wp/wp-content/uploads/2025/03/Zrzut-ekranu-z-2025-03-27-18-36-46.png "Castle Game Engine and mORMot 2") |
| [![Castle Game Engine and mORMot 2](https://forum.castle-engine.io/uploads/default/original/2X/0/08f10c280276028f27bd881d456d428d7b817b7e.png)](https://castle-engine.io/wp/wp-content/uploads/2025/03/screenshot1.png "Castle Game Engine and mORMot 2") |
| [![Castle Game Engine and mORMot 2](https://forum.castle-engine.io/uploads/default/original/2X/4/4386ffe374e4f6a08b43cb8c55ce133f769f955a.png)](https://castle-engine.io/wp/wp-content/uploads/2025/03/screenshot3.png "Castle Game Engine and mORMot 2") |

We’re happy to announce a new demo project, showcasing our [Castle Game Engine](https://castle-engine.io/) and [mORMot 2](https://github.com/synopse/mORMot2/) working together!

_mORMot_ (1 and 2) is an open-source Pascal framework (just like our engine!) providing networking and database solutions, at a few layers. You can use it for ORM (easily synchronize and persist objects), classic client-server (HTTP REST communication), peer-to-peer communication (like WebSockets), database access and many other things.

We present a demo showcasing that _Castle Game Engine_ and _mORMot 2_ can cooperate seamlessly, and together achieve something really cool:

[https://github.com/castle-engine/castle-and-mormot-collaborative-editing/](https://github.com/castle-engine/castle-and-mormot-collaborative-editing/)

The demo presents a collaborative editing of 3D world. Features:

- Multiple clients can edit a 3D world online.
- It’s synchronized using ORM with a server.
- The server in turn stores the world contents in a database (so it survives server restarts).
- Each client can add, remove, modify (move, rotate, scale) 3D objects in the world.
- The changes are immediately visible to all other clients.
- _mORMot 2_ takes care of all the network communication and database persistence.
- _Castle Game Engine_ takes care of displaying: showing and updating the 3D world, allowing user to move/rotate/scale by nice gizmos (using `CastleTransformManipulate`), allowing camera movement in 3D.

Instructions to build and run the demo are in the [README file](https://github.com/castle-engine/castle-and-mormot-collaborative-editing/blob/master/README.md). You will need the latest _Castle Game Engine_ and [mORMot 2](https://github.com/synopse/mORMot2/). Latest versions, from GIT master branches of both projects, have been tested today.

In related news, we have recently updated our URL and networking documentation, and this was a great moment to mention mORMot at the latter. Check out new:

- [URLs, loading (downloading) and saving](https://castle-engine.io/url)
- [Multi-player (networking) options](https://castle-engine.io/multi_player)

Enjoy, and as always — any feedback is welcome!

---

<div class="post-metadata">

### Author: ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)
#### Post date: [March 27, 2025, 5:48pm UTC](https://forum.castle-engine.io/t/collaborative-online-editing-of-3d-world-using-castle-game-engine-and-mormot2/1840/2 "2025-03-27T17:48:07Z")

</div>



---

<div class="post-metadata">

### Author: ![edj](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/edj/32/1701_2.png) [@edj](https://forum.castle-engine.io/u/edj)
#### Post date: [March 27, 2025, 6:58pm UTC](https://forum.castle-engine.io/t/collaborative-online-editing-of-3d-world-using-castle-game-engine-and-mormot2/1840/3 "2025-03-27T18:58:49Z")

</div>

I have been busy on other fronts, but wanting to get back to my game and move terrain handling into a client/server setup with a terrain server. I was just investigating what CGE had to offer for network and saw the indy code, and then you posted this. It looks mORMot has similar but more capabilities than indy?

---

<div class="post-metadata">

### Author: ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)
#### Post date: [March 27, 2025, 9:58pm UTC](https://forum.castle-engine.io/t/collaborative-online-editing-of-3d-world-using-castle-game-engine-and-mormot2/1840/4 "2025-03-27T21:58:20Z")

</div>

> [@edj](#):
>
> It looks mORMot has similar but more capabilities than indy?

Hm, I think the answer is complicated 🙂

There is some overlap in what they (Indy and mORMot) offer, e.g. they both can give you HTTP client and server. But there are also some differences:

- Indy focus is on components that expose _various_ network protocols.

- mORMot provides a ton of things (see [GitHub - synopse/mORMot2: OpenSource RESTful ORM/SOA/MVC ToolBox for Delphi and FreePascal](https://github.com/synopse/mORMot2/) for description), but I think the summary would be: _you probably want to do networking, using HTTP REST (clients query server) or WebSockets (client-server communication channel open), with database underneath_.

I admittedly don’t dare to make a full comparison between these 2 projects, as they are both large projects, and I’m sure that in my usage, I just scratched their surface 🙂

I am definitely impressed by what mORMot enabled in [GitHub - castle-engine/castle-and-mormot-collaborative-editing: Collaborative editing of 3D world using Castle Game Engine and mORMot2](https://github.com/castle-engine/castle-and-mormot-collaborative-editing/) . In this case, it would be impossible with Indy (or, rather: it would require a lot of work on top of Indy, to communicate object state, and to add database persistence; these things were zero work when using mORMot).

And I know mORMot (first mORMot 1, now 2) is very actively developed, for many years now. And it is used by various Pascal companies (which bodes well for the project, you can expect it will remain active for a long time). In fact, part of the [GitHub - castle-engine/castle-and-mormot-collaborative-editing: Collaborative editing of 3D world using Castle Game Engine and mORMot2](https://github.com/castle-engine/castle-and-mormot-collaborative-editing/) demo development was sponsored by a company (same company that [sponsored IFC support in our engine](https://castle-engine.io/ifc#_credits)) that is interested in using both mORMot and CGE for a long term. So, expect more cooperation between CGE and mORMot in the future 🙂

---

<div class="post-metadata">

### Author: ![DiggiDoggi](https://forum.castle-engine.io/letter_avatar_proxy/v4/letter/d/6a8cbe/32.png) [@DiggiDoggi](https://forum.castle-engine.io/u/DiggiDoggi)
#### Post date: [March 28, 2025, 12:26pm UTC](https://forum.castle-engine.io/t/collaborative-online-editing-of-3d-world-using-castle-game-engine-and-mormot2/1840/5 "2025-03-28T12:26:48Z")

</div>

My first thought was “What if 2 people select and try to manipulate the same object?” 🤔 But it’s something desired in co-op games where more people can mine the same resource deposit.

I understand the example is meant to be simple, and I thank you for that. When I checked the “readme”, I saw that it’s pulling all the time, and you shared some thoughts on optimising it.

I see you use the revision to hint changes. However, that means the client has to check for every single object’s revisions. If you used a time stamp, the client could query “where last\_updated \> my\_last\_check” to get it all at once.

I assume that games use at least a thousand editable objects. Similarly, engineers working on an architectural project would use more than a few assets. Using revisions to determine the last real-time change would be inefficient. I still like the idea of having the revisions, just not for this purpose.

Also, when real-time tracking is enabled, the database table needs updating while the user keeps moving/rotating/scaling the object - only to increment the revision. I believe the revision should be updated only when the editing is finished, otherwise the number would get super-inflated. I’d rather use a memory-based temporary table that holds only selected objects (including area-of-effect game mechanics) and updates the main table when editing is done (object selection changes, client logs out, etc). This way, the “last\_updated” could be updated many times per second. But that’s a whole different story.

---

<div class="post-metadata">

### Author: ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)
#### Post date: [March 30, 2025, 11:18am UTC](https://forum.castle-engine.io/t/collaborative-online-editing-of-3d-world-using-castle-game-engine-and-mormot2/1840/6 "2025-03-30T11:18:59Z")

</div>

Oh, I agree, and these are valid ways to improve the polling – “where last\_updated \> my\_last\_check” would be nice.

But the real solution is IMHO just WebSockets communication which gives ability to communicate from server → client the moment when something has changed. Then there’s no need to maintain any additional data like revision or last change time. I attended a lecture yesterday about mORMot (Pascal Cafe 2025, I also made a presentation about Castle Game Engine – [slides here](https://castle-engine.io/pascalcafe2025), full news post soon) where this scenario was explicitly mentioned, i.e. WebSockets are the solution in mORMot when you want server to be able to notify client.

So my recommendation in README was correct 🙂 [GitHub - castle-engine/castle-and-mormot-collaborative-editing: Collaborative editing of 3D world using Castle Game Engine and mORMot2](https://github.com/castle-engine/castle-and-mormot-collaborative-editing/?tab=readme-ov-file#how-do-all-the-clients-show-the-same-world)

I deliberately decided to keep this part of the example simple, so I think I’ll keep existing polling mechanism. An alternative version of the example (alternative client/server, maybe toggled using `{$ifdef xxx}` or some `const UseWebSockets = false/true` in shared unit) using WebSockets, and thus solving it “completely”, would be welcome if someone wants to make a PR 🙂

---

<div class="post-metadata">

### Author: ![phomm](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/phomm/32/2827_2.png) [@phomm](https://forum.castle-engine.io/u/phomm)
#### Post date: [March 31, 2025, 3:29pm UTC](https://forum.castle-engine.io/t/collaborative-online-editing-of-3d-world-using-castle-game-engine-and-mormot2/1840/7 "2025-03-31T15:29:19Z")

</div>

This is great news ! 💪  
However, I would always have a question to any such technology introduced.  
Can we have some matrix, which platform has which feature ? for example can I know if MORMOT is supported under Android currently in CGE ?  
Thanks !

---

<div class="post-metadata">

### Author: ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)
#### Post date: [April 1, 2025, 5:44am UTC](https://forum.castle-engine.io/t/collaborative-online-editing-of-3d-world-using-castle-game-engine-and-mormot2/1840/8 "2025-04-01T05:44:55Z")

</div>

> [@phomm](#):
>
> Can we have some matrix, which platform has which feature ? for example can I know if MORMOT is supported under Android currently in CGE ?

From what I understand, mORMot (2) works with FPC on all “normal” desktops (at least Windows, Linux, macOS, FreeBSD) and mobile (Android, iOS) on all CPUs (at least i386, x86\_64, aarch64). On Delphi it’s only for Windows.

This covers all platforms in CGE, except [web](https://castle-engine.io/web), [Nintendo Switch](https://castle-engine.io/nintendo_switch), and [Delphi on Linux](https://castle-engine.io/delphi_linux).

Note: All platforms support some subset of mORMot, but above I talk about everything necessary to run client and server ORM.

Disclaimer: I’m not an authority on mORMot, the [mORMot docs](https://github.com/synopse/mORMot2/) are authoritative 🙂

> [@phomm](#):
>
> However, I would always have a question to any such technology introduced.

Of course.

Note: We don’t plan to make CGE itself dependent on mORMot. Naturally, we like to keep our dependencies minimal, to stay compatible with all possible platforms and to make building of CGE easiest. Introducing any dependency for the engine is a huge thing (even when the wins are clear and upstream works great, like with the Vampyre Imaging or dglOpenGL or Kraft we use – there’s always additional work to maintain the non-typical platforms, and additional work to synchronize with upstream).

So the above-mentioned platforms are just what the examples on [GitHub - castle-engine/castle-and-mormot-collaborative-editing: Collaborative editing of 3D world using Castle Game Engine and mORMot2 · GitHub](https://github.com/castle-engine/castle-and-mormot-collaborative-editing/) are limited to. ( Well, “limited” here may be an unfortunate word 🙂 What the mORMot support is still a huge range. And I didn’t really expect to be able to run database and REST server on the web target, in a browser :), so lack of web target support is not surprising in this regard. )

---

<div class="post-metadata">

### Author: ![yottzumm](https://forum.castle-engine.io/letter_avatar_proxy/v4/letter/y/53a042/32.png) [@yottzumm](https://forum.castle-engine.io/u/yottzumm)
#### Post date: [April 2, 2025, 8:11pm UTC](https://forum.castle-engine.io/t/collaborative-online-editing-of-3d-world-using-castle-game-engine-and-mormot2/1840/9 "2025-04-02T20:11:55Z")

</div>

My thoughts are to layer ORM (object-relational) on top of socket io or below it on the server. Since you’re doing collaboration, you probably want some kind of peer-to-peer or client-server. My main thing would be to get X3D vendors to agree on a REST, GraphQL or socket io or websockets interface that doesn’t depend on one particular language. If we’ve already chosen SAI, let’s see an ORM or database implementation for that.

If there’s a way to batch network requests, even better.
