// forked from h1ro's 3D座標のランダム配置テスト //---------------------------------------- // 3D座標のランダム配置テスト // いい感じのランダムを作りたい!と思って研究中 // @author h1ro //---------------------------------------- package { import flash.events.Event; import org.papervision3d.materials.ColorMaterial; import org.papervision3d.objects.primitives.Plane; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.cameras.*; import org.papervision3d.view.BasicView; public class RandomPlace extends BasicView { private var cam:Camera3D; private var container:DisplayObject3D; //1000個ランダムで生成 private var randMax:int = 1000; public function RandomPlace() { //全部を格納しとくcontainerを作る container = new DisplayObject3D(); scene.addChild(container); //cam = cameraAsCamera3D; camera.focus = 60; camera.y = 0; camera.x = 0; camera.z = 10000; //ランダムで生成するときにいい感じに重ならず生成できるかテスト for (var i:int=0; i<randMax; i++){ //カラーもランダムでセット var material:ColorMaterial = new ColorMaterial(Math.random() * 0xff0000); //両面を使う material.doubleSided = true; //Planeを生成 var plane:Plane = new Plane(material, 100, 100); //ランダムで座標を生成 var maxPos:int = 10000; plane.x = Math.random() * maxPos - maxPos / 2; plane.y = Math.random() * maxPos * 2 - maxPos; plane.z = Math.random() * maxPos * 2 - maxPos; //シーンに追加 container.addChild(plane); } //イベント追加 addEventListener(Event.ENTER_FRAME, function(e:Event):void { //奥行き具合も確認したいのでくるくる回す container.yaw(1); camera.moveBackward(100); } ); //レンダリングスタート startRendering(); } } } forked from: 3D座標のランダム配置テスト