1.1.0 • Published 5 years ago
@react-vertex/vector-hooks v1.1.0
@react-vertex/vector-hooks
Documentation and Examples
React hooks for working with vectors in WebGL. This package just contains a couple of items that were helpful in developing the examples. I think a package like this would be great but the API needs to be fleshed out. This package uses gl-matrix.
Install via npm:
npm install @react-vertex/vector-hooks
Importing:
import {
useVector3,
} from '@react-vertex/vector-hooks'
useVector3(x, y, z)
=> vector
React hook to create a vector with x, y, and z values. If any value (x, y or z) changes the hook will return a new vector. It does not mutate the existing.
Arguments:
x
: A number for the x value.
y
: A number for the y value.
z
: A number for the z value.
Returns:
vector
: Returns an instance of a gl-matrix vec3
Example Usage:
import { useVector3 } from '@react-vertex/vector-hooks'
...
const position = useVector3(100, 0, 0)
...
1.1.0
5 years ago