Add existing to tracked

This commit is contained in:
Jay
2026-08-11 09:53:42 -04:00
parent afe07f3055
commit ffd6e3d73c
8531 changed files with 4396230 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
# wasm-splats
[![wasm-splats CI](https://github.com/CesiumGS/cesium-wasm-utils/actions/workflows/wasm-splats-ci.yml/badge.svg)](https://github.com/CesiumGS/cesium-wasm-utils/actions/workflows/wasm-splats-ci.yml)
[![npm](https://img.shields.io/npm/v/@cesium/wasm-splats)](https://www.npmjs.com/package/@cesium/wasm-splats)
The `wasm-splats` package contains high-performance algorithms used in the rendering of Gaussian Splats in CesiumJS.
## Getting Started
Follow the instructions in the [cesium-wasm-utils README](./README.md) to clone the repository and install
prerequisites.
### Building
To build the package, run:
```sh
wasm-pack build --release --target web --scope cesium
```
This will output a `pkg` directory containing the compiled WebAssembly module and JavaScript bindings.
### Testing
To run the unit and integration tests, run:
```sh
wasm-pack test --headless --chrome --firefox
```
In macOS, you can also add `--safari` to run the tests in Safari.
+25
View File
@@ -0,0 +1,25 @@
{
"name": "@cesium/wasm-splats",
"type": "module",
"collaborators": [
"Cesium GS, Inc. <https://cesium.com>"
],
"description": "Contains high-performance algorithms used in the rendering of Gaussian Splats in CesiumJS.",
"version": "0.1.0-alpha.2",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/CesiumGS/cesium-wasm-utils"
},
"files": [
"wasm_splats_bg.wasm",
"wasm_splats.js",
"wasm_splats.d.ts"
],
"main": "wasm_splats.js",
"homepage": "https://cesium.com/cesiumjs/",
"types": "wasm_splats.d.ts",
"sideEffects": [
"./snippets/*"
]
}
+76
View File
@@ -0,0 +1,76 @@
/* tslint:disable */
/* eslint-disable */
/**
* Generate a splat texture from the given attributes.
*
* Wraps the [`texture_gen::generate_texture_from_attrs`] function for access from JavaScript.
*/
export function generate_splat_texture(positions: Float32Array, scales: Float32Array, rotations: Float32Array, colors: Uint8Array, count: number): TextureData;
/**
* Sorts the Gaussian Splats by depth using a radix sort.
*
* Wraps the [`radix::radix_sort_gaussians_indexes`] function for access from JavaScript.
*/
export function radix_sort_gaussians_indexes(positions_arr: Float32Array, model_view_arr: Float32Array, count: number): Uint32Array;
/**
* A structure representing texture data. This is used to pass the texture data from generation in [`texture_gen`] to the JavaScript side.
*/
export class TextureData {
private constructor();
free(): void;
/**
* Creates a new texture data object with the underlying data, width, and height.
*/
static new(data: Uint32Array, width: number, height: number): TextureData;
/**
* Getter for the underlying texture data. Always returns a copy.
*/
readonly data: Uint32Array;
/**
* Getter for the width of the texture in pixels.
*/
readonly width: number;
/**
* Getter for the height of the texture in pixels.
*/
readonly height: number;
}
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
export interface InitOutput {
readonly memory: WebAssembly.Memory;
readonly __wbg_texturedata_free: (a: number, b: number) => void;
readonly texturedata_data: (a: number) => [number, number];
readonly texturedata_width: (a: number) => number;
readonly texturedata_height: (a: number) => number;
readonly texturedata_new: (a: number, b: number, c: number, d: number) => number;
readonly generate_splat_texture: (a: any, b: any, c: any, d: any, e: number) => [number, number, number];
readonly radix_sort_gaussians_indexes: (a: any, b: any, c: number) => [number, number, number];
readonly __wbindgen_export_0: WebAssembly.Table;
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
readonly __wbindgen_malloc: (a: number, b: number) => number;
readonly __externref_table_dealloc: (a: number) => void;
readonly __wbindgen_start: () => void;
}
export type SyncInitInput = BufferSource | WebAssembly.Module;
/**
* Instantiates the given `module`, which can either be bytes or
* a precompiled `WebAssembly.Module`.
*
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
*
* @returns {InitOutput}
*/
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
/**
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
* for everything else, calls `WebAssembly.instantiate` directly.
*
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
*
* @returns {Promise<InitOutput>}
*/
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
+315
View File
@@ -0,0 +1,315 @@
let wasm;
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
let cachedUint8ArrayMemory0 = null;
function getUint8ArrayMemory0() {
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8ArrayMemory0;
}
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
}
let cachedUint32ArrayMemory0 = null;
function getUint32ArrayMemory0() {
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
}
return cachedUint32ArrayMemory0;
}
function getArrayU32FromWasm0(ptr, len) {
ptr = ptr >>> 0;
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
}
let WASM_VECTOR_LEN = 0;
function passArray32ToWasm0(arg, malloc) {
const ptr = malloc(arg.length * 4, 4) >>> 0;
getUint32ArrayMemory0().set(arg, ptr / 4);
WASM_VECTOR_LEN = arg.length;
return ptr;
}
function takeFromExternrefTable0(idx) {
const value = wasm.__wbindgen_export_0.get(idx);
wasm.__externref_table_dealloc(idx);
return value;
}
/**
* Generate a splat texture from the given attributes.
*
* Wraps the [`texture_gen::generate_texture_from_attrs`] function for access from JavaScript.
* @param {Float32Array} positions
* @param {Float32Array} scales
* @param {Float32Array} rotations
* @param {Uint8Array} colors
* @param {number} count
* @returns {TextureData}
*/
export function generate_splat_texture(positions, scales, rotations, colors, count) {
const ret = wasm.generate_splat_texture(positions, scales, rotations, colors, count);
if (ret[2]) {
throw takeFromExternrefTable0(ret[1]);
}
return TextureData.__wrap(ret[0]);
}
/**
* Sorts the Gaussian Splats by depth using a radix sort.
*
* Wraps the [`radix::radix_sort_gaussians_indexes`] function for access from JavaScript.
* @param {Float32Array} positions_arr
* @param {Float32Array} model_view_arr
* @param {number} count
* @returns {Uint32Array}
*/
export function radix_sort_gaussians_indexes(positions_arr, model_view_arr, count) {
const ret = wasm.radix_sort_gaussians_indexes(positions_arr, model_view_arr, count);
if (ret[2]) {
throw takeFromExternrefTable0(ret[1]);
}
return takeFromExternrefTable0(ret[0]);
}
const TextureDataFinalization = (typeof FinalizationRegistry === 'undefined')
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry(ptr => wasm.__wbg_texturedata_free(ptr >>> 0, 1));
/**
* A structure representing texture data. This is used to pass the texture data from generation in [`texture_gen`] to the JavaScript side.
*/
export class TextureData {
static __wrap(ptr) {
ptr = ptr >>> 0;
const obj = Object.create(TextureData.prototype);
obj.__wbg_ptr = ptr;
TextureDataFinalization.register(obj, obj.__wbg_ptr, obj);
return obj;
}
__destroy_into_raw() {
const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0;
TextureDataFinalization.unregister(this);
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_texturedata_free(ptr, 0);
}
/**
* Getter for the underlying texture data. Always returns a copy.
* @returns {Uint32Array}
*/
get data() {
const ret = wasm.texturedata_data(this.__wbg_ptr);
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
return v1;
}
/**
* Getter for the width of the texture in pixels.
* @returns {number}
*/
get width() {
const ret = wasm.texturedata_width(this.__wbg_ptr);
return ret >>> 0;
}
/**
* Getter for the height of the texture in pixels.
* @returns {number}
*/
get height() {
const ret = wasm.texturedata_height(this.__wbg_ptr);
return ret >>> 0;
}
/**
* Creates a new texture data object with the underlying data, width, and height.
* @param {Uint32Array} data
* @param {number} width
* @param {number} height
* @returns {TextureData}
*/
static new(data, width, height) {
const ptr0 = passArray32ToWasm0(data, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.texturedata_new(ptr0, len0, width, height);
return TextureData.__wrap(ret);
}
}
async function __wbg_load(module, imports) {
if (typeof Response === 'function' && module instanceof Response) {
if (typeof WebAssembly.instantiateStreaming === 'function') {
try {
return await WebAssembly.instantiateStreaming(module, imports);
} catch (e) {
if (module.headers.get('Content-Type') != 'application/wasm') {
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
} else {
throw e;
}
}
}
const bytes = await module.arrayBuffer();
return await WebAssembly.instantiate(bytes, imports);
} else {
const instance = await WebAssembly.instantiate(module, imports);
if (instance instanceof WebAssembly.Instance) {
return { instance, module };
} else {
return instance;
}
}
}
function __wbg_get_imports() {
const imports = {};
imports.wbg = {};
imports.wbg.__wbg_buffer_609cc3eee51ed158 = function(arg0) {
const ret = arg0.buffer;
return ret;
};
imports.wbg.__wbg_length_3b4f022188ae8db6 = function(arg0) {
const ret = arg0.length;
return ret;
};
imports.wbg.__wbg_length_a446193dc22c12f8 = function(arg0) {
const ret = arg0.length;
return ret;
};
imports.wbg.__wbg_new_780abee5c1739fd7 = function(arg0) {
const ret = new Float32Array(arg0);
return ret;
};
imports.wbg.__wbg_new_a12002a7f91c75be = function(arg0) {
const ret = new Uint8Array(arg0);
return ret;
};
imports.wbg.__wbg_new_e3b321dcfef89fc7 = function(arg0) {
const ret = new Uint32Array(arg0);
return ret;
};
imports.wbg.__wbg_newwithbyteoffsetandlength_f1dead44d1fc7212 = function(arg0, arg1, arg2) {
const ret = new Uint32Array(arg0, arg1 >>> 0, arg2 >>> 0);
return ret;
};
imports.wbg.__wbg_set_10bad9bee0e9c58b = function(arg0, arg1, arg2) {
arg0.set(arg1, arg2 >>> 0);
};
imports.wbg.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
arg0.set(arg1, arg2 >>> 0);
};
imports.wbg.__wbindgen_init_externref_table = function() {
const table = wasm.__wbindgen_export_0;
const offset = table.grow(4);
table.set(0, undefined);
table.set(offset + 0, undefined);
table.set(offset + 1, null);
table.set(offset + 2, true);
table.set(offset + 3, false);
;
};
imports.wbg.__wbindgen_memory = function() {
const ret = wasm.memory;
return ret;
};
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
const ret = getStringFromWasm0(arg0, arg1);
return ret;
};
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
throw new Error(getStringFromWasm0(arg0, arg1));
};
return imports;
}
function __wbg_init_memory(imports, memory) {
}
function __wbg_finalize_init(instance, module) {
wasm = instance.exports;
__wbg_init.__wbindgen_wasm_module = module;
cachedUint32ArrayMemory0 = null;
cachedUint8ArrayMemory0 = null;
wasm.__wbindgen_start();
return wasm;
}
function initSync(module) {
if (wasm !== undefined) return wasm;
if (typeof module !== 'undefined') {
if (Object.getPrototypeOf(module) === Object.prototype) {
({module} = module)
} else {
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
}
}
const imports = __wbg_get_imports();
__wbg_init_memory(imports);
if (!(module instanceof WebAssembly.Module)) {
module = new WebAssembly.Module(module);
}
const instance = new WebAssembly.Instance(module, imports);
return __wbg_finalize_init(instance, module);
}
async function __wbg_init(module_or_path) {
if (wasm !== undefined) return wasm;
if (typeof module_or_path !== 'undefined') {
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
({module_or_path} = module_or_path)
} else {
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
}
}
if (typeof module_or_path === 'undefined') {
module_or_path = new URL('wasm_splats_bg.wasm', import.meta.url);
}
const imports = __wbg_get_imports();
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
module_or_path = fetch(module_or_path);
}
__wbg_init_memory(imports);
const { instance, module } = await __wbg_load(await module_or_path, imports);
return __wbg_finalize_init(instance, module);
}
export { initSync };
export default __wbg_init;
Binary file not shown.