Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Three.js Show single vertex as ie. a dot

Is it any way possible to show vertices of a mesh as ie. colored dots?

Thanks.

like image 296
Ejnaren Avatar asked Sep 09 '14 00:09

Ejnaren


1 Answers

I'm going to answer part A here, I recommend splitting your question up into two questions makes the site more useful for when other people are searching for the same solutions.

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

From Mesh documentation.

Properties

.geometry

An instance of Geometry, defining the object's structure.

From Geometry documentation.

Properties

.vertices

Array of vertices. The array of vertices holds every position of points in the model. To signal an update in this array, Geometry.verticesNeedUpdate needs to be set to true.

To draw the vertices you can create a billboard particle at each one. Below is a slight altered version of the billboard particle example.

//editGeometry = the geometry who's 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 );
like image 192
ClassicThunder Avatar answered Nov 10 '22 10:11

ClassicThunder