2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "camera-actor-api.h"
22 #include <object/handle-wrapper.h>
24 #include <shared/base-wrapped-object.h>
25 #include <object/property-value-wrapper.h>
33 namespace // un-named namespace
36 CameraActor GetCameraActor( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
38 HandleWrapper* handleWrapper = HandleWrapper::Unwrap( isolate, args.This() );
39 return CameraActor::DownCast( handleWrapper->mHandle );
42 } // un-named name space
44 /***************************************
45 * CAMERA ACTOR FUNCTIONS
46 ****************************************/
53 * @return {Object} CameraActor
55 Actor CameraActorApi::New( const v8::FunctionCallbackInfo< v8::Value >& args )
57 return CameraActor::New();
62 * Sets the default camera perspective projection for the given canvas size.
64 * Sets the near and far clipping planes, the field of view, the aspect ratio
65 * and the Z position of the actor based on the canvas size so that 1 unit in
66 * XY (z=0) plane is 1 pixel on screen.
68 * If the canvas size is ZERO, it sets the default camera perspective
69 * projection for the stage's size.
71 * If size is non ZERO, \e width and \e height must be greater than zero.
75 * var camera = dali.stage.getRenderTaskList().getTask(0).getCameraActor();
77 * camera.setPerspectiveProjection( [100, 150] );
81 * @method setPerspectiveProjection
82 * @param {Object} The canvas size, array of 2 numbers
84 void CameraActorApi::SetPerspectiveProjection( const v8::FunctionCallbackInfo< v8::Value >& args )
86 v8::Isolate* isolate = args.GetIsolate();
87 v8::HandleScope handleScope( isolate );
88 CameraActor cameraActor = GetCameraActor( isolate, args );
91 Vector2 size = V8Utils::GetVector2Parameter( PARAMETER_0, found, isolate, args );
94 DALI_SCRIPT_EXCEPTION( isolate, "bad parameter" );
97 cameraActor.SetPerspectiveProjection( size );
102 * Sets the camera projection to use orthographic projection.
104 * The XY plane is centered on the camera axis. The units in the X/Y
105 * plane directly equate to pixels on an equivalently sized
108 * The Z position of the actor, and the near and far clip planes of the
109 * bounding box match those that would be created by using
110 * SetPerspectiveProjection with the same size.
114 * var camera = dali.stage.getRenderTaskList().getTask(0).getCameraActor();
115 * camera.setOrthographicProjection( [1920, 1080] );
118 * @method setOrthographicProjection
119 * @param {Object} Size Size of XY plane (normal to camera axis)
121 void CameraActorApi::SetOrthographicProjection( const v8::FunctionCallbackInfo< v8::Value >& args )
123 v8::Isolate* isolate = args.GetIsolate();
124 v8::HandleScope handleScope( isolate );
125 CameraActor cameraActor = GetCameraActor( isolate, args );
128 Vector2 size = V8Utils::GetVector2Parameter( PARAMETER_0, found, isolate, args );
131 DALI_SCRIPT_EXCEPTION( isolate, "bad parameter" );
134 cameraActor.SetOrthographicProjection( size );
137 } // namespace V8Plugin