0

So far I managed to load a mesh with GLTFLoader and turn it into a wireframe. I'm stuck at the part where I want to color it and give it a line thickness. I don't completely understand how to use traverse().

My code so far:

var loader = new THREE.GLTFLoader(); loader.load('model.glb', handle_load);

var mesh;

function handle_load(gltf) {
  mesh = gltf.scene;
  mesh.traverse((node) => {
    if (!node.isMesh) return;
    node.material.wireframe = true;
  });
  scene.add(mesh);
  mesh.position.z = 2;
}
tiesfa
  • 43
  • 4
  • To get started, see https://threejs.org/examples/webgl_materials_wireframe.html. Replace the material of your loaded model with one similar to the material in the example. – WestLangley Jul 31 '20 at 03:01
  • You should know that WebGL has a limitation on `linewidth` where [values other than 1 are not guaranteed to work](https://stackoverflow.com/questions/47444239/how-to-use-gl-linewidth). The example above and [this one](https://threejs.org/examples/?q=wiref#webgl_lines_fat_wireframe) give you a good alternative, although it's a bit more complicated to implement. – M - Jul 31 '20 at 05:46

0 Answers0