Upgrading from Geometry to BufferGeometry

Hello !!!

I need convert from old version to new

Old =>https://codepen.io/Lighty/pen/qBobzWN
New => https://codepen.io/Lighty/pen/bGvpoEq

in general, I don’t understand how to change this piece of code

geometry.faces.forEach(f => {
  const a = geometry.vertices[f.a];
   const b = geometry.vertices[f.b];
   const c = geometry.vertices[f.c];
  let  max = Math.max(a.z, Math.max(b.z, c.z));
  if (max <= 0){
    return  f.color.set(0x44ccff);
  }else if (max <= 1.5){
      return  f.color.set(0x228800);
  else if (max <= 3.5){
      return  f.color.set(0xeecc44);

I’ve refactored the code a bit. Try it like so: Edit fiddle - JSFiddle - Code Playground

To make unique face colors work, you have to use a non-indexed buffer geometry.

That’s great :love_you_gesture:

and how can i remove flatshading which is unclear why there is ?