In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

flash on 2009-2-27

note.x (http://blog.r3c7.net/?p=136)より
mesh.geometry.vertices.push( v0 );が必要か実験
-> faceに追加したあとGeometry3Dでなんかしてるのは、Face3Dの正規化してるだけっぽい
よって頂点のpushは必要
Get Adobe Flash player
by yd_niku 26 Feb 2009
// note.x (http://blog.r3c7.net/?p=136)より
// mesh.geometry.vertices.push( v0 );が必要か実験
// -> faceに追加したあとGeometry3Dでなんかしてるのは、Face3Dの正規化してるだけっぽい
// よって頂点のpushは必要
package
{
    import flash.display.*;
    import flash.events.*;
 
    import org.papervision3d.view.BasicView;
    import org.papervision3d.core.geom.TriangleMesh3D;
    import org.papervision3d.core.geom.renderables.Triangle3D;
    import org.papervision3d.core.geom.renderables.Vertex3D;
    import org.papervision3d.core.math.NumberUV;
    import org.papervision3d.materials.ColorMaterial;
    import org.papervision3d.materials.special.CompositeMaterial;
 
    [SWF(backgroundColor=0x000000)]
 
    public class TriangleMesh3DTest extends BasicView
    {
        private var mesh:TriangleMesh3D;
 
        public function TriangleMesh3DTest()
        {
            stage.frameRate = 60;
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.quality = StageQuality.MEDIUM;
 
            //viewportの定義とカメラタイプ定義
            super (0,0,true,false,"Target");
            init3D();
        }
 
        public function init3D():void
        {
            //カメラ設定
            camera.z = -1000;
            camera.fov = 30;
 
 
            //マテリアル設定
            var colorMat:ColorMaterial = new ColorMaterial( 0x006699, 1 );
            colorMat.doubleSided = true;
 
            //TriangleMesh3Dオブジェクト生成
            mesh = new TriangleMesh3D( colorMat, new Array(), new Array(), null );
            scene.addChild(mesh);
 
            //頂点定義
            var v0: Vertex3D = new Vertex3D( -80, -80, 0 );
            var v1: Vertex3D = new Vertex3D( 80, -80, 0 );
            var v2: Vertex3D = new Vertex3D( 0, 80, 0 );
            mesh.geometry.vertices.push( v0 );
            mesh.geometry.vertices.push( v1 );
            mesh.geometry.vertices.push( v2 );
 
            //面定義
            var uvA:NumberUV = new NumberUV( 0, 0 );
            var uvC:NumberUV = new NumberUV( 1, 0 );
            var uvB:NumberUV = new NumberUV( 0, 1 );
            mesh.geometry.faces.push( new Triangle3D( mesh, new Array(v0,v1,v2), null, new Array(uvA,uvC,uvB) ));
 
            mesh.geometry.ready = true;
 
            //レンダリング開始
            startRendering();
        }
 
        override protected function onRenderTick(event:Event=null):void
        {
            mesh.rotationY += 2;
            super.onRenderTick(event);
        }
 
    }
}