- 最后登录
- 2018-12-19
- 注册时间
- 2012-8-20
- 阅读权限
- 90
- 积分
- 54706
- 纳金币
- 32328
- 精华
- 41
|
package
{
import flash.events.Event;
import org.papervision3d.objects.primitives.Sphere;
import org.papervision3d.view.BasicView;
import org.papervision3d.materials.BitmapFileMaterial;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.events.FileLoadEvent;
import org.papervision3d.cameras.CameraType;
/**
* ...
* @author 张首尚
*/
public class vb5 extends BasicView
{
private var pllane;
private var easeOut:Number = 0.3;
private var reachX:Number = 0.5;
private var reachY:Number = 0.5;
private var reachZ:Number = 0.05;
private var rotX:Number = 0.5;
private var rotY:Number = 0.5;
public function vb5()
{
super(600,480, ***e, false,CameraType.TARGET);
init();
}
private function init():void
{
var bfm:BitmapFileMaterial = new BitmapFileMaterial("assets/2.jpg");
bfm.addEventListener(FileLoadEvent.LOAD_COMPLETE, onComplete);
bfm.doubleSided = ***e;
bfm.smooth = ***e;
pl = new Plane(bfm, 500, 500, 16, 12);
pl.x = 100;
pl.y = 100;
camera.target = pl;
}
private function onComplete(event:FileLoadEvent):void
{
scene.addChild(pl);
this.startRendering();
}
override protected function onRenderTick(evt:Event = null):void
{
super.onRenderTick();
var xDist:Number = mouseX - stage.stageWidth * 0.5; //鼠标X轴距离舞台中心的距离
var yDist:Number = mouseY - stage.stageHeight * 0.5;//鼠标Y轴距离舞台中心的距离
camera.x += (xDist - camera.x * reachX) * easeOut;
camera.y += (yDist- camera.y * reachY) * easeOut;
camera.z += ( -mouseY * 2 - camera.z ) * reachZ;
pl.rotationX += (yDist * rotX - pl.rotationX) * easeOut;
pl.rotationY += (xDist * rotY - pl.rotationY) * easeOut;
trace(camera.x+" "+camera.y);
//pl.pitch( -1); //x
//pl.yaw(-1);//y
//pl.roll( -1);//z
//pl.rotationY += 1;
//pl.rotationX += 1;
//pl.rotationZ += 1;
}
}
}
【来源:互联网】
更多精彩教程,尽在web3D纳金网http://www.narkii.com/college/ |
|