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 🙏

© 2024 – Pkg Stats / Ryan Hefner

scatter-gl

v0.0.13

Published

webgl accelerated 3D/2D scatterplot renderer

Downloads

6,038

Readme

ScatterGL

Interactive 3D / 2D webgl-accelerated scatter plot point renderer. Core functionality from the embedding projector, capable of rendering and interacting with tens of thousands of points.

Examples

Basic use

// where `points` is an array of 2 or 3-dimensional points as number arrays.
const dataset = new ScatterGL.Dataset(points);
const scatterGL = new ScatterGL(containerElement);
scatterGL.render(dataset);

Installation

with yarn / npm
yarn add scatter-gl
via cdn
<!-- Load three.js -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/three.min.js"></script>
<!-- Load scatter-gl.js -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/scatter-gl.min.js"></script>

Parameters

The ScatterGL constructor can accept a number of parameters via a ScatterGLParams object:

| Parameter | Type | Description | default | | ------------------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | | camera | Camera | An object containing default parameters for the camera | Camera params object (zoom: number, target: Point3D, and position: Point3D) | | onClick | (point: Point \| null) => void | A callback invoked when clicking on a point or elsewhere | | | onHover | (point: Point \| null) => void | A callback invoked when hovering over a point | | | onSelect | (points: Point[]) => void | A callback invoked when a point or points are selected | | | onCameraMove | (cameraPosition: THREE.Vector3, cameraTarget: THREE.Vector3) => void | A callback invoked the camera moves due to user interaction. | | | pointColorer | (index: number, selectedIndices: Set<number>, hoverIndex: number|null) => string | A function to determine the color of points | | | renderMode | RenderMode | The render mode to display points, one of RenderMode.POINT, RenderMode.SPRITE, or RenderMode.TEXT | RenderMode.POINT | | showLabelsOnHover | boolean | Whether or not to render label text on hover | true | | selectEnabled | boolean | true | Whether or not a user can select points by clicking | | styles | Styles | An object containing style parameters to override the default options | | | rotateOnStart | boolean | Whether or not the renderer automatically rotates until interaction | true | | orbitControls | OrbitControlParams | An object containing default parameters for the orbit controls | Orbit Controls params object (zoomSpeed: number, autoRotateSpeed: number, and mouseRotateSpeed: number) |

ScatterGL methods

| Method | Description | | --------------------------------------------- | ---------------------------------------------------------- | | isOrbiting() | Returns whether the orbit animation is currently on | | render(dataset: Dataset) | Initializes and renders a dataset to the container element | | resize() | Updates the render size based on the container element | | resetZoom() | Resets the camera zoom to default | | select(pointIndices: number[]) | Selects points by index | | setPanMode() | Sets interaction mode to 'pan' | | setPointColorer(pointColorer: PointColorer) | Sets a function to determine colors | | setHoverPointIndex() | Sets the hovered point | | setPointRenderMode() | Sets point render mode | | setRenderMode(renderMode: RenderMode) | Sets a specific render mode | | setSelectMode() | Sets interaction mode to 'select' | | setSequences(sequences: Sequence[]) | Sets sequences with which to render polylines | | setSpriteRenderMode() | Sets sprite render mode | | setTextRenderMode() | Sets text render mode | | updateDataset(dataset: Dataset) | Updates the dataset | | startOrbitAnimation() | Begin rotating until an interaction | | stopOrbitAnimation() | Stops automatic rotation |

ScatterGL Styles

See styles.ts for interfaces and descriptions of a user-configurable styles object that can be provided to ScatterGL to configure colors, sizes, fog, etc.

Advanced usage

See the demo app for examples of interaction handling, spritesheet rendering, and point coloring.

Styling

You can provide an object in the form of Styles via the styles parameter of the ScatterGLParams object.

Development

yarn
yarn demo

This is not an officially supported Google product