PV3D Event
...
@author tkinjo
/**
* Copyright tkinjo ( http://wonderfl.net/user/tkinjo )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/3fTr
*/
// forked from tkinjo's forked from: Hello PV3D
package
{
import flash.text.TextField;
import org.papervision3d.events.InteractiveScene3DEvent;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.view.BasicView;
[SWF(width = "465", height = "465", frameRate = "60", backgroundColor = "#000000")]
/**
* ...
* @author tkinjo
*/
public class Main extends BasicView
{
private var counterTextField:TextField;
public function Main()
{
// カウンタ設定
counterTextField = new TextField();
counterTextField.textColor = 0xffffff;
counterTextField.text = ( 0 as uint ).toString();
addChild( counterTextField );
/* --------------------------------------------------
* PV3D の設定
* --------------------------------------------------
*/
viewport.interactive = true; // ビューポートでイベントを取得できるよう設定
var colorMaterial:ColorMaterial = new ColorMaterial( 0xffffff );
colorMaterial.interactive = true; // 当カラーマテリアルでイベントを取得できるよう設定
var plane:Plane = new Plane( colorMaterial );
scene.addChild( plane );
plane.addEventListener( InteractiveScene3DEvent.OBJECT_PRESS, planePressHandler );
startRendering();
}
private function planePressHandler( event:InteractiveScene3DEvent ):void {
counterTextField.text = ( ( parseInt( counterTextField.text ) + 1 ) as uint ).toString();
}
}
}