New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

vector-field

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vector-field

A data structure and lookup for 3D vector fields (flow fields).

latest
Source
npmnpm
Version
2.1.3
Version published
Maintainers
0
Created
Source

vector-field

npm version stability-stable npm minzipped size dependencies types Conventional Commits styled with prettier linted with eslint license

A data structure and lookup for 3D vector fields (flow fields).

paypal coinbase twitter

See the example and its source.

Installation

npm install vector-field

Usage

import VectorField from "vector-field";

let time = 0;
const directionFn = ([x, y, z]) => {
  const n = myNoise4D(x, y, z, time);
  const theta = n;
  const phi = n;

  return [
    Math.sin(theta) * Math.cos(phi),
    Math.sin(theta) * Math.sin(phi),
    Math.cos(theta),
  ];
};
const vectorField = new VectorField(directionFn, [12, 6, 6], 1);

const frame = () => {
  time += 0.001;
  vectorField.update();
  requestAnimationFrame(frame);
};

requestAnimationFrame(() => {
  frame();
});

API

Classes

VectorField

A data structure and lookup for 3D vector fields (flow fields).

Typedefs

vec3 : Array.<number>
VectorFieldCell : object
VectorFieldDirectionFn : function

The custom function to compute the cell direction (often a noise function)

VectorField

A data structure and lookup for 3D vector fields (flow fields).

Kind: global class Properties

NameType
directionFnVectorFieldDirectionFn
stepsvec3
boundsvec3
halfBoundsvec3
fieldArray.<VectorFieldCell>

new VectorField(directionFn, [steps], [bounds])

Creates an instance of VectorField.

ParamTypeDefaultDescription
directionFnVectorFieldDirectionFnThe custom function to compute the cell direction (often a noise function)
[steps]number | vec310The number of steps on each dimension (all positive integer). Use integer for identical dimensions.
[bounds]number | vec31The size of a containing box for the field. Is divided into steps for each dimension (all positive). Use integer for identical dimensions.

vectorField.update()

Create/update the field according to the provided noise function.

Kind: instance method of VectorField

vectorField.lookup(cell) ⇒ VectorFieldCell | undefined

Find a VectorFieldCell at specified position. Useful to compute a particle's velocity for instance.

Kind: instance method of VectorField

ParamTypeDescription
cellvec3[cx, cy, cz]

vec3 : Array.<number>

Kind: global typedef

VectorFieldCell : object

Kind: global typedef Properties

NameType
positionvec3
directionvec3

VectorFieldDirectionFn : function

The custom function to compute the cell direction (often a noise function)

Kind: global typedef

ParamType
positionvec3
stepPositionvec3

License

MIT. See license file.

Keywords

vector-field

FAQs

Package last updated on 07 Jul 2024

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