# bevy-explorer


A forward-looking implementation of the Decentraland protocol.

visit our [Releases](https://github.com/decentraland/bevy-explorer/releases/latest) page for the latest client downloads.

![screenshots](montage.png)

This implementation uses [rust](https://www.rust-lang.org/) and the [Bevy](https://bevy.org) engine, and targets desktop clients.

This project's goals are to:
- document current and future protocol standards
- experiment with changes to the protocol
- increase the field of alternative Explorers
- prioritize solid fundamentals, extensibility, and the use of modern open-source frameworks

# Building from source

1. Clone the repo using `git clone https://github.com/decentraland/bevy-explorer`
2. Install [rust](https://www.rust-lang.org/tools/install)
3. Download and install third party libraries
    - on linux:
      - *note: livekit networking (main-realm transport) in the linux build is temporarily disabled due to conflicting imports in webrtc and deno. we hope this will be resolved soon*
      - Install alsa and udev: `sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev`
      - Install ffmpeg deps: `sudo apt install -y --no-install-recommends clang curl pkg-config libavcodec-dev libavformat-dev libavutil-dev libavfilter-dev libavdevice-dev`
      - Install Livekit deps: `sudo apt update -y; sudo apt install -y libssl-dev libx11-dev libgl1-mesa-dev libxext-dev`
    - on macos: 
      - `brew install ffmpeg@6 pkg-config`
      - `export PKG_CONFIG_PATH=/opt/homebrew/opt/ffmpeg@6/lib/pkgconfig`
    - on windows: 
      - install `clang`, (most easily done via https://github.com/llvm/llvm-project/releases/)
      - download and unzip `https://github.com/GyanD/codexffmpeg/releases/download/6.0/ffmpeg-6.0-full_build-shared.7z`
      - set `LIBCLANG_PATH` = `path to LLVM\x64\bin` (this is packaged with visual studio, or can be downloaded separately)
      - set `FFMPEG_DIR` = `root folder where ffmpeg has been unzipped`
      - add `ffmpeg\bin` to your `PATH`
4. Install [protoc](https://github.com/protocolbuffers/protobuf/releases) (Mac Homebrew users can do `brew install protobuf`)
5. Install the CEF runtime (the react HUD renders in a CEF offscreen webview; `react-hud-cef` is a default feature)
    - install ninja: linux `sudo apt-get install ninja-build`, macos `brew install ninja`, windows ships it with visual studio
    - export the CEF distribution (once per machine): `cargo install export-cef-dir --version "139.8.0+139.0.40" && export-cef-dir --force $HOME/.local/share/cef`
    - set `CEF_PATH` to the export dir for builds: `export CEF_PATH=$HOME/.local/share/cef` (on windows use a windows-style path)
    - on linux, also put it on the loader path to run from the target dir: `export LD_LIBRARY_PATH=$CEF_PATH:$LD_LIBRARY_PATH`
6. build the react HUD — login and all 2d UI; without this bundle the app runs with no UI at all: `cd react-web && npm ci && (cd bridge-scene && npm ci) && npm run bundle:native` (needs node 20)
7. build scene engine: `cargo build --release --package dcl_deno_ipc`
8. build and run renderer (also builds the `decentra-bevy-cef` helper): `cargo build --release && cargo run --release`

With [just](https://github.com/casey/just) installed, `just setup-cef` covers step 5's CEF export and `just native-release` bundles the HUD and builds + runs everything (`just --list` for more).

To build without CEF entirely (engine-native UI instead of the react HUD): `cargo run --release --no-default-features --features "livekit,ffmpeg,inspect,social"`.

We try to keep these instructions up to date, but the [github ci](.github/workflows/ci.yml) is the most accurate source of build information.

# Arguments

`cargo run --release --bin decentra-bevy -- [options]`

`--server https://sdk-test-scenes.decentraland.zone`
- specify the content server, defaults to the sdk test server.

`--location 52,-52`
- specify the parcel at which to spawn.

`--vsync (true|false)`
- disable/enable vsync. defaults to off.

`--fps (number)`
- set target fps. defaults to 60. if vsync is true this will be overridden by the vsync refresh rate. also accessible via console `/fps` command.

`--msaa [1,2,4,8]`
- set the number of multisamples. higher values make for nicer graphics but takes more gpu power. defaults to 4.

`--threads n`
- set the max simultaneous thread count for scene javascript execution. higher will allow better performance for distant scenes, but requires more cpu power. defaults to 4.
- also accessible via console command `/scene_threads`

`--distance n`
- set the distance (in meters) at which scenes will be loaded. defaults to 100.0.
- also accessible via console command `/scene_distance`

`--no_gltf`
- disable gltf loading.

`--no_avatar`
- disable avatar rendering.

`--no_fog`
- disable distance fog

`--inspect <scene_hash>`
- when the scene with the input hash is first loaded, the js runtime will pause waiting for a debugger session (such as `chrome://inspect`) to connect, and allow you to debug the scene code. requires a build with --features "inspect"

`--params "key1=value1&key2=value2"`
  - pass arbitrary key-value parameters to the system scene, accessible via `BevyApi.getParams()`.
  - format is URL query string style: `key=value` pairs separated by `&`.
  - values are passed as-is (no URL decoding on desktop).
  - on web, all URL query parameters are automatically forwarded as params, with URL decoding applied.
  - example: `--params "disableFeatures=minimap,chat&debug=true"`
  
# Testing

`cargo test --all` executes all the tests.


Powered by the Decentraland DAO
![Decentraland DAO logo](https://bafkreibci6gg3wbjvxzlqpuh353upzrssalqqoddb6c4rez33bcagqsc2a.ipfs.nftstorage.link/)
