觀看範例
package
{
import flash.events.Event;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.view.BasicView;
/**
* 簡易Carousel,以PV3D內附的BasicView為基礎,使用yaw()跟moveForward()來放置位置
*/
[SWF (width = "320", height = "240", backgroundColor = "#000000", frameRate = "30")]
public class SimpleCarousel extends BasicView
{
private var planeNum:uint = 15;
private var carouselRadius:uint = 400;
private var carouselContainer:DisplayObject3D = new DisplayObject3D();
public function SimpleCarousel()
{
super(320, 240, true);
for (var i:uint = 0; i < planeNum; i++)
{
var planeWidth:uint = 100;
var planeHeight:uint = 100;
var randomColor:uint = Math.floor(Math.random() * 0x1000000);
var colorMat:ColorMaterial = new ColorMaterial(randomColor, .7);
colorMat.doubleSided = true;
var plane:Plane = new Plane(colorMat, planeWidth, planeHeight, 2, 2);
var angle:uint = (360 / planeNum) * i;
//旋轉角度後,直接朝該正面前進
plane.yaw(angle);
plane.moveForward(carouselRadius);
carouselContainer.addChild(plane);
}
this.addChild(this.viewport);
this.scene.addChild(carouselContainer);
this.startRendering();
}
override protected function onRenderTick(event:Event=null):void
{
super.onRenderTick(event);
carouselContainer.yaw(2);
}
}
}
這樣就完成了,同理,如果將垂直加入運算,也可簡單做出球體的感覺
good jobs~
你好,我是 flash 的初學者,最近正在學
pv3d , 從 google 找到這個網站,早上在研究
你所寫的 carousel 範例,覺得真的很不錯。
之前參考過許多網路上的範例,你寫的是讓我覺
得最好懂的, : ) 大推!
peterlawn
2010年6月2日 上午10:58感謝你的支持,你的回應是我繼續寫下去的動力^_^
GD
2010年6月24日 下午1:16