LoginSignup
5
6

More than 5 years have passed since last update.

Away3D 4.0 beta のプリミティブの中心点をずらす

Last updated at Posted at 2012-02-29
GeometryApplyTransformation.as

/**
 * copyright (c) 2012 www.romatica.com
 * @auther itoz
 */
package 
{
    import away3d.containers.View3D;
    import away3d.entities.Mesh;
    import away3d.materials.TextureMaterial;
    import away3d.primitives.CubeGeometry;
    import away3d.textures.BitmapTexture;

    import flash.display.BitmapData;
    import flash.events.Event;
    import flash.geom.Matrix3D;

    [SWF(width='800',height='600',frameRate='60',backgroundColor='#000000')]
    /**
     * Away3D 4.0 beta のプリミティブの中心点をずらす
    * 動作サンプル
    * @see http://dl.dropbox.com/u/958512/sample/away3d4/applyTransformation/index.html
    *    
    * pivotPoint movePivot という中心点を操作する?とおもわれる物があるが、現時点(2012.2.29)はまだ動かないぽい?
    * http://away3d.com/forum/viewthread/124/
    * http://away3d.com/forum/viewthread/1680/
    * のでapplyTransfomationを使ってみた
     */
    public class GeometryApplyTransformation extends View3D
    {
        private var _cubeData : CubeGeometry;
        private var _cube : Mesh;
        private var _mat3d : Matrix3D;

        public function Main()
        {
            backgroundColor = 0xc1c4c1;
            antiAlias = 4;
            var material : TextureMaterial = new TextureMaterial(new BitmapTexture(new BitmapData(32, 32, false, 0x56a0b6)));
            _cubeData = new CubeGeometry(100, 400, 100, 4, 4, 4);
            _cube = new Mesh(_cubeData, material);
            _mat3d = new Matrix3D();
            _mat3d.appendTranslation(0, -200, 0);
            _cube.geometry.applyTransformation(_mat3d);
            scene.addChild(_cube);
            addEventListener(Event.ENTER_FRAME, onUpdate);
        }

        private function onUpdate(event : Event) : void
        {
            _cube.rotationX += 4;
            render();
        }
    }
}
html:preview.html

params.wmode = "direct";
5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6