youpilat13 youpilat13 - 3 months ago 25
Javascript Question

Draw lines of mesh on SphereGeometry

I try to draw lines of a THREE.mesh whose geometry is done with

SphereGeometry
and material with
MeshBasicMaterial
.

To achieve this, I have used the following snippet code:

var segments = 32
var geometry = new THREE.SphereGeometry(3, segments, segments, 0, Math.PI * 2, 0, Math.PI * 2);
var material = new THREE.MeshBasicMaterial({color: 0x900000});
var sphere = new THREE.Mesh(geometry, material);

scene.add(sphere);


This snippet doesn't produce the expected lines.

Instead of above code, I tried also to do:

var sphere = new THREE.Object3D();
sphere.add( new THREE.LineSegments(

new THREE.Geometry(),

new THREE.LineBasicMaterial({
color: 0xffffff,
transparent: true,
opacity: 0.5
})

));

sphere.add( new THREE.Mesh(

new THREE.Geometry(),

new THREE.MeshPhongMaterial({
color: 0x156289,
emissive: 0x072534,
side: THREE.DoubleSide,
shading: THREE.FlatShading
})

));

scene.add(sphere);


The lines of mesh aren't displayed too.

I use three.min.js version 74.

Answer

Use THREE.WireframeHelper class.

var wireframe = new THREE.WireframeHelper( sphere, 0x00ff00 );
scene.add( wireframe );

http://threejs.org/docs/#Reference/Extras.Helpers/WireframeHelper