Capítulo 9 de 859

Chapter 9: Mesh

Core Idea

Class representing triangular polygon mesh based objects.

Key Concepts

  • count : number: The number of instances of this mesh. Can only be used with WebGPURenderer.
  • geometry : BufferGeometry: The mesh geometry.
  • isMesh : boolean (readonly): This flag can be used for type testing.
  • material : Material | Array.<Material>: The mesh material.
  • morphTargetDictionary : Object.<string, number> | undefined: A dictionary representing the morph targets in the geometry. The key is the morph targets name, the value its attribute index. This member …
  • morphTargetInfluences : Array.<number> | undefined: An array of weights typically in the range [0,1] that specify how much of the morph is applied. This member is undefined by default and…

Code Examples

const geometry = new THREE.BoxGeometry( 1, 1, 1 );
const material = new THREE.MeshBasicMaterial( { color: 0xffff00 } );
const mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
  • What it demonstrates: Typical usage of Mesh.

Reference Tables

Constructor

Signature
`new Mesh( geometry : BufferGeometry, material : Material

Properties

PropertyDescription
.count : numberThe number of instances of this mesh. Can only be used with WebGPURenderer.
.geometry : BufferGeometryThe mesh geometry.
.isMesh : boolean (readonly)This flag can be used for type testing.
`.material : MaterialArray.<Material>`
`.morphTargetDictionary : Object.<string, number>undefined`
`.morphTargetInfluences : Array.<number>undefined`

Methods

MethodDescription
.getVertexPosition( index : number, target : Vector3 ) : Vector3Returns the local-space position of the vertex at the given index, taking into account the current animation state of both morph targets and skinning.
.raycast( raycaster : Raycaster, intersects : Array.<Object> )Computes intersection points between a casted ray and this line.
.updateMorphTargets()Sets the values of Mesh#morphTargetDictionary and Mesh#morphTargetInfluences to make sure existing morph targets can influence th…

Key Takeaways

  1. Mesh extends: EventDispatcher → Object3D
  2. Most relevant properties: count, geometry, isMesh, material.
  3. Key methods: getVertexPosition, raycast, updateMorphTargets.

Connects To