仿造地球
文件大,没做loading 稍稍等...........
public class test extends BasicView
{
private var sphere:Sphere;
private const easing:Number = 0.1;
private const scale:Number = 0.5;
private var move:Boolean;
private var currentPosition:Point;
private var nodePosition:Point;
private var endPosition:Point;
private var oldPosition:Point;
public function test()
{
viewport.interactive = true;
var mater:BitmapMaterial = new BitmapMaterial(new globe_bg(1250, 625));
//mater.smooth = true;
mater.interactive = true;
sphere = new Sphere(mater, 420, 40, 34);
scene.addChild(sphere);
var _vl:ViewportLayer = viewport.getChildLayer(sphere);
_vl.buttonMode = true;
_vl.addEventListener(MouseEvent.MOUSE_DOWN, downH);
stage.addEventListener(MouseEvent.MOUSE_UP, upH);
addEventListener(Event.ENTER_FRAME,enter);
initForce();
singleRender();
}
private function initForce():void
{
currentPosition = new Point();
endPosition = new Point();
nodePosition = new Point();
}
private function downH(e:MouseEvent):void
{
nodePosition.x = mouseX;
nodePosition.y = mouseY;
oldPosition = endPosition.clone();
move = true;
}
private function upH(e:MouseEvent):void
{
move = false;
}
private function enter(e:Event):void
{
rotate();
}
private function rotate():void
{
if( move )
{
endPosition.x = mouseX - nodePosition.x + oldPosition.x;
endPosition.y = mouseY - nodePosition.y + oldPosition.y;
}
currentPosition.x += ( endPosition.x - currentPosition.x ) * easing;
currentPosition.y += ( endPosition.y - currentPosition.y ) * easing;
sphere.rotationX = currentPosition.y * scale;
sphere.rotationY = - currentPosition.x * scale;
if (Math.abs(endPosition.x - currentPosition.x) > 0.1 || Math.abs(endPosition.y - currentPosition.y) > 0.1) {
singleRender();
}
}
2009-4-20 12:22:21 回复该留言
建议用transform
Matrix3D.rotationMatrix()
:)
2009-4-30 13:45:40 回复该留言
http://www.flashquake.cn/?p=19 作者就是用的楼上说的方法
2009-4-30 19:09:32 回复该留言
恩恩 确实有问题
但是我这个鼠标交互上有所不同
找个空我修改一下
2009-5-6 18:23:11 回复该留言
想请教一个问题
DisplayObject3D应用rotationX/rotationY/rotationZ相关属性、方法之后,它的x/y/z属性并不改变;比如:
p.yaw(1);
// x/y/z不改变
trace(p.x+"X",p.y+"Y",p.z+"Z");
不改变x/y/z,p又是如何运动的呢?
2009-5-7 17:44:28 回复该留言
xyz是坐标 和 旋转没有关系的呀
当然不改变了啊
2009-5-8 9:42:37 回复该留言
我知道了 rotationX等等 是绕自身旋转的
2010-6-2 9:27:44 回复该留言
请问楼主你的地球是用3D画的嘛》?还是一张图片?我刚开始学PV3 呵呵
2010-6-2 10:50:15 回复该留言
是3D球 不是图片