BufferGeometry class
A representation of mesh, line, or point geometry. Includes vertex positions, face indices, normals, colors, UVs, and custom attributes within buffers, reducing the cost of passing all this data to the GPU.
To read and edit data in BufferGeometry attributes, see
BufferAttribute
documentation.
final geometry = BufferGeometry();
// create a simple square shape. We duplicate the top left and bottom right
// vertices because each vertex needs to appear once per triangle.
final vertices = Float32Array.fromList([
-1.0, -1.0, 1.0, // v0
1.0, -1.0, 1.0, // v1
1.0, 1.0, 1.0, // v2
1.0, 1.0, 1.0, // v3
-1.0, 1.0, 1.0, // v4
-1.0, -1.0, 1.0 // v5
]);
// itemSize = 3 because there are 3 values (components) per vertex
geometry.setAttribute(Attribute.position, new THREE.BufferAttribute( vertices, 3 ) );
final material = MeshBasicMaterial({MaterialProperty.color: 0xff0000});
final mesh = Mesh( geometry, material );
- Mixed-in types
- Implementers
Constructors
- BufferGeometry()
-
BufferGeometry.fromJson(Map<
String, dynamic> json, Map<String, dynamic> rootJson)
Properties
-
attributes
↔ Map<
String, dynamic> -
getter/setter pair
- boundingBox ↔ BoundingBox?
-
getter/setter pair
- boundingSphere ↔ BoundingSphere?
-
getter/setter pair
-
colors
↔ List<
Color> -
getter/setter pair
- colorsNeedUpdate ↔ bool
-
getter/setter pair
- curveSegments ↔ int
-
getter/setter pair
- directGeometry ↔ BufferGeometry?
-
getter/setter pair
- disposed ↔ bool
-
getter/setter pair
-
drawRange
↔ Map<
String, int> -
getter/setter pair
- elementsNeedUpdate ↔ bool
-
getter/setter pair
-
groups
↔ List<
Map< String, dynamic> > -
getter/setter pair
- groupsNeedUpdate ↔ bool
-
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- id ↔ int
-
getter/setter pair
-
index
↔ BufferAttribute<
NativeArray< ?num> > -
getter/setter pair
- instanceCount ↔ int?
-
getter/setter pair
-
lineDistances
↔ List<
double> -
getter/setter pair
- lineDistancesNeedUpdate ↔ bool
-
getter/setter pair
- maxInstanceCount ↔ int?
-
getter/setter pair
-
morphAttributes
↔ Map<
String, List< BufferAttribute< >NativeArray< >num> > -
getter/setter pair
-
morphTargets
↔ List<
MorphTarget> -
getter/setter pair
- morphTargetsRelative ↔ bool
-
getter/setter pair
- name ↔ String
-
getter/setter pair
- normalsNeedUpdate ↔ bool
-
getter/setter pair
-
parameters
↔ Map<
String, dynamic> ? -
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- type ↔ String
-
getter/setter pair
-
userData
↔ Map<
String, dynamic> -
getter/setter pair
- uuid ↔ String
-
getter/setter pair
- uvsNeedUpdate ↔ bool
-
getter/setter pair
- verticesNeedUpdate ↔ bool
-
getter/setter pair
Methods
-
addEventListener(
String type, Function listener) → void -
type
- The type of event to listen to.inherited -
addGroup(
int start, int count, [int materialIndex = 0]) → void - Adds a group to this geometry; see the groups property for details.
-
applyMatrix4(
Matrix4 matrix) → void - Applies the matrix transform to the geometry.
-
applyQuaternion(
Quaternion q) → BufferGeometry - Applies the rotation represented by the quaternion to the geometry.
-
center(
) → void - Center the geometry based on the bounding box.
-
clearGroups(
) → void - Clears all groups.
-
clearListeners(
) → void -
Remove all Listeners.
inherited
-
clone(
) → BufferGeometry - Creates a clone of this BufferGeometry.
-
computeBoundingBox(
) → void -
computeBoundingSphere(
) → void - Computes the bounding sphere of the geometry, and updates the boundingSphere attribute.
-
computeFaceNormals(
) → void -
computeTangents(
) → void - Calculates and adds a tangent attribute to this geometry.
-
computeVertexNormals(
) → void - Computes vertex normals for the given vertex data. For indexed geometries, the method sets each vertex normal to be the average of the face normals of the faces that share that vertex.
-
copy(
BufferGeometry source) → BufferGeometry -
deleteAttribute(
Attribute type) → BufferGeometry -
Deletes the
type
with the specified Attribute. -
deleteAttributeFromString(
String type) → BufferGeometry -
Deletes the
type
with the specified string name. -
dispatchEvent(
Event event) → void -
event
- The event that gets fired.inherited -
dispose(
) → void - Frees the GPU-related resources allocated by this instance. Call this method whenever this instance is no longer used in your app.
-
getAttribute(
Attribute type) → dynamic -
Returns the
type
with the specified Attribute. -
getAttributeFromString(
String type) → dynamic -
Returns the
type
with the specified string name. -
getIndex(
) → BufferAttribute< NativeArray< ?num> > - Return the index buffer.
-
hasAttribute(
Attribute type) → bool -
Returns
true
if the attribute with the specified name exists. -
hasAttributeFromString(
String type) → bool -
Returns
true
if the attribute with the specified name exists. -
hasEventListener(
String type, Function listener) → bool -
type
- The type of event to listen to.inherited -
lookAt(
Vector3 vector) → BufferGeometry - vector - A world vector to look at.
-
merge(
BufferGeometry geometry, [int? offset]) → BufferGeometry -
normalizeNormals(
) → void -
Every normal vector in a geometry will have a magnitude of
1
. This will correct lighting on the geometry surfaces. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeEventListener(
String type, Function listener) → void -
type - The type of the listener that gets removed.
inherited
-
rotateX(
double angle) → BufferGeometry -
Rotate the geometry about the X axis. This is typically done as a one time
operation, and not during a loop. Use
rotation
for typical real-time mesh rotation. -
rotateY(
double angle) → BufferGeometry -
Rotate the geometry about the Y axis. This is typically done as a one time
operation, and not during a loop. Use
rotation
for typical real-time mesh rotation. -
rotateZ(
double angle) → BufferGeometry -
Rotate the geometry about the Z axis. This is typically done as a one time
operation, and not during a loop. Use
rotation
for typical real-time mesh rotation. -
scale(
double x, double y, double z) → BufferGeometry - Scale the geometry data. This is typically done as a one time operation, and not during a loop. Use scale for typical real-time mesh scaling.
-
setAttribute(
Attribute type, dynamic attribute) → BufferGeometry - Sets an attribute to this geometry. Use this rather than the attributes property, because an internal hashmap of attributes is maintained to speed up iterating over attributes.
-
setAttributeFromString(
String type, dynamic source) → BufferGeometry - Sets an attribute to this geometry. Use this rather than the attributes property, because an internal hashmap of attributes is maintained to speed up iterating over attributes.
-
setDrawRange(
int start, int count) → void - Set the drawRange property. For non-indexed BufferGeometry, count is the number of vertices to render. For indexed BufferGeometry, count is the number of indices to render.
-
setFromPoints(
dynamic points) → BufferGeometry - Sets the attributes for this BufferGeometry from an array of points.
-
setIndex(
dynamic index) → void -
toJson(
{Object3dMeta? meta}) → Map< String, dynamic> - Convert the buffer geometry to three.js JSON Object/Scene format.
-
toNonIndexed(
) → BufferGeometry - Return a non-index version of an indexed BufferGeometry.
-
toString(
) → String -
A string representation of this object.
inherited
-
translate(
double x, double y, double z) → BufferGeometry -
Translate the geometry by
x,y,z
. This is typically done as a one time operation, and not during a loop. Useposition
for typical real-time mesh translation. -
translateWithVector3(
Vector3 v3) → BufferGeometry -
Translate the geometry by Vecotr3. This is typically done as a one time operation,
and not during a loop. Use
position
for typical real-time mesh translation.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited