How to use the Uint8BufferAttribute function from three

Find comprehensive JavaScript three.Uint8BufferAttribute code examples handpicked from public code repositorys.

three.Uint8BufferAttribute is a class in the Three.js library that represents an attribute containing unsigned 8-bit integer values in a buffer.

194
195
196
197
198
199
200
201
202
203
case Uint8Array:
attributeData = new dracoDecoder.DracoUInt8Array();
decoder.GetAttributeUInt8ForAllPoints(
    dracoGeometry, attribute, attributeData);
geometryBuffer[ attributeName ] = new Uint8Array( numValues );
TypedBufferAttribute = THREE.Uint8BufferAttribute;
break;

case Uint16Array:
attributeData = new dracoDecoder.DracoUInt16Array();
fork icon4
star icon26
watch icon0

+ 5 other calls in file

How does three.Uint8BufferAttribute work?

three.Uint8BufferAttribute is a class in the Three.js library that creates a new buffer attribute with an array of unsigned 8-bit integers, which can be used to define geometry data such as color or index values. The constructor of three.Uint8BufferAttribute takes three arguments: An array of the data to be stored in the buffer attribute The size of each element in the array A flag indicating whether the data should be normalized before being stored in the buffer attribute. The resulting buffer attribute can be assigned to the corresponding geometry object to define the geometry data.

Ai Example

1
2
3
4
import * as THREE from "three";

const array = new Uint8Array([1, 2, 3, 4]);
const bufferAttribute = new THREE.Uint8BufferAttribute(array, 1);

In this example, we create a Uint8Array with four elements and pass it to the Uint8BufferAttribute constructor along with a stride value of 1. This creates a new buffer attribute that uses the same data as the original array, but stores it in a format that is optimized for use with Three.js.

Other functions in three

Sorted by popularity

function icon

three.Vector3 is the most popular function in three (22341 examples)