Capítulo 87 de 859

Chapter 87: PointsMaterial

Core Idea

A material for rendering point primitives.

Materials define the appearance of renderable 3D objects.

Key Concepts

  • alphaMap : Texture: The alpha map is a grayscale texture that controls the opacity across the surface (black: fully transparent; white: fully opaque).
  • color : Color: Color of the material.
  • fog : boolean: Whether the material is affected by fog or not.
  • isPointsMaterial : boolean (readonly): This flag can be used for type testing.
  • map : Texture: The color map. May optionally include an alpha channel, typically combined with Material#transparent or [Mater…
  • size : number: Defines the size of the points in pixels.
  • sizeAttenuation : boolean: Specifies whether size of individual points is attenuated by the camera depth (perspective camera only).

Code Examples

const vertices = [];
for ( let i = 0; i < 10000; i ++ ) {
	const x = THREE.MathUtils.randFloatSpread( 2000 );
	const y = THREE.MathUtils.randFloatSpread( 2000 );
	const z = THREE.MathUtils.randFloatSpread( 2000 );
	vertices.push( x, y, z );
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) );
const material = new THREE.PointsMaterial( { color: 0x888888 } );
const points = new THREE.Points( geometry, material );
scene.add( points );
  • What it demonstrates: Typical usage of PointsMaterial.

Reference Tables

Constructor

Signature
new PointsMaterial( parameters : Object )

Properties

PropertyDescription
.alphaMap : TextureThe alpha map is a grayscale texture that controls the opacity across the surface (black: fully transparent; white: fully opaque).
.color : ColorColor of the material.
.fog : booleanWhether the material is affected by fog or not.
.isPointsMaterial : boolean (readonly)This flag can be used for type testing.
.map : TextureThe color map. May optionally include an alpha channel, typically combined with Material#transparent or Material#alphaTest. The texture map col…
.size : numberDefines the size of the points in pixels.
.sizeAttenuation : booleanSpecifies whether size of individual points is attenuated by the camera depth (perspective camera only).

Key Takeaways

  1. PointsMaterial extends: EventDispatcher → Material
  2. Most relevant properties: alphaMap, color, fog, isPointsMaterial.

Connects To