Expand description
WiFi-DensePose WebAssembly bindings
This crate provides WebAssembly bindings for browser-based applications using WiFi-DensePose technology. It includes:
- mat: WiFi-Mat disaster response dashboard module for browser integration
§Features
mat- Enable WiFi-Mat disaster detection WASM bindingsconsole_error_panic_hook- Better panic messages in browser console
§Building for WASM
# Build with wasm-pack
wasm-pack build --target web --features mat
# Or with cargo
cargo build --target wasm32-unknown-unknown --features mat§Example Usage (JavaScript)
import init, { MatDashboard, initLogging } from './wifi_densepose_wasm.js';
async function main() {
await init();
initLogging('info');
const dashboard = new MatDashboard();
// Create a disaster event
const eventId = dashboard.createEvent('earthquake', 37.7749, -122.4194, 'Bay Area Earthquake');
// Add scan zones
dashboard.addRectangleZone('Building A', 50, 50, 200, 150);
dashboard.addCircleZone('Search Area B', 400, 200, 80);
// Subscribe to events
dashboard.onSurvivorDetected((survivor) => {
console.log('Survivor detected:', survivor);
updateUI(survivor);
});
dashboard.onAlertGenerated((alert) => {
showNotification(alert);
});
// Render to canvas
const canvas = document.getElementById('map');
const ctx = canvas.getContext('2d');
function render() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
dashboard.renderZones(ctx);
dashboard.renderSurvivors(ctx);
requestAnimationFrame(render);
}
render();
}
main();Re-exports§
pub use mat::*;
Modules§
Functions§
- get_
timestamp - Get current timestamp in milliseconds (for performance measurements).
- get_
version - Get the library version.
- init
- Initialize the WASM module. Call this once at startup before using any other functions.
- init_
logging - Initialize logging with specified level.
- is_
mat_ enabled - Check if the MAT feature is enabled.