Normals on glTF file possible?

Hi guys, after checking the examples I only saw a buffer that takes an JSON input.
Is it possible to show a nice colored buffer like this one (https://github.com/mrdoob/three.js/blob/master/examples/canvas_materials_normal.html) on an object in the glTF format?

And if so, does anyone have an working example on how to do it and -or various other things like vertex normals on glTF models?

Can you please explain this sentence a bit? Honestly, I’m not sure what you are talking about^^

In any event, as soon as an object has vertex normals, you can use MeshNormalMaterial to visualize the normals (the underlying shader program maps normal data to RGB colors). And yes, glTF can represent vertex normals.

Different loaders return different arguments to the callback after loading. For the GLTFLoader usage see https://threejs.org/docs/#examples/loaders/GLTFLoader.

Once you’ve got the model (from whatever format) you can modify its materials the same way:

model.traverse( ( o ) => {
  if (!o.isMesh) return;
  o.material = new THREE.MeshNormalMaterial();
} );
1 Like

Man, I didnt know it was just that simple… you guys did an awesome job making this library ^ ^

Thank you for the reply, got it working now :slight_smile:

2 Likes