package { // Piclens type thing in 30 lines (FP10+) Liam O'Donnell - spikything.com
import flash.display.Sprite;
import flash.events.Event;
public class Main extends Sprite {
private var container :Sprite;
private var imageGrid :Sprite;
private var images :Array = [];
public function Main():void {
container = addChild(new Sprite()) as Sprite;
imageGrid = container.addChild(new Sprite()) as Sprite;
for (var i:uint = 0; i < 200; i++) images.push(getItem(i));
images.sortOn("z", Array.NUMERIC | Array.DESCENDING);
for each (var item:Sprite in images) imageGrid.addChild(item);
addEventListener(Event.ENTER_FRAME, update);
}
private function getItem(index:uint):Sprite {
var item:Sprite = new Sprite();
item.x = -(200 / 3) * 210 / 2 + (index / 3) * 210;
item.y = (index % 3) * 160 - 40;
item.z = 100 + Math.random() * 2000;
item.graphics.beginFill(Math.random() * 0xffffff);
item.graphics.drawRect(0, 0, 200, 150);
return item;
}
private function update(e:Event):void {
imageGrid.x += ((stage.stageWidth / 2) - mouseX) * .2;
container.rotationY = ((stage.stageWidth / 2) - mouseX) * .2;
}
}
}
Category Archives: 3D
Anything related to 3-D rendering, modeling or animation.
Head tracking in 3D
I started trying to find useful things to do with face detection, but with limited success. I tried using the Libspark Haar Cascades implementation of face detection with Papervision3D to create a sort of head tracking effect, but it’s a little flaky – partly because of poor tracking accuracy and partly because it’s too CPU intensive. You can view it on its own page here.
You are here…
I made this globe that ‘should’ look up your IP address and point to where you are on Earth – the nearest city at least. Am I close? 😉
Flash 10 Matrix3D demo
I quickly cobbled together this little demo using the new native 3D transforms in Flash 10. Alongside the regular transform.matrix property, DisplayObjects now have a transform.matrix3D property, which controls its appearance in 3-D space. It’s pretty easy to play with in Flash CS4, without any coding knowledge – I can’t wait to see a version of GTA built using this 🙂