Skip to content

Instantly share code, notes, and snippets.

@jonathantorres
Created January 31, 2012 04:44
Show Gist options
  • Save jonathantorres/1708867 to your computer and use it in GitHub Desktop.
Save jonathantorres/1708867 to your computer and use it in GitHub Desktop.
A circle of circles in Away3D
package com.practices.onaway
{
import away3d.containers.ObjectContainer3D;
import away3d.core.base.Vertex;
import away3d.debug.AwayStats;
import away3d.primitives.Sphere;
import flash.events.Event;
/**
* @author Jonathan Torres
*/
[SWF(backgroundColor="#FFFFFF", frameRate="31", width="800", height="600")];
public class CoolCircle extends Away3DTemplate
{
private var _guideSphere : Sphere;
private var _pivot : ObjectContainer3D;
public function CoolCircle()
{
super();
}
override protected function initScene() : void
{
camera.zoom = 15;
_pivot = new ObjectContainer3D();
scene.addChild(_pivot);
_guideSphere = new Sphere();
_guideSphere.radius = 150;
_guideSphere.segmentsH = 20;
_guideSphere.segmentsW = 20;
for each (var vertex : Vertex in _guideSphere.vertices) {
var smallSphere:Sphere = new Sphere();
smallSphere.radius = 5;
smallSphere.segmentsH = 2;
smallSphere.segmentsW = 4;
smallSphere.x = vertex.x;
smallSphere.y = vertex.y;
smallSphere.z = vertex.z;
_pivot.addChild(smallSphere);
}
stage.addChild(new AwayStats());
}
override protected function onEnterFrame(event:Event) : void
{
var dx : Number = mouseX - stage.stageWidth * 0.5;
var dy : Number = mouseY - stage.stageHeight * 0.5;
camera.x = -dx / 4;
camera.y = dy / 4;
_pivot.rotationY += 3;
super.onEnterFrame(event);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment