Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Away3D 4.0 beta のプリミティブの中心点をずらす ref: http://qiita.com/items/2890
/**
* 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();
}
}
}
params.wmode = "direct";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.