npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

webgpu-sonar

v0.2.0

Published

GPU-accelerated multibeam sonar rendering, phase correlation, and mosaic stitching via WebGPU

Downloads

174

Readme

webgpu-sonar

GPU-accelerated multibeam sonar rendering, phase correlation, and mosaic stitching in the browser via WebGPU.

Install

npm install webgpu-sonar

Requirements

  • A browser with WebGPU support
  • A palette texture URL (512x18 RGBA PNG with 9 colour palettes)

Usage

All GPU classes follow the same pattern: async create() factory, instance methods for processing, and destroy() for cleanup.

Render a sonar ping (polar view)

import { MultibeamRenderer } from "webgpu-sonar";

const renderer = await MultibeamRenderer.create(canvas, paletteUrl);
renderer.render(ping, { palette: 0 });
renderer.destroy();

Render a Cartesian reprojection

import { CartesianReprojector } from "webgpu-sonar";

const reprojector = await CartesianReprojector.create(canvas, paletteUrl);
reprojector.render(ping, 0);
reprojector.destroy();

Phase correlation (translation estimation)

import { PhaseCorrelator } from "webgpu-sonar";

const correlator = await PhaseCorrelator.create();
const result = await correlator.correlate(pingA, pingB);
// result.dx, result.dy, result.peak
correlator.destroy();

Real-time mosaic pipeline

import {
  MosaicCompositor,
  PhaseCorrelator,
  PolarPhaseCorrelator,
  RealtimeMosaicPipeline,
} from "webgpu-sonar";

const compositor = await MosaicCompositor.create(canvas, paletteUrl);
const translation = await PhaseCorrelator.create();
const rotation = await PolarPhaseCorrelator.create();   // optional
const pipeline = new RealtimeMosaicPipeline(compositor, translation, {
  rotationCorrelator: rotation,   // omit/null for translation-only mode
  minPeak: 0.05,                  // minimum correlation peak (default: 0.05)
  maxDisplacement: 25,            // hard cap on displacement in pixels (default: 25)
  consistencyFactor: 3,           // adaptive threshold = factor × median (default: 3)
});

for (const ping of pings) {
  await pipeline.processPing(ping);
  pipeline.render(0); // palette index
}

// Export timing data
const csv = pipeline.exportCSV();

React components

import { MultibeamPing, MultibeamCartesian, MultibeamMosaic } from "webgpu-sonar/react";

<MultibeamPing ping={ping} paletteUrl={paletteUrl} palette={0} />
<MultibeamCartesian ping={ping} paletteUrl={paletteUrl} palette={0} />
<MultibeamMosaic pings={pings} paletteUrl={paletteUrl} palette={0} />

React is an optional peer dependency and only required when importing from webgpu-sonar/react.

Input format

All processing stages accept a SonarPing object:

interface SonarPing {
  numberOfBeams: number;
  numberOfRanges: number;
  bearings: ArrayLike<number>; // bearing angles in degrees, one per beam
  pingData: ArrayLike<number>; // row-major intensity data, values 0-255
  range: number; // sonar range in metres
}

ArrayLike<number> accepts both standard arrays and typed arrays (e.g. Uint8Array, Float32Array) without copying.

Core exports

| Class | Description | | ------------------------ | ----------------------------------------------------------------- | | MultibeamRenderer | Polar-coordinate sonar visualisation | | CartesianReprojector | Polar-to-Cartesian reprojection (512x512) | | MosaicCompositor | Feathered blending into 2048x2048 mosaic | | PhaseCorrelator | Translation estimation via Cartesian-domain phase correlation | | PolarPhaseCorrelator | Rotation estimation via polar-domain phase correlation | | RealtimeMosaicPipeline | Orchestrates correlation, outlier rejection, and compositing | | FFT2D | Radix-2 2D FFT in WGSL (512x512) |

License

MIT