Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //############################################################################################
- //##Scala Code
- //##
- //##All this code is done with my own, right now experimental, framework based on threejs
- //############################################################################################
- class ThreeJSApp19 extends JSApp with BasicCanvas with DrawingUtils with SimplexNoise{
- Setup._2D.asScene.withStats.withControls
- val radius = 100
- val cols = List(0x2537b5, 0xff3804, 0xffffff).map(Hex(_))
- val polarCoords = for{
- g <- (0 to 20).map(_*TWO_PI/10)
- t <- (-10 to 10).map(_*PI/10)
- } yield (g, t)
- val sPos = polarCoords.map{ case(g,t)=> (sin(g)*cos(t)*radius, cos(g)*cos(t)*radius, sin(t)*radius) }
- val rPos = polarCoords.map{ case(g,t)=> (sin(g)*cos(t)*radius, cos(g)*tan(t)*radius, sin(t)*radius) }
- val vals = sPos.map(_=>sphere(center,2,cols(randInt(cols.size))))
- val all = (sPos,rPos,vals).zipped
- val g = new Group()
- vals.foreach(g.add)
- scene.add(g)
- def render():Unit = {
- all.foreach{ case(sp, rp, s) =>
- s.position.lerpVectors(sp, rp, sin(map(frameCount,0,60*5,0,TWO_PI)).map(-1,1,0,1))
- }
- g.setRotationFromAxisAngle(yAxis,map(frameCount,0,60*5,0,TWO_PI))
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement