Source: http://blog.sina.com.cn/s/blog_59f0ac9d0101ci2j.html
View3D has been created at the time of initialization camera3d so sometimes camera3d is not created but you can still see the 3D scene.
The default initial position of the CAMERA3D is x:0,y:0,c:-1000.
Camera Properties:
Camea.lookat (new Vector3D). This is to have the camera pointing at some point. Even if the camera is moving. Will always be pointing at this point.
Camera.roll (angle) camera rotates around the green axis
Camera.pitch (angle) camera rotates around the red axis
Amera.yaw (angle) camera rotates around the blue axis
The camera moves by distance.
Camera.movebackward (distance)
Camera.moveforward (distance);
Camera.movedown (distance);
Camera.moveleft (distance);
Camera.moveright (distance);
Camera.moveup (distance);
Mobile camera
Setting the X, Y, and Z properties of the camera directly is possible.
Rotating camera
The camera's rotation uses its rotationx,rotationy and RotationZ properties, which are the same as normal three-dimensional objects. Like what:
Camera.rotationy = 10;
Adjust zoom and Focus properties
Zoom is closely related to the magnification of the camera. The larger the zoom, the greater the magnification.
The focus property differs from the focal length of the actual lens in Away3d, which refers to the distance between the camera position and the view plane. The smaller the focus, the closer the camera is to the viewing plane, the wider the view, similar to the wide-angle lens, with greater distortion
Camera Render distance settings
Camera.lens.far=distance;
These are the basic properties of some cameras. Below are 2 of the most used camera controllers in our project
The 1:hovercontroller camera rotates around a point. 3D objects can be viewed at 360 degrees. or create a 360-degree panorama.
2 Firstpersoncontroller. First-person view controller. This can be a perfect simulation of roaming with a first view.
The basic properties of the 2 controllers are the same.
TargetObject. This is the camera object we're going to give the controller.
Lookatobject: This one is owned by Hovercontroller. Is the object we are going to surround.
Panangle: Angle at which the camera rotates on the Y axis
Tiltangle: The angle at which the camera rotates on the x axis
distance; The distance of the X-ray machine.
Minpanangle: The minimum angle at which the y-axis rotates.
Mintileangle: The minimum angle at which the x-axis rotates.
Maxpanangle: The maximum angle to rotate with the Y axis.
Maxtileangle: The maximum angle at which the x-axis rotates.
The following 2 properties are firstpersoncontroller that can simulate the first view of walking
The camera's direction is moving at speed.
Incrementwalk (speed);
90 degrees in the camera direction at speed
Incrementstrafe (speed);
All right, now let's start with Hovercontroller to make our panorama.
Simple theory of production. We need to use a panorama. Panorama can be done with a seamless map of 6 skybox. It can also be made with 360 of the fish-eye lens. It is more difficult to make a seamless mapping of 6 faces in general. So more time we use a 360-degree panorama taken by the fisheye lens. The fisheye lens is generally a spherical lens. So we're going to use a ball here to put this panorama map on. Then put a ray machine in the ball, so that basically can simulate people in a place 360 degrees to see around.
var view:view3d=new view3d ();
AddChild (view);
I'll create a ball with a radius of 1000 so I'm going to make this camera render range to 2000. cannot be below the radius. No, I can't see the surface of the ball.
view.camera.lens.far=2000;
Create a hovercontroller and then give View.camera initialization tiltangle the value is 90 degrees so this is the camera's first knowledge is parallel. Camera to center point distance is 300
var _camercontroller:hovercontroller = new Hovercontroller (view.camera,null,90,0,300);
is to create a bitmap map with a radius of 1000 and give it this panorama.
var sphere:spheregeometry = new Spheregeometry (1000);
var bitmaptexture:bitmaptexture = new Bitmaptexture (bitmapData);
var texturematerial:texturematerial = new Texturematerial (bitmaptexture);
Away3d's model defaults to one-sided rendering, so we can't see the inside of the ball from the ball. So I'm going to open this bitmap-mapped double-sided rendering
Texturematerial.bothsides = true;
var Mesh:mesh = new Mesh (sphere,texturematerial);
View.scene.addChild (mesh);
Because you want to use the mouse to drag to see any direction, so we need to calculate the angle by the mouse displacement
_startx is the value that initializes the camera Panangle Starty is the value of the initial Tiltangle
MouseX is the mouse x axis movement distance
Mousey is the y-axis moving distance of the mouse
_camercontroller.panangle = (MouseX-_mousex) *. 3 + _startx;
_camercontroller.tiltangle = (Mousey-_mousey) *. 3 + _starty;
All right, that's basically the finish.
We can output 360 degrees to see the panorama. Is it very immersive? Here's the whole code.
Import flash.display.*;
Import flash.events.*;
Import Away3d.containers.View3D;
Import Away3d.primitives.SphereGeometry;
Import Away3d.textures.BitmapTexture;
Import away3d.materials.TextureMaterial;
Import Away3d.entities.Mesh;
Import Away3d.controllers.HoverController;
var _startx:number;
var _starty:number;
var _mousex:number;
var _mousey:number;
var view:view3d=new view3d ();
AddChild (view);
view.camera.lens.far=2000;
var _camercontroller:hovercontroller = new Hovercontroller (view.camera,null,90,0,300);
var loader:loader=new loader ();
var bitmapdata:quanjing=new quanjing ();//Map own definition
var sphere:spheregeometry = new Spheregeometry (1000);
var bitmaptexture:bitmaptexture = new Bitmaptexture (bitmapData);
var texturematerial:texturematerial = new Texturematerial (bitmaptexture);
Texturematerial.bothsides = true;
var Mesh:mesh = new Mesh (sphere,texturematerial);
View.scene.addChild (mesh);
Stage.addeventlistener (mouseevent.mouse_down,mousedownfunction);
function Mousedownfunction (evt:mouseevent): void
{
_startx = _camercontroller.panangle;
_starty = _camercontroller.tiltangle;
_mousex = MouseX;
_mousey = Mousey;
Stage.addeventlistener (mouseevent.mouse_move,mousemovefunction);
Stage.addeventlistener (mouseevent.mouse_up,mouseupfunction);
}
function Mousemovefunction (evt:mouseevent): void
{
_camercontroller.panangle = (MouseX-_mousex) *. 3 + _startx;
_camercontroller.tiltangle = (Mousey-_mousey) *. 3 + _starty;
}
function Mouseupfunction (evt:mouseevent): void
{
Stage.removeeventlistener (mouseevent.mouse_move,mousemovefunction);
Stage.removeeventlistener (mouseevent.mouse_up,mouseupfunction);
Stage.addeventlistener (mouseevent.mouse_down,mousedownfunction);
}
AddEventListener (event.enter_frame,enterframefunction);
function Enterframefunction (evt:event): void
{
View.render ();
}
Away 3d Basic Properties