# utils-three-js

> This module helps to build three-js application

Latest version **1.0.20** (published 2023-11-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install utils-three-js
pnpm add utils-three-js
yarn add utils-three-js
bun add utils-three-js
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.20 |
| Published | 2023-11-23 |
| First published | 2023-08-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 23 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Raumik Rana |
| Maintainers | ranaraumik16 |
| Keywords | three-js, three, three-js-utils, three-js-utils-module, buffergeometry, geometry |

## Links

- npm: https://www.npmjs.com/package/utils-three-js
- Repository: https://github.com/ranaraumik16/utils-three-js
- Homepage: https://github.com/ranaraumik16/utils-three-js#readme
- Issues: https://github.com/ranaraumik16/utils-three-js/issues
- npm.io page: https://npm.io/package/utils-three-js

## Dependencies (1)

- [three](https://npm.io/package/three.md) >=0.140.0

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.0.20 (latest) — 2023-11-23
- 1.0.19 — 2023-09-23
- 1.0.18 — 2023-09-19
- 1.0.17 — 2023-09-07
- 1.0.16 — 2023-09-07
- 1.0.15 — 2023-08-30
- 1.0.14 — 2023-08-19
- 1.0.13 — 2023-08-18
- 1.0.12 — 2023-08-18
- 1.0.11 — 2023-08-16
- 1.0.10 — 2023-08-14
- 1.0.9 — 2023-08-13
- 1.0.8 — 2023-08-13
- 1.0.7 — 2023-08-12
- 1.0.6 — 2023-08-12
- … 6 more at https://npm.io/package/utils-three-js/versions

## README

# utils-three-js

A utility library for working with BufferGeometry in Three.js.
I have created this library to make it easier to work with BufferGeometry in Three.js.

## Installation

You can install `utils-three-js` using npm:


```
    npm install utils-three-js
```

## Usage

import { BufferGeoUtils } from 'utils-three-js';

import * as THREE from 'three';

// Create a BufferGeometry

const geometry = new THREE.BoxGeometry();


// Perform operations on the geometry

const positionArray = BufferGeoUtils.getPositionArray(geometry);

const normalArray   = BufferGeoUtils.getNormalArray(geometry);

const uvArray       = BufferGeoUtils.getUVArray(geometry);

const facePoints    = BufferGeoUtils.getFacePoints(geometry,10)

// ...and more

## API Documentation
`BufferGeoUtils`

| Method                   | Description                                                          | Parameters                                 | Returns                   |
|--------------------------|----------------------------------------------------------------------|--------------------------------------------|--------------------------|
| `isBufferGeometry`       | Checks if the given geometry is a BufferGeometry.                   | `geometry` (THREE.BufferGeometry)           | `Boolean`                |
| `getPositionArray`       | Returns the position array of the geometry.                          | `geometry` (THREE.BufferGeometry)           | `Array`                  |
| `getNormalArray`         | Returns the normal array of the geometry.                            | `geometry` (THREE.BufferGeometry)           | `Array`                  |
| `getUVArray`             | Returns the UV array of the geometry.                                | `geometry` (THREE.BufferGeometry)           | `Array`                  |
| `getIndicesArray`        | Returns the indices array of the geometry.                           | `geometry` (THREE.BufferGeometry)           | `Array`                  |
| `getNumberOfFaces`       | Returns the number of faces in the geometry.                         | `geometry` (THREE.BufferGeometry)           | `Number`                 |
| `getNumberOfVertices`    | Returns the number of vertices in the geometry.                      | `geometry` (THREE.BufferGeometry)           | `Number`                 |
| `getPoint`               | Returns the point at the given index.                                | `geometry` (THREE.BufferGeometry), `index` (Number) | `THREE.Vector3`           |
| `getFacePointIndices`    | Returns the indices of the points of the face at the given index.    | `geometry` (THREE.BufferGeometry), `faceIndex` (Number) | `Array[Number]`           |
| `getFacePoints`          | Returns the points of the face at the given index.                   | `geometry` (THREE.BufferGeometry), `faceIndex` (Number) | `Array[THREE.Vector3]`    |
| `getTriangleArea`        | Returns the area of the triangle with the given points.              | `p1` (THREE.Vector3), `p2` (THREE.Vector3), `p3` (THREE.Vector3) | `Number` |
| `getSurfaceArea`         | Returns the surface area of the geometry.                            | `geometry` (THREE.BufferGeometry)           | `Number`                 |

`Object3DUtils`
| Method                   | Description                                                          | Parameters                                 | Returns                   |
|--------------------------|----------------------------------------------------------------------|--------------------------------------------|--------------------------|
| `getAllMeshes`           | Returns all meshes of the given object.                              | `object` (THREE.Object3D)                  | `Array[THREE.Mesh]`      |
| `unGroupAllMeshes`       | Un-groups all meshes of the given object.(Scaling may not work) If removeMeshTransformation is true, the transformation of the mesh is removed and applied to the geometry      | `object` (THREE.Object3D), `removeMeshTransformation` (Boolean) (default value is false) | `Array[THREE.Mesh]`      |
| `deleteMeshWithData`      | Deletes the mesh and its geometry, material, textures    | `mesh` (THREE.Mesh) | `Boolean`      |
| `deleteObjectWithData`    | Deletes the object and its geometry, material, textures. warning - make sure that they are not used by any other mesh    | `object` (THREE.Object3D) | `Boolean`      |
| `getBoundingBox`         | Returns the bounding box of the object.                              | `object` (THREE.Object3D), `inLocalSpace` (Boolean) (Optional)(default value is false)  | `THREE.Box3`    |
| `getClassInstanceObjects`| Returns all objects of the object with the given class.              | `object` (THREE.Object3D), `objectClass` (any)  | `Array<objectClass>`  |
| `isObject`               | Checks if the given object is an instance of THREE.Object3D.         | `object` (THREE.Object3D)                  | `Boolean`                |
| `isMesh`                 | Checks if the given object is an instance of THREE.Mesh.             | `object` (THREE.Object3D)                  | `Boolean`                |

`UtilsMath`
| Method                   | Description                                                          | Parameters                                 | Returns                   |
|--------------------------|----------------------------------------------------------------------|--------------------------------------------|--------------------------|
| `removeFloatingPointError`| Removes the floating point error of the given value.                 | `value` (Number), `decimals` (Number) (Optional)(default value is 2) | `Number` |
| `removeFloatingPointErrorVec3`| Removes the floating point error of the given vector.                 | `inVec` (THREE.Vector3), `inDecimals` (Number) (Optional)(default value is 2) | `THREE.Vector3` |
## License

This project is licensed under the MIT License.

---
_Source: https://npm.io/package/utils-three-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
