Air Island 3D V.2.0

 


Para navegar por la “Air Island” presionar en la imagen:

Pellizcar diagonal - Zoom
Arrastrar dos dedos - Desplazar
Arrastrar un dedo - Giro

For swim in this world press at image:

Diagonal Pinch - Zoom
Drag two fingers - Scroll
Drag one finger - Turn

CÓDIGO
//(C)Sergio Salazar Latorre
// Air Island 3D V.2.0

let l= 1000
let szMax =200
let np = 100
let pc = Array(np)
let pe = Array(np)

//-------------------

function configSetup(){
  createCanvas(l,l, WEBGL);
  angleMode(DEGREES)
}
function configDraw(){
  orbitControl()
  background(0);

  strokeWeight(0.1)
  stroke(0)
}

function Firma(){
  push()
  fill(0)
  strokeWeight(4)
  stroke(0)
  text("(C)Sergio Salazar Latorre", 10, l-20)
  text("Air Island 3D V.2.0",10,l-9)
  strokeWeight(0.1)
  pop()
}

function cargarParticulas(){
  for(let i=0; i<np; i++){
    pc[i] = new Fig3D(4)  
    pe[i] = new Fig3D(2)  
  }
}

function verParticulas(){
  for(let i=0; i<np; i++){
    pc[i].caja()
    pe[i].esfera()
  }
}

//-------------------

function setup() {
  configSetup()
  cargarParticulas()
}

function draw() {
  
  configDraw()
  verParticulas()
}

//....................

class Fig3D{
  constructor(cC){
    this.x = random(-l/2,l/2)
    this.y = random(-l/2,l/2)
    this.z = random(-l/2,l/2)
    this.ww = random(szMax)
    this.hh = random(szMax)
    this.dd = random(szMax)
    this.col 
    this.givemeKC(cC)
  }
  
  givemeKC(c){
    let KC = new KarlaColors()
    if(c==1){
      this.col = KC.karlaMangaSunday()
    } else if(c==2){
      this.col = KC.karlaMarina()
    } else if(c==3){
      this.col = KC.karlaDeepCuore()
    } else if(c==4){
      this.col = KC.karlaAutumnIng()  
    }
  }
  
  caja(){
    push()
    translate(this.x, this.y, this.z)
    fill(this.col)
    box(this.ww, this.hh, this.dd)
    pop()
  }
  
  
  esfera(){
    push()
    translate(this.x, this.y, this.z)
    fill(this.col)
    sphere(this.ww/2)
    pop()
  }
  
}

// CLASE KARLACOLORS---------------------

class KarlaColors
{
  constructor(){}
  
  karlaAutumnIng(){
    return color(random(0,255),
                 random(50,255),
                 random(120,128))
  }
  karlaMarina(){
    return color(random(255),
                 random(190,255),
                 random(220,255))
  }
  karlaDeepCuore(){
    return color(random(245,255),
                 random(100,255),
                 random(100,255))
  }
  karlaMangaSunday(){
    return color(random(100,255),
                 random(100,255),
                 random(100,255))
  }
  karlaTurquoise(){
     //color(93,193,185)
     //color('hsla(160,100%,50%,1)')
    return color(93,193,185,
                 random(200,255))
  }
}

Comentarios

Entradas populares