How to rotate the central object instead of the camera

Software: Away3D 4.x

Nusakan, Newbie
Posted: 08 February 2015 06:15 PM   Total Posts: 10

I am still this tutorial:
file:///C:/Documents and Settings/User 1/Mis documentos/temp000002ยบ/ChatRooms123/Engendro/posibles recursos/Globe Materials Tutorial _ Away3D Tutorials Wiki.htm

and need to change a thing: That the camera remains still and is the land the one that moves.
I need to make it like that because the light has to be fixed. I have managed to rotate the land but it does it chaotic. It does not stop in the poles like it does the camera (or the HoverController)

Some help with this please? Thank you.

   

Pierce, Jr. Member
Posted: 19 February 2015 10:57 PM   Total Posts: 40   [ # 1 ]

camera3d and lightbase are both entities, so you should be able to parent your light to the camera rather than the scene. that way, however you move your camera, the light moves with it in a constant fixed relationship.

   

Nusakan, Newbie
Posted: 21 February 2015 08:33 PM   Total Posts: 10   [ # 2 ]

Thank you for his response, Pierce.

It that you say has logic and is the first thing that I tried but

did not know how to do it because I think that it is necessary to

modify some class of away3d and there already I get lost. The OOP

still is a bit a mystery for me.

Might it put on the object inside two containers and move each of

them in an axis?

I have this that does not work very well:

package 
{
 import away3d
.containers.*;
 
import away3d.entities.*;
 
import away3d.materials.*;
 
import away3d.primitives.*;
 
import away3d.utils.*;
 
import flash.display.*;
 
import flash.events.*;
 
import flash.geom.Vector3D;

 
[SWF(backgroundColor="#000000"frameRate="31"quality="MEDIUM"width="500"height="300")]
 
public class Main extends Sprite
 {
  
private var _view:View3D;
  private var 
cubo:Mesh;
  private var 
mouseIsDown:Boolean;
  private var 
lastMouseX:Number;
  private var 
lastPanAngle:Number 0;

  public function 
Main()
  
{
   stage
.scaleMode StageScaleMode.NO_SCALE;
   
stage.align StageAlign.TOP_LEFT;
   
   
addEventListener(Event.ENTER_FRAME_onEnterFrame);
   
addEventListenerMouseEvent.MOUSE_DOWN_MouseDown );
   
addEventListenerMouseEvent.MOUSE_UP_MouseUp );

   
_view = new View3D();
   
addChild(_view);
   
_view.camera.= -300;
   
_view.camera.lookAt(new Vector3D());
   
   
cubo = new Mesh(new CubeGeometry(100,100,100));
   
_view.scene.addChild(cubo);
  
}

  
private function _onEnterFrame(e:Event):void
  {
   
if (mouseIsDown)
   
{
    cubo
.rotationY 0.5 * ( _view.mouseX lastMouseX );
   
}
   cubo
.rotationY = (cubo.rotationY 0.4) + lastMouseX;
   
_view.render();
  
}
  
private function _MouseDownevent:MouseEvent ):void
  {
   mouseIsDown 
true;
   
lastPanAngle cubo.rotationY;
   
lastMouseX stage.mouseX;
  
}
  
private function _MouseUpevent:MouseEvent ):void
  {
   mouseIsDown 
false;
  
}
 }

But I not know how to drag the object correctly and with effect

“easing”.


Might someone say me something that should me clarify a bit the

things?

Thank you.

Pardon by my English.

   

Nusakan, Newbie
Posted: 21 February 2015 08:35 PM   Total Posts: 10   [ # 3 ]

Thank you for his response, Pierce.

It that you say has logic and is the first thing that I tried but did not know how to do it because I think that it is necessary to modify some class of away3d and there already I get lost. The OOP still is a bit a mystery for me.

Might it put on the object inside two containers and move each of them in an axis?

I have this that does not work very well:

package 
{
 import away3d
.containers.*;
 
import away3d.entities.*;
 
import away3d.materials.*;
 
import away3d.primitives.*;
 
import away3d.utils.*;
 
import flash.display.*;
 
import flash.events.*;
 
import flash.geom.Vector3D;

 
[SWF(backgroundColor="#000000"frameRate="31"quality="MEDIUM"width="500"height="300")]
 
public class Main extends Sprite
 {
  
private var _view:View3D;
  private var 
cubo:Mesh;
  private var 
mouseIsDown:Boolean;
  private var 
lastMouseX:Number;
  private var 
lastPanAngle:Number 0;

  public function 
Main()
  
{
   stage
.scaleMode StageScaleMode.NO_SCALE;
   
stage.align StageAlign.TOP_LEFT;
   
   
addEventListener(Event.ENTER_FRAME_onEnterFrame);
   
addEventListenerMouseEvent.MOUSE_DOWN_MouseDown );
   
addEventListenerMouseEvent.MOUSE_UP_MouseUp );

   
_view = new View3D();
   
addChild(_view);
   
_view.camera.= -300;
   
_view.camera.lookAt(new Vector3D());
   
   
cubo = new Mesh(new CubeGeometry(100,100,100));
   
_view.scene.addChild(cubo);
  
}

  
private function _onEnterFrame(e:Event):void
  {
   
if (mouseIsDown)
   
{
    cubo
.rotationY 0.5 * ( _view.mouseX lastMouseX );
   
}
   cubo
.rotationY = (cubo.rotationY 0.4) + lastMouseX;
   
_view.render();
  
}
  
private function _MouseDownevent:MouseEvent ):void
  {
   mouseIsDown 
true;
   
lastPanAngle cubo.rotationY;
   
lastMouseX stage.mouseX;
  
}
  
private function _MouseUpevent:MouseEvent ):void
  {
   mouseIsDown 
false;
  
}
 }

But I not know how to drag the object correctly and with effect “easing”.

Might someone say me something that should me clarify a bit the things?

Thank you.

Pardon by my English.

   

Pierce, Jr. Member
Posted: 23 February 2015 09:46 PM   Total Posts: 40   [ # 4 ]

can you upload the swf?

you shouldn’t need to modify anything to add a light to the camera. post the code you tried for it. it could be that some functionality of the light or camera affects their transform objects in a certain way or something, in which case you’d just have to manually alter some other property like counter-rotating the light or something.

if your rotations are bugging out and acting erratic, it’s probably bcs you’re only setting the y rotation and the x and z values are inverting themselves in the background bcs of the way quaternions are automatically interpreted. if you set all the rotations at once with a vector3d through the eulers property, you can prevent this from happening.

   

Nusakan, Newbie
Posted: 06 March 2015 05:02 PM   Total Posts: 10   [ # 5 ]

Thank you for trying to help, but I think that I am going to desist.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X