纳金网
标题:
[pv3d专题]物体移动
[打印本页]
作者:
.
时间:
2013-3-21 14:44
标题:
[pv3d专题]物体移动
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 pl
lane;
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/
作者:
89684598
时间:
2014-2-22 15:33
好东西啊,感谢分享
欢迎光临 纳金网 (http://rs.narkii.com/club/)
Powered by Discuz! X2.5