Advertisement
Guest User

MCCC Code Submit 25/11/15

a guest
Nov 25th, 2015
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 1.24 KB | None | 0 0
  1. //############################################################################################
  2. //##Scala Code
  3. //##
  4. //##All this code is done with my own, right now experimental, framework based on threejs
  5. //############################################################################################
  6.  
  7. class ThreeJSApp19 extends JSApp with BasicCanvas with DrawingUtils with SimplexNoise{
  8.   Setup._2D.asScene.withStats.withControls
  9.  
  10.   val radius = 100
  11.  
  12.   val cols = List(0x2537b5, 0xff3804, 0xffffff).map(Hex(_))
  13.  
  14.   val polarCoords = for{
  15.     g <- (0 to 20).map(_*TWO_PI/10)
  16.     t <- (-10 to 10).map(_*PI/10)
  17.   } yield (g, t)
  18.  
  19.   val sPos = polarCoords.map{ case(g,t)=> (sin(g)*cos(t)*radius, cos(g)*cos(t)*radius, sin(t)*radius) }
  20.   val rPos = polarCoords.map{ case(g,t)=> (sin(g)*cos(t)*radius, cos(g)*tan(t)*radius, sin(t)*radius) }
  21.  
  22.   val vals = sPos.map(_=>sphere(center,2,cols(randInt(cols.size))))
  23.  
  24.   val all = (sPos,rPos,vals).zipped
  25.  
  26.   val g = new Group()
  27.   vals.foreach(g.add)
  28.   scene.add(g)
  29.  
  30.   def render():Unit = {
  31.     all.foreach{ case(sp, rp, s) =>
  32.       s.position.lerpVectors(sp, rp, sin(map(frameCount,0,60*5,0,TWO_PI)).map(-1,1,0,1))
  33.     }
  34.     g.setRotationFromAxisAngle(yAxis,map(frameCount,0,60*5,0,TWO_PI))
  35.   }
  36.  
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement