Away3d Study Notes 4-view3d (view)

Source: Internet
Author: User

Before <Four basic components of the 3D world> Compare flash3d to a TV, and strive to vividly describe the logical relationship between the four essential "objects" in the 3D away3d world. In this example, the "View" is compared to the TV screen. Through this screen, our audience can see the scenes taken by cameras (3D objects ). This article further describes several important parameter settings of view3d.

Create view3d

In away3d, the Class Name of the viewport is view3d. Like creating any instance in AS, import the view3d class first, and then click New:

// Import the view3d class.

Import away3d. containers. view3d;

// Set the size of the Flash video (you can set the size in the Flash file ).

[SWF (width = "500", Height = "400 "]

// Create a new view

VaR view: view3d = new view3d (CAM: cam, Scene: SCE, X: 250, Y: 200 );

In the previous sentence, we can see several parameters in view3d: Camera: cam, Scene: SCE, X: 250, Y: 200. The following describes the four attributes.

Camera and scenario in the viewport

As mentioned in the previous notes, camera and scene. And view and 3D ModelsFour basic components of the 3D world. The camera and scene we used in the previous example are all newly created. In fact, the view3d in the front view comes with cameras and scenes.

1. var view: view3d = new view3d (Camera: cam, Scene: SCE, X: 250, Y: 200 );

2. Cam. z =-1000;

In this sentence, specify the camera and scene that comes with the view in the constructor of the view, and name them "Wipe Cam" and "SCE" respectively. There is another default camera and scenario:

3. var view: view3d = new view3d (X: 250, Y: 200 );

4. View. Camera. z =-1000;

1, 2 is the same as 3, 4, but 1 is used to name the camera that comes with the viewport as cam, and 4 is directly referenced by. View. Camera. Similarly, we can use the default scenario as follows:

View. Scene. addchild ();

Set the position of the View

For example, VAR view: view3d = new view3d (Camera: cam, Scene: SCE, X: 250, Y: 200); position the view point in the Flash video at the point (250,200). Generally, we want the video views to always be in the center of the Flash video. Therefore, for a video with a size of 500x400, we need to set X and Y to 250,200.

Finally, let's talk about how to set the preview size.

Set the preview size

Depending on the needs of different families, the TV screen is large and small, and the aspect ratio is different, including and. Similarly, sometimes we also need to set the height and width of the eye contact. However, the setting of the View Size is "atypical ". In as, we set the size of an object by setting the values of the width and height attributes of the object, however, the view does not have the width and height attributes (if you set the view in the code. width and view. height does not report an error, but it does not work), but we can use the clipping attribute to crop the eye to set its height and width.

Import away3d. Core. Clip. rectangleclipping;

VaR W: Number = 300;

VaR H: Number = 200;

// Create a rectangleclipping class instance myclip. We use myclip to crop the view.

VaR myclip: rectangleclipping = new rectangleclipping ({Minx:-W/2, miny:-H/2, Maxx: W/2, Maxy: H/2 });

View. Clipping = myclip;

In this way, the viewport is set to a rectangle with a width of PX and a height of PX.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.