Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@midpoint68/pocket

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@midpoint68/pocket

A simple and efficient particle manager for JavaScript.

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Pocket

An efficient and scalable method of managing particle systems.

Creating a Pocket

var pocket = new Pocket();

Adding Particles to a Pocket

// Add 1000 particles with random locations within the bounds (0, 0, 0) and (100, 100, 100)
for(let i = 0; i < 1000; i++){
  pocket.put({
    data: 'Particle #'+i,
    x: Math.random()*100,
    y: Math.random()*100,
    z: Math.random()*100,
    radius: 0.5
  });
}

Searching for Particles

// Get a Set of all particles within a 1 unit radius of the point (50, 50, 50)
const particles = pocket.search(1, {x: 50, y: 50, z: 50});

Getting the Closest Particle

// Get only the closest particle to the point (50, 50, 50)
const closest = pocket.closest({x: 50, y: 50, z: 50});

Moving a Particle

// Get the closest particle to (50, 50, 50) and move it to (0, 0, 0)
const closest = pocket.closest({x: 50, y: 50, z: 50});
closest.moveTo({x: 0, y: 0, z: 0});

Keywords

FAQs

Package last updated on 08 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc