///Class tentacule///

class tentacule
{
  init()
{
  this.img_back = loadImage('assets/neonback.jpg');
}

FX()
{
let count = 20
let boxSize = 50
let spacing = 1

function fx02_transform(timer,x,y,z){
    let sclx = 1-abs(x/count);  
    let scly = 1-abs(y/count);  
    let sclz = 1-abs(z/count);  
    let scl = sclx * scly * sclz;
    
    rotateX( sin(scl + timer) * 1.3 )
    rotateY( cos(scl + timer) * sin(timer) * 2 )
    rotateX( cos(scl + timer) * 1 )
    scale( lerp( 0.5 + scl, 1.2,  sin(scl*3.14+timer*4) * 0.5 + 0.5 ) )
    translate(
      x * boxSize * spacing,
      y * boxSize * spacing,
      z * boxSize * spacing,
      )
}

  let timer = millis() / 1000
  
  rotateX(cos(timer*0.5))
  rotateY(sin(timer*1.1))
  rotateZ(cos(timer*2.2))
  
  //ambientLight(255,96,0)
  
  for (let x=-count; x<=count; x++)
  {
    stroke(0)
    
    push()    
    fill(150,0,90,50)
    let scl = 1-abs(x/count);  
    fx02_transform(timer,x,0,0)
    blendMode(SCREEN)
    box(boxSize)
    pop()
  }
  for (let x=-count; x<=count; x++)
  {
    push()   
    fill(50,0,190,50)
    let scl = 1-abs(x/count);  
    fx02_transform(timer,0,x,0)
    box(boxSize)
    pop()
  }
  for (let x=-count; x<=count; x++)
  {
    push()  
    fill(90,0,90,15)
    let scl = 1-abs(x/count);  
    fx02_transform(timer,0,0,x)
    //noStroke();
    box(boxSize)
    pop()
            
  }
  push()  
  texture(this.img_back)
  rotateY(millis() /40000)
  box(2000)
  pop()
  
  }
}