Three.js Shows a single vertex, i.e. point

Is it possible to show grid vertices as ie. colored dots?

Thanks.

+5
source share
1 answer

I am going to answer Part A here, I recommend splitting the question into two questions so that the site becomes more useful when other people are looking for the same solutions.

A Mesh has Geometry and Geometry has an array of Vertices .

From the Mesh documentation.

The properties

.geometry

A geometry instance defining the structure of an object.

From the Geometry documentation.

The properties

.vertices

An array of vertices. The vertex array contains each position of the points in the model. To signal an update in this array, the Geometry.verticesNeedUpdate parameter must be set to true.

To draw vertices, you can create a particle of a billboard on each of them. Below is a small modified version of a poster example .

//editGeometry = the geometry who vertices we want to show geometry = new THREE.Geometry(); sprite = THREE.ImageUtils.loadTexture( "textures/sprites/disc.png" ); for ( i = 0; i < editGeometry.vertices.length; i ++ ) { geometry.vertices.push(editGeometry.vertices[i]); } material = new THREE.PointCloudMaterial( { size: 35, sizeAttenuation: false, map: sprite, transparent: true } ); material.color.setHSL( 1.0, 0.3, 0.7 ); particles = new THREE.PointCloud( geometry, material ); particles.sortParticles = true; scene.add( particles ); 
+4
source

Source: https://habr.com/ru/post/1202114/


All Articles