https://github.com/moethu/webg3n
3D web-viewer running g3n server-side
https://github.com/moethu/webg3n
3d-web-viewer g3n golang serverside-rendering websocket
Last synced: about 2 months ago
JSON representation
3D web-viewer running g3n server-side
- Host: GitHub
- URL: https://github.com/moethu/webg3n
- Owner: moethu
- License: bsd-2-clause
- Created: 2019-09-07T11:55:04.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-05-05T02:28:34.000Z (about 2 years ago)
- Last Synced: 2025-04-14T19:08:52.937Z (about 2 months ago)
- Topics: 3d-web-viewer, g3n, golang, serverside-rendering, websocket
- Language: Go
- Homepage:
- Size: 28.8 MB
- Stars: 104
- Watchers: 2
- Forks: 20
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# webg3n
webg3n is a 3D web-viewer running [G3N](https://github.com/g3n/engine) as a server side OpenGL renderer.
[](https://goreportcard.com/report/github.com/moethu/webg3n)

[Checkout this demo video](https://vimeo.com/358812535)
## How it works

webg3n is a GO webserver handling sockets to one G3N rendering instance per connection. The G3N application is constantly streaming images (jpeg) and listens for navigation events and commands from the client. The server supports multiple clients at the same time. For each client it will open one socket and spin off a separate 3D engine for rendering. The G3N application is reading [GLTF models](https://github.com/KhronosGroup/glTF), the example model is taken from [here](https://github.com/KhronosGroup/glTF-Sample-Models)
## Why Server Side Rendering
Client and server side renderers have both pros and cons. Depending on your use case server side rendering of 3D models can be a great alternative to client side WebGL rendering. Here are just a few reasons why:
- Browser doesn't need to support WebGL (older Browsers)
- Smaller and weaker devices might not be able to render large models on client side
- The geometry remains on the server and is not transferred to the clientOn the other hand it shifts the bottleneck from the client's rendering capabilites to the bandwith.
## Image Streaming Approaches
This project has various branches to investigate different streaming approaches:
- The default branch `master` streams base64 encoded image contents. This works very fast and has very little delay.
- The `binary-image-transfer` branch streams binary image content (uint8Array). Slightly less data to transfer but adds some delay.
- The `video-jmux` branch streams H264 encoded video stream to a video tag (also as uint8Array) using [jmuxer](https://github.com/samirkumardas/jmuxer). Image transitions are very smooth but this also adds some delay.## Dependencies and Installation
### Docker
The easies way to run webg3n is to `build` and `run` a container using the supplied Dockerfile.
### Not using Docker?
Go 1.8+ is required. The engine also requires the system to have an OpenGL driver and a GCC-compatible C compiler.
Requires this modified [G3N engine](https://github.com/moethu/engine) which gets installed via go modules.
On Unix-based systems the engine depends on some C libraries that can be installed using the appropriate distribution package manager. See below for OS specific requirements.
#### Ubuntu/Debian-like
```
$ sudo apt-get install xorg-dev libgl1-mesa-dev libopenal1 libopenal-dev libvorbis0a libvorbis-dev libvorbisfile3 libjpeg-turbo8 libjpeg-turbo8-dev
```#### Fedora
```
$ sudo dnf -y install xorg-x11-proto-devel mesa-libGL mesa-libGL-devel openal-soft openal-soft-devel libvorbis libvorbis-devel glfw-devel libXi-devel libjpeg-turbo8 libjpeg-turbo8-devel
```#### CentOS 7
Enable the EPEL repository:
```
$ sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
```
Then install the same packages as for Fedora - remember to use yum instead of dnf for the package installation command.#### Windows
The necessary audio libraries sources and DLLs are supplied but they need to be installed manually. Please see Audio libraries for Windows for details. We tested the Windows build using the mingw-w64 toolchain (you can download this file in particular).
#### macOS
Install the development files of OpenAL and Vorbis using Homebrew:
```
brew install libvorbis openal-soft
```
Important Note: OpenGL has been deprecated on MacOS.
If you are experiencing issues building webg3n please read the following issue:
https://github.com/moethu/webg3n/issues/18
You might be able to acitvate it using this hint:
https://www.alora.io/forums/topic/28972-how-to-get-hd-opengl-working-on-mac-osx-high-sierra-mojave/## Example
This implementation comes with a simple webUI, simply go run it and connect to port 8000.
Once you click connect, a g3n window will appear which is the server side rendering screen.## Features
- mouse navigation
- keyboard navigation
- multi-select elements
- hide and unhide element selection
- focus on element selection
- zoom extents
- default views (top, down, left, right, front, rear)
- change field of view
- set compression quality
- automatically set higher compression while navigating
- adjust image settings (invert, brightness, contrast, saturation, blur)## Contributing
If you find a bug or create a new feature you are encouraged to send pull requests!