# retroplasma/earth-reverse-engineering architecture

> Architecture diagram of the GitHub repository retroplasma/earth-reverse-engineering, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/retroplasma/earth-reverse-engineering
- Repository: https://github.com/retroplasma/earth-reverse-engineering

## Overview

This repository reverse-engineers Google Earth’s 3D satellite resources through two product workflows: a C++ flycam client that retrieves octree metadata and node assets for viewing, and a JavaScript exporter that retrieves and decodes resources for model export or coordinate-to-octant lookup. The README documents the resource hierarchy and mesh/texture formats; source excerpts show portions of the client and exporter wiring, but not every internal call or rendering step.

Main entry points: [`client/rocktree_util.h`](https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/rocktree_util.h) (Resource requests), [`client/main.cpp`](https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/main.cpp) (Flycam runtime), [`exporter/lib/utils.js`](https://github.com/retroplasma/earth-reverse-engineering/blob/master/exporter/lib/utils.js) (Resource access), [`client/rocktree_http.h`](https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/rocktree_http.h) (HTTP transport)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Flycam client"]
  node_app["Flycam runtime<br/>[main.cpp]"]
  node_client_fetch["Resource requests<br/>[rocktree_util.h]"]
  node_client_http["HTTP transport<br/>[rocktree_http.h]"]
  node_http_lib["Socket HTTP<br/>[http.h]"]
  node_decoder["Asset decoder<br/>[rocktree_decoder.h]"]
  node_types["Resource types<br/>[rocktree_types.h]"]
  node_math["Octree math<br/>[rocktree_math.h]"]
  node_geometry["Mesh processing<br/>[rocktree_ex.h]"]
  node_texture["Texture loading<br/>[stb_image.h]"]
  node_crn_decode["CRN decompression<br/>[crn_decomp.h]"]
  node_crn_api["CRN declarations<br/>[crnlib.h]"]
  node_renderer["OpenGL rendering<br/>[rocktree_gl.h]"]
  node_gl_loader["OpenGL loader<br/>[glad.c]"]
  node_threads["Request threads<br/>[threads.h]"]
end

subgraph group_exporter["Model exporter"]
  node_export_cli["Exporter command<br/>[dump_obj.js]"]
  node_export_utils["Resource access<br/>[utils.js]"]
  node_url["URL retrieval<br/>[get-url.js]"]
  node_resource_decode["Payload decoding<br/>[decode-resource.js]"]
  node_texture_decode["Texture decoding<br/>[decode-texture.js]"]
  node_octant_cli["Coordinate lookup"]
  node_octant["Octant conversion"]
end

subgraph group_formats["Resource formats"]
  node_proto["Rocktree schema<br/>[rocktree.proto]"]
end

node_user(("User"))
node_earth["Google Earth"]

node_user -->|"uses"| node_app
node_app -->|"requests assets"| node_client_fetch
node_client_fetch -->|"fetches resources"| node_client_http
node_client_http -->|"uses transport"| node_http_lib
node_client_http -->|"requests URLs"| node_earth
node_client_fetch -->|"decodes payloads"| node_decoder
node_client_fetch -->|"populates assets"| node_types
node_app -.->|"uses octree logic"| node_math
node_app -.->|"renders scene"| node_renderer
node_app -->|"initializes graphics"| node_gl_loader
node_geometry -->|"decompresses textures"| node_crn_decode
node_geometry -->|"loads images"| node_texture
node_crn_decode -->|"uses declarations"| node_crn_api
node_client_fetch -->|"dispatches work"| node_threads
node_user -->|"runs export"| node_export_cli
node_export_cli -->|"retrieves resources"| node_export_utils
node_export_cli -->|"decodes textures"| node_texture_decode
node_export_utils -->|"downloads payloads"| node_url
node_export_utils -->|"decodes responses"| node_resource_decode
node_export_utils -->|"requests URLs"| node_earth
node_user -->|"requests location"| node_octant_cli
node_octant_cli -->|"converts coordinates"| node_octant
node_octant -->|"queries octree"| node_export_utils
node_client_fetch -->|"parses schema assets"| node_proto

click node_app "https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/main.cpp"
click node_client_fetch "https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/rocktree_util.h"
click node_client_http "https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/rocktree_http.h"
click node_http_lib "https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/http.h"
click node_decoder "https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/rocktree_decoder.h"
click node_types "https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/rocktree_types.h"
click node_math "https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/rocktree_math.h"
click node_geometry "https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/rocktree_ex.h"
click node_texture "https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/stb_image.h"
click node_crn_decode "https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/crn/crn_decomp.h"
click node_crn_api "https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/crn/crnlib.h"
click node_renderer "https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/rocktree_gl.h"
click node_gl_loader "https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/gl2/src/glad.c"
click node_threads "https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/threads.h"
click node_export_cli "https://github.com/retroplasma/earth-reverse-engineering/blob/master/exporter/dump_obj.js"
click node_export_utils "https://github.com/retroplasma/earth-reverse-engineering/blob/master/exporter/lib/utils.js"
click node_url "https://github.com/retroplasma/earth-reverse-engineering/blob/master/exporter/lib/get-url.js"
click node_resource_decode "https://github.com/retroplasma/earth-reverse-engineering/blob/master/exporter/lib/decode-resource.js"
click node_texture_decode "https://github.com/retroplasma/earth-reverse-engineering/blob/master/exporter/lib/decode-texture.js"
click node_octant_cli "https://github.com/retroplasma/earth-reverse-engineering/blob/master/exporter/lat_long_to_octant.js"
click node_octant "https://github.com/retroplasma/earth-reverse-engineering/blob/master/exporter/lib/convert-lat-long-to-octant.js"
click node_proto "https://github.com/retroplasma/earth-reverse-engineering/blob/master/proto/rocktree.proto"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_client_fetch,node_client_http,node_http_lib,node_decoder,node_types,node_math,node_geometry,node_texture,node_crn_decode,node_crn_api,node_renderer,node_gl_loader,node_threads,node_user toneBlue
class node_export_cli,node_export_utils,node_url,node_resource_decode,node_texture_decode,node_octant_cli,node_octant toneAmber
class node_proto toneMint
class node_earth toneIndigo
```

## Components

### Flycam client

- [Flycam runtime](https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/main.cpp): `client/main.cpp`
- [Resource requests](https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/rocktree_util.h): `client/rocktree_util.h`
- [HTTP transport](https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/rocktree_http.h): `client/rocktree_http.h`
- [Socket HTTP](https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/http.h): `client/http.h`
- [Asset decoder](https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/rocktree_decoder.h): `client/rocktree_decoder.h`
- [Resource types](https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/rocktree_types.h): `client/rocktree_types.h`
- [Octree math](https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/rocktree_math.h): `client/rocktree_math.h`
- [Mesh processing](https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/rocktree_ex.h): `client/rocktree_ex.h`
- [Texture loading](https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/stb_image.h): `client/stb_image.h`
- [CRN decompression](https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/crn/crn_decomp.h): `client/crn/crn_decomp.h`
- [CRN declarations](https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/crn/crnlib.h): `client/crn/crnlib.h`
- [OpenGL rendering](https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/rocktree_gl.h): `client/rocktree_gl.h`
- [OpenGL loader](https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/gl2/src/glad.c): `client/gl2/src/glad.c`
- [Request threads](https://github.com/retroplasma/earth-reverse-engineering/blob/master/client/threads.h): `client/threads.h`

### Model exporter

- [Exporter command](https://github.com/retroplasma/earth-reverse-engineering/blob/master/exporter/dump_obj.js): `exporter/dump_obj.js`
- [Resource access](https://github.com/retroplasma/earth-reverse-engineering/blob/master/exporter/lib/utils.js): `exporter/lib/utils.js`
- [URL retrieval](https://github.com/retroplasma/earth-reverse-engineering/blob/master/exporter/lib/get-url.js): `exporter/lib/get-url.js`
- [Payload decoding](https://github.com/retroplasma/earth-reverse-engineering/blob/master/exporter/lib/decode-resource.js): `exporter/lib/decode-resource.js`
- [Texture decoding](https://github.com/retroplasma/earth-reverse-engineering/blob/master/exporter/lib/decode-texture.js): `exporter/lib/decode-texture.js`
- [Coordinate lookup](https://github.com/retroplasma/earth-reverse-engineering/blob/master/exporter/lat_long_to_octant.js): `exporter/lat_long_to_octant.js`
- [Octant conversion](https://github.com/retroplasma/earth-reverse-engineering/blob/master/exporter/lib/convert-lat-long-to-octant.js): `exporter/lib/convert-lat-long-to-octant.js`

### Resource formats

- [Rocktree schema](https://github.com/retroplasma/earth-reverse-engineering/blob/master/proto/rocktree.proto): `proto/rocktree.proto`

### Other components

- **User**
- **Google Earth**

## Connections

- User → Flycam runtime: uses (evidence: `README.md`)
- Flycam runtime → Resource requests: requests assets (evidence: `client/main.cpp`)
- Resource requests → HTTP transport: fetches resources (evidence: `client/rocktree_util.h`)
- HTTP transport → Socket HTTP: uses transport (evidence: `client/rocktree_http.h`)
- HTTP transport → Google Earth: requests URLs (evidence: `README.md`)
- Resource requests → Asset decoder: decodes payloads (evidence: `client/rocktree_util.h`)
- Resource requests → Resource types: populates assets (evidence: `client/rocktree_util.h`)
- Flycam runtime → Octree math: uses octree logic
- Flycam runtime → OpenGL rendering: renders scene
- Flycam runtime → OpenGL loader: initializes graphics (evidence: `client/main.cpp`)
- Mesh processing → CRN decompression: decompresses textures (evidence: `client/rocktree_ex.h`)
- Mesh processing → Texture loading: loads images (evidence: `client/rocktree_ex.h`)
- CRN decompression → CRN declarations: uses declarations (evidence: `client/crn/crn_decomp.h`)
- Resource requests → Request threads: dispatches work (evidence: `client/rocktree_util.h`)
- User → Exporter command: runs export (evidence: `README.md`)
- Exporter command → Resource access: retrieves resources (evidence: `exporter/dump_obj.js`)
- Exporter command → Texture decoding: decodes textures (evidence: `exporter/dump_obj.js`)
- Resource access → URL retrieval: downloads payloads (evidence: `exporter/lib/utils.js`)
- Resource access → Payload decoding: decodes responses (evidence: `exporter/lib/utils.js`)
- Resource access → Google Earth: requests URLs (evidence: `README.md`)
- User → Coordinate lookup: requests location (evidence: `README.md`)
- Coordinate lookup → Octant conversion: converts coordinates (evidence: `exporter/lat_long_to_octant.js`)
- Octant conversion → Resource access: queries octree (evidence: `exporter/lib/convert-lat-long-to-octant.js`)
- Resource requests → Rocktree schema: parses schema assets (evidence: `client/rocktree_util.h`)
