@gov.nasa.jpl.honeycomb/geometry-optimization-utils
v0.0.6
Published
Utilities for optimizing three.js geometry memory.
Downloads
3
Readme
Geometry Optimization Utilities
Use
import { SphereBufferGeometry } from 'three';
import { optimizeGeometry } from '@gov.nasa.jpl.honeycomb/optimize-geometry-utils';
// modifies the attributes in place!
const geometry = new SphereBufferGeometry();
optimizeGeometry(geometry);
// smaller memory footprint!API
Functions
optimizeGeometry
optimizeGeometry( geometry : BufferGeometry ) : voidTakes a buffer geometry and optimizes the memory of the uv, uv2, normal, and index attributes in place to normalized attributes. Note that UVs outside the range of [0, 1] will not normalize correcrly.
!> Note that the BufferAttributes are modified in place instead of creating new ones.
!> Note that InterleavedBufferAttributes are not supported.
toNormalizedByteArray
toNormalizedByteArray(
array : TypedArray,
signed : Boolean = true,
bytes : Number = 1
) : TypedArrayTakes a given typed array and converts it into an array that can store data with the given sign flag and byte precision. Float arrays are converted such that [0, 1.0] (or [-1.0, 1.0] if signed) is normalized to the whole byte precision. Int or Uint types are normal mapped to the new byte range.
If the given array is already of the target type it is returned unchanged immediately.
toFloatArray
toFloatArray( array : TypedArray, bytes : Number = 4 ) : TypedArrayTakes a given typed array and converts it into a float array of the given byte length with normalized data.
