Skip to content

Commit d1d86f2

Browse files
committed
Updated documentation.
1 parent ea9710b commit d1d86f2

File tree

7 files changed

+112
-82
lines changed

7 files changed

+112
-82
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ For ideas for Cesium WASM Utilities code contributions, see:
4141
- issues labeled [`good first issue`](https://github.com/CesiumGS/cesium/labels/good%20first%20issue) and
4242
- issues labeled [`type - roadmap`](https://github.com/CesiumGS/cesium/labels/type%20-%20roadmap).
4343

44-
See the [Build Guide](Documentation/BuildGuide.md) for how to build and run Cesium on your system.
44+
See the [README](README.md) for how to build and run Cesium on your system.
4545

4646
Always feel free to introduce yourself on the [Cesium community forum](https://community.cesium.com/) to brainstorm ideas and ask for guidance.
4747

Documentation/BuildGuide.md

-1
This file was deleted.

README.md

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# cesium-wasm-utils
2+
3+
![Cesium](https://github.com/CesiumGS/cesium/wiki/logos/Cesium_Logo_Color.jpg)
4+
5+
CesiumJS is a JavaScript library for creating 3D globes and 2D maps in a web browser without a plugin. It uses WebGL for
6+
hardware-accelerated graphics, and is cross-platform, cross-browser, and tuned for dynamic-data visualization.
7+
8+
Built on open formats, CesiumJS is designed for robust interoperability and scaling for massive datasets.
9+
10+
The `cesium-wasm-utils` mono-repository contains utilities for CesiumJS written in WebAssembly (Wasm) for
11+
performance-critical tasks.
12+
13+
**NOTE**: This repository is only required for development of these WebAssembly packages. If you are a CesiumJS user or
14+
contributor, you do not need to clone this repository. Instead, follow the instructions in
15+
the [CesiumJS README](https://github.com/CesiumGS/cesium/blob/main/README.md).
16+
17+
## Packages in this Repository
18+
19+
- [wasm-splats](wasm-splats/README.md): High-performance algorithms used in the rendering Gaussian Splats in CesiumJS.
20+
21+
# Get Started
22+
23+
These instructions assume that you already
24+
have [CesiumJS](https://github.com/CesiumGS/cesium/blob/main/README.md#rocket-get-started) configured on your system.
25+
26+
## Prerequisites
27+
28+
- [Node.js](https://nodejs.org/en/download/) v22 or later.
29+
- [Rust](https://www.rust-lang.org/tools/install) v1.55 or later.
30+
- [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/) v0.13 or later.
31+
32+
### Installation recommendations.
33+
34+
#### Node.js
35+
36+
##### Windows
37+
38+
On Windows, we recommend using [chocolatey](https://chocolatey.org/) to install Node.js.
39+
40+
```sh
41+
choco install nodejs
42+
```
43+
44+
##### Linux and macOS
45+
46+
On Linux and macOS, we recommend using [nvm](https://github.com/nvm-sh/nvm) to install Node.js.
47+
48+
See the [nvm README](https://github.com/nvm-sh/nvm/blob/master/README.md) for installation instructions.
49+
50+
#### Rust
51+
52+
On all platforms, we recommend using [rustup](https://rustup.rs/) to install Rust.
53+
54+
See the [rust website](https://www.rust-lang.org/tools/install) for installation instructions.
55+
56+
#### wasm-pack
57+
58+
On all platforms, we recommend using the wasm-pack installer to install wasm-pack.
59+
60+
See the [wasm-pack website](https://rustwasm.github.io/wasm-pack/installer/) for installation instructions.
61+
62+
## Clone the Repository
63+
64+
```sh
65+
git clone [email protected]:CesiumGS/cesium-wasm-utils.git
66+
```
67+
68+
## Generate Documentation and open in Browser
69+
70+
To generate the documentation for all packages in the workspace and open in your default browser, run:
71+
72+
```sh
73+
cargo doc --no-deps --document-private-items --open
74+
```
75+
76+
## Further instructions
77+
78+
For further instructions on building and running the packages in this repository, see the README in each package
79+
directory.

wasm-splats/README.md

+15-71
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,28 @@
1-
<div align="center">
1+
# wasm-splats
22

3-
<h1><code>wasm-pack-template</code></h1>
3+
The `wasm-splats` package contains high-performance algorithms used in the rendering Gaussian Splats in CesiumJS.
44

5-
<strong>A template for kick starting a Rust and WebAssembly project using <a href="https://github.com/rustwasm/wasm-pack">wasm-pack</a>.</strong>
5+
## Getting Started
66

7-
<p>
8-
<a href="https://travis-ci.org/rustwasm/wasm-pack-template"><img src="https://img.shields.io/travis/rustwasm/wasm-pack-template.svg?style=flat-square" alt="Build Status" /></a>
9-
</p>
7+
Follow the instructions in the [cesium-wasm-utils README](./README.md) to clone the repository and install
8+
prerequisites.
109

11-
<h3>
12-
<a href="https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/index.html">Tutorial</a>
13-
<span> | </span>
14-
<a href="https://discordapp.com/channels/442252698964721669/443151097398296587">Chat</a>
15-
</h3>
10+
### Building
1611

17-
<sub>Built with 🦀🕸 by <a href="https://rustwasm.github.io/">The Rust and WebAssembly Working Group</a></sub>
18-
</div>
12+
To build the package, run:
1913

20-
## About
21-
22-
[**📚 Read this template tutorial! 📚**][template-docs]
23-
24-
This template is designed for compiling Rust libraries into WebAssembly and
25-
publishing the resulting package to NPM.
26-
27-
Be sure to check out [other `wasm-pack` tutorials online][tutorials] for other
28-
templates and usages of `wasm-pack`.
29-
30-
[tutorials]: https://rustwasm.github.io/docs/wasm-pack/tutorials/index.html
31-
[template-docs]: https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/index.html
32-
33-
## 🚴 Usage
34-
35-
### 🐑 Use `cargo generate` to Clone this Template
36-
37-
[Learn more about `cargo generate` here.](https://github.com/ashleygwilliams/cargo-generate)
38-
39-
```
40-
cargo generate --git https://github.com/rustwasm/wasm-pack-template.git --name my-project
41-
cd my-project
14+
```sh
15+
wasm-pack build --release --target web --scope cesium
4216
```
4317

44-
### 🛠️ Build with `wasm-pack build`
18+
This will output a `pkg` directory containing the compiled WebAssembly module and JavaScript bindings.
4519

46-
```
47-
wasm-pack build
48-
```
20+
### Testing
4921

50-
### 🔬 Test in Headless Browsers with `wasm-pack test`
22+
To run the unit and integration tests, run:
5123

24+
```sh
25+
wasm-pack test --headless --chrome --firefox
5226
```
53-
wasm-pack test --headless --firefox
54-
```
55-
56-
### 🎁 Publish to NPM with `wasm-pack publish`
57-
58-
```
59-
wasm-pack publish
60-
```
61-
62-
## 🔋 Batteries Included
63-
64-
* [`wasm-bindgen`](https://github.com/rustwasm/wasm-bindgen) for communicating
65-
between WebAssembly and JavaScript.
66-
* [`console_error_panic_hook`](https://github.com/rustwasm/console_error_panic_hook)
67-
for logging panic messages to the developer console.
68-
* `LICENSE-APACHE` and `LICENSE-MIT`: most Rust projects are licensed this way, so these are included for you
69-
70-
## License
71-
72-
Licensed under either of
73-
74-
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
75-
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
76-
77-
at your option.
78-
79-
### Contribution
8027

81-
Unless you explicitly state otherwise, any contribution intentionally
82-
submitted for inclusion in the work by you, as defined in the Apache-2.0
83-
license, shall be dual licensed as above, without any additional terms or
84-
conditions.
28+
In macOS, you can also add `--safari` to run the tests in Safari.

wasm-splats/src/lib.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ pub mod texture_gen;
44
use js_sys::{Float32Array, Object, Uint32Array, Uint8Array};
55
use wasm_bindgen::prelude::*;
66

7-
#[wasm_bindgen]
8-
extern "C" {
9-
fn alert(s: &str);
10-
}
11-
12-
//Wrapper func. Most are called directly
7+
/// Generate a splat texture from the given attributes.
8+
///
9+
/// Wraps the [`texture_gen::generate_texture_from_attrs`] function for access from JavaScript.
1310
#[wasm_bindgen]
1411
pub fn generate_splat_texture_from_attrs(
1512
positions: &Float32Array,

wasm-splats/src/radix.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
use js_sys::{Float32Array, Uint32Array};
22
use wasm_bindgen::prelude::*;
33

4+
/// Sorts the Gaussian Splats by depth using a radix sort.
45
#[wasm_bindgen]
56
pub fn radix_sort_gaussians_indexes(
67
positions: &Float32Array,
78
model_view: &Float32Array,
89
_texture_width: u32, // TODO: FIGURE OUT IF THIS IS NEEDED.
910
count: usize,
10-
) -> Result<js_sys::Uint32Array, JsValue> {
11+
) -> Result<Uint32Array, JsValue> {
1112
if positions.length() as usize != count * 3 {
1213
return Err(JsValue::from_str("Invalid positions length"));
1314
}

wasm-splats/src/texture_gen.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,38 @@
11
use js_sys::{Float32Array, Uint8Array};
22
use wasm_bindgen::prelude::*;
33

4+
/// Represents a texture data object.
45
#[wasm_bindgen]
56
pub struct TextureData {
7+
/// The texture data.
68
data: Vec<u32>,
9+
/// Width of the texture in pixels.
710
width: u32,
11+
/// Height of the texture in pixels.
812
height: u32,
913
}
1014

1115
#[wasm_bindgen]
1216
impl TextureData {
17+
/// Getter for the underlying texture data. Always returns a copy.
1318
#[wasm_bindgen(getter)]
1419
pub fn data(&self) -> Vec<u32> {
1520
self.data.clone()
1621
}
1722

23+
/// Getter for the width of the texture in pixels.
1824
#[wasm_bindgen(getter)]
1925
pub fn width(&self) -> u32 {
2026
self.width
2127
}
2228

29+
/// Getter for the height of the texture in pixels.
2330
#[wasm_bindgen(getter)]
2431
pub fn height(&self) -> u32 {
2532
self.height
2633
}
2734

35+
/// Creates a new texture data object with the underlying data, width, and height.
2836
pub fn new(data: Vec<u32>, width: u32, height: u32) -> Self {
2937
TextureData {
3038
data,
@@ -34,9 +42,10 @@ impl TextureData {
3442
}
3543
}
3644

37-
//Algorithm from ILM
38-
//https://github.com/mitsuba-renderer/openexr/blob/master/IlmBase/Half/half.cpp
45+
/// Converts a 32-bit float to a 16-bit integer.
3946
fn float_to_half(f: f32) -> i16 {
47+
//Algorithm from ILM
48+
//https://github.com/mitsuba-renderer/openexr/blob/master/IlmBase/Half/half.cpp
4049
let f_int = f.to_bits() as i32;
4150
let sign = (f_int >> 16) & 0x00008000;
4251
let mut exp = ((f_int >> 23) & 0x000000ff) - (127 - 15);
@@ -78,6 +87,7 @@ fn float_to_half(f: f32) -> i16 {
7887
(sign | (exp << 10) | (frac >> 13)) as i16
7988
}
8089

90+
/// Generates a texture from the given attributes.
8191
#[wasm_bindgen]
8292
pub fn generate_texture_from_attrs(
8393
positions: &Float32Array,

0 commit comments

Comments
 (0)